From 846057f0d696fded87d105dec1245e9ba32763ce Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 11 Jul 2021 16:22:21 +0200 Subject: Block/unblock (#96) * remote + local block logic, incl. federation * improve blocking stuff * fiddle with display of blocked profiles * go fmt --- internal/typeutils/converter.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'internal/typeutils/converter.go') diff --git a/internal/typeutils/converter.go b/internal/typeutils/converter.go index 30c1c7d2c..57c2a1f6d 100644 --- a/internal/typeutils/converter.go +++ b/internal/typeutils/converter.go @@ -48,6 +48,10 @@ type TypeConverter interface { // if something goes wrong. The returned account should be ready to serialize on an API level, and may NOT have sensitive fields. // In other words, this is the public record that the server has of an account. AccountToMastoPublic(account *gtsmodel.Account) (*model.Account, error) + // AccountToMastoBlocked takes a db model account as a param, and returns a mastotype account, or an error if + // something goes wrong. The returned account will be a bare minimum representation of the account. This function should be used + // when someone wants to view an account they've blocked. + AccountToMastoBlocked(account *gtsmodel.Account) (*model.Account, error) // AppToMastoSensitive takes a db model application as a param, and returns a populated mastotype application, or an error // if something goes wrong. The returned application should be ready to serialize on an API level, and may have sensitive fields // (such as client id and client secret), so serve it only to an authorized user who should have permission to see it. @@ -104,6 +108,8 @@ 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) + // ASBlockToBlock converts a remote activity streams 'block' representation into a gts model block. + ASBlockToBlock(blockable Blockable) (*gtsmodel.Block, error) // ASAnnounceToStatus converts an activitystreams 'announce' into a status. // // The returned bool indicates whether this status is new (true) or not new (false). @@ -124,6 +130,11 @@ type TypeConverter interface { // AccountToAS converts a gts model account into an activity streams person, suitable for federation AccountToAS(a *gtsmodel.Account) (vocab.ActivityStreamsPerson, error) + // AccountToASMinimal converts a gts model account into an activity streams person, suitable for federation. + // + // The returned account will just have the Type, Username, PublicKey, and ID properties set. This is + // suitable for serving to requesters to whom we want to give as little information as possible because + // we don't trust them (yet). AccountToASMinimal(a *gtsmodel.Account) (vocab.ActivityStreamsPerson, error) // StatusToAS converts a gts model status into an activity streams note, suitable for federation StatusToAS(s *gtsmodel.Status) (vocab.ActivityStreamsNote, error) @@ -137,6 +148,8 @@ type TypeConverter interface { 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) + // BlockToAS converts a gts model block into an activityStreams BLOCK, suitable for federation. + BlockToAS(block *gtsmodel.Block) (vocab.ActivityStreamsBlock, error) /* INTERNAL (gts) MODEL TO INTERNAL MODEL -- cgit v1.2.3