Skip to content

Node.js based forum software built for the modern web

fix: tests

Julian Lam135f7aafe4da
diff --git a/src/posts/queue.js b/src/posts/queue.js
index 1bb33bec75..c323244363 100644
--- a/src/posts/queue.js
+++ b/src/posts/queue.js
@@ -160,10 +160,10 @@ module.exports = function (Posts) {
}
function getType(data) {
- if (data.hasOwnProperty('tid')) {
- return 'reply';
- } else if (data.hasOwnProperty('crosspostCid')) {
+ if (data.hasOwnProperty('crosspostCid')) {
return 'crosspost';
+ } else if (data.hasOwnProperty('tid')) {
+ return 'reply';
} else if (data.hasOwnProperty('cid')) {
return 'topic';
}
@@ -300,7 +300,7 @@ module.exports = function (Posts) {
}
const [canPost] = await Promise.all([
- privileges.categories.can(typeToPrivilege[type], cid, data.uid),
+ (type === 'crosspost' && data.uid === 0) || privileges.categories.can(typeToPrivilege[type], cid, data.uid),
user.isReadyToQueue(data.uid, cid),
]);
if (!canPost) {
diff --git a/test/activitypub/notes.js b/test/activitypub/notes.js
index ff0c98f088..fdede98971 100644
--- a/test/activitypub/notes.js
+++ b/test/activitypub/notes.js
@@ -493,7 +493,7 @@ describe('Notes', () => {
assert.strictEqual(queueCount, 1);
});
- it('should queue parent and also queue replies when hasTid is false', async () => {
+ it('should queue parent and drop replies when hasTid is false', async () => {
const { id: parentId } = helpers.mocks.note();
const { id: replyId } = helpers.mocks.note({
inReplyTo: parentId,
@@ -522,7 +522,7 @@ describe('Notes', () => {
assert.strictEqual(await posts.exists(replyId), false);
const queueCount = await db.sortedSetCard('post:queue');
- assert.strictEqual(queueCount, 2);
+ assert.strictEqual(queueCount, 1);
});
});
@@ -704,8 +704,8 @@ describe('Notes', () => {
});
assert(assertion);
- assert.strictEqual(assertion.queued, 1);
- assert.strictEqual(assertion.tid, null);
+ assert.strictEqual(assertion.queued, 0); // topic in remote category parsed normally
+ assert(assertion.tid);
// Verify queue entry has crosspostCid
const queueIds = await db.getSortedSetMembers('post:queue');
@@ -715,7 +715,7 @@ describe('Notes', () => {
assert.strictEqual(queueData.type, 'crosspost');
const parsedData = typeof queueData.data === 'string' ? JSON.parse(queueData.data) : queueData.data;
assert.strictEqual(parseInt(parsedData.crosspostCid, 10), targetCid);
- assert.strictEqual(parsedData.pid, noteId);
+ assert.strictEqual(parsedData.tid, assertion.tid);
});
});
});