mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: inReplyTo for private notes so that refer to the immediately previous message if not explicitly defined
This commit is contained in:
@@ -6,6 +6,7 @@ const path = require('path');
|
|||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const sanitize = require('sanitize-html');
|
const sanitize = require('sanitize-html');
|
||||||
|
|
||||||
|
const db = require('../database');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
const categories = require('../categories');
|
const categories = require('../categories');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
@@ -482,6 +483,14 @@ Mocks.notes.private = async ({ messageObj }) => {
|
|||||||
`${nconf.get('url')}/api/v3/chats/${messageObj.roomId}/messages/${messageObj.toMid}` :
|
`${nconf.get('url')}/api/v3/chats/${messageObj.roomId}/messages/${messageObj.toMid}` :
|
||||||
messageObj.toMid;
|
messageObj.toMid;
|
||||||
}
|
}
|
||||||
|
if (!inReplyTo) {
|
||||||
|
// Get immediately preceding message
|
||||||
|
const index = await db.sortedSetRank(`chat:room:${messageObj.roomId}:mids`, messageObj.mid);
|
||||||
|
const previousMid = await db.getSortedSetRange(`chat:room:${messageObj.roomId}:mids`, index - 1, index - 1);
|
||||||
|
inReplyTo = utils.isNumber(previousMid) ?
|
||||||
|
`${nconf.get('url')}/api/v3/chats/${messageObj.roomId}/messages/${previousMid}` :
|
||||||
|
messageObj.toMid;
|
||||||
|
}
|
||||||
|
|
||||||
const object = {
|
const object = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
|||||||
Reference in New Issue
Block a user