mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-23 10:11:46 +02:00
fix: update targets in 1b12 rebroadcast when cid is remote
This commit is contained in:
@@ -21,17 +21,13 @@ Feps.announce = async function announce(id, activity) {
|
|||||||
* - local tids (posted to remote cids) only
|
* - local tids (posted to remote cids) only
|
||||||
*/
|
*/
|
||||||
const tid = await posts.getPostField(localId || id, 'tid');
|
const tid = await posts.getPostField(localId || id, 'tid');
|
||||||
let cid = await topics.getTopicField(tid, 'cid');
|
const cid = await topics.getTopicField(tid, 'cid');
|
||||||
const localCid = utils.isNumber(cid) && cid > 0;
|
const localCid = utils.isNumber(cid) && cid > 0;
|
||||||
const shouldAnnounce = localCid || utils.isNumber(tid);
|
const shouldAnnounce = localCid || utils.isNumber(tid);
|
||||||
if (!shouldAnnounce) { // inverse conditionals can kiss my ass.
|
if (!shouldAnnounce) { // inverse conditionals can kiss my ass.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!localCid) {
|
|
||||||
cid = 0; // override cid to 0 so application actor sends the announce
|
|
||||||
}
|
|
||||||
|
|
||||||
let relays = await activitypub.relays.list();
|
let relays = await activitypub.relays.list();
|
||||||
relays = relays.reduce((memo, { state, url }) => {
|
relays = relays.reduce((memo, { state, url }) => {
|
||||||
if (state === 2) {
|
if (state === 2) {
|
||||||
@@ -39,7 +35,7 @@ Feps.announce = async function announce(id, activity) {
|
|||||||
}
|
}
|
||||||
return memo;
|
return memo;
|
||||||
}, []);
|
}, []);
|
||||||
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
const followers = localCid ? await activitypub.notes.getCategoryFollowers(cid) : [cid];
|
||||||
const targets = relays.concat(followers);
|
const targets = relays.concat(followers);
|
||||||
if (!targets.length) {
|
if (!targets.length) {
|
||||||
return;
|
return;
|
||||||
@@ -54,7 +50,7 @@ Feps.announce = async function announce(id, activity) {
|
|||||||
const isMain = await posts.isMain(localId || id);
|
const isMain = await posts.isMain(localId || id);
|
||||||
if (isMain) {
|
if (isMain) {
|
||||||
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing plain object (${activity.id}) to followers of cid ${cid} and ${relays.length} relays`);
|
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing plain object (${activity.id}) to followers of cid ${cid} and ${relays.length} relays`);
|
||||||
await activitypub.send('cid', cid, targets, {
|
await activitypub.send('cid', localCid ? cid : 0, targets, {
|
||||||
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now}`,
|
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now}`,
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
actor: `${nconf.get('url')}/category/${cid}`,
|
actor: `${nconf.get('url')}/category/${cid}`,
|
||||||
@@ -66,7 +62,7 @@ Feps.announce = async function announce(id, activity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing ${activity.type} (${activity.id}) to followers of cid ${cid} and ${relays.length} relays`);
|
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing ${activity.type} (${activity.id}) to followers of cid ${cid} and ${relays.length} relays`);
|
||||||
await activitypub.send('cid', cid, targets, {
|
await activitypub.send('cid', localCid ? cid : 0, targets, {
|
||||||
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now + 1}`,
|
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now + 1}`,
|
||||||
type: 'Announce',
|
type: 'Announce',
|
||||||
actor: `${nconf.get('url')}/category/${cid}`,
|
actor: `${nconf.get('url')}/category/${cid}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user