mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
* testing thumn/post upload refactor
* fix: isOrphan check
* lint: fix md5
* test: fix upload test
* user
* fix: upgrade script
* refactor: long line
* lint: lint
* test: fix tests
* Squashed commit of the following:
commit cd70e6c610
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date: Fri Apr 4 09:24:54 2025 -0400
fix: req.body can be undefined
* refactor: show data on test fail
* test: logs
* test: change test
* make sure timestamps are different
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const nconf = require('nconf');
|
|
|
|
const posts = require('../posts');
|
|
|
|
const activitypub = module.parent.exports;
|
|
const Feps = module.exports;
|
|
|
|
Feps.announce = async function announce(id, activity) {
|
|
let localId;
|
|
if (String(id).startsWith(nconf.get('url'))) {
|
|
({ id: localId } = await activitypub.helpers.resolveLocalId(id));
|
|
}
|
|
const cid = await posts.getCidByPid(localId || id);
|
|
if (cid === -1) {
|
|
return;
|
|
}
|
|
|
|
const followers = await activitypub.notes.getCategoryFollowers(cid);
|
|
if (!followers.length) {
|
|
return;
|
|
}
|
|
|
|
const { actor } = activity;
|
|
if (actor && !actor.startsWith(nconf.get('url'))) {
|
|
followers.unshift(actor);
|
|
}
|
|
const now = Date.now();
|
|
if (activity.type === 'Create') {
|
|
const isMain = await posts.isMain(localId || id);
|
|
if (isMain) {
|
|
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing plain object (${activity.id}) to followers of cid ${cid}`);
|
|
await activitypub.send('cid', cid, followers, {
|
|
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now}`,
|
|
type: 'Announce',
|
|
actor: `${nconf.get('url')}/category/${cid}`,
|
|
to: [`${nconf.get('url')}/category/${cid}/followers`],
|
|
cc: [actor, activitypub._constants.publicAddress],
|
|
object: activity.object,
|
|
});
|
|
}
|
|
}
|
|
|
|
activitypub.helpers.log(`[activitypub/inbox.announce(1b12)] Announcing ${activity.type} (${activity.id}) to followers of cid ${cid}`);
|
|
await activitypub.send('cid', cid, followers, {
|
|
id: `${nconf.get('url')}/post/${encodeURIComponent(id)}#activity/announce/${now + 1}`,
|
|
type: 'Announce',
|
|
actor: `${nconf.get('url')}/category/${cid}`,
|
|
to: [`${nconf.get('url')}/category/${cid}/followers`],
|
|
cc: [actor, activitypub._constants.publicAddress],
|
|
object: activity,
|
|
});
|
|
};
|