mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
fix: lemmy integration, handle image property as topic thumb
This commit is contained in:
@@ -165,8 +165,7 @@ Mocks.post = async (objects) => {
|
|||||||
attributedTo: uid,
|
attributedTo: uid,
|
||||||
inReplyTo: toPid,
|
inReplyTo: toPid,
|
||||||
published, updated, name, content, source,
|
published, updated, name, content, source,
|
||||||
to, cc, audience, attachment, tag,
|
to, cc, audience, attachment, tag, image,
|
||||||
// conversation, // mastodon-specific, ignored.
|
|
||||||
} = object;
|
} = object;
|
||||||
|
|
||||||
const resolved = await activitypub.helpers.resolveLocalId(toPid);
|
const resolved = await activitypub.helpers.resolveLocalId(toPid);
|
||||||
@@ -187,6 +186,22 @@ Mocks.post = async (objects) => {
|
|||||||
content = '<em>This post did not contain any content.</em>';
|
content = '<em>This post did not contain any content.</em>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case image && image.hasOwnProperty('url') && image.url && mime.getType(image.url).startsWith('image/'): {
|
||||||
|
image = image.url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case image && typeof image === 'string' && mime.getType(image).startsWith('image/'): {
|
||||||
|
// no change
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
image = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
uid,
|
uid,
|
||||||
pid,
|
pid,
|
||||||
@@ -199,7 +214,7 @@ Mocks.post = async (objects) => {
|
|||||||
|
|
||||||
edited,
|
edited,
|
||||||
editor: edited ? uid : undefined,
|
editor: edited ? uid : undefined,
|
||||||
_activitypub: { to, cc, audience, attachment, tag, url },
|
_activitypub: { to, cc, audience, attachment, tag, url, image },
|
||||||
};
|
};
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
|
|||||||
@@ -187,6 +187,14 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
]);
|
]);
|
||||||
unprocessed.shift();
|
unprocessed.shift();
|
||||||
|
|
||||||
|
// These must come after topic is posted
|
||||||
|
await Promise.all([
|
||||||
|
mainPost._activitypub.image ? topics.thumbs.associate({
|
||||||
|
id: tid,
|
||||||
|
path: mainPost._activitypub.image,
|
||||||
|
}) : null,
|
||||||
|
]);
|
||||||
|
|
||||||
if (context) {
|
if (context) {
|
||||||
activitypub.helpers.log(`[activitypub/notes.assert] Associating tid ${tid} with context ${context}`);
|
activitypub.helpers.log(`[activitypub/notes.assert] Associating tid ${tid} with context ${context}`);
|
||||||
await topics.setTopicField(tid, 'context', context);
|
await topics.setTopicField(tid, 'context', context);
|
||||||
|
|||||||
Reference in New Issue
Block a user