diff options
Diffstat (limited to 'internal')
25 files changed, 1128 insertions, 184 deletions
diff --git a/internal/ap/extract.go b/internal/ap/extract.go index 40578b8fc..14b7bb059 100644 --- a/internal/ap/extract.go +++ b/internal/ap/extract.go @@ -1173,15 +1173,7 @@ func extractCanLike( return gtsmodel.PolicyRules{} } - withRules := propIter.Get() - if withRules == nil { - return gtsmodel.PolicyRules{} - } - - return gtsmodel.PolicyRules{ - Always: extractPolicyValues(withRules.GetGoToSocialAlways(), owner), - WithApproval: extractPolicyValues(withRules.GetGoToSocialApprovalRequired(), owner), - } + return extractPolicyRules(propIter.Get(), owner) } func extractCanReply( @@ -1197,15 +1189,7 @@ func extractCanReply( return gtsmodel.PolicyRules{} } - withRules := propIter.Get() - if withRules == nil { - return gtsmodel.PolicyRules{} - } - - return gtsmodel.PolicyRules{ - Always: extractPolicyValues(withRules.GetGoToSocialAlways(), owner), - WithApproval: extractPolicyValues(withRules.GetGoToSocialApprovalRequired(), owner), - } + return extractPolicyRules(propIter.Get(), owner) } func extractCanAnnounce( @@ -1226,9 +1210,39 @@ func extractCanAnnounce( return gtsmodel.PolicyRules{} } + return extractPolicyRules(propIter.Get(), owner) +} + +func extractPolicyRules( + withRules WithPolicyRules, + owner *gtsmodel.Account, +) gtsmodel.PolicyRules { + if withRules == nil { + return gtsmodel.PolicyRules{} + } + + // Check for `automaticApproval` and + // `manualApproval` properties first. + var ( + automaticApproval = withRules.GetGoToSocialAutomaticApproval() + manualApproval = withRules.GetGoToSocialManualApproval() + ) + if (automaticApproval != nil && automaticApproval.Len() != 0) || + (manualApproval != nil && manualApproval.Len() != 0) { + // At least one is set, use these props. + return gtsmodel.PolicyRules{ + AutomaticApproval: extractPolicyValues(automaticApproval, owner), + ManualApproval: extractPolicyValues(manualApproval, owner), + } + } + + // Fall back to deprecated `always` + // and `withApproval` properties. + // + // TODO: Remove this in GtS v0.21.0. return gtsmodel.PolicyRules{ - Always: extractPolicyValues(withRules.GetGoToSocialAlways(), owner), - WithApproval: extractPolicyValues(withRules.GetGoToSocialApprovalRequired(), owner), + AutomaticApproval: extractPolicyValues(withRules.GetGoToSocialAlways(), owner), + ManualApproval: extractPolicyValues(withRules.GetGoToSocialApprovalRequired(), owner), } } diff --git a/internal/ap/extractpolicy_test.go b/internal/ap/extractpolicy_test.go index a5e8db6a7..d735b9618 100644 --- a/internal/ap/extractpolicy_test.go +++ b/internal/ap/extractpolicy_test.go @@ -45,6 +45,106 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicy() { }, "interactionPolicy": { "canLike": { + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] + }, + "canReply": { + "automaticApproval": [ + "http://localhost:8080/users/the_mighty_zork", + "http://localhost:8080/users/the_mighty_zork/followers", + "https://gts.superseriousbusiness.org/users/dumpsterqueer", + "https://gts.superseriousbusiness.org/users/f0x" + ], + "manualApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ] + }, + "canAnnounce": { + "automaticApproval": [ + "http://localhost:8080/users/the_mighty_zork" + ], + "manualApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ] + } + }, + "tag": [ + { + "href": "https://gts.superseriousbusiness.org/users/dumpsterqueer", + "name": "@dumpsterqueer@superseriousbusiness.org", + "type": "Mention" + }, + { + "href": "https://gts.superseriousbusiness.org/users/f0x", + "name": "@f0x@superseriousbusiness.org", + "type": "Mention" + } + ], + "type": "Note" +}` + + statusable, err := ap.ResolveStatusable( + context.Background(), + io.NopCloser( + bytes.NewBufferString(rawNote), + ), + ) + if err != nil { + suite.FailNow(err.Error()) + } + + policy := ap.ExtractInteractionPolicy( + statusable, + // Zork didn't actually create + // this status but nevermind. + suite.testAccounts["local_account_1"], + ) + + expectedPolicy := >smodel.InteractionPolicy{ + CanLike: gtsmodel.PolicyRules{ + AutomaticApproval: gtsmodel.PolicyValues{ + gtsmodel.PolicyValuePublic, + }, + ManualApproval: gtsmodel.PolicyValues{}, + }, + CanReply: gtsmodel.PolicyRules{ + AutomaticApproval: gtsmodel.PolicyValues{ + gtsmodel.PolicyValueAuthor, + gtsmodel.PolicyValueFollowers, + "https://gts.superseriousbusiness.org/users/dumpsterqueer", + "https://gts.superseriousbusiness.org/users/f0x", + }, + ManualApproval: gtsmodel.PolicyValues{ + gtsmodel.PolicyValuePublic, + }, + }, + CanAnnounce: gtsmodel.PolicyRules{ + AutomaticApproval: gtsmodel.PolicyValues{ + gtsmodel.PolicyValueAuthor, + }, + ManualApproval: gtsmodel.PolicyValues{ + gtsmodel.PolicyValuePublic, + }, + }, + } + suite.EqualValues(expectedPolicy, policy) +} + +func (suite *ExtractPolicyTestSuite) TestExtractPolicyDeprecated() { + rawNote := `{ + "@context": [ + "https://gotosocial.org/ns", + "https://www.w3.org/ns/activitystreams" + ], + "content": "hey @f0x and @dumpsterqueer", + "contentMap": { + "en": "hey @f0x and @dumpsterqueer", + "fr": "bonjour @f0x et @dumpsterqueer" + }, + "interactionPolicy": { + "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], @@ -104,27 +204,27 @@ func (suite *ExtractPolicyTestSuite) TestExtractPolicy() { expectedPolicy := >smodel.InteractionPolicy{ CanLike: gtsmodel.PolicyRules{ - Always: gtsmodel.PolicyValues{ + AutomaticApproval: gtsmodel.PolicyValues{ gtsmodel.PolicyValuePublic, }, - WithApproval: gtsmodel.PolicyValues{}, + ManualApproval: gtsmodel.PolicyValues{}, }, CanReply: gtsmodel.PolicyRules{ - Always: gtsmodel.PolicyValues{ + AutomaticApproval: gtsmodel.PolicyValues{ gtsmodel.PolicyValueAuthor, gtsmodel.PolicyValueFollowers, "https://gts.superseriousbusiness.org/users/dumpsterqueer", "https://gts.superseriousbusiness.org/users/f0x", }, - WithApproval: gtsmodel.PolicyValues{ + ManualApproval: gtsmodel.PolicyValues{ gtsmodel.PolicyValuePublic, }, }, CanAnnounce: gtsmodel.PolicyRules{ - Always: gtsmodel.PolicyValues{ + AutomaticApproval: gtsmodel.PolicyValues{ gtsmodel.PolicyValueAuthor, }, - WithApproval: gtsmodel.PolicyValues{ + ManualApproval: gtsmodel.PolicyValues{ gtsmodel.PolicyValuePublic, }, }, diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 28b5c0d20..faf793bd8 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -755,8 +755,10 @@ type WithInteractionPolicy interface { // WithPolicyRules represents an activity with always and approvalRequired properties. type WithPolicyRules interface { - GetGoToSocialAlways() vocab.GoToSocialAlwaysProperty - GetGoToSocialApprovalRequired() vocab.GoToSocialApprovalRequiredProperty + GetGoToSocialAutomaticApproval() vocab.GoToSocialAutomaticApprovalProperty + GetGoToSocialManualApproval() vocab.GoToSocialManualApprovalProperty + GetGoToSocialAlways() vocab.GoToSocialAlwaysProperty // Deprecated + GetGoToSocialApprovalRequired() vocab.GoToSocialApprovalRequiredProperty // Deprecated } // WithApprovedBy represents a Statusable with the approvedBy property. diff --git a/internal/ap/normalize.go b/internal/ap/normalize.go index f6608ed94..fb9dbe0a6 100644 --- a/internal/ap/normalize.go +++ b/internal/ap/normalize.go @@ -582,16 +582,16 @@ func NormalizeOutgoingContentProp(item WithContent, rawJSON map[string]interface // // "interactionPolicy": { // "canAnnounce": { -// "always": "https://www.w3.org/ns/activitystreams#Public", -// "approvalRequired": [] +// "automaticApproval": "https://www.w3.org/ns/activitystreams#Public", +// "manualApproval": [] // }, // "canLike": { -// "always": "https://www.w3.org/ns/activitystreams#Public", -// "approvalRequired": [] +// "automaticApproval": "https://www.w3.org/ns/activitystreams#Public", +// "manualApproval": [] // }, // "canReply": { -// "always": "https://www.w3.org/ns/activitystreams#Public", -// "approvalRequired": [] +// "automaticApproval": "https://www.w3.org/ns/activitystreams#Public", +// "manualApproval": [] // } // } // @@ -599,22 +599,22 @@ func NormalizeOutgoingContentProp(item WithContent, rawJSON map[string]interface // // "interactionPolicy": { // "canAnnounce": { -// "always": [ +// "automaticApproval": [ // "https://www.w3.org/ns/activitystreams#Public" // ], -// "approvalRequired": [] +// "manualApproval": [] // }, // "canLike": { -// "always": [ +// "automaticApproval": [ // "https://www.w3.org/ns/activitystreams#Public" // ], -// "approvalRequired": [] +// "manualApproval": [] // }, // "canReply": { -// "always": [ +// "automaticApproval": [ // "https://www.w3.org/ns/activitystreams#Public" // ], -// "approvalRequired": [] +// "manualApproval": [] // } // } // @@ -655,8 +655,10 @@ func NormalizeOutgoingInteractionPolicyProp(item WithInteractionPolicy, rawJSON } for _, PolicyValuesKey := range []string{ - "always", - "approvalRequired", + "automaticApproval", + "manualApproval", + "always", // deprecated + "approvalRequired", // deprecated } { PolicyValuesVal, ok := rulesValMap[PolicyValuesKey] if !ok { diff --git a/internal/api/client/admin/reportsget_test.go b/internal/api/client/admin/reportsget_test.go index 8489d5c28..8ba1338b6 100644 --- a/internal/api/client/admin/reportsget_test.go +++ b/internal/api/client/admin/reportsget_test.go @@ -572,6 +572,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -579,6 +584,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -586,6 +596,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -829,6 +844,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -836,6 +856,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -843,6 +868,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1086,6 +1116,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1093,6 +1128,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1100,6 +1140,11 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" diff --git a/internal/api/client/statuses/statusboost_test.go b/internal/api/client/statuses/statusboost_test.go index 333334bbc..abbe4857b 100644 --- a/internal/api/client/statuses/statusboost_test.go +++ b/internal/api/client/statuses/statusboost_test.go @@ -113,6 +113,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -120,6 +125,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -127,6 +137,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -168,6 +183,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -175,6 +195,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -182,6 +207,11 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -298,6 +328,13 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -305,6 +342,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -314,6 +356,13 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -349,6 +398,13 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -356,6 +412,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -365,6 +426,13 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -513,6 +581,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -520,6 +593,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -527,6 +605,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -560,6 +643,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -567,6 +655,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -574,6 +667,11 @@ func (suite *StatusBoostTestSuite) TestPostBoostImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, diff --git a/internal/api/client/statuses/statuscreate_test.go b/internal/api/client/statuses/statuscreate_test.go index 514109223..60069d362 100644 --- a/internal/api/client/statuses/statuscreate_test.go +++ b/internal/api/client/statuses/statuscreate_test.go @@ -156,6 +156,13 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -163,6 +170,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -172,6 +184,13 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "mentioned", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -241,6 +260,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicy() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -248,6 +272,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicy() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -258,6 +287,16 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicy() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "following", + "mentioned", + "me" + ], + "manual_approval": [ + "public" + ], "with_approval": [ "public" ] @@ -338,6 +377,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicyJSON() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -345,6 +389,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicyJSON() { "author", "me" ], + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -355,6 +404,16 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusIntPolicyJSON() { "mentioned", "me" ], + "automatic_approval": [ + "author", + "followers", + "following", + "mentioned", + "me" + ], + "manual_approval": [ + "public" + ], "with_approval": [ "public" ] @@ -553,6 +612,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -560,6 +624,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -567,6 +636,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -638,6 +712,11 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -645,6 +724,11 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -652,6 +736,11 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -717,6 +806,11 @@ func (suite *StatusCreateTestSuite) TestPostStatusWithLinksAndTags() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -724,6 +818,11 @@ func (suite *StatusCreateTestSuite) TestPostStatusWithLinksAndTags() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -731,6 +830,11 @@ func (suite *StatusCreateTestSuite) TestPostStatusWithLinksAndTags() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -810,6 +914,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithEmoji() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -817,6 +926,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithEmoji() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -824,6 +938,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithEmoji() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -901,6 +1020,11 @@ func (suite *StatusCreateTestSuite) TestReplyToLocalStatus() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -908,6 +1032,11 @@ func (suite *StatusCreateTestSuite) TestReplyToLocalStatus() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -915,6 +1044,11 @@ func (suite *StatusCreateTestSuite) TestReplyToLocalStatus() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -985,6 +1119,11 @@ func (suite *StatusCreateTestSuite) TestAttachNewMediaSuccess() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -992,6 +1131,11 @@ func (suite *StatusCreateTestSuite) TestAttachNewMediaSuccess() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -999,6 +1143,11 @@ func (suite *StatusCreateTestSuite) TestAttachNewMediaSuccess() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -1091,6 +1240,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithNoncanonicalLanguageTag "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -1098,6 +1252,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithNoncanonicalLanguageTag "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -1105,6 +1264,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithNoncanonicalLanguageTag "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -1167,6 +1331,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollForm() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -1174,6 +1343,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollForm() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -1181,6 +1355,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollForm() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -1265,6 +1444,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollJSON() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -1272,6 +1456,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollJSON() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -1279,6 +1468,11 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollJSON() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, diff --git a/internal/api/client/statuses/statusfave_test.go b/internal/api/client/statuses/statusfave_test.go index 11ac4fc5f..11c03cc5b 100644 --- a/internal/api/client/statuses/statusfave_test.go +++ b/internal/api/client/statuses/statusfave_test.go @@ -119,6 +119,11 @@ func (suite *StatusFaveTestSuite) TestPostFave() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -126,6 +131,11 @@ func (suite *StatusFaveTestSuite) TestPostFave() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -133,6 +143,11 @@ func (suite *StatusFaveTestSuite) TestPostFave() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, @@ -244,6 +259,11 @@ func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reblog": { @@ -251,6 +271,11 @@ func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] }, "can_reply": { @@ -258,6 +283,11 @@ func (suite *StatusFaveTestSuite) TestPostFaveImplicitAccept() { "public", "me" ], + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "with_approval": [] } }, diff --git a/internal/api/client/statuses/statusmute_test.go b/internal/api/client/statuses/statusmute_test.go index d3c880f09..3ef82da31 100644 --- a/internal/api/client/statuses/statusmute_test.go +++ b/internal/api/client/statuses/statusmute_test.go @@ -152,6 +152,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -159,6 +164,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -166,6 +176,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -242,6 +257,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -249,6 +269,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -256,6 +281,11 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" diff --git a/internal/api/model/interactionpolicy.go b/internal/api/model/interactionpolicy.go index 7c5df09e8..c43142d58 100644 --- a/internal/api/model/interactionpolicy.go +++ b/internal/api/model/interactionpolicy.go @@ -48,9 +48,16 @@ const ( // // swagger:model interactionPolicyRules type PolicyRules struct { + // Policy entries for accounts that will receive automatic approval for this type of interaction. + AutomaticApproval []PolicyValue `form:"automatic_approval" json:"automatic_approval"` + // Policy entries for accounts that require manual approval for this type of interaction. + ManualApproval []PolicyValue `form:"manual_approval" json:"manual_approval"` + // Policy entries for accounts that can always do this type of interaction. + // Deprecated: Use "automatic_approval" instead. Always []PolicyValue `form:"always" json:"always"` // Policy entries for accounts that require approval to do this type of interaction. + // Deprecated: Use "manual_approval" instead. WithApproval []PolicyValue `form:"with_approval" json:"with_approval"` } diff --git a/internal/federation/dereferencing/status_permitted.go b/internal/federation/dereferencing/status_permitted.go index 65251ed55..848a821d1 100644 --- a/internal/federation/dereferencing/status_permitted.go +++ b/internal/federation/dereferencing/status_permitted.go @@ -265,7 +265,7 @@ func (d *Dereferencer) isPermittedReply( ) } - if replyable.Permitted() && + if replyable.AutomaticApproval() && !replyable.MatchedOnCollection() { // Reply is permitted and match was *not* made // based on inclusion in a followers/following @@ -569,7 +569,7 @@ func (d *Dereferencer) isPermittedBoost( return false, nil } - if boostable.Permitted() && + if boostable.AutomaticApproval() && !boostable.MatchedOnCollection() { // Booster is permitted to do this // interaction, and didn't match on diff --git a/internal/federation/federatingdb/like.go b/internal/federation/federatingdb/like.go index 76ae19a52..970ca53ef 100644 --- a/internal/federation/federatingdb/like.go +++ b/internal/federation/federatingdb/like.go @@ -98,7 +98,7 @@ func (f *federatingDB) Like(ctx context.Context, likeable vocab.ActivityStreamsL ) switch { - case policyResult.WithApproval(): + case policyResult.ManualApproval(): // Requester allowed to do // this pending approval. pendingApproval = true @@ -111,7 +111,7 @@ func (f *federatingDB) Like(ctx context.Context, likeable vocab.ActivityStreamsL pendingApproval = true preApproved = true - case policyResult.Permitted(): + case policyResult.AutomaticApproval(): // Requester straight up // permitted to do this, // no need for Accept. diff --git a/internal/filter/interaction/interactable.go b/internal/filter/interaction/interactable.go index e8afbd83c..2052ac78e 100644 --- a/internal/filter/interaction/interactable.go +++ b/internal/filter/interaction/interactable.go @@ -78,8 +78,8 @@ func (f *Filter) StatusLikeable( // always like their own status, // no need for further checks. return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), }, nil } @@ -110,7 +110,7 @@ func (f *Filter) StatusLikeable( // about interaction policies, and just return OK. default: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, + Permission: gtsmodel.PolicyPermissionAutomaticApproval, }, nil } } @@ -153,7 +153,7 @@ func (f *Filter) StatusReplyable( // and having the reply-to-their-own-reply go // through as Permitted. None of that! return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionWithApproval, + Permission: gtsmodel.PolicyPermissionManualApproval, }, nil } } @@ -163,8 +163,8 @@ func (f *Filter) StatusReplyable( // always reply to their own status, // no need for further checks. return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), }, nil } @@ -173,8 +173,8 @@ func (f *Filter) StatusReplyable( // to them being mentioned, and easier to check! if status.InReplyToAccountID == requester.ID { return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: util.Ptr(gtsmodel.PolicyValueMentioned), + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: util.Ptr(gtsmodel.PolicyValueMentioned), }, nil } @@ -229,8 +229,8 @@ func (f *Filter) StatusReplyable( // A mentioned account can always // reply, no need for further checks. return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: util.Ptr(gtsmodel.PolicyValueMentioned), + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: util.Ptr(gtsmodel.PolicyValueMentioned), }, nil } @@ -261,7 +261,7 @@ func (f *Filter) StatusReplyable( // about interaction policies, and just return OK. default: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, + Permission: gtsmodel.PolicyPermissionAutomaticApproval, }, nil } } @@ -291,8 +291,8 @@ func (f *Filter) StatusBoostable( // always boost non-directs, // no need for further checks. return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: util.Ptr(gtsmodel.PolicyValueAuthor), }, nil } @@ -324,7 +324,7 @@ func (f *Filter) StatusBoostable( case status.Visibility == gtsmodel.VisibilityPublic || status.Visibility == gtsmodel.VisibilityUnlocked: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, + Permission: gtsmodel.PolicyPermissionAutomaticApproval, }, nil // Not permitted by any of the @@ -353,7 +353,7 @@ func (f *Filter) checkPolicy( matchAlways, matchAlwaysValue, err := f.matchPolicy(fctx, requester, status, - rules.Always, + rules.AutomaticApproval, ) if err != nil { return nil, gtserror.Newf("error checking policy match: %w", err) @@ -364,7 +364,7 @@ func (f *Filter) checkPolicy( matchWithApproval, _, err := f.matchPolicy(fctx, requester, status, - rules.WithApproval, + rules.ManualApproval, ) if err != nil { return nil, gtserror.Newf("error checking policy approval match: %w", err) @@ -376,26 +376,26 @@ func (f *Filter) checkPolicy( // prioritizing "always". case matchAlways == explicit: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: &matchAlwaysValue, + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: &matchAlwaysValue, }, nil case matchWithApproval == explicit: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionWithApproval, + Permission: gtsmodel.PolicyPermissionManualApproval, }, nil // Then try implicit match, // prioritizing "always". case matchAlways == implicit: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionPermitted, - PermittedMatchedOn: &matchAlwaysValue, + Permission: gtsmodel.PolicyPermissionAutomaticApproval, + PermissionMatchedOn: &matchAlwaysValue, }, nil case matchWithApproval == implicit: return >smodel.PolicyCheckResult{ - Permission: gtsmodel.PolicyPermissionWithApproval, + Permission: gtsmodel.PolicyPermissionManualApproval, }, nil } diff --git a/internal/gtsmodel/interactionpolicy.go b/internal/gtsmodel/interactionpolicy.go index 7fcafc80d..886c2e44b 100644 --- a/internal/gtsmodel/interactionpolicy.go +++ b/internal/gtsmodel/interactionpolicy.go @@ -123,10 +123,10 @@ const ( // Interaction is conditionally permitted // for this PolicyValue + interaction combo, // pending approval by the item owner. - PolicyPermissionWithApproval + PolicyPermissionManualApproval // Interaction is permitted for this // PolicyValue + interaction combination. - PolicyPermissionPermitted + PolicyPermissionAutomaticApproval ) // PolicyCheckResult encapsulates the results @@ -138,39 +138,39 @@ type PolicyCheckResult struct { Permission PolicyPermission // Value that this check matched on. - // Only set if Permission = permitted. - PermittedMatchedOn *PolicyValue + // Only set if Permission = automatic. + PermissionMatchedOn *PolicyValue } // MatchedOnCollection returns true if this policy check -// result turned up Permitted, and matched based on the +// result turned up AutomaticApproval, and matched based on the // requester's presence in a followers or following collection. func (pcr *PolicyCheckResult) MatchedOnCollection() bool { - if !pcr.Permitted() { + if !pcr.AutomaticApproval() { // Not permitted at all // so definitely didn't // match on collection. return false } - if pcr.PermittedMatchedOn == nil { + if pcr.PermissionMatchedOn == nil { return false } - return *pcr.PermittedMatchedOn == PolicyValueFollowers || - *pcr.PermittedMatchedOn == PolicyValueFollowing + return *pcr.PermissionMatchedOn == PolicyValueFollowers || + *pcr.PermissionMatchedOn == PolicyValueFollowing } -// Permitted returns true if this policy -// check resulted in Permission = permitted. -func (pcr *PolicyCheckResult) Permitted() bool { - return pcr.Permission == PolicyPermissionPermitted +// AutomaticApproval returns true if this policy +// check resulted in Permission = automatic approval. +func (pcr *PolicyCheckResult) AutomaticApproval() bool { + return pcr.Permission == PolicyPermissionAutomaticApproval } // Permitted returns true if this policy -// check resulted in Permission = with approval. -func (pcr *PolicyCheckResult) WithApproval() bool { - return pcr.Permission == PolicyPermissionWithApproval +// check resulted in Permission = manual approval. +func (pcr *PolicyCheckResult) ManualApproval() bool { + return pcr.Permission == PolicyPermissionManualApproval } // Permitted returns true if this policy @@ -201,14 +201,22 @@ type InteractionPolicy struct { // to which a certain interaction is permitted // to various Actor and Actor Collection URIs. type PolicyRules struct { - // Always is for PolicyValues who are - // permitted to do an interaction - // without requiring approval. - Always PolicyValues - // WithApproval is for PolicyValues who - // are conditionally permitted to do - // an interaction, pending approval. - WithApproval PolicyValues + // AutomaticApproval is for PolicyValue entries + // that are pre-approved to do an interaction + // and will receive automatic approval. + // + // Note: This is stored in the db as JSON. + // JSON tags set for back compat with previous + // (now deprecated) name for this PolicyValues. + AutomaticApproval PolicyValues `json:"Always,omitempty"` + // ManualApproval is for PolicyValues entries + // that are conditionally permitted to do + // an interaction, pending manual approval. + // + // Note: This is stored in the db as JSON. + // JSON tags set for back compat with previous + // (now deprecated) name for this PolicyValues. + ManualApproval PolicyValues `json:"WithApproval,omitempty"` } // Returns the default interaction policy @@ -231,24 +239,24 @@ func DefaultInteractionPolicyFor(v Visibility) *InteractionPolicy { var defaultPolicyPublic = &InteractionPolicy{ CanLike: PolicyRules{ // Anyone can like. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValuePublic, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanReply: PolicyRules{ // Anyone can reply. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValuePublic, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanAnnounce: PolicyRules{ // Anyone can announce. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValuePublic, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, } @@ -269,29 +277,29 @@ var defaultPolicyFollowersOnly = &InteractionPolicy{ CanLike: PolicyRules{ // Self, followers and // mentioned can like. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, PolicyValueFollowers, PolicyValueMentioned, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanReply: PolicyRules{ // Self, followers and // mentioned can reply. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, PolicyValueFollowers, PolicyValueMentioned, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanAnnounce: PolicyRules{ // Only self can announce. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, } @@ -305,27 +313,27 @@ var defaultPolicyDirect = &InteractionPolicy{ CanLike: PolicyRules{ // Mentioned and self // can always like. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, PolicyValueMentioned, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanReply: PolicyRules{ // Mentioned and self // can always reply. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, PolicyValueMentioned, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, CanAnnounce: PolicyRules{ // Only self can announce. - Always: PolicyValues{ + AutomaticApproval: PolicyValues{ PolicyValueAuthor, }, - WithApproval: make(PolicyValues, 0), + ManualApproval: make(PolicyValues, 0), }, } diff --git a/internal/processing/status/boost.go b/internal/processing/status/boost.go index c8c50d3ee..7c7162c12 100644 --- a/internal/processing/status/boost.go +++ b/internal/processing/status/boost.go @@ -96,7 +96,7 @@ func (p *Processor) BoostCreate( // Derive pendingApproval status. var pendingApproval bool switch { - case policyResult.WithApproval(): + case policyResult.ManualApproval(): // We're allowed to do // this pending approval. pendingApproval = true @@ -117,7 +117,7 @@ func (p *Processor) BoostCreate( boost.PreApproved = true } - case policyResult.Permitted(): + case policyResult.AutomaticApproval(): // We're permitted to do this // based on another kind of match. pendingApproval = false diff --git a/internal/processing/status/create.go b/internal/processing/status/create.go index 8596f2f1a..23189411a 100644 --- a/internal/processing/status/create.go +++ b/internal/processing/status/create.go @@ -406,7 +406,7 @@ func (p *Processor) processInReplyTo( // Derive pendingApproval status. var pendingApproval bool switch { - case policyResult.WithApproval(): + case policyResult.ManualApproval(): // We're allowed to do // this pending approval. pendingApproval = true @@ -427,7 +427,7 @@ func (p *Processor) processInReplyTo( status.PreApproved = true } - case policyResult.Permitted(): + case policyResult.AutomaticApproval(): // We're permitted to do this // based on another kind of match. pendingApproval = false diff --git a/internal/processing/status/fave.go b/internal/processing/status/fave.go index 95eb8bff2..52e6b9d43 100644 --- a/internal/processing/status/fave.go +++ b/internal/processing/status/fave.go @@ -112,7 +112,7 @@ func (p *Processor) FaveCreate( ) switch { - case policyResult.WithApproval(): + case policyResult.ManualApproval(): // We're allowed to do // this pending approval. pendingApproval = true @@ -133,7 +133,7 @@ func (p *Processor) FaveCreate( preApproved = true } - case policyResult.Permitted(): + case policyResult.AutomaticApproval(): // We're permitted to do this // based on another kind of match. pendingApproval = false diff --git a/internal/processing/stream/statusupdate_test.go b/internal/processing/stream/statusupdate_test.go index 0045cceed..f11ab40a2 100644 --- a/internal/processing/stream/statusupdate_test.go +++ b/internal/processing/stream/statusupdate_test.go @@ -135,6 +135,11 @@ func (suite *StatusUpdateTestSuite) TestStreamNotification() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -142,6 +147,11 @@ func (suite *StatusUpdateTestSuite) TestStreamNotification() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -149,6 +159,11 @@ func (suite *StatusUpdateTestSuite) TestStreamNotification() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" diff --git a/internal/transport/dereference_test.go b/internal/transport/dereference_test.go index c1d6fb952..d3778563e 100644 --- a/internal/transport/dereference_test.go +++ b/internal/transport/dereference_test.go @@ -115,8 +115,8 @@ func (suite *DereferenceTestSuite) TestDerefLocalStatus() { defer resp.Body.Close() suite.Equal(http.StatusOK, resp.StatusCode) - suite.EqualValues(1502, resp.ContentLength) - suite.Equal("1502", resp.Header.Get("Content-Length")) + suite.EqualValues(1769, resp.ContentLength) + suite.Equal("1769", resp.Header.Get("Content-Length")) suite.Equal(apiutil.AppActivityLDJSON, resp.Header.Get("Content-Type")) b, err := io.ReadAll(resp.Body) @@ -150,19 +150,31 @@ func (suite *DereferenceTestSuite) TestDerefLocalStatus() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-10-20T10:40:37Z", diff --git a/internal/typeutils/frontendtointernal.go b/internal/typeutils/frontendtointernal.go index daf64a0d2..973b20632 100644 --- a/internal/typeutils/frontendtointernal.go +++ b/internal/typeutils/frontendtointernal.go @@ -228,16 +228,16 @@ func APIInteractionPolicyToInteractionPolicy( return >smodel.InteractionPolicy{ CanLike: gtsmodel.PolicyRules{ - Always: canLikeAlways, - WithApproval: canLikeWithApproval, + AutomaticApproval: canLikeAlways, + ManualApproval: canLikeWithApproval, }, CanReply: gtsmodel.PolicyRules{ - Always: canReplyAlways, - WithApproval: canReplyWithApproval, + AutomaticApproval: canReplyAlways, + ManualApproval: canReplyWithApproval, }, CanAnnounce: gtsmodel.PolicyRules{ - Always: canAnnounceAlways, - WithApproval: canAnnounceWithApproval, + AutomaticApproval: canAnnounceAlways, + ManualApproval: canAnnounceWithApproval, }, }, nil } diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index debd93a0b..cef48e194 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -1928,6 +1928,9 @@ func populateValuesForProp[T ap.WithIRI]( // InteractionPolicyToASInteractionPolicy returns a // GoToSocial interaction policy suitable for federation. +// +// Note: This currently includes deprecated properties `always` +// and `approvalRequired`. These will be removed in v0.21.0. func (c *Converter) InteractionPolicyToASInteractionPolicy( ctx context.Context, interactionPolicy *gtsmodel.InteractionPolicy, @@ -1942,30 +1945,56 @@ func (c *Converter) InteractionPolicyToASInteractionPolicy( // Build canLike canLike := streams.NewGoToSocialCanLike() - // Build canLike.always + // Build canLike.automaticApproval + canLikeAutomaticApprovalProp := streams.NewGoToSocialAutomaticApprovalProperty() + if err := populateValuesForProp( + canLikeAutomaticApprovalProp, + status, + interactionPolicy.CanLike.AutomaticApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canLike.automaticApproval: %w", err) + } + + // Set canLike.manualApproval + canLike.SetGoToSocialAutomaticApproval(canLikeAutomaticApprovalProp) + + // Build canLike.manualApproval + canLikeManualApprovalProp := streams.NewGoToSocialManualApprovalProperty() + if err := populateValuesForProp( + canLikeManualApprovalProp, + status, + interactionPolicy.CanLike.ManualApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canLike.manualApproval: %w", err) + } + + // Set canLike.manualApproval. + canLike.SetGoToSocialManualApproval(canLikeManualApprovalProp) + + // deprecated: Build canLike.always canLikeAlwaysProp := streams.NewGoToSocialAlwaysProperty() if err := populateValuesForProp( canLikeAlwaysProp, status, - interactionPolicy.CanLike.Always, + interactionPolicy.CanLike.AutomaticApproval, ); err != nil { return nil, gtserror.Newf("error setting canLike.always: %w", err) } - // Set canLike.always + // deprecated: Set canLike.always canLike.SetGoToSocialAlways(canLikeAlwaysProp) - // Build canLike.approvalRequired + // deprecated: Build canLike.approvalRequired canLikeApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() if err := populateValuesForProp( canLikeApprovalRequiredProp, status, - interactionPolicy.CanLike.WithApproval, + interactionPolicy.CanLike.ManualApproval, ); err != nil { return nil, gtserror.Newf("error setting canLike.approvalRequired: %w", err) } - // Set canLike.approvalRequired. + // deprecated: Set canLike.approvalRequired. canLike.SetGoToSocialApprovalRequired(canLikeApprovalRequiredProp) // Set canLike on the policy. @@ -1980,30 +2009,56 @@ func (c *Converter) InteractionPolicyToASInteractionPolicy( // Build canReply canReply := streams.NewGoToSocialCanReply() - // Build canReply.always + // Build canReply.automaticApproval + canReplyAutomaticApprovalProp := streams.NewGoToSocialAutomaticApprovalProperty() + if err := populateValuesForProp( + canReplyAutomaticApprovalProp, + status, + interactionPolicy.CanReply.AutomaticApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canReply.automaticApproval: %w", err) + } + + // Set canReply.manualApproval + canReply.SetGoToSocialAutomaticApproval(canReplyAutomaticApprovalProp) + + // Build canReply.manualApproval + canReplyManualApprovalProp := streams.NewGoToSocialManualApprovalProperty() + if err := populateValuesForProp( + canReplyManualApprovalProp, + status, + interactionPolicy.CanReply.ManualApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canReply.manualApproval: %w", err) + } + + // Set canReply.manualApproval. + canReply.SetGoToSocialManualApproval(canReplyManualApprovalProp) + + // deprecated: Build canReply.always canReplyAlwaysProp := streams.NewGoToSocialAlwaysProperty() if err := populateValuesForProp( canReplyAlwaysProp, status, - interactionPolicy.CanReply.Always, + interactionPolicy.CanReply.AutomaticApproval, ); err != nil { return nil, gtserror.Newf("error setting canReply.always: %w", err) } - // Set canReply.always + // deprecated: Set canReply.always canReply.SetGoToSocialAlways(canReplyAlwaysProp) - // Build canReply.approvalRequired + // deprecated: Build canReply.approvalRequired canReplyApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() if err := populateValuesForProp( canReplyApprovalRequiredProp, status, - interactionPolicy.CanReply.WithApproval, + interactionPolicy.CanReply.ManualApproval, ); err != nil { return nil, gtserror.Newf("error setting canReply.approvalRequired: %w", err) } - // Set canReply.approvalRequired. + // deprecated: Set canReply.approvalRequired. canReply.SetGoToSocialApprovalRequired(canReplyApprovalRequiredProp) // Set canReply on the policy. @@ -2018,30 +2073,56 @@ func (c *Converter) InteractionPolicyToASInteractionPolicy( // Build canAnnounce canAnnounce := streams.NewGoToSocialCanAnnounce() - // Build canAnnounce.always + // Build canAnnounce.automaticApproval + canAnnounceAutomaticApprovalProp := streams.NewGoToSocialAutomaticApprovalProperty() + if err := populateValuesForProp( + canAnnounceAutomaticApprovalProp, + status, + interactionPolicy.CanAnnounce.AutomaticApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canAnnounce.automaticApproval: %w", err) + } + + // Set canAnnounce.manualApproval + canAnnounce.SetGoToSocialAutomaticApproval(canAnnounceAutomaticApprovalProp) + + // Build canAnnounce.manualApproval + canAnnounceManualApprovalProp := streams.NewGoToSocialManualApprovalProperty() + if err := populateValuesForProp( + canAnnounceManualApprovalProp, + status, + interactionPolicy.CanAnnounce.ManualApproval, + ); err != nil { + return nil, gtserror.Newf("error setting canAnnounce.manualApproval: %w", err) + } + + // Set canAnnounce.manualApproval. + canAnnounce.SetGoToSocialManualApproval(canAnnounceManualApprovalProp) + + // deprecated: Build canAnnounce.always canAnnounceAlwaysProp := streams.NewGoToSocialAlwaysProperty() if err := populateValuesForProp( canAnnounceAlwaysProp, status, - interactionPolicy.CanAnnounce.Always, + interactionPolicy.CanAnnounce.AutomaticApproval, ); err != nil { return nil, gtserror.Newf("error setting canAnnounce.always: %w", err) } - // Set canAnnounce.always + // deprecated: Set canAnnounce.always canAnnounce.SetGoToSocialAlways(canAnnounceAlwaysProp) - // Build canAnnounce.approvalRequired + // deprecated: Build canAnnounce.approvalRequired canAnnounceApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty() if err := populateValuesForProp( canAnnounceApprovalRequiredProp, status, - interactionPolicy.CanAnnounce.WithApproval, + interactionPolicy.CanAnnounce.ManualApproval, ); err != nil { return nil, gtserror.Newf("error setting canAnnounce.approvalRequired: %w", err) } - // Set canAnnounce.approvalRequired. + // deprecated: Set canAnnounce.approvalRequired. canAnnounce.SetGoToSocialApprovalRequired(canAnnounceApprovalRequiredProp) // Set canAnnounce on the policy. diff --git a/internal/typeutils/internaltoas_test.go b/internal/typeutils/internaltoas_test.go index f8d69491c..5ba23a77e 100644 --- a/internal/typeutils/internaltoas_test.go +++ b/internal/typeutils/internaltoas_test.go @@ -540,19 +540,31 @@ func (suite *InternalToASTestSuite) TestStatusToAS() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-10-20T12:40:37+02:00", @@ -630,19 +642,31 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-10-20T11:36:45Z", @@ -738,19 +762,31 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-10-20T11:36:45Z", @@ -831,19 +867,31 @@ func (suite *InternalToASTestSuite) TestStatusToASWithMentions() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-11-20T13:32:16Z", diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index a22e504c0..6da78ed83 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -2862,19 +2862,29 @@ func (c *Converter) InteractionPolicyToAPIInteractionPolicy( ) (*apimodel.InteractionPolicy, error) { apiPolicy := &apimodel.InteractionPolicy{ CanFavourite: apimodel.PolicyRules{ - Always: policyValsToAPIPolicyVals(policy.CanLike.Always), - WithApproval: policyValsToAPIPolicyVals(policy.CanLike.WithApproval), + AutomaticApproval: policyValsToAPIPolicyVals(policy.CanLike.AutomaticApproval), + ManualApproval: policyValsToAPIPolicyVals(policy.CanLike.ManualApproval), }, CanReply: apimodel.PolicyRules{ - Always: policyValsToAPIPolicyVals(policy.CanReply.Always), - WithApproval: policyValsToAPIPolicyVals(policy.CanReply.WithApproval), + AutomaticApproval: policyValsToAPIPolicyVals(policy.CanReply.AutomaticApproval), + ManualApproval: policyValsToAPIPolicyVals(policy.CanReply.ManualApproval), }, CanReblog: apimodel.PolicyRules{ - Always: policyValsToAPIPolicyVals(policy.CanAnnounce.Always), - WithApproval: policyValsToAPIPolicyVals(policy.CanAnnounce.WithApproval), + AutomaticApproval: policyValsToAPIPolicyVals(policy.CanAnnounce.AutomaticApproval), + ManualApproval: policyValsToAPIPolicyVals(policy.CanAnnounce.ManualApproval), }, } + defer func() { + // Include deprecated fields for back-compat. TODO: Remove these in 0.21.0. + apiPolicy.CanFavourite.Always = apiPolicy.CanFavourite.AutomaticApproval + apiPolicy.CanFavourite.WithApproval = apiPolicy.CanFavourite.ManualApproval + apiPolicy.CanReply.Always = apiPolicy.CanReply.AutomaticApproval + apiPolicy.CanReply.WithApproval = apiPolicy.CanReply.ManualApproval + apiPolicy.CanReblog.Always = apiPolicy.CanReblog.AutomaticApproval + apiPolicy.CanReblog.WithApproval = apiPolicy.CanReblog.ManualApproval + }() + if status == nil || requester == nil { // We're done here! return apiPolicy, nil @@ -2890,16 +2900,16 @@ func (c *Converter) InteractionPolicyToAPIInteractionPolicy( return nil, err } - if likeable.Permission == gtsmodel.PolicyPermissionPermitted { + if likeable.Permission == gtsmodel.PolicyPermissionAutomaticApproval { // We can do this! - apiPolicy.CanFavourite.Always = append( - apiPolicy.CanFavourite.Always, + apiPolicy.CanFavourite.AutomaticApproval = append( + apiPolicy.CanFavourite.AutomaticApproval, apimodel.PolicyValueMe, ) - } else if likeable.Permission == gtsmodel.PolicyPermissionWithApproval { + } else if likeable.Permission == gtsmodel.PolicyPermissionManualApproval { // We can do this with approval. - apiPolicy.CanFavourite.WithApproval = append( - apiPolicy.CanFavourite.WithApproval, + apiPolicy.CanFavourite.ManualApproval = append( + apiPolicy.CanFavourite.ManualApproval, apimodel.PolicyValueMe, ) } @@ -2910,16 +2920,16 @@ func (c *Converter) InteractionPolicyToAPIInteractionPolicy( return nil, err } - if replyable.Permission == gtsmodel.PolicyPermissionPermitted { + if replyable.Permission == gtsmodel.PolicyPermissionAutomaticApproval { // We can do this! - apiPolicy.CanReply.Always = append( - apiPolicy.CanReply.Always, + apiPolicy.CanReply.AutomaticApproval = append( + apiPolicy.CanReply.AutomaticApproval, apimodel.PolicyValueMe, ) - } else if replyable.Permission == gtsmodel.PolicyPermissionWithApproval { + } else if replyable.Permission == gtsmodel.PolicyPermissionManualApproval { // We can do this with approval. - apiPolicy.CanReply.WithApproval = append( - apiPolicy.CanReply.WithApproval, + apiPolicy.CanReply.ManualApproval = append( + apiPolicy.CanReply.ManualApproval, apimodel.PolicyValueMe, ) } @@ -2930,16 +2940,16 @@ func (c *Converter) InteractionPolicyToAPIInteractionPolicy( return nil, err } - if boostable.Permission == gtsmodel.PolicyPermissionPermitted { + if boostable.Permission == gtsmodel.PolicyPermissionAutomaticApproval { // We can do this! - apiPolicy.CanReblog.Always = append( - apiPolicy.CanReblog.Always, + apiPolicy.CanReblog.AutomaticApproval = append( + apiPolicy.CanReblog.AutomaticApproval, apimodel.PolicyValueMe, ) - } else if boostable.Permission == gtsmodel.PolicyPermissionWithApproval { + } else if boostable.Permission == gtsmodel.PolicyPermissionManualApproval { // We can do this with approval. - apiPolicy.CanReblog.WithApproval = append( - apiPolicy.CanReblog.WithApproval, + apiPolicy.CanReblog.ManualApproval = append( + apiPolicy.CanReblog.ManualApproval, apimodel.PolicyValueMe, ) } diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index 63e242f79..6a5503e83 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -583,6 +583,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -590,6 +595,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -597,6 +607,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -731,6 +746,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -738,6 +758,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -745,6 +770,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -881,6 +911,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendApplicationDeleted "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -888,6 +923,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendApplicationDeleted "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -895,6 +935,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendApplicationDeleted "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1088,6 +1133,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() { ], "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1095,6 +1145,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1102,6 +1157,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1274,6 +1334,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { ], "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1281,6 +1346,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1288,6 +1358,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1366,6 +1441,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { ], "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1373,6 +1453,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1380,6 +1465,11 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1665,6 +1755,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1672,6 +1767,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1679,6 +1779,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1744,18 +1849,30 @@ func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public" + ], + "manual_approval": [], "always": [ "public" ], "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public" + ], + "manual_approval": [], "always": [ "public" ], "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public" + ], + "manual_approval": [], "always": [ "public" ], @@ -1985,6 +2102,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1992,6 +2114,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -1999,6 +2126,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -2084,18 +2216,30 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendPartialInteraction "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "author" + ], + "manual_approval": [], "always": [ "author" ], "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "author" + ], + "manual_approval": [], "always": [ "author" ], "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "author" + ], + "manual_approval": [], "always": [ "author" ], @@ -2208,6 +2352,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval() "content_type": "text/markdown", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -2215,6 +2364,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval() "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -2222,6 +2376,11 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval() "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3186,6 +3345,11 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "poll": null, "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3193,6 +3357,11 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3200,6 +3369,11 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3688,6 +3862,11 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3695,6 +3874,13 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "author", + "me" + ], + "manual_approval": [ + "public" + ], "always": [ "author", "me" @@ -3704,6 +3890,11 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { ] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3787,6 +3978,11 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "content_type": "text/markdown", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3794,6 +3990,11 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3801,6 +4002,11 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3947,6 +4153,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3954,6 +4165,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -3961,6 +4177,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -4117,6 +4338,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() { "content_type": "text/plain", "interaction_policy": { "can_favourite": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -4124,6 +4350,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() { "with_approval": [] }, "can_reply": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" @@ -4131,6 +4362,11 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() { "with_approval": [] }, "can_reblog": { + "automatic_approval": [ + "public", + "me" + ], + "manual_approval": [], "always": [ "public", "me" diff --git a/internal/typeutils/wrap_test.go b/internal/typeutils/wrap_test.go index 612b92ae8..ae68d98c8 100644 --- a/internal/typeutils/wrap_test.go +++ b/internal/typeutils/wrap_test.go @@ -100,19 +100,31 @@ func (suite *WrapTestSuite) TestWrapNoteInCreate() { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canLike": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] }, "canReply": { "always": [ "https://www.w3.org/ns/activitystreams#Public" ], - "approvalRequired": [] + "approvalRequired": [], + "automaticApproval": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "manualApproval": [] } }, "published": "2021-10-20T12:40:37+02:00", |
