From bd2cf7e6f4cf8a60d6996795b37e01c257e7df59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 13 Nov 2023 18:05:58 +0100 Subject: [PATCH] fix(chat): Handle `at-all` in note to self Signed-off-by: Joas Schilling --- lib/Chat/Parser/UserMention.php | 1 + lib/Room.php | 9 +++++++++ .../features/bootstrap/FeatureContext.php | 17 +++++++++++++++++ .../integration/features/chat/mentions.feature | 10 ++++++++++ 4 files changed, 37 insertions(+) diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php index e5f17c4d41..8b557f1ce5 100644 --- a/lib/Chat/Parser/UserMention.php +++ b/lib/Chat/Parser/UserMention.php @@ -214,6 +214,7 @@ class UserMention implements IEventListener { switch ($room->getType()) { case Room::TYPE_ONE_TO_ONE: case Room::TYPE_ONE_TO_ONE_FORMER: + case Room::TYPE_NOTE_TO_SELF: return 'one2one'; case Room::TYPE_GROUP: return 'group'; diff --git a/lib/Room.php b/lib/Room.php index 60da71c04a..88e9953807 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -238,6 +238,7 @@ class Room { protected ?Participant $participant = null; /** + * @psalm-param Room::TYPE_* $type * @psalm-param RecordingService::CONSENT_REQUIRED_* $recordingConsent */ public function __construct( @@ -282,10 +283,18 @@ class Room { return $this->id; } + /** + * @return int + * @psalm-return Room::TYPE_* + */ public function getType(): int { return $this->type; } + /** + * @param int $type + * @psalm-param Room::TYPE_* $type + */ public function setType(int $type): void { $this->type = $type; } diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 3539dd1d73..30c2ed4f45 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -895,6 +895,23 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->userCreatesRoomWith($user, $identifier, 201, $apiVersion, $formData); } + /** + * @Then /^user "([^"]*)" creates note-to-self \((v4)\)$/ + * + * @param string $user + * @param string $apiVersion + */ + public function userCreatesNoteToSelf(string $user, string $apiVersion): void { + $this->setCurrentUser($user); + $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/note-to-self'); + $this->assertStatusCode($this->response, 200); + + $response = $this->getDataFromResponse($this->response); + self::$identifierToToken[$user . '-note-to-self'] = $response['token']; + self::$identifierToId[$user . '-note-to-self'] = $response['id']; + self::$tokenToIdentifier[$response['token']] = $user . '-note-to-self'; + } + /** * @Then /^user "([^"]*)" creates room "([^"]*)" with (\d+) \((v4)\)$/ * diff --git a/tests/integration/features/chat/mentions.feature b/tests/integration/features/chat/mentions.feature index 2c039f95cf..77d6de4251 100644 --- a/tests/integration/features/chat/mentions.feature +++ b/tests/integration/features/chat/mentions.feature @@ -623,3 +623,13 @@ Feature: chat/mentions And user "participant3" is participant of the following rooms (v4) | id | unreadMention | unreadMentionDirect | | group room | 0 | 0 | + + Scenario: At-all in note-to-self broke the mention parsing + And user "participant1" creates note-to-self (v4) + And user "participant1" sends message "Test @all" to room "participant1-note-to-self" with 201 + And user "participant1" is participant of the following rooms (v4) +# | id | type | name | +# | participant1-note-to-self | 6 | Note to self | + Then user "participant1" sees the following messages in room "participant1-note-to-self" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | + | participant1-note-to-self | users | participant1 | participant1-displayname | Test {mention-call1} | "IGNORE" |