summaryrefslogtreecommitdiff
path: root/internal/federation/gone.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-11 12:18:38 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-11 12:18:38 +0100
commitedcee14d07bae129e2d1a06d99c30fc6f659ff5e (patch)
tree5b9d605654347fe104c55bf4b0e7fb1e1533e2a0 /internal/federation/gone.go
parent[feature] S3: add config flag to proxy S3 media (#1014) (diff)
downloadgotosocial-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 'internal/federation/gone.go')
-rw-r--r--internal/federation/gone.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/federation/gone.go b/internal/federation/gone.go
new file mode 100644
index 000000000..3d9fe3b84
--- /dev/null
+++ b/internal/federation/gone.go
@@ -0,0 +1,34 @@
+package federation
+
+import (
+ "context"
+ "fmt"
+ "net/url"
+
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
+)
+
+// CheckGone checks if a tombstone exists in the database for AP Actor or Object with the given uri.
+func (f *federator) CheckGone(ctx context.Context, uri *url.URL) (bool, error) {
+ return f.db.TombstoneExistsWithURI(ctx, uri.String())
+}
+
+// HandleGone puts a tombstone in the database, which marks an AP Actor or Object with the given uri as gone.
+func (f *federator) HandleGone(ctx context.Context, uri *url.URL) error {
+ tombstoneID, err := id.NewULID()
+ if err != nil {
+ err = fmt.Errorf("HandleGone: error generating id for new tombstone %s: %s", uri, err)
+ log.Error(err)
+ return err
+ }
+
+ tombstone := &gtsmodel.Tombstone{
+ ID: tombstoneID,
+ Domain: uri.Host,
+ URI: uri.String(),
+ }
+
+ return f.db.PutTombstone(ctx, tombstone)
+}