summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-04-10 13:41:35 +0200
committerJoas Schilling <coding@schilljs.com>2024-04-11 11:14:03 +0200
commit91091e90c8dea2dce4080a34b228efa42adfdd21 (patch)
treedf215fac5b3c086d3edf55f5fe247a8c23feaad1
parentbe4a1b250ff6a6e06e00032902f713fb5c30cb80 (diff)
refactor(OpenAPI): Use proper type inheritance for chat messages
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--lib/Model/ProxyCacheMessage.php4
-rw-r--r--lib/ResponseDefinitions.php28
-rw-r--r--openapi-backend-sipbridge.json248
-rw-r--r--openapi-federation.json248
-rw-r--r--openapi-full.json248
-rw-r--r--openapi.json248
-rw-r--r--src/types/openapi/openapi-backend-sipbridge.ts42
-rw-r--r--src/types/openapi/openapi-federation.ts42
-rw-r--r--src/types/openapi/openapi-full.ts42
-rw-r--r--src/types/openapi/openapi.ts42
10 files changed, 521 insertions, 671 deletions
diff --git a/lib/Model/ProxyCacheMessage.php b/lib/Model/ProxyCacheMessage.php
index 7e3e7dec5..a4f1a23ff 100644
--- a/lib/Model/ProxyCacheMessage.php
+++ b/lib/Model/ProxyCacheMessage.php
@@ -59,7 +59,7 @@ use OCP\AppFramework\Db\Entity;
* @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';
@@ -108,7 +108,7 @@ class ProxyCacheMessage extends Entity implements \JsonSerializable {
}
/**
- * @return TalkRoomProxyMessage
+ * @return TalkChatProxyMessage
*/
public function jsonSerialize(): array {
$expirationTimestamp = 0;
diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php
index 263f3deb2..0348c76c3 100644
--- a/lib/ResponseDefinitions.php
+++ b/lib/ResponseDefinitions.php
@@ -93,21 +93,24 @@ namespace OCA\Talk;
* 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,
@@ -117,18 +120,9 @@ namespace OCA\Talk;
* 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}
*
diff --git a/openapi-backend-sipbridge.json b/openapi-backend-sipbridge.json
index 4d9fee9b1..f5d83638b 100644
--- a/openapi-backend-sipbridge.json
+++ b/openapi-backend-sipbridge.json
@@ -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": [
@@ -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",
@@ -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"
- }
- }
}
}
},
diff --git a/openapi-federation.json b/openapi-federation.json
index 26404c955..3107c12b6 100644
--- a/openapi-federation.json
+++ b/openapi-federation.json
@@ -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": [
@@ -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"
},
"FederationInvite": {
"type": "object",
@@ -766,52 +783,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"
- }
- }
}
}
},
diff --git a/openapi-full.json b/openapi-full.json
index 8cc1e159c..58607cae4 100644
--- a/