mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #12729, replies to existing topics from Pixelfed not asserting properly due to incorrect toPid
Pixelfed supplies an object _url_ instead of the expected _id_ in the `inReplyTo` field, and that tripped up NodeBB because we don't store a backreference for those. The ideal solution here would be to set up a backreference for urls to pids, but in the meantime, this shortcut will function (it assumes that the object that it is in reply to is in the chain/context).
This commit is contained in:
@@ -121,8 +121,15 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
|||||||
tid = tid || utils.generateUUID();
|
tid = tid || utils.generateUUID();
|
||||||
mainPost.tid = tid;
|
mainPost.tid = tid;
|
||||||
|
|
||||||
|
const urlMap = chain.reduce((map, post) => (post.url ? map.set(post.url, post.id) : map), new Map());
|
||||||
const unprocessed = chain.map((post) => {
|
const unprocessed = chain.map((post) => {
|
||||||
post.tid = tid; // add tid to post hash
|
post.tid = tid; // add tid to post hash
|
||||||
|
|
||||||
|
// Ensure toPids in replies are ids
|
||||||
|
if (urlMap.has(post.toPid)) {
|
||||||
|
post.toPid = urlMap.get(post.toPid);
|
||||||
|
}
|
||||||
|
|
||||||
return post;
|
return post;
|
||||||
}).filter((p, idx) => !members[idx]);
|
}).filter((p, idx) => !members[idx]);
|
||||||
const count = unprocessed.length;
|
const count = unprocessed.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user