diff options
author | 2021-10-10 12:39:25 +0200 | |
---|---|---|
committer | 2021-10-10 12:39:25 +0200 | |
commit | 367bdca25093ee76b36506d8a5e6733b0aa2e2bb (patch) | |
tree | 37b1b82ae6e9fad7e6d95b8abbb58bdb42049707 /testrig/testmodels.go | |
parent | Derive visibility fixes (#271) (diff) | |
download | gotosocial-367bdca25093ee76b36506d8a5e6733b0aa2e2bb.tar.xz |
Handle forwarded messages (#273)
* correct path of foss_satan
* add APIri and notes
* test create forward note
* rename target => receiving account
* split up create into separate funcs
* update extractFromCtx
* tidy up from federator processing
* foss satan => http not https
* check if status in db
* mock dereference of status from IRI
* add forward message deref test
* update test with activities
* add remote_account_2 to test rig
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r-- | testrig/testmodels.go | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go index 8ed5054d1..3fd542e27 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -446,6 +446,41 @@ func NewTestAccounts() map[string]*gtsmodel.Account { HideCollections: false, SuspensionOrigin: "", }, + "remote_account_2": { + ID: "01FHMQX3GAABWSM0S2VZEC2SWC", + Username: "some_user", + Domain: "example.org", + DisplayName: "some user", + Fields: []gtsmodel.Field{}, + Note: "i'm a real son of a gun", + Memorial: false, + MovedToAccountID: "", + CreatedAt: TimeMustParse("2020-08-10T14:13:28+02:00"), + UpdatedAt: time.Now().Add(-1 * time.Hour), + Bot: false, + Locked: true, + Discoverable: true, + Sensitive: false, + Language: "en", + URI: "http://example.org/users/some_user", + URL: "http://example.org/@some_user", + LastWebfingeredAt: time.Time{}, + InboxURI: "http://example.org/users/some_user/inbox", + OutboxURI: "http://example.org/users/some_user/outbox", + FollowersURI: "http://example.org/users/some_user/followers", + FollowingURI: "http://example.org/users/some_user/following", + FeaturedCollectionURI: "http://example.org/users/some_user/collections/featured", + ActorType: ap.ActorPerson, + AlsoKnownAs: "", + PrivateKey: &rsa.PrivateKey{}, + PublicKey: &rsa.PublicKey{}, + PublicKeyURI: "http://example.org/users/some_user#main-key", + SensitizedAt: time.Time{}, + SilencedAt: time.Time{}, + SuspendedAt: time.Time{}, + HideCollections: false, + SuspensionOrigin: "", + }, } // generate keys for each account @@ -1268,29 +1303,53 @@ type ActivityWithSignature struct { // their requesting signatures. func NewTestActivities(accounts map[string]*gtsmodel.Account) map[string]ActivityWithSignature { dmForZork := newNote( - URLMustParse("https://fossbros-anonymous.io/users/foss_satan/statuses/5424b153-4553-4f30-9358-7b92f7cd42f6"), - URLMustParse("https://fossbros-anonymous.io/@foss_satan/5424b153-4553-4f30-9358-7b92f7cd42f6"), + URLMustParse("http://fossbros-anonymous.io/users/foss_satan/statuses/5424b153-4553-4f30-9358-7b92f7cd42f6"), + URLMustParse("http://fossbros-anonymous.io/@foss_satan/5424b153-4553-4f30-9358-7b92f7cd42f6"), time.Now(), "hey zork here's a new private note for you", "new note for zork", - URLMustParse("https://fossbros-anonymous.io/users/foss_satan"), + URLMustParse("http://fossbros-anonymous.io/users/foss_satan"), []*url.URL{URLMustParse("http://localhost:8080/users/the_mighty_zork")}, nil, true, []vocab.ActivityStreamsMention{}) createDmForZork := wrapNoteInCreate( - URLMustParse("https://fossbros-anonymous.io/users/foss_satan/statuses/5424b153-4553-4f30-9358-7b92f7cd42f6/activity"), - URLMustParse("https://fossbros-anonymous.io/users/foss_satan"), + URLMustParse("http://fossbros-anonymous.io/users/foss_satan/statuses/5424b153-4553-4f30-9358-7b92f7cd42f6/activity"), + URLMustParse("http://fossbros-anonymous.io/users/foss_satan"), time.Now(), dmForZork) - sig, digest, date := GetSignatureForActivity(createDmForZork, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI)) + createDmForZorkSig, createDmForZorkDigest, creatDmForZorkDate := GetSignatureForActivity(createDmForZork, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI)) + + forwardedMessage := newNote( + URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1"), + URLMustParse("http://example.org/@some_user/afaba698-5740-4e32-a702-af61aa543bc1"), + time.Now(), + "this is a public status, please forward it!", + "", + URLMustParse("http://example.org/users/some_user"), + []*url.URL{URLMustParse(pub.PublicActivityPubIRI)}, + nil, + false, + []vocab.ActivityStreamsMention{}) + createForwardedMessage := wrapNoteInCreate( + URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1/activity"), + URLMustParse("http://example.org/users/some_user"), + time.Now(), + forwardedMessage) + createForwardedMessageSig, createForwardedMessageDigest, createForwardedMessageDate := GetSignatureForActivity(createForwardedMessage, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI)) return map[string]ActivityWithSignature{ "dm_for_zork": { Activity: createDmForZork, - SignatureHeader: sig, - DigestHeader: digest, - DateHeader: date, + SignatureHeader: createDmForZorkSig, + DigestHeader: createDmForZorkDigest, + DateHeader: creatDmForZorkDate, + }, + "forwarded_message": { + Activity: createForwardedMessage, + SignatureHeader: createForwardedMessageSig, + DigestHeader: createForwardedMessageDigest, + DateHeader: createForwardedMessageDate, }, } } |