diff --git a/public/openapi/components/schemas/TopicObject.yaml b/public/openapi/components/schemas/TopicObject.yaml index 590872e03e..2e5085158f 100644 --- a/public/openapi/components/schemas/TopicObject.yaml +++ b/public/openapi/components/schemas/TopicObject.yaml @@ -13,8 +13,7 @@ TopicObject: description: A category identifier mainPid: type: number - description: The post id of the first post in this topic (also called the - "original post") + description: The post id of the first post in this topic (also called the "original post") title: type: string slug: @@ -55,6 +54,7 @@ TopicObject: description: An ISO 8601 formatted date string (complementing `timestamp`) lastposttimeISO: type: string + description: An ISO 8601 formatted date string (complementing `lastposttime`) votes: type: number category: @@ -230,5 +230,65 @@ TopicObject: description: A topic identifier thumb: type: string + pinExpiry: + type: number + description: A UNIX timestamp indicating when a pinned topic will no longer be pinned (i.e. the pin has expired) + pinExpiryISO: + type: string + description: "`pinExpiry` rendered as an ISO 8601 format" required: - - tid \ No newline at end of file + - tid +TopicObjectSlim: + description: The output of a call to `Topics.getTopicField`, these properties are always present no matter the fields passed in + type: object + properties: + tid: + type: number + description: A topic identifier + uid: + type: number + description: A user identifier + cid: + type: number + description: A category identifier + mainPid: + type: number + description: The post id of the first post in this topic (also called the "original post") + postcount: + type: number + viewcount: + type: number + postercount: + type: number + deleted: + type: number + deleterUid: + type: number + locked: + type: number + pinned: + type: number + description: Whether or not this particular topic is pinned to the top of the + category + timestamp: + type: number + timestampISO: + type: string + description: An ISO 8601 formatted date string (complementing `timestamp`) + lastposttime: + type: number + lastposttimeISO: + type: string + description: An ISO 8601 formatted date string (complementing `lastposttime`) + pinExpiry: + type: number + description: A UNIX timestamp indicating when a pinned topic will no longer be pinned (i.e. the pin has expired) + pinExpiryISO: + type: string + description: "`pinExpiry` rendered as an ISO 8601 format" + upvotes: + type: number + downvotes: + type: number + votes: + type: number \ No newline at end of file diff --git a/public/openapi/read/topic/tid/id.yaml b/public/openapi/read/topic/tid/id.yaml index cdc638a1f5..5305a99c7f 100644 --- a/public/openapi/read/topic/tid/id.yaml +++ b/public/openapi/read/topic/tid/id.yaml @@ -15,50 +15,16 @@ get: content: application/json: schema: - type: object - properties: - tid: - type: number - uid: - type: number - cid: - type: number - mainPid: - type: number - teaserPid: - type: number - nullable: true - title: - type: string - slug: - type: string - timestamp: - type: number - lastposttime: - type: number - postercount: - type: number - postcount: - type: number - viewcount: - type: number - deleted: - type: number - locked: - type: number - pinned: - type: number - upvotes: - type: number - downvotes: - type: number - deleterUid: - type: number - titleRaw: - type: string - timestampISO: - type: string - lastposttimeISO: - type: string - votes: - type: number \ No newline at end of file + allOf: + - $ref: ../../../components/schemas/TopicObject.yaml#/TopicObjectSlim + - type: object + properties: + teaserPid: + type: number + nullable: true + title: + type: string + slug: + type: string + titleRaw: + type: string \ 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 88081d23dc..67f7ef3096 100644 --- a/public/openapi/read/topic/topic_id.yaml +++ b/public/openapi/read/topic/topic_id.yaml @@ -30,62 +30,18 @@ get: application/json: schema: allOf: + - $ref: ../../components/schemas/TopicObject.yaml#/TopicObjectSlim - type: object properties: - tid: - type: number - description: A topic identifier - uid: - type: number - description: A user identifier - cid: - type: number - description: A category identifier title: type: string slug: type: string - timestamp: - type: number - lastposttime: - type: number - postcount: - type: number - viewcount: - type: number - postercount: - type: number - description: The number of unique users who made a post in this topic - mainPid: - type: number - description: The post id of the first post in this topic (also called the - "original post") teaserPid: type: number nullable: true - upvotes: - type: number - downvotes: - type: number - deleted: - type: number - locked: - type: number - pinned: - type: number - description: Whether or not this particular topic is pinned to the top of the - category - deleterUid: - type: number titleRaw: type: string - timestampISO: - type: string - description: An ISO 8601 formatted date string (complementing `timestamp`) - lastposttimeISO: - type: string - votes: - type: number tags: type: array items: diff --git a/public/openapi/read/unread.yaml b/public/openapi/read/unread.yaml index a5fe83348e..e2b48faee9 100644 --- a/public/openapi/read/unread.yaml +++ b/public/openapi/read/unread.yaml @@ -22,162 +22,42 @@ get: topics: type: array items: - type: object - properties: - tid: - type: number - description: A topic identifier - uid: - type: number - description: A user identifier - cid: - type: number - description: A category identifier - mainPid: - type: number - description: The post id of the first post in this topic (also called the - "original post") - title: - type: string - slug: - type: string - timestamp: - type: number - lastposttime: - type: number - postcount: - type: number - viewcount: - type: number - postercount: - type: number - teaserPid: - type: number - nullable: true - upvotes: - type: number - downvotes: - type: number - deleterUid: - type: number - deleted: - type: number - locked: - type: number - pinned: - type: number - description: Whether or not this particular topic is pinned to the top of the - category - titleRaw: - type: string - timestampISO: - type: string - description: An ISO 8601 formatted date string (complementing `timestamp`) - lastposttimeISO: - type: string - votes: - type: number - category: - type: object + allOf: + - $ref: ../components/schemas/TopicObject.yaml#/TopicObjectSlim + - type: object properties: - cid: - type: number - description: A category identifier - name: + title: type: string slug: type: string - icon: - type: string - backgroundImage: - nullable: true - imageClass: + teaserPid: + type: number nullable: true + titleRaw: type: string - bgColor: - type: string - color: - type: string - disabled: - type: number - user: - type: object - properties: - uid: - type: number - description: A user identifier - username: - type: string - description: A friendly name for a given user account - displayname: - type: string - description: This is either username or fullname depending on forum and user settings - fullname: - type: string - userslug: - type: string - description: An URL-safe variant of the username (i.e. lower-cased, spaces - removed, etc.) - reputation: - type: number - postcount: - type: number - picture: - nullable: true - type: string - signature: - nullable: true - type: string - banned: - type: number - status: - type: string - icon:text: - type: string - description: A single-letter representation of a username. This is used in the - auto-generated icon given to users without - an avatar - icon:bgColor: - type: string - description: A six-character hexadecimal colour code assigned to the user. This - value is used in conjunction with - `icon:text` for the user's auto-generated - icon - example: "#f44336" - banned_until_readable: - type: string - required: - - uid - - username - - userslug - - reputation - - postcount - - picture - - signature - - banned - - status - - icon:text - - icon:bgColor - - banned_until_readable - teaser: - type: object - nullable: true - properties: - pid: - type: number - uid: - type: number - description: A user identifier - timestamp: - type: number - tid: - type: number - description: A topic identifier - content: - type: string - timestampISO: - type: string - description: An ISO 8601 formatted date string (complementing `timestamp`) + category: + type: object + properties: + cid: + type: number + description: A category identifier + name: + type: string + slug: + type: string + icon: + type: string + backgroundImage: + nullable: true + imageClass: + nullable: true + type: string + bgColor: + type: string + color: + type: string + disabled: + type: number user: type: object properties: @@ -187,47 +67,125 @@ get: username: type: string description: A friendly name for a given user account + displayname: + type: string + description: This is either username or fullname depending on forum and user settings + fullname: + type: string userslug: type: string description: An URL-safe variant of the username (i.e. lower-cased, spaces removed, etc.) + reputation: + type: number + postcount: + type: number picture: nullable: true type: string + signature: + nullable: true + type: string + banned: + type: number + status: + type: string icon:text: type: string description: A single-letter representation of a username. This is used in the - auto-generated icon given to users - without an avatar + auto-generated icon given to users without + an avatar icon:bgColor: type: string description: A six-character hexadecimal colour code assigned to the user. This value is used in conjunction with - `icon:text` for the user's - auto-generated icon + `icon:text` for the user's auto-generated + icon example: "#f44336" + banned_until_readable: + type: string + required: + - uid + - username + - userslug + - reputation + - postcount + - picture + - signature + - banned + - status + - icon:text + - icon:bgColor + - banned_until_readable + teaser: + type: object + nullable: true + properties: + pid: + type: number + uid: + type: number + description: A user identifier + timestamp: + type: number + tid: + type: number + description: A topic identifier + content: + type: string + timestampISO: + type: string + description: An ISO 8601 formatted date string (complementing `timestamp`) + user: + type: object + properties: + uid: + type: number + description: A user identifier + username: + type: string + description: A friendly name for a given user account + userslug: + type: string + description: An URL-safe variant of the username (i.e. lower-cased, spaces + removed, etc.) + picture: + nullable: true + type: string + icon:text: + type: string + description: A single-letter representation of a username. This is used in the + auto-generated icon given to users + without an avatar + icon:bgColor: + type: string + description: A six-character hexadecimal colour code assigned to the user. This + value is used in conjunction with + `icon:text` for the user's + auto-generated icon + example: "#f44336" + index: + type: number + tags: + type: array + items: + $ref: ../components/schemas/TagObject.yaml#/TagObject + isOwner: + type: boolean + ignored: + type: boolean + unread: + type: boolean + bookmark: + nullable: true + unreplied: + type: boolean + icons: + type: array + items: + type: string index: type: number - tags: - type: array - items: - $ref: ../components/schemas/TagObject.yaml#/TagObject - isOwner: - type: boolean - ignored: - type: boolean - unread: - type: boolean - bookmark: - nullable: true - unreplied: - type: boolean - icons: - type: array - items: - type: string - index: - type: number topicCount: type: number title: diff --git a/src/topics/data.js b/src/topics/data.js index 720d2e63ad..f518a5f5c0 100644 --- a/src/topics/data.js +++ b/src/topics/data.js @@ -11,7 +11,7 @@ const plugins = require('../plugins'); const intFields = [ 'tid', 'cid', 'uid', 'mainPid', 'postcount', 'viewcount', 'postercount', 'deleted', 'locked', 'pinned', - 'timestamp', 'upvotes', 'downvotes', 'lastposttime', + 'pinExpiry', 'timestamp', 'upvotes', 'downvotes', 'lastposttime', 'deleterUid', ]; @@ -110,6 +110,10 @@ function modifyTopic(topic, fields) { topic.lastposttimeISO = utils.toISOString(topic.lastposttime); } + if (topic.hasOwnProperty('pinExpiry')) { + topic.pinExpiryISO = utils.toISOString(topic.pinExpiry); + } + if (topic.hasOwnProperty('upvotes') && topic.hasOwnProperty('downvotes')) { topic.votes = topic.upvotes - topic.downvotes; }