mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
fix: #10175, fix topic linkbacks duplicating on post edit
This commit is contained in:
@@ -370,13 +370,13 @@ module.exports = function (Topics) {
|
||||
}
|
||||
|
||||
const { pid, uid, tid } = postData;
|
||||
let add = matches.map(match => match[1]);
|
||||
let add = matches.map(match => match[1]).map(tid => parseInt(tid, 10));
|
||||
|
||||
const now = Date.now();
|
||||
const topicsExist = await Topics.exists(add);
|
||||
const current = (await db.getSortedSetMembers(`pid:${pid}:backlinks`)).map(tid => parseInt(tid, 10));
|
||||
const remove = current.filter(tid => !add.includes(tid));
|
||||
add = add.filter((_tid, idx) => topicsExist[idx] && !current.includes(_tid) && tid !== parseInt(_tid, 10));
|
||||
add = add.filter((_tid, idx) => topicsExist[idx] && !current.includes(_tid) && tid !== _tid);
|
||||
|
||||
// Remove old backlinks
|
||||
await db.sortedSetRemove(`pid:${pid}:backlinks`, remove);
|
||||
|
||||
Reference in New Issue
Block a user