Skip to content

Commit

Permalink
Merge pull request #10881 from nextcloud/bugfix/10880/handle-at-all-i…
Browse files Browse the repository at this point in the history
…n-note-to-self

fix(chat): Handle `at-all` in note to self
  • Loading branch information
nickvergessen authored Nov 13, 2023
2 parents 9ee4aea + bd2cf7e commit c78abeb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ protected function getRoomType(Room $room): string {
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';
Expand Down
9 changes: 9 additions & 0 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class Room {
protected ?Participant $participant = null;

/**
* @psalm-param Room::TYPE_* $type
* @psalm-param RecordingService::CONSENT_REQUIRED_* $recordingConsent
*/
public function __construct(
Expand Down Expand Up @@ -282,10 +283,18 @@ public function getId(): int {
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;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,23 @@ public function userCreatesRoom(string $user, string $identifier, string $apiVer
$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)\)$/
*
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/features/chat/mentions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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" |

0 comments on commit c78abeb

Please sign in to comment.