fix: #13375, plus additional tests

This commit is contained in:
Julian Lam
2025-05-13 13:59:34 -04:00
parent 30db15836b
commit fe13c75549
3 changed files with 72 additions and 47 deletions

View File

@@ -115,24 +115,18 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
if (hasTid) {
mainPid = await topics.getTopicField(tid, 'mainPid');
} else {
// Check recipients/audience for category (local or remote)
// Check recipients/audience for local category
const set = activitypub.helpers.makeSet(_activitypub, ['to', 'cc', 'audience']);
await activitypub.actors.assert(Array.from(set));
// Local
const resolved = await Promise.all(Array.from(set).map(async id => await activitypub.helpers.resolveLocalId(id)));
const recipientCids = resolved
.filter(Boolean)
.filter(({ type }) => type === 'category')
.map(obj => obj.id);
// Remote
const assertedGroups = await db.exists(Array.from(set).map(id => `categoryRemote:${id}`));
const remoteCid = Array.from(set).filter((_, idx) => assertedGroups[idx]).shift();
if (remoteCid || recipientCids.length) {
if (recipientCids.length) {
// Overrides passed-in value, respect addressing from main post over booster
options.cid = remoteCid || recipientCids.shift();
options.cid = recipientCids.shift();
}
// mainPid ok to leave as-is