summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Kangas <gabek@real-ity.com>2022-01-06 20:49:18 -0800
committerGabe Kangas <gabek@real-ity.com>2022-01-06 23:02:49 -0800
commit7dbf763acf5a59980fede14d0d12434780394ff2 (patch)
tree39eb3ad5f3d6613058b8234ed3998a10a3d4840c
parent83f30f05249d18da143b559604383b444daade35 (diff)
Do not allow multiple follows to send multiple events. Closes #1650
-rw-r--r--activitypub/inbox/follow.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/activitypub/inbox/follow.go b/activitypub/inbox/follow.go
index 3d849865e..70b26abf1 100644
--- a/activitypub/inbox/follow.go
+++ b/activitypub/inbox/follow.go
@@ -50,10 +50,24 @@ func handleFollowInboxRequest(c context.Context, activity vocab.ActivityStreamsF
object := activity.GetActivityStreamsObject()
objectIRI := object.At(0).GetIRI().String()
actorIRI := actorReference.At(0).GetIRI().String()
+
+ // If this request is approved and we have not previously sent an action to
+ // chat due to a previous follow request, then do so.
+ hasPreviouslyhandled := true // Default so we don't send anything if it fails.
+ if approved {
+ hasPreviouslyhandled, err = persistence.HasPreviouslyHandledInboundActivity(objectIRI, actorIRI, events.FediverseEngagementFollow)
+ if err != nil {
+ log.Errorln("error checking for previously handled follow activity", err)
+ }
+ }
+
+ // Save this follow action to our activities table.
if err := persistence.SaveInboundFediverseActivity(objectIRI, actorIRI, events.FediverseEngagementFollow, time.Now()); err != nil {
return errors.Wrap(err, "unable to save inbound share/re-post activity")
}
- if approved {
+
+ // Send action to chat if it has not been previously handled.
+ if !hasPreviouslyhandled {
return handleEngagementActivity(events.FediverseEngagementFollow, false, actorReference, events.FediverseEngagementFollow)
}