Skip to content
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

[stable29] refactor(OpenAPI): Use proper type inheritance for chat messages #12056

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Model/ProxyCacheMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* @method void setMetaData(?string $metaData)
* @method string|null getMetaData()
*
* @psalm-import-type TalkRoomProxyMessage from ResponseDefinitions
* @psalm-import-type TalkChatProxyMessage from ResponseDefinitions
*/
class ProxyCacheMessage extends Entity implements \JsonSerializable {
public const METADATA_REPLY_TO_ACTOR_TYPE = 'replyToActorType';
Expand Down Expand Up @@ -108,7 +108,7 @@ public function getParsedMetaData(): array {
}

/**
* @return TalkRoomProxyMessage
* @return TalkChatProxyMessage
*/
public function jsonSerialize(): array {
$expirationTimestamp = 0;
Expand Down
28 changes: 11 additions & 17 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,24 @@
* conversation?: string,
* }
*
* @psalm-type TalkChatMessage = array{
* @psalm-type TalkBaseMessage = array{
* actorDisplayName: string,
* actorId: string,
* actorType: string,
* deleted?: true,
* expirationTimestamp: int,
* id: int,
* isReplyable: bool,
* markdown: bool,
* message: string,
* messageParameters: array<string, TalkRichObjectParameter>,
* messageType: string,
* systemMessage: string,
* }
*
* @psalm-type TalkChatMessage = TalkBaseMessage&array{
* deleted?: true,
* id: int,
* isReplyable: bool,
* markdown: bool,
* reactions: array<string, integer>|\stdClass,
* referenceId: string,
* systemMessage: string,
* timestamp: int,
* token: string,
* lastEditActorDisplayName?: string,
Expand All @@ -117,18 +120,9 @@
* silent?: bool,
* }
*
* @psalm-type TalkRoomProxyMessage = array{
* actorDisplayName: string,
* actorId: string,
* actorType: string,
* expirationTimestamp: int,
* message: string,
* messageParameters: array<string, TalkRichObjectParameter>,
* messageType: string,
* systemMessage: string,
* }
* @psalm-type TalkChatProxyMessage = TalkBaseMessage
*
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkRoomProxyMessage
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkChatProxyMessage
*
* @psalm-type TalkChatMessageWithParent = TalkChatMessage&array{parent?: TalkChatMessage}
*
Expand Down
248 changes: 111 additions & 137 deletions openapi-backend-sipbridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,49 @@
}
},
"schemas": {
"BaseMessage": {
"type": "object",
"required": [
"actorDisplayName",
"actorId",
"actorType",
"expirationTimestamp",
"message",
"messageParameters",
"messageType",
"systemMessage"
],
"properties": {
"actorDisplayName": {
"type": "string"
},
"actorId": {
"type": "string"
},
"actorType": {
"type": "string"
},
"expirationTimestamp": {
"type": "integer",
"format": "int64"
},
"message": {
"type": "string"
},
"messageParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
},
"messageType": {
"type": "string"
},
"systemMessage": {
"type": "string"
}
}
},
"Capabilities": {
"type": "object",
"required": [
Expand Down Expand Up @@ -209,103 +252,77 @@
}
},
"ChatMessage": {
"type": "object",
"required": [
"actorDisplayName",
"actorId",
"actorType",
"expirationTimestamp",
"id",
"isReplyable",
"markdown",
"message",
"messageParameters",
"messageType",
"reactions",
"referenceId",
"systemMessage",
"timestamp",
"token"
],
"properties": {
"actorDisplayName": {
"type": "string"
},
"actorId": {
"type": "string"
},
"actorType": {
"type": "string"
},
"deleted": {
"type": "boolean",
"enum": [
true
]
},
"expirationTimestamp": {
"type": "integer",
"format": "int64"
},
"id": {
"type": "integer",
"format": "int64"
},
"isReplyable": {
"type": "boolean"
},
"markdown": {
"type": "boolean"
},
"message": {
"type": "string"
},
"messageParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
},
"messageType": {
"type": "string"
"allOf": [
{
"$ref": "#/components/schemas/BaseMessage"
},
"reactions": {
{
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
"required": [
"id",
"isReplyable",
"markdown",
"reactions",
"referenceId",
"timestamp",
"token"
],
"properties": {
"deleted": {
"type": "boolean",
"enum": [
true
]
},
"id": {
"type": "integer",
"format": "int64"
},
"isReplyable": {
"type": "boolean"
},
"markdown": {
"type": "boolean"
},
"reactions": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
},
"referenceId": {
"type": "string"
},
"timestamp": {
"type": "integer",
"format": "int64"
},
"token": {
"type": "string"
},
"lastEditActorDisplayName": {
"type": "string"
},
"lastEditActorId": {
"type": "string"
},
"lastEditActorType": {
"type": "string"
},
"lastEditTimestamp": {
"type": "integer",
"format": "int64"
},
"silent": {
"type": "boolean"
}
}
},
"referenceId": {
"type": "string"
},
"systemMessage": {
"type": "string"
},
"timestamp": {
"type": "integer",
"format": "int64"
},
"token": {
"type": "string"
},
"lastEditActorDisplayName": {
"type": "string"
},
"lastEditActorId": {
"type": "string"
},
"lastEditActorType": {
"type": "string"
},
"lastEditTimestamp": {
"type": "integer",
"format": "int64"
},
"silent": {
"type": "boolean"
}
}
]
},
"ChatProxyMessage": {
"$ref": "#/components/schemas/BaseMessage"
},
"OCSMeta": {
"type": "object",
Expand Down Expand Up @@ -712,52 +729,9 @@
"$ref": "#/components/schemas/ChatMessage"
},
{
"$ref": "#/components/schemas/RoomProxyMessage"
"$ref": "#/components/schemas/ChatProxyMessage"
}
]
},
"RoomProxyMessage": {
"type": "object",
"required": [
"actorDisplayName",
"actorId",
"actorType",
"expirationTimestamp",
"message",
"messageParameters",
"messageType",
"systemMessage"
],
"properties": {
"actorDisplayName": {
"type": "string"
},
"actorId": {
"type": "string"
},
"actorType": {
"type": "string"
},
"expirationTimestamp": {
"type": "integer",
"format": "int64"
},
"message": {
"type": "string"
},
"messageParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
},
"messageType": {
"type": "string"
},
"systemMessage": {
"type": "string"
}
}
}
}
},
Expand Down
Loading
Loading