diff --git a/docs/chat.md b/docs/chat.md index 3c9fe3bbe14..b76e150a218 100644 --- a/docs/chat.md +++ b/docs/chat.md @@ -130,6 +130,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13 + `404 Not Found` When the conversation could not be found for the participant + `412 Precondition Failed` When the lobby is active and the user is not a moderator + `413 Payload Too Large` When the message was longer than the allowed limit of 32000 characters (or 1000 until Nextcloud 16.0.1, check the `spreed => config => chat => max-length` capability for the limit) + + `429 Too Many Requests` When a guest mentioned other participants too often (50 mention meesages per day) - Header: diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index 61e5c7794d9..fe247115195 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -45,13 +45,17 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Collaboration\Reference\IReferenceManager; use OCP\Comments\IComment; +use OCP\Comments\MessageTooLongException; use OCP\Comments\NotFoundException; use OCP\EventDispatcher\IEventDispatcher; use OCP\ICache; use OCP\ICacheFactory; use OCP\IDBConnection; +use OCP\IRequest; use OCP\IUser; use OCP\Notification\IManager as INotificationManager; +use OCP\Security\RateLimiting\ILimiter; +use OCP\Security\RateLimiting\IRateLimitExceededException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; @@ -69,6 +73,9 @@ class ChatManager { public const MAX_CHAT_LENGTH = 32000; + public const RATE_LIMIT_GUEST_MENTIONS_LIMIT = 50; + public const RATE_LIMIT_GUEST_MENTIONS_PERIOD = 24 * 60 * 60; + public const GEO_LOCATION_VALIDATOR = '/^geo:-?\d{1,2}(\.\d+)?,-?\d{1,3}(\.\d+)?(,-?\d+(\.\d+)?)?(;crs=wgs84)?(;u=\d+(\.\d+)?)?$/i'; public const VERB_MESSAGE = 'comment'; public const VERB_SYSTEM = 'system'; @@ -96,6 +103,8 @@ public function __construct( protected ITimeFactory $timeFactory, protected AttachmentService $attachmentService, protected IReferenceManager $referenceManager, + protected ILimiter $rateLimiter, + protected IRequest $request, ) { $this->cache = $cacheFactory->createDistributed('talk/lastmsgid'); $this->unreadCountCache = $cacheFactory->createDistributed('talk/unreadcount'); @@ -219,8 +228,11 @@ public function addChangelogMessage(Room $chat, string $message): IComment { /** * Sends a new message to the given chat. + * + * @throws IRateLimitExceededException Only when $rateLimitGuestMentions is true and the author is a guest participant + * @throws MessageTooLongException */ - public function sendMessage(Room $chat, ?Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, ?IComment $replyTo, string $referenceId, bool $silent): IComment { + public function sendMessage(Room $chat, ?Participant $participant, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, ?IComment $replyTo = null, string $referenceId = '', bool $silent = false, bool $rateLimitGuestMentions = true): IComment { $comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId()); $comment->setMessage($message, self::MAX_CHAT_LENGTH); $comment->setCreationDateTime($creationDateTime); @@ -238,6 +250,18 @@ public function sendMessage(Room $chat, ?Participant $participant, string $actor } $this->setMessageExpiration($chat, $comment); + if ($rateLimitGuestMentions && $participant instanceof Participant && $participant->isGuest()) { + $mentions = $comment->getMentions(); + if (!empty($mentions)) { + $this->rateLimiter->registerAnonRequest( + 'talk-mentions', + self::RATE_LIMIT_GUEST_MENTIONS_LIMIT, + self::RATE_LIMIT_GUEST_MENTIONS_PERIOD, + $this->request->getRemoteAddress(), + ); + } + } + $event = new BeforeChatMessageSentEvent($chat, $comment, $participant, $silent); $this->dispatcher->dispatchTyped($event); diff --git a/lib/Controller/BotController.php b/lib/Controller/BotController.php index d8f53f122bc..9f17ce35a2b 100644 --- a/lib/Controller/BotController.php +++ b/lib/Controller/BotController.php @@ -173,7 +173,7 @@ public function sendMessage(string $token, string $message, string $referenceId $creationDateTime = $this->timeFactory->getDateTime('now', new \DateTimeZone('UTC')); try { - $this->chatManager->sendMessage($room, $this->participant, $actorType, $actorId, $message, $creationDateTime, $parent, $referenceId, $silent); + $this->chatManager->sendMessage($room, $this->participant, $actorType, $actorId, $message, $creationDateTime, $parent, $referenceId, $silent, rateLimitGuestMentions: false); } catch (MessageTooLongException) { return new DataResponse([], Http::STATUS_REQUEST_ENTITY_TOO_LARGE); } catch (\Exception) { diff --git a/lib/Controller/BreakoutRoomController.php b/lib/Controller/BreakoutRoomController.php index 297d9253197..31a82754f66 100644 --- a/lib/Controller/BreakoutRoomController.php +++ b/lib/Controller/BreakoutRoomController.php @@ -62,7 +62,7 @@ public function __construct( * @param 0|1|2|3 $mode Mode of the breakout rooms * @psalm-param BreakoutRoom::MODE_* $mode * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20 $amount Number of breakout rooms - * @psalm-param int<1, 20> $amount Constants {@see BreakoutRoom::MINIMUM_ROOM_AMOUNT} and {@see BreakoutRoom::MAXIMUM_ROOM_AMOUNT} + * @psalm-param int<1, 20> $amount Number of breakout rooms - Constants {@see BreakoutRoom::MINIMUM_ROOM_AMOUNT} and {@see BreakoutRoom::MAXIMUM_ROOM_AMOUNT} * @param string $attendeeMap Mapping of the attendees to breakout rooms * @return DataResponse|DataResponse * diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 6c4570667b1..ab68e5e84bc 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -73,6 +73,7 @@ use OCP\RichObjectStrings\InvalidObjectExeption; use OCP\RichObjectStrings\IValidator; use OCP\Security\ITrustedDomainHelper; +use OCP\Security\RateLimiting\IRateLimitExceededException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IShare; use OCP\User\Events\UserLiveStatusEvent; @@ -182,12 +183,13 @@ protected function parseCommentToResponse(IComment $comment, Message $parentMess * @param int $replyTo Parent id which this message is a reply to * @psalm-param non-negative-int $replyTo * @param bool $silent If sent silent the chat message will not create any notifications - * @return DataResponse|DataResponse, array{}> + * @return DataResponse|DataResponse, array{}> * * 201: Message sent successfully * 400: Sending message is not possible * 404: Actor not found * 413: Message too long + * 429: Mention rate limit exceeded (guests only) */ #[PublicPage] #[RequireModeratorOrNoLobby] @@ -225,8 +227,10 @@ public function sendMessage(string $message, string $actorDisplayName = '', stri try { $comment = $this->chatManager->sendMessage($this->room, $this->participant, $actorType, $actorId, $message, $creationDateTime, $parent, $referenceId, $silent); - } catch (MessageTooLongException $e) { + } catch (MessageTooLongException) { return new DataResponse([], Http::STATUS_REQUEST_ENTITY_TOO_LARGE); + } catch (IRateLimitExceededException) { + return new DataResponse([], Http::STATUS_TOO_MANY_REQUESTS); } catch (\Exception $e) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index ed8553c5a39..cd368080305 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -126,9 +126,7 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch $participant->getAttendee()->getActorId(), $this->prepareMention($mode, $participant) . $message, new \DateTime(), - null, - '', - false + rateLimitGuestMentions: false, ); } catch (UnexpectedValueException|ParticipantNotFoundException|RoomNotFoundException) { continue; diff --git a/lib/Service/BreakoutRoomService.php b/lib/Service/BreakoutRoomService.php index 2346c51cf17..a4e369e50d7 100644 --- a/lib/Service/BreakoutRoomService.php +++ b/lib/Service/BreakoutRoomService.php @@ -366,7 +366,7 @@ public function broadcastChatMessage(Room $parent, Participant $participant, str try { foreach ($breakoutRooms as $breakoutRoom) { $breakoutParticipant = $this->participantService->getParticipantByActor($breakoutRoom, $attendeeType, $attendeeId); - $comment = $this->chatManager->sendMessage($breakoutRoom, $breakoutParticipant, $attendeeType, $attendeeId, $message, $creationDateTime, null, '', false); + $comment = $this->chatManager->sendMessage($breakoutRoom, $breakoutParticipant, $attendeeType, $attendeeId, $message, $creationDateTime, rateLimitGuestMentions: false); $breakoutRoom->setLastMessage($comment); } } finally { diff --git a/openapi.json b/openapi.json index 4cdc351ee9f..40ba28b1ab0 100644 --- a/openapi.json +++ b/openapi.json @@ -2768,17 +2768,25 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2, + 3 + ] } }, { "name": "amount", "in": "query", - "description": "Number of breakout rooms", + "description": "Number of breakout rooms - Constants {@see BreakoutRoom::MINIMUM_ROOM_AMOUNT} and {@see BreakoutRoom::MAXIMUM_ROOM_AMOUNT}", "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 1, + "maximum": 20 } }, { @@ -3997,8 +4005,25 @@ "description": "In-Call flags", "schema": { "type": "integer", - "format": "int64", - "nullable": true + "nullable": true, + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ] } }, { @@ -4007,8 +4032,265 @@ "description": "In-call permissions", "schema": { "type": "integer", - "format": "int64", - "nullable": true + "nullable": true, + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255 + ] } }, { @@ -4935,7 +5217,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1 + ] } }, { @@ -4955,7 +5241,8 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "minimum": 0 } }, { @@ -4965,7 +5252,8 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "minimum": 0 } }, { @@ -4975,7 +5263,9 @@ "schema": { "type": "integer", "format": "int64", - "default": 30 + "default": 30, + "minimum": 0, + "maximum": 30 } }, { @@ -4985,7 +5275,11 @@ "schema": { "type": "integer", "format": "int64", - "default": 1 + "default": 1, + "enum": [ + 0, + 1 + ] } }, { @@ -4995,7 +5289,11 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "enum": [ + 0, + 1 + ] } }, { @@ -5005,7 +5303,11 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "enum": [ + 0, + 1 + ] } }, { @@ -5015,7 +5317,11 @@ "schema": { "type": "integer", "format": "int64", - "default": 1 + "default": 1, + "enum": [ + 0, + 1 + ] } }, { @@ -5194,7 +5500,8 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "minimum": 0 } }, { @@ -5360,6 +5667,34 @@ } } } + }, + "429": { + "description": "Mention rate limit exceeded (guests only)", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } } } }, @@ -5560,7 +5895,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -5788,7 +6124,9 @@ "schema": { "type": "integer", "format": "int64", - "default": 50 + "default": 50, + "minimum": 1, + "maximum": 100 } }, { @@ -5819,7 +6157,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -5950,7 +6289,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -5981,7 +6321,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -6099,7 +6440,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -6217,7 +6559,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -6314,7 +6657,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -6839,7 +7183,8 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "minimum": 0 } }, { @@ -6849,7 +7194,9 @@ "schema": { "type": "integer", "format": "int64", - "default": 100 + "default": 100, + "minimum": 1, + "maximum": 200 } }, { @@ -6952,7 +7299,9 @@ "schema": { "type": "integer", "format": "int64", - "default": 7 + "default": 7, + "minimum": 1, + "maximum": 20 } }, { @@ -8500,7 +8849,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1 + ] } }, { @@ -8652,7 +9005,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -8784,7 +9138,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -8931,7 +9286,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -9273,7 +9629,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -9471,7 +9828,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -9633,7 +9991,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -9751,7 +10110,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -10323,7 +10683,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -10451,7 +10812,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -10461,7 +10823,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -10589,7 +10952,11 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "enum": [ + 0, + 1 + ] } }, { @@ -10608,7 +10975,8 @@ "schema": { "type": "integer", "format": "int64", - "default": 0 + "default": 0, + "minimum": 0 } }, { @@ -11949,7 +12317,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1 + ] } }, { @@ -12067,7 +12439,12 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2 + ] } }, { @@ -12339,7 +12716,265 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255 + ] } }, { @@ -13122,7 +13757,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -13297,7 +13933,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -13321,7 +13958,265 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255 + ] } }, { @@ -13510,7 +14405,265 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255 + ] } }, { @@ -13916,7 +15069,8 @@ "schema": { "type": "integer", "format": "int64", - "nullable": true + "nullable": true, + "minimum": 0 } }, { @@ -14035,7 +15189,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1 + ] } }, { @@ -14184,7 +15342,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -14357,7 +15516,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -14935,7 +16095,8 @@ "schema": { "type": "integer", "format": "int64", - "nullable": true + "nullable": true, + "minimum": 0 } }, { @@ -15055,7 +16216,12 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 0, + 1, + 2 + ] } }, { @@ -15418,7 +16584,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { @@ -15658,8 +16825,16 @@ "in": "query", "description": "New value for the key", "schema": { - "type": "string", - "nullable": true + "nullable": true, + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer", + "format": "int64" + } + ] } }, { @@ -15920,7 +17095,8 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0 } }, { diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php index 99fd88e2bb0..7ba54a45b7a 100644 --- a/tests/php/Chat/ChatManagerTest.php +++ b/tests/php/Chat/ChatManagerTest.php @@ -42,8 +42,10 @@ use OCP\Comments\ICommentsManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\ICacheFactory; +use OCP\IRequest; use OCP\IUser; use OCP\Notification\IManager as INotificationManager; +use OCP\Security\RateLimiting\ILimiter; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; @@ -78,6 +80,10 @@ class ChatManagerTest extends TestCase { protected $attachmentService; /** @var IReferenceManager|MockObject */ protected $referenceManager; + /** @var ILimiter|MockObject */ + protected $rateLimiter; + /** @var IRequest|MockObject */ + protected $request; protected ?ChatManager $chatManager = null; public function setUp(): void { @@ -95,24 +101,10 @@ public function setUp(): void { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->attachmentService = $this->createMock(AttachmentService::class); $this->referenceManager = $this->createMock(IReferenceManager::class); - $cacheFactory = $this->createMock(ICacheFactory::class); + $this->rateLimiter = $this->createMock(ILimiter::class); + $this->request = $this->createMock(IRequest::class); - $this->chatManager = new ChatManager( - $this->commentsManager, - $this->dispatcher, - \OC::$server->getDatabaseConnection(), - $this->notificationManager, - $this->shareManager, - $this->shareProvider, - $this->participantService, - $this->roomService, - $this->pollService, - $this->notifier, - $cacheFactory, - $this->timeFactory, - $this->attachmentService, - $this->referenceManager, - ); + $this->chatManager = $this->getManager(); } /** @@ -139,6 +131,8 @@ protected function getManager(array $methods = []): ChatManager { $this->timeFactory, $this->attachmentService, $this->referenceManager, + $this->rateLimiter, + $this->request, ]) ->onlyMethods($methods) ->getMock(); @@ -159,6 +153,8 @@ protected function getManager(array $methods = []): ChatManager { $this->timeFactory, $this->attachmentService, $this->referenceManager, + $this->rateLimiter, + $this->request, ); } diff --git a/vendor-bin/openapi-extractor/composer.lock b/vendor-bin/openapi-extractor/composer.lock index 80b5b4269e9..c5f999eb8f1 100644 --- a/vendor-bin/openapi-extractor/composer.lock +++ b/vendor-bin/openapi-extractor/composer.lock @@ -83,12 +83,12 @@ "source": { "type": "git", "url": "https://github.com/nextcloud/openapi-extractor.git", - "reference": "d99e9c0fbaa6502a704d53d4ca8b7566566ab4be" + "reference": "f4bda5419d4c76e70078ccfc3a0710548826333d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/openapi-extractor/zipball/d99e9c0fbaa6502a704d53d4ca8b7566566ab4be", - "reference": "d99e9c0fbaa6502a704d53d4ca8b7566566ab4be", + "url": "https://api.github.com/repos/nextcloud/openapi-extractor/zipball/f4bda5419d4c76e70078ccfc3a0710548826333d", + "reference": "f4bda5419d4c76e70078ccfc3a0710548826333d", "shasum": "" }, "require": { @@ -113,7 +113,7 @@ "source": "https://github.com/nextcloud/openapi-extractor/tree/main", "issues": "https://github.com/nextcloud/openapi-extractor/issues" }, - "time": "2023-10-29T16:42:12+00:00" + "time": "2023-12-08T08:42:33+00:00" }, { "name": "nikic/php-parser", @@ -173,16 +173,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.2", + "version": "1.24.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bcad8d995980440892759db0c32acae7c8e79442" + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", - "reference": "bcad8d995980440892759db0c32acae7c8e79442", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", "shasum": "" }, "require": { @@ -214,9 +214,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" }, - "time": "2023-09-26T12:28:12+00:00" + "time": "2023-11-26T18:29:22+00:00" } ], "aliases": [],