From b1d65922e257d605d3d95b6e679728524ba1e609 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Tue, 21 Jun 2022 23:13:21 -0700 Subject: checking for empty replyto, checking if already cached object already db need to format all query strings to be easier to read and modify --- activitypub/activity.go | 2 ++ activitypub/actor.go | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'activitypub') diff --git a/activitypub/activity.go b/activitypub/activity.go index 1956475..bd57778 100644 --- a/activitypub/activity.go +++ b/activitypub/activity.go @@ -392,6 +392,8 @@ func (activity Activity) MakeRequestInbox() error { }(actor, activity) } } + + time.Sleep(150 * time.Millisecond) } return nil diff --git a/activitypub/actor.go b/activitypub/actor.go index 540d159..77c4f90 100644 --- a/activitypub/actor.go +++ b/activitypub/actor.go @@ -1206,14 +1206,20 @@ func (actor Actor) ProcessInboxCreate(activity Activity) error { return util.MakeError(errors.New("Object does not exist"), "ActorInbox") } - if locked, _ := activity.Object.InReplyTo[0].IsLocked(); locked { - return util.MakeError(errors.New("Object locked"), "ActorInbox") + if len(activity.Object.InReplyTo) > 0 { + if locked, _ := activity.Object.InReplyTo[0].IsLocked(); locked { + return util.MakeError(errors.New("Object locked"), "ActorInbox") + } } if wantToCache, err := activity.Object.WantToCache(actor); !wantToCache { return util.MakeError(err, "ActorInbox") } + if col, _ := activity.Object.GetCollectionLocal(); len(col.OrderedItems) != 0 { + return nil + } + if _, err := activity.Object.WriteCache(); err != nil { return util.MakeError(err, "ActorInbox") } @@ -1241,7 +1247,19 @@ func (actor Actor) GetStickies() (Collection, error) { var nColl Collection var result []ObjectBase - query := `select count (x.id) over(), x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' and id in (select activity_id from sticky where actor_id=$1) union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' and id in (select activity_id from sticky where actor_id=$1)) as x order by x.updated desc limit 15` + query := ` +select count +(x.id) over(), x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive + from + (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream + where actor=$1 and id in (select id from replies where inreplyto='') and type='Note' and id in (select activity_id from sticky where actor_id=$1) + union + select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream + where actor in (select following from following where id=$1) and id in (select id from replies where inreplyto='') and type='Note' and id in (select activity_id from sticky where actor_id=$1) + union + select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where actor in (select following from following where id=$1) + and id in (select id from replies where inreplyto='') and type='Note' and id in (select activity_id from sticky where actor_id=$1) +) as x order by x.updated desc limit 15` rows, err := config.DB.Query(query, actor.Id) -- cgit v1.2.3