mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
fix: #12865, crash on liking a chat message
This commit is contained in:
@@ -11,6 +11,7 @@ const crypto = require('crypto');
|
|||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
const categories = require('../categories');
|
const categories = require('../categories');
|
||||||
|
const messaging = require('../messaging');
|
||||||
const request = require('../request');
|
const request = require('../request');
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const ttl = require('../cache/ttl');
|
const ttl = require('../cache/ttl');
|
||||||
@@ -263,6 +264,7 @@ Helpers.resolveObjects = async (ids) => {
|
|||||||
}
|
}
|
||||||
return activitypub.mocks.actors.user(resolvedId);
|
return activitypub.mocks.actors.user(resolvedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'post': {
|
case 'post': {
|
||||||
const post = (await posts.getPostSummaryByPids(
|
const post = (await posts.getPostSummaryByPids(
|
||||||
[resolvedId],
|
[resolvedId],
|
||||||
@@ -277,12 +279,23 @@ Helpers.resolveObjects = async (ids) => {
|
|||||||
}
|
}
|
||||||
return activitypub.mocks.notes.public(post);
|
return activitypub.mocks.notes.public(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'category': {
|
case 'category': {
|
||||||
if (!await categories.exists(resolvedId)) {
|
if (!await categories.exists(resolvedId)) {
|
||||||
throw new Error('[[error:activitypub.invalid-id]]');
|
throw new Error('[[error:activitypub.invalid-id]]');
|
||||||
}
|
}
|
||||||
return activitypub.mocks.actors.category(resolvedId);
|
return activitypub.mocks.actors.category(resolvedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'message': {
|
||||||
|
if (!await messaging.messageExists(resolvedId)) {
|
||||||
|
throw new Error('[[error:activitypub.invalid-id]]');
|
||||||
|
}
|
||||||
|
const messageObj = await messaging.getMessageFields(resolvedId, []);
|
||||||
|
messageObj.content = await messaging.parse(messageObj.content, messageObj.fromuid, 0, messageObj.roomId, false);
|
||||||
|
return activitypub.mocks.notes.private({ messageObj });
|
||||||
|
}
|
||||||
|
|
||||||
// if the type is not recognized, assume it's not a local ID and fetch the object from its origin
|
// if the type is not recognized, assume it's not a local ID and fetch the object from its origin
|
||||||
default: {
|
default: {
|
||||||
return activitypub.get('uid', 0, id);
|
return activitypub.get('uid', 0, id);
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ middleware.resolveObjects = async function (req, res, next) {
|
|||||||
return res.sendStatus(424);
|
return res.sendStatus(424);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user