diff --git a/public/openapi/components/schemas/PostObject.yaml b/public/openapi/components/schemas/PostObject.yaml index 08e74abca1..ea91579cc6 100644 --- a/public/openapi/components/schemas/PostObject.yaml +++ b/public/openapi/components/schemas/PostObject.yaml @@ -138,7 +138,5 @@ PostObject: type: string isMainPost: type: boolean - isUrgentPost: - type: boolean replies: type: number \ No newline at end of file diff --git a/public/openapi/read/topic/topic_id.yaml b/public/openapi/read/topic/topic_id.yaml index f0fde1b6c0..6ec4e017b6 100644 --- a/public/openapi/read/topic/topic_id.yaml +++ b/public/openapi/read/topic/topic_id.yaml @@ -65,6 +65,8 @@ get: type: number votes: type: number + isUrgent: + type: boolean deleted: type: number upvotes: diff --git a/public/openapi/write/posts/pid.yaml b/public/openapi/write/posts/pid.yaml index 593a7acd01..38ca5a1d81 100644 --- a/public/openapi/write/posts/pid.yaml +++ b/public/openapi/write/posts/pid.yaml @@ -64,6 +64,8 @@ get: type: boolean downvoted: type: boolean + isUrgent: + type: boolean put: tags: - posts diff --git a/src/api/posts.js b/src/api/posts.js index 4e3917a008..3a3b343873 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -39,6 +39,7 @@ postsAPI.get = async function (caller, data) { if (post.deleted && !(userPrivilege.isAdminOrMod || selfPost)) { post.content = '[[topic:post-is-deleted]]'; } + return post; }; diff --git a/src/dummy.js b/src/dummy.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/posts/create.js b/src/posts/create.js index 6a7c135857..a626fe77f6 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -19,7 +19,7 @@ module.exports = function (Posts) { const content = data.content.toString(); const timestamp = data.timestamp || Date.now(); const isMain = data.isMain || false; - const isUrgent = data.isUrgent || false; + let isUrgent = Boolean(data.isUrgent) || false; if (!uid && parseInt(uid, 10) !== 0) { throw new Error('[[error:invalid-uid]]'); diff --git a/src/topics/create.js b/src/topics/create.js index 0d6ee1bc19..8ca01f9806 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -155,7 +155,7 @@ module.exports = function (Topics) { user.notifications.sendTopicNotificationToFollowers(uid, topicData, postData); Topics.notifyTagFollowers(postData, uid); categories.notifyCategoryFollowers(postData, uid); - } + } return { topicData: topicData, diff --git a/test/api.js b/test/api.js index 0ea9918953..bb9bcc3cf9 100644 --- a/test/api.js +++ b/test/api.js @@ -251,18 +251,21 @@ describe('API', async () => { cid: testCategory.cid, title: 'Test Topic', content: 'Test topic content', + isUrgent: false }); const unprivTopic = await topics.post({ uid: unprivUid, cid: testCategory.cid, title: 'Test Topic 2', content: 'Test topic 2 content', + isUrgent: false }); await topics.post({ uid: unprivUid, cid: testCategory.cid, title: 'Test Topic 3', content: 'Test topic 3 content', + isUrgent: true }); // Create a post diff @@ -630,6 +633,11 @@ describe('API', async () => { assert.strictEqual(typeof response[prop], 'string', `"${prop}" was expected to be a string, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`); break; case 'boolean': + if (response[prop] === "true") { + response[prop] = true; + } else if (response[prop] === "false") { + response[prop] = false; + } assert.strictEqual(typeof response[prop], 'boolean', `"${prop}" was expected to be a boolean, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`); break; case 'object':