fix: rejig some tertiary conditionals, fix broken inReplyTo when toPid is not defined and mainPid is a remote post

This commit is contained in:
Julian Lam
2024-02-09 11:18:23 -05:00
parent 11dba85d0a
commit 5fee4e3306

View File

@@ -212,12 +212,12 @@ Mocks.note = async (post) => {
let inReplyTo = null;
let name = null;
if (post.toPid) { // direct reply
inReplyTo = activitypub.helpers.isUri(post.toPid) ? post.toPid : `${nconf.get('url')}/post/${post.toPid}`;
inReplyTo = utils.isNumber(post.toPid) ? `${nconf.get('url')}/post/${post.toPid}` : post.toPid;
const parentId = await posts.getPostField(post.toPid, 'uid');
to.unshift(activitypub.helpers.isUri(parentId) ? parentId : `${nconf.get('url')}/uid/${parentId}`);
to.unshift(utils.isNumber(parentId) ? `${nconf.get('url')}/uid/${parentId}` : parentId);
} else if (!post.isMainPost) { // reply to OP
inReplyTo = `${nconf.get('url')}/post/${post.topic.mainPid}`;
to.unshift(activitypub.helpers.isUri(post.topic.uid) ? post.topic.uid : `${nconf.get('url')}/uid/${post.topic.uid}`);
inReplyTo = utils.isNumber(post.topic.mainPid) ? `${nconf.get('url')}/post/${post.topic.mainPid}` : post.topic.mainPid;
to.unshift(utils.isNumber(post.topic.uid) ? `${nconf.get('url')}/uid/${post.topic.uid}` : post.topic.uid);
} else { // new topic
name = await topics.getTitleByPid(post.pid);
}