summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltoas_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-10-11 15:22:05 +0200
committerLibravatar GitHub <noreply@github.com>2024-10-11 15:22:05 +0200
commit77d755e330d41e681097b0606088281c255c18e0 (patch)
treed0fe9d092b87481230ab95a2d0e1fd08decb5d8d /internal/typeutils/internaltoas_test.go
parent[bugfix] Check interaction policies properly on incoming Likes (#3416) (diff)
downloadgotosocial-77d755e330d41e681097b0606088281c255c18e0.tar.xz
[chore] Don't cc Accept of likes to followers (#3417)v0.17.0-rc4
Diffstat (limited to 'internal/typeutils/internaltoas_test.go')
-rw-r--r--internal/typeutils/internaltoas_test.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/internal/typeutils/internaltoas_test.go b/internal/typeutils/internaltoas_test.go
index d0ed4204c..a97eee2b8 100644
--- a/internal/typeutils/internaltoas_test.go
+++ b/internal/typeutils/internaltoas_test.go
@@ -1143,7 +1143,7 @@ func (suite *InternalToASTestSuite) TestPollVoteToASCreate() {
}`, string(bytes))
}
-func (suite *InternalToASTestSuite) TestInteractionReqToASAccept() {
+func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() {
acceptingAccount := suite.testAccounts["local_account_1"]
interactingAccount := suite.testAccounts["remote_account_1"]
@@ -1192,6 +1192,51 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAccept() {
}`, string(b))
}
+func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() {
+ acceptingAccount := suite.testAccounts["local_account_1"]
+ interactingAccount := suite.testAccounts["remote_account_1"]
+
+ req := &gtsmodel.InteractionRequest{
+ ID: "01J1AKMZ8JE5NW0ZSFTRC1JJNE",
+ CreatedAt: testrig.TimeMustParse("2022-06-09T13:12:00Z"),
+ TargetAccountID: acceptingAccount.ID,
+ TargetAccount: acceptingAccount,
+ InteractingAccountID: interactingAccount.ID,
+ InteractingAccount: interactingAccount,
+ InteractionURI: "https://fossbros-anonymous.io/users/foss_satan/statuses/01J1AKRRHQ6MDDQHV0TP716T2K",
+ InteractionType: gtsmodel.InteractionLike,
+ URI: "http://localhost:8080/users/the_mighty_zork/accepts/01J1AKMZ8JE5NW0ZSFTRC1JJNE",
+ AcceptedAt: testrig.TimeMustParse("2022-06-09T13:12:00Z"),
+ }
+
+ accept, err := suite.typeconverter.InteractionReqToASAccept(
+ context.Background(),
+ req,
+ )
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ i, err := ap.Serialize(accept)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ b, err := json.MarshalIndent(i, "", " ")
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ suite.Equal(`{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "actor": "http://localhost:8080/users/the_mighty_zork",
+ "id": "http://localhost:8080/users/the_mighty_zork/accepts/01J1AKMZ8JE5NW0ZSFTRC1JJNE",
+ "object": "https://fossbros-anonymous.io/users/foss_satan/statuses/01J1AKRRHQ6MDDQHV0TP716T2K",
+ "to": "http://fossbros-anonymous.io/users/foss_satan",
+ "type": "Accept"
+}`, string(b))
+}
+
func TestInternalToASTestSuite(t *testing.T) {
suite.Run(t, new(InternalToASTestSuite))
}