mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user