mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +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,
|
||||
} = object;
|
||||
|
||||
if (Array.isArray(uid)) { // Handle array attributedTo
|
||||
uid = uid.reduce((valid, cur) => {
|
||||
if (typeof cur === 'string') {
|
||||
valid.push(cur);
|
||||
} else if (typeof cur === 'object') {
|
||||
if (cur.type === 'Person' && cur.id) {
|
||||
valid.push(cur.id);
|
||||
switch (true) { // non-string attributedTo handling
|
||||
case Array.isArray(uid): {
|
||||
uid = uid.reduce((valid, cur) => {
|
||||
if (typeof cur === 'string') {
|
||||
valid.push(cur);
|
||||
} else if (typeof cur === 'object') {
|
||||
if (cur.type === 'Person' && cur.id) {
|
||||
valid.push(cur.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}, []);
|
||||
uid = uid.shift(); // take first valid uid
|
||||
await activitypub.actors.assert(uid);
|
||||
return valid;
|
||||
}, []);
|
||||
uid = uid.shift(); // take first valid uid
|
||||
break;
|
||||
}
|
||||
|
||||
case typeof uid === 'object' && uid.hasOwnProperty('id'): {
|
||||
uid = uid.id;
|
||||
}
|
||||
}
|
||||
await activitypub.actors.assert(uid);
|
||||
|
||||
const resolved = await activitypub.helpers.resolveLocalId(toPid);
|
||||
if (resolved.type === 'post') {
|
||||
|
||||
Reference in New Issue
Block a user