Skip to content

Commit

Permalink
feat(openapi): Add more type/int limitations
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 23, 2024
1 parent 78f4009 commit 334f1f1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 39 deletions.
83 changes: 44 additions & 39 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
namespace OCA\Talk;

/**
* @psalm-type TalkRoomTypes = 1|2|3|4|5|6
* @psalm-type TalkParticipantTypes = 1|2|3|4|5|6
* @psalm-type TalkCallFlags = int<0, 15>
* @psalm-type TalkPermissions = int<0, 255>
*
* @psalm-type TalkBan = array{
* id: int,
* moderatorActorType: string,
Expand All @@ -26,12 +31,12 @@
* description: ?string,
* id: int,
* name: string,
* state: int,
* state: 0|1|2,
* }
*
* @psalm-type TalkBotWithDetails = TalkBot&array{
* error_count: int,
* features: int,
* features: 0|1|2|3,
* last_error_date: int,
* last_error_message: string,
* url: string,
Expand All @@ -56,11 +61,11 @@
* label: string,
* source: string,
* mentionId: string,
* details: ?string,
* status: ?string,
* statusClearAt: ?int,
* statusIcon: ?string,
* statusMessage: ?string,
* details?: string,
* status?: 'online'|'away'|'dnd'|'busy'|'offline'|'invisible',
* statusClearAt?: ?int,
* statusIcon?: ?string,
* statusMessage?: ?string,
* }
*
* @psalm-type TalkRichObjectParameter = array{
Expand Down Expand Up @@ -136,7 +141,7 @@
*
* @psalm-type TalkFederationInvite = array{
* id: int,
* state: int,
* state: 0|1,
* localCloudId: string,
* localToken: string,
* remoteAttendeeId: int,
Expand Down Expand Up @@ -167,16 +172,16 @@
* actorId: string,
* actorType: string,
* attendeeId: int,
* attendeePermissions: int,
* attendeePermissions: TalkPermissions,
* attendeePin: string,
* displayName: string,
* inCall: int,
* inCall: TalkCallFlags,
* lastPing: int,
* participantType: int,
* permissions: int,
* participantType: TalkParticipantTypes,
* permissions: TalkPermissions,
* roomToken: string,
* sessionIds: string[],
* status?: string,
* status?: 'online'|'away'|'dnd'|'busy'|'offline'|'invisible',
* statusClearAt?: ?int,
* statusIcon?: ?string,
* statusMessage?: ?string,
Expand All @@ -201,8 +206,8 @@
* numVoters?: int,
* options: string[],
* question: string,
* resultMode: int,
* status: int,
* resultMode: 0|1,
* status: 0|1,
* votedSelf?: int[],
* votes?: array<string, int>,
* }
Expand All @@ -218,20 +223,20 @@
* actorId: string,
* actorType: string,
* attendeeId: int,
* attendeePermissions: int,
* attendeePermissions: TalkPermissions,
* attendeePin: ?string,
* avatarVersion: string,
* breakoutRoomMode: int,
* breakoutRoomStatus: int,
* callFlag: int,
* callPermissions: int,
* callRecording: int,
* breakoutRoomMode: 0|1|2|3,
* breakoutRoomStatus: 0|1|2,
* callFlag: TalkCallFlags,
* callPermissions: TalkPermissions,
* callRecording: int<0, 5>,
* callStartTime: int,
* canDeleteConversation: bool,
* canEnableSIP: bool,
* canLeaveConversation: bool,
* canStartCall: bool,
* defaultPermissions: int,
* defaultPermissions: TalkPermissions,
* description: string,
* displayName: string,
* hasCall: bool,
Expand All @@ -244,38 +249,38 @@
* lastMessage: TalkRoomLastMessage|array<empty>,
* lastPing: int,
* lastReadMessage: int,
* listable: int,
* lobbyState: int,
* listable: 0|1|2,
* lobbyState: 0|1,
* lobbyTimer: int,
* mentionPermissions: int,
* mentionPermissions: 0|1,
* messageExpiration: int,
* name: string,
* notificationCalls: int,
* notificationLevel: int,
* notificationCalls: 0|1,
* notificationLevel: 0|1|2|3,
* objectId: string,
* objectType: string,
* participantFlags: int,
* participantType: int,
* permissions: int,
* readOnly: int,
* recordingConsent: int,
* participantFlags: TalkCallFlags,
* participantType: TalkParticipantTypes,
* permissions: TalkPermissions,
* readOnly: 0|1,
* recordingConsent: 0|1|2,
* sessionId: string,
* sipEnabled: int,
* status?: string,
* sipEnabled: 0|1|2,
* status?: 'online'|'away'|'dnd'|'busy'|'offline'|'invisible',
* statusClearAt?: ?int,
* statusIcon?: ?string,
* statusMessage?: ?string,
* token: string,
* type: int,
* type: TalkRoomTypes,
* unreadMention: bool,
* unreadMentionDirect: bool,
* unreadMessages: int,
* }
*
* @psalm-type TalkSignalingSession = array{
* inCall: int,
* inCall: TalkCallFlags,
* lastPing: int,
* participantPermissions: int,
* participantPermissions: TalkPermissions,
* roomId: int,
* sessionId: string,
* userId: string,
Expand Down Expand Up @@ -323,9 +328,9 @@
* },
* chat: array{
* max-length: int,
* read-privacy: int,
* read-privacy: 0|1,
* has-translation-providers: bool,
* typing-privacy: int,
* typing-privacy: 0|1,
* },
* conversations: array{
* can-create: bool,
Expand Down
3 changes: 3 additions & 0 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ public function getMentionPermissions(): int {
return $this->mentionPermissions;
}

/**
* @psalm-param self::MENTION_PERMISSIONS_* $mentionPermissions
*/
public function setMentionPermissions(int $mentionPermissions): void {
$this->mentionPermissions = $mentionPermissions;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Service/RoomService.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ public function setPermissions(Room $room, string $level, string $method, int $p
return true;
}

/**
* @psalm-param Webinary::SIP_* $newSipEnabled
*/
public function setSIPEnabled(Room $room, int $newSipEnabled): bool {
$oldSipEnabled = $room->getSIPEnabled();

Expand Down

0 comments on commit 334f1f1

Please sign in to comment.