Skip to content

Commit bbefc29

Browse files
committed
Fixes after code review
Signed-off-by: Vitor Mattos <[email protected]>
1 parent e93e832 commit bbefc29

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

docs/conversation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
| `isCustomAvatar` | bool | v4 | | Flag if the conversation has a custom avatar (only available with `avatar` capability) |
108108
| `callStartTime` | int | v4 | | Timestamp when the call was started (only available with `recording-v1` capability) |
109109
| `callRecording` | int | v4 | | Type of call recording (see [Constants - Call recording status](constants.md#call-recording-status)) (only available with `recording-v1` capability) |
110-
| `canMentionEveryone` | int | v4 | | Type of call recording (see [Constants - Can mention everyone](constants.md#can-mention-everyone)) (only available with `can-mention-everyone` capability) |
110+
| `canMentionEveryone` | int | v4 | | Flag if non moderators can mention everyone (see [Constants - Can mention everyone](constants.md#can-mention-everyone)) (only available with `can-mention-everyone` capability) |
111111

112112
## Creating a new conversation
113113

lib/Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function createRoomObject(array $row): Room {
230230
(int) $row['breakout_room_mode'],
231231
(int) $row['breakout_room_status'],
232232
(int) $row['call_recording'],
233-
(int) $row['can_mention_everyone']
233+
(int) $row['can_mention_everyone'],
234234
);
235235
}
236236

lib/Migration/Version16000Date20230505122109.php renamed to lib/Migration/Version18000Date20230505122109.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
use OCP\Migration\IOutput;
3333
use OCP\Migration\SimpleMigrationStep;
3434

35-
class Version16000Date20230505122109 extends SimpleMigrationStep {
35+
class Version18000Date20230505122109 extends SimpleMigrationStep {
3636

3737
/**
3838
* @param IOutput $output

lib/Room.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class Room {
101101
public const PARTICIPANT_REMOVED_ALL = 'remove_all';
102102
public const PARTICIPANT_LEFT = 'leave';
103103

104+
public const CAN_MENTION_EVERYONE = 1;
105+
public const CAN_NOT_MENTION_EVERYONE = 0;
106+
104107
public const EVENT_AFTER_ROOM_CREATE = self::class . '::createdRoom';
105108
public const EVENT_BEFORE_ROOM_DELETE = self::class . '::preDeleteRoom';
106109
public const EVENT_AFTER_ROOM_DELETE = self::class . '::postDeleteRoom';
@@ -663,7 +666,7 @@ public function setCallRecording(int $callRecording): void {
663666
}
664667

665668
public function setCanMentionEveryone(int $canMentionEveryone): void {
666-
$this->canMentionEveryone = $canMentionEveryone === 1 ? 1 : 0;
669+
$this->canMentionEveryone = $canMentionEveryone;
667670
}
668671

669672
public function getCanMentionEveryone(): int {

lib/Service/RoomFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function formatRoomV4(
139139
'isCustomAvatar' => $this->avatarService->isCustomAvatar($room),
140140
'breakoutRoomMode' => BreakoutRoom::MODE_NOT_CONFIGURED,
141141
'breakoutRoomStatus' => BreakoutRoom::STATUS_STOPPED,
142-
'canMentionEveryone' => 1
142+
'canMentionEveryone' => Room::CAN_MENTION_EVERYONE,
143143
];
144144

145145
$lastActivity = $room->getLastActivity();

lib/Service/RoomService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,11 +853,15 @@ public function deleteRoom(Room $room): void {
853853
}
854854

855855
public function setCanMentionEveryone(Room $room, int $canMentionEveryone): void {
856-
if (!in_array($canMentionEveryone, [0, 1])) {
856+
if (!in_array($canMentionEveryone, [Room::CAN_NOT_MENTION_EVERYONE, Room::CAN_MENTION_EVERYONE])) {
857857
throw new InvalidArgumentException('config');
858858
}
859859

860860
$old = $room->getCanMentionEveryone();
861+
if ($old === $canMentionEveryone) {
862+
return;
863+
}
864+
861865
$event = new ModifyRoomEvent($room, 'canMentionEveryone', $canMentionEveryone, $old);
862866
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_CAN_MENTION_EVERYONE, $event);
863867

tests/php/Service/RoomServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public function testVerifyPassword(): void {
397397
0,
398398
0,
399399
0,
400-
0
400+
0,
401401
);
402402

403403
$verificationResult = $service->verifyPassword($room, '1234');

0 commit comments

Comments
 (0)