mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 01:26: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 posts = require('../posts');
|
||||
const categories = require('../categories');
|
||||
const messaging = require('../messaging');
|
||||
const request = require('../request');
|
||||
const db = require('../database');
|
||||
const ttl = require('../cache/ttl');
|
||||
@@ -263,6 +264,7 @@ Helpers.resolveObjects = async (ids) => {
|
||||
}
|
||||
return activitypub.mocks.actors.user(resolvedId);
|
||||
}
|
||||
|
||||
case 'post': {
|
||||
const post = (await posts.getPostSummaryByPids(
|
||||
[resolvedId],
|
||||
@@ -277,12 +279,23 @@ Helpers.resolveObjects = async (ids) => {
|
||||
}
|
||||
return activitypub.mocks.notes.public(post);
|
||||
}
|
||||
|
||||
case 'category': {
|
||||
if (!await categories.exists(resolvedId)) {
|
||||
throw new Error('[[error:activitypub.invalid-id]]');
|
||||
}
|
||||
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
|
||||
default: {
|
||||
return activitypub.get('uid', 0, id);
|
||||
|
||||
@@ -134,6 +134,7 @@ middleware.resolveObjects = async function (req, res, next) {
|
||||
return res.sendStatus(424);
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user