mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-27 17:11:14 +01:00
fix: inReplyTo incorrectly including system messages, #12834
This commit is contained in:
@@ -485,8 +485,13 @@ Mocks.notes.private = async ({ messageObj }) => {
|
|||||||
if (!inReplyTo) {
|
if (!inReplyTo) {
|
||||||
// Get immediately preceding message
|
// Get immediately preceding message
|
||||||
const index = await db.sortedSetRank(`chat:room:${messageObj.roomId}:mids`, messageObj.mid);
|
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);
|
if (index > 0) {
|
||||||
inReplyTo = utils.isNumber(previousMid) ? `${nconf.get('url')}/message/${previousMid}` : previousMid;
|
const mids = await db.getSortedSetRevRange(`chat:room:${messageObj.roomId}:mids`, 1, -1);
|
||||||
|
let isSystem = await messaging.getMessagesFields(mids, ['system']);
|
||||||
|
isSystem = isSystem.map(o => o.system);
|
||||||
|
inReplyTo = mids.reduce((memo, mid, idx) => (memo || (!isSystem[idx] ? mid : undefined)), undefined);
|
||||||
|
inReplyTo = utils.isNumber(inReplyTo) ? `${nconf.get('url')}/message/${inReplyTo}` : inReplyTo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const object = {
|
const object = {
|
||||||
|
|||||||
Reference in New Issue
Block a user