mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: remote announces not showing up in local inboxes
This commit is contained in:
@@ -71,7 +71,7 @@ inbox.like = async (req) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inbox.announce = async (req) => {
|
inbox.announce = async (req) => {
|
||||||
const { actor, object, published } = req.body;
|
const { actor, object, published, to, cc } = req.body;
|
||||||
let timestamp = Date.now();
|
let timestamp = Date.now();
|
||||||
try {
|
try {
|
||||||
timestamp = new Date(published).getTime();
|
timestamp = new Date(published).getTime();
|
||||||
@@ -103,6 +103,8 @@ inbox.announce = async (req) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await topics.updateLastPostTime(tid, timestamp);
|
await topics.updateLastPostTime(tid, timestamp);
|
||||||
|
await activitypub.notes.updateLocalRecipients(pid, { to, cc });
|
||||||
|
await activitypub.notes.syncUserInboxes(tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
winston.info(`[activitypub/inbox/announce] Parsing id ${pid}`);
|
winston.info(`[activitypub/inbox/announce] Parsing id ${pid}`);
|
||||||
|
|||||||
@@ -42,11 +42,7 @@ Notes.assert = async (uid, input, options = {}) => {
|
|||||||
|
|
||||||
// Parse ActivityPub-specific data
|
// Parse ActivityPub-specific data
|
||||||
const { to, cc } = postData._activitypub;
|
const { to, cc } = postData._activitypub;
|
||||||
let recipients = new Set([...to, ...cc]);
|
await Notes.updateLocalRecipients(id, { to, cc });
|
||||||
recipients = await Notes.getLocalRecipients(recipients);
|
|
||||||
if (recipients.size > 0) {
|
|
||||||
await db.setAdd(`post:${id}:recipients`, Array.from(recipients));
|
|
||||||
}
|
|
||||||
|
|
||||||
const hash = { ...postData };
|
const hash = { ...postData };
|
||||||
delete hash._activitypub;
|
delete hash._activitypub;
|
||||||
@@ -62,7 +58,8 @@ Notes.assert = async (uid, input, options = {}) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
Notes.getLocalRecipients = async (recipients) => {
|
Notes.updateLocalRecipients = async (id, { to, cc }) => {
|
||||||
|
const recipients = new Set([...to, ...cc]);
|
||||||
const uids = new Set();
|
const uids = new Set();
|
||||||
await Promise.all(Array.from(recipients).map(async (recipient) => {
|
await Promise.all(Array.from(recipients).map(async (recipient) => {
|
||||||
const { type, id } = await activitypub.helpers.resolveLocalId(recipient);
|
const { type, id } = await activitypub.helpers.resolveLocalId(recipient);
|
||||||
@@ -81,7 +78,9 @@ Notes.getLocalRecipients = async (recipients) => {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return uids;
|
if (uids.size > 0) {
|
||||||
|
await db.setAdd(`post:${id}:recipients`, Array.from(uids));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Notes.getParentChain = async (uid, input) => {
|
Notes.getParentChain = async (uid, input) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user