From 4f9e3a9228e38e94b77a31878104f16315bb21d3 Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Mon, 25 Jan 2021 19:09:17 -0800 Subject: send activity to all followers of To field --- main.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 55c97cd..95ed554 100644 --- a/main.go +++ b/main.go @@ -1027,20 +1027,33 @@ func CreateObject(objType string) ObjectBase { func AddFollowersToActivity(db *sql.DB, activity Activity) Activity{ followers := GetActorFollowDB(db, activity.Actor.Id) - + + var nActivity Activity for _, e := range followers { - var alreadyTo = false - for _, k := range activity.To { - if k == e.Id { - alreadyTo = true - } + var tempActivity Activity + actor := GetActor(e.Id) + aFollowers := GetActorCollection(actor.Followers) + for _, k := range aFollowers.Items { + tempActivity.To = append(tempActivity.To, k.Id) } + tempActivity.To = append(tempActivity.To, e.Id) + + for _, k := range tempActivity.To { + var alreadyTo = false + for _, n := range nActivity.To { + if k == n { + alreadyTo = true + } + } - if !alreadyTo { - activity.To = append(activity.To, e.Id) + if !alreadyTo { + nActivity.To = append(nActivity.To, k) + } } } + activity.To = nActivity.To + return activity } -- cgit v1.2.3