Skip to content

Commit 2042ded

Browse files
provokateurinbackportbot[bot]
authored andcommitted
refactor(OpenAPI): Use proper type inheritance for chat messages
Signed-off-by: provokateurin <[email protected]>
1 parent 51bc69d commit 2042ded

10 files changed

+521
-671
lines changed

Diff for: lib/Model/ProxyCacheMessage.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* @method void setMetaData(?string $metaData)
6060
* @method string|null getMetaData()
6161
*
62-
* @psalm-import-type TalkRoomProxyMessage from ResponseDefinitions
62+
* @psalm-import-type TalkChatProxyMessage from ResponseDefinitions
6363
*/
6464
class ProxyCacheMessage extends Entity implements \JsonSerializable {
6565
public const METADATA_REPLY_TO_ACTOR_TYPE = 'replyToActorType';
@@ -108,7 +108,7 @@ public function getParsedMetaData(): array {
108108
}
109109

110110
/**
111-
* @return TalkRoomProxyMessage
111+
* @return TalkChatProxyMessage
112112
*/
113113
public function jsonSerialize(): array {
114114
$expirationTimestamp = 0;

Diff for: lib/ResponseDefinitions.php

+11-17
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,24 @@
9393
* conversation?: string,
9494
* }
9595
*
96-
* @psalm-type TalkChatMessage = array{
96+
* @psalm-type TalkBaseMessage = array{
9797
* actorDisplayName: string,
9898
* actorId: string,
9999
* actorType: string,
100-
* deleted?: true,
101100
* expirationTimestamp: int,
102-
* id: int,
103-
* isReplyable: bool,
104-
* markdown: bool,
105101
* message: string,
106102
* messageParameters: array<string, TalkRichObjectParameter>,
107103
* messageType: string,
104+
* systemMessage: string,
105+
* }
106+
*
107+
* @psalm-type TalkChatMessage = TalkBaseMessage&array{
108+
* deleted?: true,
109+
* id: int,
110+
* isReplyable: bool,
111+
* markdown: bool,
108112
* reactions: array<string, integer>|\stdClass,
109113
* referenceId: string,
110-
* systemMessage: string,
111114
* timestamp: int,
112115
* token: string,
113116
* lastEditActorDisplayName?: string,
@@ -117,18 +120,9 @@
117120
* silent?: bool,
118121
* }
119122
*
120-
* @psalm-type TalkRoomProxyMessage = array{
121-
* actorDisplayName: string,
122-
* actorId: string,
123-
* actorType: string,
124-
* expirationTimestamp: int,
125-
* message: string,
126-
* messageParameters: array<string, TalkRichObjectParameter>,
127-
* messageType: string,
128-
* systemMessage: string,
129-
* }
123+
* @psalm-type TalkChatProxyMessage = TalkBaseMessage
130124
*
131-
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkRoomProxyMessage
125+
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkChatProxyMessage
132126
*
133127
* @psalm-type TalkChatMessageWithParent = TalkChatMessage&array{parent?: TalkChatMessage}
134128
*

Diff for: openapi-backend-sipbridge.json

+111-137
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,49 @@
2020
}
2121
},
2222
"schemas": {
23+
"BaseMessage": {
24+
"type": "object",
25+
"required": [
26+
"actorDisplayName",
27+
"actorId",
28+
"actorType",
29+
"expirationTimestamp",
30+
"message",
31+
"messageParameters",
32+
"messageType",
33+
"systemMessage"
34+
],
35+
"properties": {
36+
"actorDisplayName": {
37+
"type": "string"
38+
},
39+
"actorId": {
40+
"type": "string"
41+
},
42+
"actorType": {
43+
"type": "string"
44+
},
45+
"expirationTimestamp": {
46+
"type": "integer",
47+
"format": "int64"
48+
},
49+
"message": {
50+
"type": "string"
51+
},
52+
"messageParameters": {
53+
"type": "object",
54+
"additionalProperties": {
55+
"$ref": "#/components/schemas/RichObjectParameter"
56+
}
57+
},
58+
"messageType": {
59+
"type": "string"
60+
},
61+
"systemMessage": {
62+
"type": "string"
63+
}
64+
}
65+
},
2366
"Capabilities": {
2467
"type": "object",
2568
"required": [
@@ -209,103 +252,77 @@
209252
}
210253
},
211254
"ChatMessage": {
212-
"type": "object",
213-
"required": [
214-
"actorDisplayName",
215-
"actorId",
216-
"actorType",
217-
"expirationTimestamp",
218-
"id",
219-
"isReplyable",
220-
"markdown",
221-
"message",
222-
"messageParameters",
223-
"messageType",
224-
"reactions",
225-
"referenceId",
226-
"systemMessage",
227-
"timestamp",
228-
"token"
229-
],
230-
"properties": {
231-
"actorDisplayName": {
232-
"type": "string"
233-
},
234-
"actorId": {
235-
"type": "string"
236-
},
237-
"actorType": {
238-
"type": "string"
239-
},
240-
"deleted": {
241-
"type": "boolean",
242-
"enum": [
243-
true
244-
]
245-
},
246-
"expirationTimestamp": {
247-
"type": "integer",
248-
"format": "int64"
249-
},
250-
"id": {
251-
"type": "integer",
252-
"format": "int64"
253-
},
254-
"isReplyable": {
255-
"type": "boolean"
256-
},
257-
"markdown": {
258-
"type": "boolean"
259-
},
260-
"message": {
261-
"type": "string"
262-
},
263-
"messageParameters": {
264-
"type": "object",
265-
"additionalProperties": {
266-
"$ref": "#/components/schemas/RichObjectParameter"
267-
}
268-
},
269-
"messageType": {
270-
"type": "string"
255+
"allOf": [
256+
{
257+
"$ref": "#/components/schemas/BaseMessage"
271258
},
272-
"reactions": {
259+
{
273260
"type": "object",
274-
"additionalProperties": {
275-
"type": "integer",
276-
"format": "int64"
261+
"required": [
262+
"id",
263+
"isReplyable",
264+
"markdown",
265+
"reactions",
266+
"referenceId",
267+
"timestamp",
268+
"token"
269+
],
270+
"properties": {
271+
"deleted": {
272+
"type": "boolean",
273+
"enum": [
274+
true
275+
]
276+
},
277+
"id": {
278+
"type": "integer",
279+
"format": "int64"
280+
},
281+
"isReplyable": {
282+
"type": "boolean"
283+
},
284+
"markdown": {
285+
"type": "boolean"
286+
},
287+
"reactions": {
288+
"type": "object",
289+
"additionalProperties": {
290+
"type": "integer",
291+
"format": "int64"
292+
}
293+
},
294+
"referenceId": {
295+
"type": "string"
296+
},
297+
"timestamp": {
298+
"type": "integer",
299+
"format": "int64"
300+
},
301+
"token": {
302+
"type": "string"
303+
},
304+
"lastEditActorDisplayName": {
305+
"type": "string"
306+
},
307+
"lastEditActorId": {
308+
"type": "string"
309+
},
310+
"lastEditActorType": {
311+
"type": "string"
312+
},
313+
"lastEditTimestamp": {
314+
"type": "integer",
315+
"format": "int64"
316+
},
317+
"silent": {
318+
"type": "boolean"
319+
}
277320
}
278-
},
279-
"referenceId": {
280-
"type": "string"
281-
},
282-
"systemMessage": {
283-
"type": "string"
284-
},
285-
"timestamp": {
286-
"type": "integer",
287-
"format": "int64"
288-
},
289-
"token": {
290-
"type": "string"
291-
},
292-
"lastEditActorDisplayName": {
293-
"type": "string"
294-
},
295-
"lastEditActorId": {
296-
"type": "string"
297-
},
298-
"lastEditActorType": {
299-
"type": "string"
300-
},
301-
"lastEditTimestamp": {
302-
"type": "integer",
303-
"format": "int64"
304-
},
305-
"silent": {
306-
"type": "boolean"
307321
}
308-
}
322+
]
323+
},
324+
"ChatProxyMessage": {
325+
"$ref": "#/components/schemas/BaseMessage"
309326
},
310327
"OCSMeta": {
311328
"type": "object",
@@ -712,52 +729,9 @@
712729
"$ref": "#/components/schemas/ChatMessage"
713730
},
714731
{
715-
"$ref": "#/components/schemas/RoomProxyMessage"
732+
"$ref": "#/components/schemas/ChatProxyMessage"
716733
}
717734
]
718-
},
719-
"RoomProxyMessage": {
720-
"type": "object",
721-
"required": [
722-
"actorDisplayName",
723-
"actorId",
724-
"actorType",
725-
"expirationTimestamp",
726-
"message",
727-
"messageParameters",
728-
"messageType",
729-
"systemMessage"
730-
],
731-
"properties": {
732-
"actorDisplayName": {
733-
"type": "string"
734-
},
735-
"actorId": {
736-
"type": "string"
737-
},
738-
"actorType": {
739-
"type": "string"
740-
},
741-
"expirationTimestamp": {
742-
"type": "integer",
743-
"format": "int64"
744-
},
745-
"message": {
746-
"type": "string"
747-
},
748-
"messageParameters": {
749-
"type": "object",
750-
"additionalProperties": {
751-
"$ref": "#/components/schemas/RichObjectParameter"
752-
}
753-
},
754-
"messageType": {
755-
"type": "string"
756-
},
757-
"systemMessage": {
758-
"type": "string"
759-
}
760-
}
761735
}
762736
}
763737
},

0 commit comments

Comments
 (0)