aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <>2022-06-21 23:13:21 -0700
committerFChannel <>2022-06-21 23:13:21 -0700
commitb1d65922e257d605d3d95b6e679728524ba1e609 (patch)
treef3d48efc3779a8f0fbb41e4a8eab10ef9901453b
parentb02f813e519dc890f2eb4827ff52cff3ff90c828 (diff)
checking for empty replyto, checking if already cached object already db
need to format all query strings to be easier to read and modify
-rw-r--r--activitypub/activity.go2
-rw-r--r--activitypub/actor.go24
2 files changed, 23 insertions, 3 deletions
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)