-
Notifications
You must be signed in to change notification settings - Fork 232
OpenAPI: Migrate create draft, send message, update message #4220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 9 commits
9db32d7
632d587
a266d90
1c9cb6f
822f7b8
b62d694
31cfe2e
d5cc4e6
57edd9e
b4fd299
105688d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ allowed_endpoints=( | |
| blockUsers | ||
| castPollVote | ||
| createDevice | ||
| createDraft | ||
| createPoll | ||
| createPollOption | ||
| createUserGroup | ||
|
|
@@ -44,13 +45,16 @@ allowed_endpoints=( | |
| removeUserGroupMembers | ||
| searchRoles | ||
| searchUserGroups | ||
| sendMessage | ||
| showChannel | ||
| stopWatchingChannel | ||
| unblockUsers | ||
| unmuteChannel | ||
| unreadCounts | ||
| updateLiveLocation | ||
| updateMemberPartial | ||
| updateMessage | ||
| updateMessagePartial | ||
| updatePollPartial | ||
| updatePushNotificationPreferences | ||
| updateUserGroup | ||
|
|
@@ -63,22 +67,29 @@ allowed_models=( | |
| Action | ||
| AddUserGroupMembersRequest | ||
| AppResponseFields | ||
| Attachment | ||
| BlockedUserResponse | ||
| BlockUsersRequest | ||
| BlockUsersResponse | ||
| CastPollVoteRequest | ||
| ChannelContextResponse | ||
| ChannelMemberPartialResponse | ||
| ChannelMemberRequest | ||
| ChannelMemberResponse | ||
| ChannelMute | ||
| ChannelOwnCapability | ||
| ChannelResponse | ||
| CreateDeviceRequest | ||
| CreateDraftRequest | ||
| CreateDraftResponse | ||
| CreatePollOptionRequest | ||
| CreatePollRequest | ||
| CreateUserGroupRequest | ||
| DeleteChannelResponse | ||
| DeliveredMessagePayload | ||
| DeviceResponse | ||
| DraftPayloadResponse | ||
| DraftResponse | ||
| Field | ||
| FileUploadConfig | ||
| FileUploadResponse | ||
|
|
@@ -96,6 +107,9 @@ allowed_models=( | |
| ListUserGroupsResponse | ||
| MarkDeliveredRequest | ||
| MembersResponse | ||
| MessageRequest | ||
| MessageResponse | ||
| ModerationV2Response | ||
| MuteChannelRequest | ||
| MuteChannelResponse | ||
| PollOptionInput | ||
|
|
@@ -111,10 +125,16 @@ allowed_models=( | |
| QueryMembersPayload | ||
| QueryPollVotesRequest | ||
| QueryReactionsRequest | ||
| ReactionGroupResponse | ||
| ReactionResponse | ||
| ReminderResponseData | ||
| RemoveUserGroupMembersRequest | ||
| Role | ||
| SearchResultMessage | ||
| SearchRolesResponse | ||
| SendMessageRequest | ||
| SendMessageResponse | ||
| SharedLocation | ||
| SharedLocationResponseData | ||
| SharedLocationsResponse | ||
| SortParamRequest | ||
|
|
@@ -127,6 +147,10 @@ allowed_models=( | |
| UpdateLiveLocationRequest | ||
| UpdateMemberPartialRequest | ||
| UpdateMemberPartialResponse | ||
| UpdateMessagePartialRequest | ||
| UpdateMessagePartialResponse | ||
| UpdateMessageRequest | ||
| UpdateMessageResponse | ||
| UpdatePollPartialRequest | ||
| UpdateUserGroupRequest | ||
| UploadChannelFileResponse | ||
|
|
@@ -377,6 +401,7 @@ rename_generated_type CreateUserGroupResponse UserGroupResponse | |
| rename_generated_type RemoveUserGroupMembersResponse UserGroupResponse | ||
| rename_generated_type UpdateUserGroupResponse UserGroupResponse | ||
| rename_generated_type SearchUserGroupsResponse ListUserGroupsResponse | ||
| rename_generated SharedLocation NewLocationRequestPayload | ||
| rename_generated SharedLocationResponseData SharedLocation | ||
| rename_generated_type SharedLocationResponse SharedLocation | ||
| rename_generated MarkDeliveredRequest ChannelDeliveredRequestPayload | ||
|
|
@@ -400,6 +425,14 @@ rename_generated ChannelMemberResponse MemberPayload | |
| rename_generated ChannelMute MutedChannelPayload | ||
| rename_generated ChannelResponse ChannelDetailPayload | ||
| rename_generated MuteChannelResponse MutedChannelPayloadResponse | ||
| rename_generated Attachment MessageAttachmentPayload | ||
| rename_generated ChannelMemberPartialResponse MemberInfoPayload | ||
| rename_generated DraftPayloadResponse DraftMessagePayload | ||
| rename_generated DraftResponse DraftPayload | ||
| rename_generated ModerationV2Response MessageModerationDetailsPayload | ||
| rename_generated ReactionGroupResponse MessageReactionGroupPayload | ||
| rename_generated ReminderResponseData ReminderPayload | ||
| rename_generated SendMessageResponse SendMessageResponsePayload | ||
|
|
||
| rename_generated_type HideChannelResponse EmptyResponse | ||
| rename_generated_type MarkDeliveredResponse EmptyResponse | ||
|
|
@@ -479,12 +512,28 @@ remove_property DeleteChannelResponse duration | |
| remove_property MutedChannelPayloadResponse channelMutes | ||
| remove_property MutedChannelPayloadResponse duration | ||
| remove_property MutedChannelPayloadResponse ownUser | ||
| remove_property CreateDraftResponse duration | ||
| remove_property SendMessageResponsePayload duration | ||
| remove_property UpdateMessagePartialResponse duration | ||
| remove_property UpdateMessageResponse duration | ||
|
|
||
| # Server-side only: client-side requests cannot set these fields | ||
| remove_property SendMessageResponsePayload pendingMessageMetadata | ||
| remove_property UpdateMessagePartialResponse pendingMessageMetadata | ||
| remove_property UpdateMessageResponse pendingMessageMetadata | ||
|
laevandus marked this conversation as resolved.
Comment on lines
+520
to
+523
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CHA-4779 |
||
|
|
||
| # TODO: reaction group reactors need CoreData and public API design first | ||
| remove_property MessageReactionGroupPayload latestReactionsBy | ||
|
Comment on lines
+525
to
+526
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for later (separate PR). Captured in IOS-1972 |
||
|
|
||
| retype_property ChannelDetailPayload cid String ChannelId | ||
| retype_property ChannelDetailPayload config ChannelConfigWithInfo ChannelConfig | ||
| # Will be changed on the generation side later | ||
| require_property ChannelDetailPayload config | ||
|
|
||
| # TODO: Legacy v1 payloads may contain null; keep optional until legacy compatibility is removed. | ||
| optionalize_property MessageResponse reactionCounts | ||
| optionalize_property SearchResultMessage reactionCounts | ||
|
|
||
| remove_nested_enum() { | ||
| local file="$OUTPUT_DIR_CHAT/models/$1.swift" | ||
| awk -v e="$2" ' | ||
|
|
@@ -590,12 +639,8 @@ inject_v1_endpoint_paths() { | |
| case channelEvent(String) | ||
| case pinnedMessages(String) | ||
|
|
||
| case sendMessage(ChannelId) | ||
| case message(MessageId) | ||
| case editMessage(MessageId) | ||
| case deleteMessage(MessageId) | ||
| case pinMessage(MessageId) | ||
| case unpinMessage(MessageId) | ||
| case replies(MessageId) | ||
| case addReaction(MessageId) | ||
| case deleteReaction(MessageId, MessageReactionType) | ||
|
|
@@ -646,12 +691,8 @@ EOF | |
| case let .channelEvent(channelId): return "channels/\(channelId)/event" | ||
| case let .pinnedMessages(channelId): return "channels/\(channelId)/pinned_messages" | ||
|
|
||
| case let .sendMessage(channelId): return "channels/\(channelId.apiPath)/message" | ||
| case let .message(messageId): return "messages/\(messageId)" | ||
| case let .editMessage(messageId): return "messages/\(messageId)" | ||
| case let .deleteMessage(messageId): return "messages/\(messageId)" | ||
| case let .pinMessage(messageId): return "messages/\(messageId)" | ||
| case let .unpinMessage(messageId): return "messages/\(messageId)" | ||
| case let .replies(messageId): return "messages/\(messageId)/replies" | ||
| case let .addReaction(messageId): return "messages/\(messageId)/reaction" | ||
| case let .deleteReaction(messageId, reaction): return "messages/\(messageId)/reaction/\(reaction.rawValue)" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| import Foundation | ||
|
|
||
| extension Endpoint { | ||
| static func getMessage(messageId: MessageId) -> Endpoint<MessagePayload.Boxed> { | ||
| static func getMessage(messageId: MessageId) -> Endpoint<MessageResponse.Boxed> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Update the remaining response mocks to
Also applies to: 47-47 🤖 Prompt for AI Agents |
||
| .init( | ||
| path: .message(messageId), | ||
| method: .get, | ||
|
|
@@ -15,7 +15,7 @@ extension Endpoint { | |
| ) | ||
| } | ||
|
|
||
| static func deleteMessage(messageId: MessageId, hard: Bool, deleteForMe: Bool? = nil) -> Endpoint<MessagePayload.Boxed> { | ||
| static func deleteMessage(messageId: MessageId, hard: Bool, deleteForMe: Bool? = nil) -> Endpoint<MessageResponse.Boxed> { | ||
| var body: [String: AnyEncodable] = ["hard": AnyEncodable(hard)] | ||
| if let deleteForMe = deleteForMe { | ||
| body["delete_for_me"] = AnyEncodable(deleteForMe) | ||
|
|
@@ -29,43 +29,6 @@ extension Endpoint { | |
| ) | ||
| } | ||
|
|
||
| static func editMessage(payload: MessageRequestBody, skipEnrichUrl: Bool, skipPush: Bool) | ||
| -> Endpoint<EmptyResponse> { | ||
| .init( | ||
| path: .editMessage(payload.id), | ||
| method: .post, | ||
| queryItems: nil, | ||
| requiresConnectionId: false, | ||
| body: [ | ||
| "message": AnyEncodable(payload), | ||
| "skip_enrich_url": AnyEncodable(skipEnrichUrl), | ||
| "skip_push": AnyEncodable(skipPush) | ||
| ] | ||
| ) | ||
| } | ||
|
|
||
| static func pinMessage(messageId: MessageId, request: MessagePartialUpdateRequest) | ||
| -> Endpoint<EmptyResponse> { | ||
| .init( | ||
| path: .pinMessage(messageId), | ||
| method: .put, | ||
| queryItems: nil, | ||
| requiresConnectionId: false, | ||
| body: request | ||
| ) | ||
| } | ||
|
|
||
| static func partialUpdateMessage(messageId: MessageId, request: MessagePartialUpdateRequest) | ||
| -> Endpoint<MessagePayload.Boxed> { | ||
| .init( | ||
| path: .editMessage(messageId), | ||
| method: .put, | ||
| queryItems: nil, | ||
| requiresConnectionId: false, | ||
| body: request | ||
| ) | ||
| } | ||
|
|
||
| static func loadReplies(messageId: MessageId, pagination: MessagesPagination) | ||
| -> Endpoint<MessageRepliesPayload> { | ||
| .init( | ||
|
|
@@ -81,7 +44,7 @@ extension Endpoint { | |
| cid: ChannelId, | ||
| messageId: MessageId, | ||
| action: AttachmentAction | ||
| ) -> Endpoint<MessagePayload.Boxed> { | ||
| ) -> Endpoint<MessageResponse.Boxed> { | ||
| .init( | ||
| path: .messageAction(messageId), | ||
| method: .post, | ||
|
|
@@ -99,7 +62,7 @@ extension Endpoint { | |
| .init(path: .search, method: .get, queryItems: nil, requiresConnectionId: false, body: ["payload": query]) | ||
| } | ||
|
|
||
| static func translate(messageId: MessageId, to language: TranslationLanguage) -> Endpoint<MessagePayload.Boxed> { | ||
| static func translate(messageId: MessageId, to language: TranslationLanguage) -> Endpoint<MessageResponse.Boxed> { | ||
| .init( | ||
| path: .translateMessage(messageId), | ||
| method: .post, | ||
|
|
@@ -109,45 +72,3 @@ extension Endpoint { | |
| ) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Helper data structures | ||
|
|
||
| struct MessagePartialUpdateRequest: Encodable { | ||
| var set: SetProperties? | ||
| var unset: [String]? | ||
| var skipEnrichUrl: Bool? | ||
| var userId: String? | ||
| var user: UserRequestBody? | ||
|
|
||
| /// The available message properties that can be updated. | ||
| struct SetProperties: Encodable { | ||
| var pinned: Bool? | ||
| var text: String? | ||
| var extraData: [String: RawJSON]? | ||
| var attachments: [MessageAttachmentPayload]? | ||
|
|
||
| enum CodingKeys: String, CodingKey { | ||
| case text | ||
| case pinned | ||
| case extraData | ||
| case attachments | ||
| } | ||
|
|
||
| func encode(to encoder: any Encoder) throws { | ||
| var container = encoder.container(keyedBy: CodingKeys.self) | ||
| try container.encodeIfPresent(text, forKey: .text) | ||
| try container.encodeIfPresent(pinned, forKey: .pinned) | ||
| try container.encodeIfPresent(attachments, forKey: .attachments) | ||
| try extraData?.encode(to: encoder) | ||
| } | ||
| } | ||
|
|
||
| func encode(to encoder: Encoder) throws { | ||
| var container = encoder.container(keyedBy: MessagePayloadsCodingKeys.self) | ||
| try container.encodeIfPresent(skipEnrichUrl, forKey: .skipEnrichUrl) | ||
| try container.encodeIfPresent(userId, forKey: .userId) | ||
| try container.encodeIfPresent(user, forKey: .user) | ||
| try container.encodeIfPresent(set, forKey: .set) | ||
| try container.encodeIfPresent(unset, forKey: .unset) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming conflict with our public API layer and what generator uses.
SharedLocationtype name was taken by us in the public API layer and it does not equal to what generator generates. Therefore, we keep using the otherNewLocationRequestPayloadname.