mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
fix: #13224, handle note attributedTo when it is of type object
This commit is contained in:
@@ -170,21 +170,28 @@ Mocks.post = async (objects) => {
|
|||||||
type, to, cc, audience, attachment, tag, image,
|
type, to, cc, audience, attachment, tag, image,
|
||||||
} = object;
|
} = object;
|
||||||
|
|
||||||
if (Array.isArray(uid)) { // Handle array attributedTo
|
switch (true) { // non-string attributedTo handling
|
||||||
uid = uid.reduce((valid, cur) => {
|
case Array.isArray(uid): {
|
||||||
if (typeof cur === 'string') {
|
uid = uid.reduce((valid, cur) => {
|
||||||
valid.push(cur);
|
if (typeof cur === 'string') {
|
||||||
} else if (typeof cur === 'object') {
|
valid.push(cur);
|
||||||
if (cur.type === 'Person' && cur.id) {
|
} else if (typeof cur === 'object') {
|
||||||
valid.push(cur.id);
|
if (cur.type === 'Person' && cur.id) {
|
||||||
|
valid.push(cur.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}, []);
|
}, []);
|
||||||
uid = uid.shift(); // take first valid uid
|
uid = uid.shift(); // take first valid uid
|
||||||
await activitypub.actors.assert(uid);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case typeof uid === 'object' && uid.hasOwnProperty('id'): {
|
||||||
|
uid = uid.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
await activitypub.actors.assert(uid);
|
||||||
|
|
||||||
const resolved = await activitypub.helpers.resolveLocalId(toPid);
|
const resolved = await activitypub.helpers.resolveLocalId(toPid);
|
||||||
if (resolved.type === 'post') {
|
if (resolved.type === 'post') {
|
||||||
|
|||||||
Reference in New Issue
Block a user