Skip to content

Node.js based forum software built for the modern web

feat: handle receipt of Update(Tombstone)

Julian Lamf404395962e4
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index 80412aca8b..a1a514c544 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -11,6 +11,7 @@ const topics = require('../topics');
const categories = require('../categories');
const notifications = require('../notifications');
const flags = require('../flags');
+const api = require('../api');
const activitypub = require('.');
const socketHelpers = require('../socket.io/helpers');
@@ -74,6 +75,10 @@ inbox.update = async (req) => {
try {
if (exists) {
await posts.edit(postData);
+ const isDeleted = await posts.getPostField(object.id, 'deleted');
+ if (isDeleted) {
+ await api.posts.restore({ uid: actor }, { pid: object.id });
+ }
} else {
await activitypub.notes.assert(0, object.id);
}
@@ -87,6 +92,25 @@ inbox.update = async (req) => {
await activitypub.actors.assert(object.id, { update: true });
break;
}
+
+ case 'Tombstone': {
+ const [isNote, isActor] = await Promise.all([
+ posts.exists(object.id),
+ db.isSortedSetMember('usersRemote:lastCrawled', object.id),
+ ]);
+
+ switch (true) {
+ case isNote: {
+ await api.posts.delete({ uid: actor }, { pid: object.id });
+ break;
+ }
+
+ // case isActor: {
+ // console.log('actor');
+ // break;
+ // }
+ }
+ }
}
};