aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/follow.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/db/follow.go b/db/follow.go
index 1aa9965..3f7868d 100644
--- a/db/follow.go
+++ b/db/follow.go
@@ -270,3 +270,35 @@ func MakeActivityRequest(activity activitypub.Activity) error {
return nil
}
+
+func SendToFollowers(actor string, activity activitypub.Activity) error {
+ nActor, err := activitypub.GetActorFromDB(actor)
+ if err != nil {
+ return err
+ }
+
+ activity.Actor = &nActor
+
+ followers, err := activitypub.GetActorFollowDB(actor)
+ if err != nil {
+ return err
+ }
+
+ var to []string
+
+ for _, e := range followers {
+ for _, k := range activity.To {
+ if e.Id != k {
+ to = append(to, e.Id)
+ }
+ }
+ }
+
+ activity.To = to
+
+ if len(activity.Object.InReplyTo) > 0 {
+ err = MakeActivityRequest(activity)
+ }
+
+ return err
+}