feat: send Update(Note) on chat message deletion and restoration, serving Tombstone if deleted

re: #12853
This commit is contained in:
Julian Lam
2024-10-17 11:05:27 -04:00
parent b472c58946
commit 61445d3d87
4 changed files with 36 additions and 7 deletions

View File

@@ -288,16 +288,22 @@ activitypubApi.update.note = enabledCheck(async (caller, { post }) => {
});
activitypubApi.update.privateNote = enabledCheck(async (caller, { messageObj }) => {
if (!utils.isNumber(messageObj.mid)) {
return;
}
const { roomId } = messageObj;
let targets = await messaging.getUidsInRoom(roomId, 0, -1);
targets = targets.filter(uid => !utils.isNumber(uid)); // remote uids only
let uids = await messaging.getUidsInRoom(roomId, 0, -1);
uids = uids.filter(uid => String(uid) !== String(messageObj.fromuid)); // no author
const to = uids.map(uid => (utils.isNumber(uid) ? `${nconf.get('url')}/uid/${uid}` : uid));
const targets = uids.filter(uid => !utils.isNumber(uid)); // remote uids only
const object = await activitypub.mocks.notes.private({ messageObj });
const payload = {
id: `${object.id}#activity/create/${Date.now()}`,
type: 'Update',
to: object.to,
to,
object,
};