From 48b929f8dcabe236986440a35481f9eb46538bf5 Mon Sep 17 00:00:00 2001 From: kazekunz Date: Fri, 3 May 2024 13:37:46 +0700 Subject: [PATCH 1/6] schedule story api --- swagger.yaml | 116 ++++++++++++++++++++++++++++++++++++ v1/admin/schedule_post.yaml | 4 -- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 14beb0b..5a7bd4c 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -5985,6 +5985,122 @@ paths: $ref: './global/error.yaml#/UnProcessableError' '500': $ref: './global/error.yaml#/UnexpectedError' + /admin/v1/stories/schedule: + post: + summary: 'schedule a story' + tags: + - 'Admin' + security: + - BearerAuth: [] + description: "Schedule a story at specific date/time but the scheduled time need to be within next 1 hour and next 30 days\n" + requestBody: + $ref: './v4/story/request.yaml#/CreateStoryRequestPayload' + responses: + '200': + description: 'ok' + content: + application/json: + schema: + $ref: './v4/story/response.yaml#/CreateStoryResponsePayload' + '400': + $ref: './global/error.yaml#/BadRequestError' + '422': + $ref: './global/error.yaml#/UnProcessableError' + '500': + $ref: './global/error.yaml#/UnexpectedError' + delete: + summary: 'delete scheduled story' + tags: + - 'Admin' + security: + - BearerAuth: [] + description: "Delete scheduled story" + parameters: + - in: query + name: id + required: true + schema: + type: string + description: 'to specify which scheduled story to delete' + responses: + '200': + description: 'ok, not returning any data' + '404': + $ref: './global/error.yaml#/NotFoundError' + '422': + $ref: './global/error.yaml#/UnProcessableError' + '500': + $ref: './global/error.yaml#/UnexpectedError' + get: + summary: 'get scheduled stories' + tags: + - 'Admin' + security: + - BearerAuth: [] + description: "Get scheduled stories" + parameters: + - name: 'isPending' + in: 'query' + schema: + type: 'boolean' + default: false + description: 'to get only scheduled stories that not posted yet' + - name: 'sortBy' + in: 'query' + schema: + type: 'string' + enum: + - 'lastCreated' + - 'firstCreated' + default: 'lastCreated' + - name: 'options' + in: 'query' + style: 'deepObject' + schema: + type: 'object' + properties: + limit: + type: 'integer' + minimum: 1 + maximum: 100 + default: 10 + token: + type: 'string' + maxLength: 1000 + before: + type: 'string' + maxLength: 24 + after: + type: 'string' + maxLength: 24 + updatedAt: + type: 'string' + maxLength: 30 + - name: 'targetType' + in: 'query' + schema: + type: 'string' + enum: + - 'content' + - 'community' + - 'user' + description: 'target type of scheduled story' + - name: 'targetId' + in: 'query' + schema: + type: 'string' + description: 'target id of scheduled story' + responses: + '200': + description: 'Return all scheduled post informations or only scheduled post that not posted yet' + content: + application/json: + schema: + $ref: './v4/story/response.yaml#/CreateStoryResponsePayload' + '422': + $ref: './global/error.yaml#/UnProcessableError' + '500': + $ref: './global/error.yaml#/UnexpectedError' /admin/v1/channels/count: get: summary: 'Get channel count' diff --git a/v1/admin/schedule_post.yaml b/v1/admin/schedule_post.yaml index 45f6e52..847850f 100644 --- a/v1/admin/schedule_post.yaml +++ b/v1/admin/schedule_post.yaml @@ -8,10 +8,6 @@ postResponseData: type: 'string' description: 'data for text in post parent' example: 'example text' - dataType: - type: 'string' - example: 'upstra.customtype' - description: 'Must be in dot separated string format or system defined format (ex. "upstra.customtype", "com.eko.birthday")' targetType: type: 'string' enum: From 9a35b500dc095b1cf3a458a99c9d5e7a98f1dd20 Mon Sep 17 00:00:00 2001 From: kazekunz Date: Fri, 3 May 2024 13:41:31 +0700 Subject: [PATCH 2/6] schedule story api --- swagger.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/swagger.yaml b/swagger.yaml index 5a7bd4c..06e2961 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -5994,7 +5994,10 @@ paths: - BearerAuth: [] description: "Schedule a story at specific date/time but the scheduled time need to be within next 1 hour and next 30 days\n" requestBody: - $ref: './v4/story/request.yaml#/CreateStoryRequestPayload' + content: + application/json: + schema: + $ref: './v4/story/request.yaml#/CreateStoryRequestPayload' responses: '200': description: 'ok' From c01e6a27eaf9fb14de60fd762e9ebc80df9cff31 Mon Sep 17 00:00:00 2001 From: kazekunz Date: Wed, 29 May 2024 13:57:33 +0700 Subject: [PATCH 3/6] fix schedule schema --- swagger.yaml | 4 +- v1/admin/schedule_post.yaml | 4 ++ v4/story/request.yaml | 94 ++++++++++++++++++++----------------- 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 06e2961..79ef2b5 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -6004,7 +6004,7 @@ paths: content: application/json: schema: - $ref: './v4/story/response.yaml#/CreateStoryResponsePayload' + $ref: './v1/admin/schedule_post.yaml#/postRespBody' '400': $ref: './global/error.yaml#/BadRequestError' '422': @@ -6099,7 +6099,7 @@ paths: content: application/json: schema: - $ref: './v4/story/response.yaml#/CreateStoryResponsePayload' + $ref: './v1/admin/schedule_post.yaml#/getRespBody' '422': $ref: './global/error.yaml#/UnProcessableError' '500': diff --git a/v1/admin/schedule_post.yaml b/v1/admin/schedule_post.yaml index 847850f..60ecf9b 100644 --- a/v1/admin/schedule_post.yaml +++ b/v1/admin/schedule_post.yaml @@ -192,6 +192,10 @@ getRespBody: type: string description: 'User display name' example: 'Alex' + communities: + type: array + items: + $ref: "../../schema/community.yaml#/Community" networkId: type: string description: 'network id of all of the posts' diff --git a/v4/story/request.yaml b/v4/story/request.yaml index fe82f56..74816a0 100644 --- a/v4/story/request.yaml +++ b/v4/story/request.yaml @@ -1,54 +1,62 @@ CreateStoryRequestPayload: type: object properties: - data: + scheduledAt: + type: 'string' + description: 'The date/time when a post is scheduled. Need to be within next hour and next 30 days.' + format: 'date-time' + example: '2022-07-07T04:24:20.444Z' + postData: type: object - description: Main data contained in the story, required only 1 field depends on dataType. The size of this object must be less than 10 KB. properties: - text: + data: + type: object + description: Main data contained in the story, required only 1 field depends on dataType. The size of this object must be less than 10 KB. + properties: + text: + type: string + description: text data (required if dataType is text) + example: example text + fileId: + type: string + description: image or video file id (required if dataType is image or video) + imageDisplayMode: + type: string + description: > + image display mode (required if dataType is image) + represents the display mode of an image for maintaining the correct visual dimensions when displaying or processing image. + enum: + - fit + - fill + default: fit + dataType: type: string - description: text data (required if dataType is text) - example: example text - fileId: - type: string - description: image or video file id (required if dataType is image or video) - imageDisplayMode: + enum: + - text + - image + - video + items: + type: array + description: List of items contained in story. Currently only support hyperlink item. Only one hyperlink item is allowed per story. + items: + $ref: "../../schema/story.yaml#/StoryItem" + maxItems: 10 + targetType: type: string - description: > - image display mode (required if dataType is image) - represents the display mode of an image for maintaining the correct visual dimensions when displaying or processing image. enum: - - fit - - fill - default: fit - dataType: - type: string - enum: - - text - - image - - video - items: - type: array - description: List of items contained in story. Currently only support hyperlink item. Only one hyperlink item is allowed per story. - items: - $ref: "../../schema/story.yaml#/StoryItem" - maxItems: 10 - targetType: - type: string - enum: - - community - description: where to create story to. currently limited to community only - targetId: - type: string - example: public_community_id - description: Resource public id depends on target type (ex. target type is community, target id will be community public id) - metadata: - type: object - description: Metadata of the story. The size of this object must be less than 20 KB - example: { "anything": "you want" } - referenceId: - type: string - description: the id used for reference when optimistically create the story + - community + description: where to create story to. currently limited to community only + targetId: + type: string + example: public_community_id + description: Resource public id depends on target type (ex. target type is community, target id will be community public id) + metadata: + type: object + description: Metadata of the story. The size of this object must be less than 20 KB + example: { "anything": "you want" } + referenceId: + type: string + description: the id used for reference when optimistically create the story required: - data - dataType From ef4b42fe25118f7299fac5b51ea4405326975b4a Mon Sep 17 00:00:00 2001 From: kazekunz Date: Wed, 29 May 2024 16:14:37 +0700 Subject: [PATCH 4/6] fix schedule schema --- v4/story/request.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v4/story/request.yaml b/v4/story/request.yaml index 74816a0..0765022 100644 --- a/v4/story/request.yaml +++ b/v4/story/request.yaml @@ -62,4 +62,5 @@ CreateStoryRequestPayload: - dataType - targetId - targetType - - referenceId \ No newline at end of file + - referenceId + - scheduledAt \ No newline at end of file From 37e4b59f99fbbb778b7cc0644849f4fe69ed3fba Mon Sep 17 00:00:00 2001 From: kazekunz Date: Thu, 30 May 2024 15:42:39 +0700 Subject: [PATCH 5/6] add required field --- v4/story/request.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v4/story/request.yaml b/v4/story/request.yaml index 0765022..45d4750 100644 --- a/v4/story/request.yaml +++ b/v4/story/request.yaml @@ -63,4 +63,5 @@ CreateStoryRequestPayload: - targetId - targetType - referenceId - - scheduledAt \ No newline at end of file + - scheduledAt + - postData \ No newline at end of file From fbfe17dbca25f6ab255dff26fe0fd5463bd03e00 Mon Sep 17 00:00:00 2001 From: Nuttapong Thaiauboon Date: Tue, 13 Aug 2024 13:49:03 +0700 Subject: [PATCH 6/6] feat: update schedule post as brand payload --- v1/admin/schedule_post.yaml | 278 +++++++++++++++++++----------------- 1 file changed, 145 insertions(+), 133 deletions(-) diff --git a/v1/admin/schedule_post.yaml b/v1/admin/schedule_post.yaml index 60ecf9b..43ead7a 100644 --- a/v1/admin/schedule_post.yaml +++ b/v1/admin/schedule_post.yaml @@ -1,61 +1,61 @@ -postResponseData: - type: 'object' - properties: +postResponseData: + type: "object" + properties: data: - type: 'object' + type: "object" properties: text: - type: 'string' - description: 'data for text in post parent' - example: 'example text' + type: "string" + description: "data for text in post parent" + example: "example text" targetType: - type: 'string' + type: "string" enum: - - 'user' - - 'community' - - 'content' - default: 'user' - description: 'where to create post to' + - "user" + - "community" + - "content" + default: "user" + description: "where to create post to" targetId: - type: 'string' - example: 'public_user_id' - description: 'Resource public id depends on target type (ex. target type is community, target id will be community public id)' + type: "string" + example: "public_user_id" + description: "Resource public id depends on target type (ex. target type is community, target id will be community public id)" metadata: - type: 'object' + type: "object" example: - anything: 'you want' + anything: "you want" postId: - type: 'string' - example: 'postidiwant' - description: 'for specify public post id on post creation' + type: "string" + example: "postidiwant" + description: "for specify public post id on post creation" tags: - type: 'array' + type: "array" minItems: 0 maxItems: 5 items: - type: 'string' - description: 'tags' + type: "string" + description: "tags" maximum: 24 mentionees: - type: 'array' - description: 'The object of the mentions type and user who get a notification from the post.' + type: "array" + description: "The object of the mentions type and user who get a notification from the post." items: - type: 'object' + type: "object" properties: type: - type: 'string' - example: 'user' + type: "string" + example: "user" description: "type: * `user` - need to specific userIds and notification mentions individual user\n" enum: - - 'user' + - "user" userIds: - type: 'array' + type: "array" example: - - 'userId1' - - 'userId2' - description: 'Array of UserId. if the mention type is a channel, doesn''t send userIds' + - "userId1" + - "userId2" + description: "Array of UserId. if the mention type is a channel, doesn't send userIds" items: - type: 'string' + type: "string" userPublicIds: type: array description: Array of UserPublicId. @@ -67,68 +67,68 @@ postResponseData: items: type: string -postRequestData: - type: 'object' - properties: +postRequestData: + type: "object" + properties: data: - type: 'object' + type: "object" properties: text: - type: 'string' - description: 'data for text in post parent' - example: 'example text' + type: "string" + description: "data for text in post parent" + example: "example text" dataType: - type: 'string' - example: 'upstra.customtype' + type: "string" + example: "upstra.customtype" description: 'Must be in dot separated string format or system defined format (ex. "upstra.customtype", "com.eko.birthday")' targetType: - type: 'string' + type: "string" enum: - - 'user' - - 'community' - - 'content' - default: 'user' - description: 'where to create post to' + - "user" + - "community" + - "content" + default: "user" + description: "where to create post to" targetId: - type: 'string' - example: 'public_user_id' - description: 'Resource public id depends on target type (ex. target type is community, target id will be community public id)' + type: "string" + example: "public_user_id" + description: "Resource public id depends on target type (ex. target type is community, target id will be community public id)" metadata: - type: 'object' + type: "object" example: - anything: 'you want' + anything: "you want" postId: - type: 'string' - example: 'postidiwant' - description: 'for specify public post id on post creation' + type: "string" + example: "postidiwant" + description: "for specify public post id on post creation" tags: - type: 'array' + type: "array" minItems: 0 maxItems: 5 items: - type: 'string' - description: 'tags' + type: "string" + description: "tags" maximum: 24 mentionees: - type: 'array' - description: 'The object of the mentions type and user who get a notification from the post.' + type: "array" + description: "The object of the mentions type and user who get a notification from the post." items: - type: 'object' + type: "object" properties: type: - type: 'string' - example: 'user' + type: "string" + example: "user" description: "type: * `user` - need to specific userIds and notification mentions individual user\n" enum: - - 'user' + - "user" userIds: - type: 'array' + type: "array" example: - - 'userId1' - - 'userId2' - description: 'Array of UserId. if the mention type is a channel, doesn''t send userIds' + - "userId1" + - "userId2" + description: "Array of UserId. if the mention type is a channel, doesn't send userIds" items: - type: 'string' + type: "string" postRespBody: type: object @@ -139,91 +139,103 @@ postRespBody: example: 60e4b1b4b3b2b5c4c4b3b2b5 getRespBody: - type: 'object' - properties: + type: "object" + properties: data: - type: 'array' + type: "array" items: - type: 'object' - description: 'list of scheduled post' + type: "object" + description: "list of scheduled post" properties: - _id: - type: 'string' - description: 'scheduled post id' - example: '60e4b1b4b3b2b5c4c4b3b2b5' - scheduledAt: - $ref: '#/postReqSchema/properties/scheduledAt' + _id: + type: "string" + description: "scheduled post id" + example: "60e4b1b4b3b2b5c4c4b3b2b5" + scheduledAt: + $ref: "#/postReqSchema/properties/scheduledAt" status: - type: 'object' - description: 'status of scheduled post' + type: "object" + description: "status of scheduled post" properties: code: - type: 'string' - description: 'status type' + type: "string" + description: "status type" enum: - - 'WAIT' - - 'DONE' - - 'FAIL' + - "WAIT" + - "DONE" + - "FAIL" description: - type: 'string' - description: 'description of status' - example: 'waiting to be posted' - postData: - $ref: '#/postResponseData' - userId: - type: 'string' - description: 'user id who create this scheduled post' - example: '60e4b1b4b3b2b5c4c4b3b2b5' + type: "string" + description: "description of status" + example: "waiting to be posted" + postData: + $ref: "#/postResponseData" + userId: + type: "string" + description: "user id who create this scheduled post" + example: "60e4b1b4b3b2b5c4c4b3b2b5" createdAt: - type: 'string' - description: 'The date/time when this scheduled post is created.' - format: 'date-time' - example: '2022-07-07T04:24:20.444Z' + type: "string" + description: "The date/time when this scheduled post is created." + format: "date-time" + example: "2022-07-07T04:24:20.444Z" updatedAt: - type: 'string' - description: 'The date/time when this scheduled post is updated.' - format: 'date-time' - example: '2022-07-07T04:24:20.444Z' + type: "string" + description: "The date/time when this scheduled post is updated." + format: "date-time" + example: "2022-07-07T04:24:20.444Z" files: type: array items: $ref: "../../schema/file.yaml#/File" userDisplayName: type: string - description: 'User display name' - example: 'Alex' + description: "User display name" + example: "Alex" communities: type: array items: $ref: "../../schema/community.yaml#/Community" - networkId: + networkId: type: string - description: 'network id of all of the posts' - example: '60e4b1b4b3b2b5c4c4b3b2b5' + description: "network id of all of the posts" + example: "60e4b1b4b3b2b5c4c4b3b2b5" + files: + type: array + description: "list of files that related to user" + items: + $ref: "../../schema/file.yaml#/File" + users: + type: array + description: "list of users that related to schedule post" + items: + $ref: "../../schema/user.yaml#/UserV3" paging: - type: 'object' + type: "object" properties: - next: - type: 'string' - example: 'eyJiZWZvcmUiOiI2NDgxNzYxNmU0ZDgzODgxMTFhNDMwZjUiLCJsaW1pdCI6Mn0' - previous: - type: 'string' - example: 'eyJhZnRlciI6IjY0ODE3NjE2ZTRkODM4ODExMWE0MzBmMCIsImxpbWl0IjoyfQ==' + next: + type: "string" + example: "eyJiZWZvcmUiOiI2NDgxNzYxNmU0ZDgzODgxMTFhNDMwZjUiLCJsaW1pdCI6Mn0" + previous: + type: "string" + example: "eyJhZnRlciI6IjY0ODE3NjE2ZTRkODM4ODExMWE0MzBmMCIsImxpbWl0IjoyfQ==" -postReqSchema: - type: 'object' +postReqSchema: + type: "object" properties: - postData: - $ref: '#/postRequestData' - scheduledAt: - type: 'string' - description: 'The date/time when a post is scheduled. Need to be within next hour and next 30 days.' - format: 'date-time' - example: '2022-07-07T04:24:20.444Z' + postData: + $ref: "#/postRequestData" + scheduledAt: + type: "string" + description: "The date/time when a post is scheduled. Need to be within next hour and next 30 days." + format: "date-time" + example: "2022-07-07T04:24:20.444Z" + postAs: + type: "string" + description: "Brand user private id to post as" required: - - 'postData' - - 'scheduledAt' - + - "postData" + - "scheduledAt" postReqBody: description: " @@ -245,5 +257,5 @@ postReqBody: required: true content: application/json: - schema: - $ref: '#/postReqSchema' + schema: + $ref: "#/postReqSchema"