diff options
author | 2022-11-11 12:18:38 +0100 | |
---|---|---|
committer | 2022-11-11 12:18:38 +0100 | |
commit | edcee14d07bae129e2d1a06d99c30fc6f659ff5e (patch) | |
tree | 5b9d605654347fe104c55bf4b0e7fb1e1533e2a0 /testrig/testmodels.go | |
parent | [feature] S3: add config flag to proxy S3 media (#1014) (diff) | |
download | gotosocial-edcee14d07bae129e2d1a06d99c30fc6f659ff5e.tar.xz |
[feature] Read + Write tombstones for deleted Actors (#1005)
* [feature] Read + Write tombstones for deleted Actors
* copyTombstone
* update to use resultcache instead of old ttl cache
Signed-off-by: kim <grufwub@gmail.com>
* update go-cache library to fix result cache capacity / ordering bugs
Signed-off-by: kim <grufwub@gmail.com>
* bump go-cache/v3 to v3.1.6 to fix bugs
Signed-off-by: kim <grufwub@gmail.com>
* switch on status code
* better explain ErrGone reasoning
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r-- | testrig/testmodels.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go index fa2eabf04..9f987eeae 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -583,6 +583,18 @@ func NewTestAccounts() map[string]*gtsmodel.Account { return accounts } +func NewTestTombstones() map[string]*gtsmodel.Tombstone { + return map[string]*gtsmodel.Tombstone{ + "https://somewhere.mysterious/users/rest_in_piss#main-key": { + ID: "01GHBTVE9HQPPBDH2W5VH2DGN4", + CreatedAt: TimeMustParse("2021-11-09T19:33:45Z"), + UpdatedAt: TimeMustParse("2021-11-09T19:33:45Z"), + Domain: "somewhere.mysterious", + URI: "https://somewhere.mysterious/users/rest_in_piss#main-key", + }, + } +} + // NewTestAttachments returns a map of attachments keyed according to which account // and status they belong to, and which attachment number of that status they are. func NewTestAttachments() map[string]*gtsmodel.MediaAttachment { @@ -1835,6 +1847,16 @@ func NewTestActivities(accounts map[string]*gtsmodel.Account) map[string]Activit ) announceForwarded2ZorkSig, announceForwarded2ZorkDigest, announceForwarded2ZorkDate := GetSignatureForActivity(announceForwarded2Zork, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI)) + deleteForRemoteAccount3 := newAPDelete( + URLMustParse("https://somewhere.mysterious/users/rest_in_piss"), + URLMustParse("https://somewhere.mysterious/users/rest_in_piss"), + TimeMustParse("2022-07-13T12:13:12+02:00"), + URLMustParse(accounts["local_account_1"].URI), + ) + // it doesn't really matter what key we use to sign this, since we're not going to be able to verify if anyway + keyToSignDelete := accounts["remote_account_1"].PrivateKey + deleteForRemoteAccount3Sig, deleteForRemoteAccount3Digest, deleteForRemoteAccount3Date := GetSignatureForActivity(deleteForRemoteAccount3, "https://somewhere.mysterious/users/rest_in_piss#main-key", keyToSignDelete, URLMustParse(accounts["local_account_1"].InboxURI)) + return map[string]ActivityWithSignature{ "dm_for_zork": { Activity: createDmForZork, @@ -1878,6 +1900,12 @@ func NewTestActivities(accounts map[string]*gtsmodel.Account) map[string]Activit DigestHeader: announceForwarded2ZorkDigest, DateHeader: announceForwarded2ZorkDate, }, + "delete_https://somewhere.mysterious/users/rest_in_piss#main-key": { + Activity: deleteForRemoteAccount3, + SignatureHeader: deleteForRemoteAccount3Sig, + DigestHeader: deleteForRemoteAccount3Digest, + DateHeader: deleteForRemoteAccount3Date, + }, } } @@ -3151,3 +3179,25 @@ func newAPAnnounce(announceID *url.URL, announceActor *url.URL, announcePublishe return announce } + +func newAPDelete(deleteTarget *url.URL, deleteActor *url.URL, deletePublished time.Time, deleteTo *url.URL) vocab.ActivityStreamsDelete { + delete := streams.NewActivityStreamsDelete() + + objectProp := streams.NewActivityStreamsObjectProperty() + objectProp.AppendIRI(deleteTarget) + delete.SetActivityStreamsObject(objectProp) + + to := streams.NewActivityStreamsToProperty() + to.AppendIRI(deleteTo) + delete.SetActivityStreamsTo(to) + + actor := streams.NewActivityStreamsActorProperty() + actor.AppendIRI(deleteActor) + delete.SetActivityStreamsActor(actor) + + published := streams.NewActivityStreamsPublishedProperty() + published.Set(deletePublished) + delete.SetActivityStreamsPublished(published) + + return delete +} |