[chore] Don't cc Accept of likes to followers (#3417)
This commit is contained in:
parent
1c895f314c
commit
77d755e330
|
@ -1988,16 +1988,6 @@ func (c *Converter) InteractionReqToASAccept(
|
||||||
return nil, gtserror.Newf("invalid interacting account uri: %w", err)
|
return nil, gtserror.Newf("invalid interacting account uri: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
publicIRI, err := url.Parse(pub.PublicActivityPubIRI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf("invalid public uri: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
followersIRI, err := url.Parse(req.TargetAccount.FollowersURI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf("invalid followers uri: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set id to the URI of
|
// Set id to the URI of
|
||||||
// interaction request.
|
// interaction request.
|
||||||
ap.SetJSONLDId(accept, acceptID)
|
ap.SetJSONLDId(accept, acceptID)
|
||||||
|
@ -2013,8 +2003,39 @@ func (c *Converter) InteractionReqToASAccept(
|
||||||
// of interaction URI.
|
// of interaction URI.
|
||||||
ap.AppendTo(accept, toIRI)
|
ap.AppendTo(accept, toIRI)
|
||||||
|
|
||||||
// Cc to the actor's followers, and to Public.
|
// Whether or not we cc this Accept to
|
||||||
ap.AppendCc(accept, publicIRI, followersIRI)
|
// followers and public depends on the
|
||||||
|
// type of interaction it Accepts.
|
||||||
|
|
||||||
|
var cc bool
|
||||||
|
switch req.InteractionType {
|
||||||
|
|
||||||
|
case gtsmodel.InteractionLike:
|
||||||
|
// Accept of Like doesn't get cc'd
|
||||||
|
// because it's not that important.
|
||||||
|
|
||||||
|
case gtsmodel.InteractionReply:
|
||||||
|
// Accept of reply gets cc'd.
|
||||||
|
cc = true
|
||||||
|
|
||||||
|
case gtsmodel.InteractionAnnounce:
|
||||||
|
// Accept of announce gets cc'd.
|
||||||
|
cc = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if cc {
|
||||||
|
publicIRI, err := url.Parse(pub.PublicActivityPubIRI)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gtserror.Newf("invalid public uri: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
followersIRI, err := url.Parse(req.TargetAccount.FollowersURI)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gtserror.Newf("invalid followers uri: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ap.AppendCc(accept, publicIRI, followersIRI)
|
||||||
|
}
|
||||||
|
|
||||||
return accept, nil
|
return accept, nil
|
||||||
}
|
}
|
||||||
|
@ -2047,16 +2068,6 @@ func (c *Converter) InteractionReqToASReject(
|
||||||
return nil, gtserror.Newf("invalid interacting account uri: %w", err)
|
return nil, gtserror.Newf("invalid interacting account uri: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
publicIRI, err := url.Parse(pub.PublicActivityPubIRI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf("invalid public uri: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
followersIRI, err := url.Parse(req.TargetAccount.FollowersURI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf("invalid followers uri: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set id to the URI of
|
// Set id to the URI of
|
||||||
// interaction request.
|
// interaction request.
|
||||||
ap.SetJSONLDId(reject, rejectID)
|
ap.SetJSONLDId(reject, rejectID)
|
||||||
|
@ -2072,8 +2083,39 @@ func (c *Converter) InteractionReqToASReject(
|
||||||
// of interaction URI.
|
// of interaction URI.
|
||||||
ap.AppendTo(reject, toIRI)
|
ap.AppendTo(reject, toIRI)
|
||||||
|
|
||||||
// Cc to the actor's followers, and to Public.
|
// Whether or not we cc this Reject to
|
||||||
ap.AppendCc(reject, publicIRI, followersIRI)
|
// followers and public depends on the
|
||||||
|
// type of interaction it Rejects.
|
||||||
|
|
||||||
|
var cc bool
|
||||||
|
switch req.InteractionType {
|
||||||
|
|
||||||
|
case gtsmodel.InteractionLike:
|
||||||
|
// Reject of Like doesn't get cc'd
|
||||||
|
// because it's not that important.
|
||||||
|
|
||||||
|
case gtsmodel.InteractionReply:
|
||||||
|
// Reject of reply gets cc'd.
|
||||||
|
cc = true
|
||||||
|
|
||||||
|
case gtsmodel.InteractionAnnounce:
|
||||||
|
// Reject of announce gets cc'd.
|
||||||
|
cc = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if cc {
|
||||||
|
publicIRI, err := url.Parse(pub.PublicActivityPubIRI)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gtserror.Newf("invalid public uri: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
followersIRI, err := url.Parse(req.TargetAccount.FollowersURI)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gtserror.Newf("invalid followers uri: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ap.AppendCc(reject, publicIRI, followersIRI)
|
||||||
|
}
|
||||||
|
|
||||||
return reject, nil
|
return reject, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ func (suite *InternalToASTestSuite) TestPollVoteToASCreate() {
|
||||||
}`, string(bytes))
|
}`, string(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InternalToASTestSuite) TestInteractionReqToASAccept() {
|
func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() {
|
||||||
acceptingAccount := suite.testAccounts["local_account_1"]
|
acceptingAccount := suite.testAccounts["local_account_1"]
|
||||||
interactingAccount := suite.testAccounts["remote_account_1"]
|
interactingAccount := suite.testAccounts["remote_account_1"]
|
||||||
|
|
||||||
|
@ -1192,6 +1192,51 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAccept() {
|
||||||
}`, string(b))
|
}`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() {
|
||||||
|
acceptingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
interactingAccount := suite.testAccounts["remote_account_1"]
|
||||||
|
|
||||||
|
req := >smodel.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) {
|
func TestInternalToASTestSuite(t *testing.T) {
|
||||||
suite.Run(t, new(InternalToASTestSuite))
|
suite.Run(t, new(InternalToASTestSuite))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue