diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index 70e8a57799..0000000000 Binary files a/dump.rdb and /dev/null differ diff --git a/public/openapi/components/schemas/PostObject.yaml b/public/openapi/components/schemas/PostObject.yaml index ea91579cc6..fc640d4bb4 100644 --- a/public/openapi/components/schemas/PostObject.yaml +++ b/public/openapi/components/schemas/PostObject.yaml @@ -16,6 +16,8 @@ PostObject: type: number deleted: type: boolean + endorsed: + type: boolean upvotes: type: number downvotes: diff --git a/public/openapi/read/topic/topic_id.yaml b/public/openapi/read/topic/topic_id.yaml index f0fde1b6c0..6e9eed2ed0 100644 --- a/public/openapi/read/topic/topic_id.yaml +++ b/public/openapi/read/topic/topic_id.yaml @@ -67,6 +67,8 @@ get: type: number deleted: type: number + endorsed: + type: number upvotes: type: number downvotes: diff --git a/public/openapi/write/posts/pid.yaml b/public/openapi/write/posts/pid.yaml index 593a7acd01..147c7a4537 100644 --- a/public/openapi/write/posts/pid.yaml +++ b/public/openapi/write/posts/pid.yaml @@ -40,6 +40,8 @@ get: type: number deleted: type: number + endorsed: + type: number upvotes: type: number downvotes: diff --git a/public/openapi/write/posts/pid/replies.yaml b/public/openapi/write/posts/pid/replies.yaml index b021eec14e..727c5b0acf 100644 --- a/public/openapi/write/posts/pid/replies.yaml +++ b/public/openapi/write/posts/pid/replies.yaml @@ -45,6 +45,8 @@ get: type: number deleted: type: number + endorsed: + type: number upvotes: type: number downvotes: diff --git a/src/posts/create.js b/src/posts/create.js index d541564c2e..c035f86013 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -19,6 +19,7 @@ module.exports = function (Posts) { const content = data.content.toString(); const timestamp = data.timestamp || Date.now(); const isMain = data.isMain || false; + const endorsed = data.endorsed || false; if (!uid && parseInt(uid, 10) !== 0) { throw new Error('[[error:invalid-uid]]'); @@ -35,6 +36,7 @@ module.exports = function (Posts) { tid: tid, content: content, timestamp: timestamp, + endorsed: endorsed, }; if (data.toPid) { diff --git a/src/posts/summary.js b/src/posts/summary.js index 364baad1f7..cc2fe4eb87 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -20,7 +20,7 @@ module.exports = function (Posts) { options.parse = options.hasOwnProperty('parse') ? options.parse : true; options.extraFields = options.hasOwnProperty('extraFields') ? options.extraFields : []; - const fields = ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted', 'upvotes', 'downvotes', 'replies', 'handle'].concat(options.extraFields); + const fields = ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted', 'upvotes', 'downvotes', 'replies', 'handle', 'endorsed'].concat(options.extraFields); let posts = await Posts.getPostsFields(pids, fields); posts = posts.filter(Boolean); @@ -51,6 +51,7 @@ module.exports = function (Posts) { post.category = post.topic && cidToCategory[post.topic.cid]; post.isMainPost = post.topic && post.pid === post.topic.mainPid; post.deleted = post.deleted === 1; + post.endorsed = post.endorsed === 1; post.timestampISO = utils.toISOString(post.timestamp); }); diff --git a/src/search.js b/src/search.js index df249ec1f6..053eec783c 100644 --- a/src/search.js +++ b/src/search.js @@ -177,7 +177,7 @@ async function filterAndSort(pids, data) { } async function getMatchedPosts(pids, data) { - const postFields = ['pid', 'uid', 'tid', 'timestamp', 'deleted', 'upvotes', 'downvotes']; + const postFields = ['pid', 'uid', 'tid', 'timestamp', 'deleted', 'upvotes', 'downvotes', 'endorsed']; let postsData = await posts.getPostsFields(pids, postFields); postsData = postsData.filter(post => post && !post.deleted); diff --git a/src/topics/posts.js b/src/topics/posts.js index 050f80743c..b4f3979c3c 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -78,8 +78,6 @@ module.exports = function (Topics) { // The following code was created with the assistance of ChatGPT. async function addEventStartEnd(postData, set, reverse, topicData) { - console.log('Lucas Lin'); - if (!postData.length) { return; }