diff --git a/public/openapi/write.yaml b/public/openapi/write.yaml index c59b9bce29..81335c78f3 100644 --- a/public/openapi/write.yaml +++ b/public/openapi/write.yaml @@ -150,6 +150,8 @@ paths: $ref: 'write/topics/tid/follow.yaml' /topics/{tid}/ignore: $ref: 'write/topics/tid/ignore.yaml' + /topics/{tid}/favorite: + $ref: 'write/topics/tid/favorite.yaml' /topics/{tid}/tags: $ref: 'write/topics/tid/tags.yaml' /topics/{tid}/thumbs: diff --git a/public/openapi/write/topics/tid/favorite.yaml b/public/openapi/write/topics/tid/favorite.yaml new file mode 100644 index 0000000000..b36daa28ef --- /dev/null +++ b/public/openapi/write/topics/tid/favorite.yaml @@ -0,0 +1,53 @@ +put: + tags: + - topics + summary: Add a topic to favorites + description: This operation saves the specified topic to the current user's favorites. + parameters: + - in: path + name: tid + schema: + type: string + required: true + description: A valid topic id + example: 1 + responses: + '200': + description: Topic successfully saved to favorites + content: + application/json: + schema: + type: object + properties: + status: + $ref: ../../../components/schemas/Status.yaml#/Status + response: + type: object + properties: {} + +delete: + tags: + - topics + summary: Remove a topic from favorites + description: This operation removes the specified topic from the current user's favorites. + parameters: + - in: path + name: tid + schema: + type: string + required: true + description: A valid topic ID + example: 1 + responses: + '200': + description: Topic successfully removed from favorites + content: + application/json: + schema: + type: object + properties: + status: + $ref: ../../../components/schemas/Status.yaml#/Status + response: + type: object + properties: {} diff --git a/src/api/topics.js b/src/api/topics.js index 7a6cabf966..83442d6dc8 100644 --- a/src/api/topics.js +++ b/src/api/topics.js @@ -173,6 +173,14 @@ topicsAPI.unfollow = async function (caller, data) { await topics.unfollow(data.tid, caller.uid); }; +topicsAPI.favorite = async function (caller, data) { + await topics.favorite(data.tid, caller.uid); +}; + +topicsAPI.unfavorite = async function (caller, data) { + await topics.unfavorite(data.tid, caller.uid); +}; + topicsAPI.updateTags = async (caller, { tid, tags }) => { if (!await privileges.topics.canEdit(tid, caller.uid)) { throw new Error('[[error:no-privileges]]');