From 87177d840b9703f572392ef4bd0f5013fd5c3a77 Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 28 May 2021 19:57:04 +0200 Subject: Announce/boost (#35) Remote boosts incoming/outgoing now working. --- internal/typeutils/converter.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/typeutils/converter.go') diff --git a/internal/typeutils/converter.go b/internal/typeutils/converter.go index cf94faf2e..93ac6bd84 100644 --- a/internal/typeutils/converter.go +++ b/internal/typeutils/converter.go @@ -100,6 +100,19 @@ type TypeConverter interface { ASFollowToFollow(followable Followable) (*gtsmodel.Follow, error) // ASLikeToFave converts a remote activitystreams 'like' representation into a gts model status fave. ASLikeToFave(likeable Likeable) (*gtsmodel.StatusFave, error) + // ASAnnounceToStatus converts an activitystreams 'announce' into a status. + // + // The returned bool indicates whether this status is new (true) or not new (false). + // + // In other words, if the status is already in the database with the ID set on the announceable, then that will be returned, + // the returned bool will be false, and no further processing is necessary. If the returned bool is true, indicating + // that this is a new announce, then further processing will be necessary, because the returned status will be bareboned and + // require further dereferencing. + // + // This is useful when multiple users on an instance might receive the same boost, and we only want to process the boost once. + // + // NOTE -- this is different from one status being boosted multiple times! In this case, new boosts should indeed be created. + ASAnnounceToStatus(announceable Announceable) (status *gtsmodel.Status, new bool, err error) /* INTERNAL (gts) MODEL TO ACTIVITYSTREAMS MODEL @@ -117,6 +130,8 @@ type TypeConverter interface { AttachmentToAS(a *gtsmodel.MediaAttachment) (vocab.ActivityStreamsDocument, error) // FaveToAS converts a gts model status fave into an activityStreams LIKE, suitable for federation. FaveToAS(f *gtsmodel.StatusFave) (vocab.ActivityStreamsLike, error) + // BoostToAS converts a gts model boost into an activityStreams ANNOUNCE, suitable for federation + BoostToAS(boostWrapperStatus *gtsmodel.Status, boostingAccount *gtsmodel.Account, boostedAccount *gtsmodel.Account) (vocab.ActivityStreamsAnnounce, error) /* INTERNAL (gts) MODEL TO INTERNAL MODEL -- cgit v1.2.3