aboutsummaryrefslogtreecommitdiff
path: root/activitypub/actor.go
diff options
context:
space:
mode:
authorFChannel <>2022-06-14 14:50:32 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit7306338e7f23d652b6b0bfecddcee408a4227169 (patch)
tree58bac2a3a97b1f5456734f654cc6264e919016e7 /activitypub/actor.go
parent27d0796d7f775034f391ba8aaca99f2a81018842 (diff)
added sendtofollowers to cc incase not already sending to followers
ie. sending from other server than fchannel
Diffstat (limited to 'activitypub/actor.go')
-rw-r--r--activitypub/actor.go56
1 files changed, 42 insertions, 14 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go
index afd9efd..be51460 100644
--- a/activitypub/actor.go
+++ b/activitypub/actor.go
@@ -893,34 +893,32 @@ func (actor Actor) SetAutoSubscribe() error {
}
func (actor Actor) SendToFollowers(activity Activity) error {
- nActor, err := GetActorFromDB(actor.Id)
-
- if err != nil {
- return util.MakeError(err, "SendToFollowers")
- }
-
- activity.Actor = &nActor
- followers, err := nActor.GetFollower()
+ followers, err := actor.GetFollower()
if err != nil {
return util.MakeError(err, "SendToFollowers")
}
- var to []string
+ var cc []string
for _, e := range followers {
+ var isTo = false
+
for _, k := range activity.To {
if e.Id != k {
- to = append(to, e.Id)
+ isTo = true
}
}
+
+ if !isTo {
+ cc = append(cc, e.Id)
+ }
}
- activity.To = to
+ activity.To = make([]string, 0)
+ activity.Cc = cc
- if len(activity.Object.InReplyTo) > 0 {
- err = activity.MakeRequestInbox()
- }
+ err = activity.MakeRequestInbox()
return util.MakeError(err, "SendToFollowers")
}
@@ -1169,3 +1167,33 @@ func (actor Actor) GetJanitors() ([]util.Verify, error) {
return list, nil
}
+
+func (actor Actor) ProcessInboxCreate(activity Activity) error {
+ if local, _ := actor.IsLocal(); local {
+ if local, _ := activity.Actor.IsLocal(); !local {
+ reqActivity := Activity{Id: activity.Object.Id}
+ col, err := reqActivity.GetCollection()
+ if err != nil {
+ return util.MakeError(err, "ActorInbox")
+ }
+
+ if len(col.OrderedItems) < 1 {
+ return util.MakeError(errors.New("Object does not exist"), "ActorInbox")
+ }
+
+ if wantToCache, err := activity.Object.WantToCache(actor); !wantToCache {
+ return util.MakeError(err, "ActorInbox")
+ }
+
+ if _, err := activity.Object.WriteCache(); err != nil {
+ return util.MakeError(err, "ActorInbox")
+ }
+
+ if err := actor.ArchivePosts(); err != nil {
+ return util.MakeError(err, "ActorInbox")
+ }
+ }
+ }
+
+ return nil
+}