Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ title: Constants
* `2` Group
* `3` Public
* `4` Changelog
* `5` Former "One to one" (When a user is deleted from the server or removed from all their conversations, `1` "One to one" rooms are converted to this type)

### Read-only states
* `0` Read-write
Expand Down
2 changes: 1 addition & 1 deletion lib/Activity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function generateCallActivity(Room $room, bool $endForEveryone = false, ?
$message = 'call_ended';
if ($endForEveryone) {
$message = 'call_ended_everyone';
} elseif ($room->getType() === Room::TYPE_ONE_TO_ONE && \count($userIds) === 1) {
} elseif (($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) && \count($userIds) === 1) {
$message = 'call_missed';
}

Expand Down
1 change: 1 addition & 0 deletions lib/Activity/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected function setSubjects(IEvent $event, string $subject, array $parameters
protected function getRoom(Room $room, string $userId): array {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
$stringType = 'one2one';
break;
case Room::TYPE_GROUP:
Expand Down
1 change: 1 addition & 0 deletions lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function parseMessage(Message $chatMessage): void {
protected function getRoomType(Room $room): string {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
return 'one2one';
case Room::TYPE_GROUP:
return 'group';
Expand Down
3 changes: 2 additions & 1 deletion lib/Collaboration/Reference/TalkReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ protected function fetchReference(Reference $reference): void {
$description = str_replace($placeholders, $replacements, $message->getMessage());

$titleLine = $this->l->t('Message of {user} in {conversation}');
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$titleLine = $this->l->t('Message of {user}');
}

Expand Down Expand Up @@ -264,6 +264,7 @@ public function getCacheKey(string $referenceId): ?string {
protected function getRoomType(Room $room): string {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
return 'one2one';
case Room::TYPE_GROUP:
return 'group';
Expand Down
1 change: 1 addition & 0 deletions lib/Collaboration/Resources/ConversationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function getType(): string {
protected function getRoomType(Room $room): string {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
return 'one2one';
case Room::TYPE_GROUP:
return 'group';
Expand Down
6 changes: 4 additions & 2 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,8 @@ public function deleteMessage(int $messageId): DataResponse {
$isOwnMessage = $isOwnMessage || ($message->getActorType() === Attendee::ACTOR_BRIDGED && $attendee->getActorId() === MatterbridgeManager::BRIDGE_BOT_USERID);
if (!$isOwnMessage
&& (!$this->participant->hasModeratorPermissions(false)
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE)) {
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER)) {
// Actor is not a moderator or not the owner of the message
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
Expand Down Expand Up @@ -702,7 +703,8 @@ public function deleteMessage(int $messageId): DataResponse {
public function clearHistory(): DataResponse {
$attendee = $this->participant->getAttendee();
if (!$this->participant->hasModeratorPermissions(false)
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE) {
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
// Actor is not a moderator or not the owner of the message
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Controller/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function __construct(string $appName,
* @return DataResponse
*/
public function createPoll(string $question, array $options, int $resultMode, int $maxVotes): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand Down
17 changes: 10 additions & 7 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ protected function formatRoomV4(Room $room, ?Participant $currentParticipant, ?a
if ($roomData['notificationLevel'] === Participant::NOTIFY_DEFAULT) {
if ($currentParticipant->isGuest()) {
$roomData['notificationLevel'] = Participant::NOTIFY_NEVER;
} elseif ($room->getType() === Room::TYPE_ONE_TO_ONE) {
} elseif ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$roomData['notificationLevel'] = Participant::NOTIFY_ALWAYS;
} else {
$adminSetting = (int) $this->config->getAppValue('spreed', 'default_group_notification', (string) Participant::NOTIFY_DEFAULT);
Expand Down Expand Up @@ -574,6 +574,7 @@ protected function formatRoomV4(Room $room, ?Participant $currentParticipant, ?a
$roomData['lastReadMessage'] = $lastReadMessage;

$roomData['canDeleteConversation'] = $room->getType() !== Room::TYPE_ONE_TO_ONE
&& $room->getType() !== Room::TYPE_ONE_TO_ONE_FORMER
&& $currentParticipant->hasModeratorPermissions(false);
$roomData['canLeaveConversation'] = true;
$roomData['canEnableSIP'] =
Expand Down Expand Up @@ -920,7 +921,7 @@ public function setNotificationCalls(int $level): DataResponse {
* @return DataResponse
*/
public function renameRoom(string $roomName): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand All @@ -942,7 +943,7 @@ public function renameRoom(string $roomName): DataResponse {
* @return DataResponse
*/
public function setDescription(string $description): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand All @@ -962,7 +963,7 @@ public function setDescription(string $description): DataResponse {
* @return DataResponse
*/
public function deleteRoom(): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand Down Expand Up @@ -1118,7 +1119,9 @@ public function getParticipants(bool $includeStatus = false): DataResponse {
* @return DataResponse
*/
public function addParticipantToRoom(string $newParticipant, string $source = 'users'): DataResponse {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getObjectType() === 'share:password') {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER
|| $this->room->getObjectType() === 'share:password') {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand Down Expand Up @@ -1269,7 +1272,7 @@ public function removeSelfFromRoom(): DataResponse {
}

protected function removeSelfFromRoomLogic(Room $room, Participant $participant): DataResponse {
if ($room->getType() !== Room::TYPE_ONE_TO_ONE) {
if ($room->getType() !== Room::TYPE_ONE_TO_ONE && $room->getType() !== Room::TYPE_ONE_TO_ONE_FORMER) {
if ($participant->hasModeratorPermissions(false)
&& $this->participantService->getNumberOfUsers($room) > 1
&& $this->participantService->getNumberOfModerators($room) === 1) {
Expand Down Expand Up @@ -1318,7 +1321,7 @@ public function removeAttendeeFromRoom(int $attendeeId): DataResponse {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}

if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

Expand Down
6 changes: 5 additions & 1 deletion lib/Dashboard/TalkWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$attendee = $participant->getAttendee();
return $room->getCallFlag() !== Participant::FLAG_DISCONNECTED
|| $attendee->getLastMentionMessage() > $attendee->getLastReadMessage()
|| ($room->getType() === Room::TYPE_ONE_TO_ONE && $room->getLastMessage() && $room->getLastMessage()->getId() > $attendee->getLastReadMessage());
|| (
($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER)
&& $room->getLastMessage()
&& $room->getLastMessage()->getId() > $attendee->getLastReadMessage()
);
});

uasort($rooms, [$this, 'sortRooms']);
Expand Down
5 changes: 3 additions & 2 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,13 @@ public function removeUserFromAllRooms(IUser $user): void {

$leftRooms = $this->getLeftOneToOneRoomsForUser($user->getUID());
foreach ($leftRooms as $room) {
// We are changing the room type and name so a potential follow up
// We are changing the room type and name so a potential follow-up
// user with the same user-id can not reopen the one-to-one conversation.
/** @var RoomService $roomService */
$roomService = Server::get(RoomService::class);
$roomService->setType($room, Room::TYPE_GROUP, true);
$roomService->setType($room, Room::TYPE_ONE_TO_ONE_FORMER, true);
$roomService->setName($room, $user->getDisplayName(), '');
$roomService->setReadOnly($room, Room::READ_ONLY);
}
}

Expand Down
15 changes: 8 additions & 7 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
'id' => $message->getComment()->getId(),
'name' => $shortenMessage,
];
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = "{user}\n{message}";
} elseif ($richSubjectUser) {
$subject = $l->t('{user} in {call}') . "\n{message}";
Expand All @@ -518,7 +518,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
}
}
} elseif ($notification->getSubject() === 'chat') {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} sent you a private message');
} elseif ($richSubjectUser) {
$subject = $l->t('{user} sent a message in conversation {call}');
Expand All @@ -533,7 +533,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
}
}
} elseif ($notification->getSubject() === 'reply') {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} replied to your private message');
} elseif ($richSubjectUser) {
$subject = $l->t('{user} replied to your message in conversation {call}');
Expand All @@ -554,7 +554,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
'name' => $subjectParameters['reaction'],
];

if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} reacted with {reaction} to your private message');
} elseif ($richSubjectUser) {
$subject = $l->t('{user} reacted with {reaction} to your message in conversation {call}');
Expand All @@ -568,7 +568,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
$subject = $l->t('A guest reacted with {reaction} to your message in conversation {call}');
}
}
} elseif ($room->getType() === Room::TYPE_ONE_TO_ONE) {
} elseif ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} mentioned you in a private conversation');
} elseif ($richSubjectUser) {
$subject = $l->t('{user} mentioned you in conversation {call}');
Expand Down Expand Up @@ -628,6 +628,7 @@ protected function getGuestParameter(Room $room, string $actorId): array {
protected function getRoomType(Room $room): string {
switch ($room->getType()) {
case Room::TYPE_ONE_TO_ONE:
case Room::TYPE_ONE_TO_ONE_FORMER:
return 'one2one';
case Room::TYPE_GROUP:
return 'group';
Expand Down Expand Up @@ -660,7 +661,7 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
}

$roomName = $room->getDisplayName($notification->getUser());
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} invited you to a private conversation');
if ($this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
Expand Down Expand Up @@ -731,7 +732,7 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
}

$roomName = $room->getDisplayName($notification->getUser());
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$parameters = $notification->getSubjectParameters();
$calleeId = $parameters['callee'];
$userDisplayName = $this->userManager->getDisplayName($calleeId);
Expand Down
1 change: 1 addition & 0 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Room {
public const TYPE_GROUP = 2;
public const TYPE_PUBLIC = 3;
public const TYPE_CHANGELOG = 4;
public const TYPE_ONE_TO_ONE_FORMER = 5;

public const RECORDING_NONE = 0;
public const RECORDING_VIDEO = 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/Search/ConversationSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
continue;
}

if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$otherUserId = str_replace(
json_encode($user->getUID()),
'',
Expand Down
2 changes: 1 addition & 1 deletion lib/Search/MessageSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment
}

$subline = $this->getSublineTemplate();
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subline = '{user}';
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Service/AvatarService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
}

public function setAvatarFromRequest(Room $room, ?array $file): void {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
throw new InvalidArgumentException($this->l->t('One to one rooms always need to show the other users avatar'));
}

Expand Down Expand Up @@ -97,7 +97,7 @@ public function setAvatarFromRequest(Room $room, ?array $file): void {
}

public function setAvatar(Room $room, \OC_Image $image): void {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
throw new InvalidArgumentException($this->l->t('One to one rooms always need to show the other users avatar'));
}
$image->fixOrientation();
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getAvatar(Room $room, ?IUser $user, bool $darkTheme = false): IS
}
// Fallback
if (!isset($file)) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$users = json_decode($room->getName(), true);
foreach ($users as $participantId) {
if ($user instanceof IUser && $participantId !== $user->getUID()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function updateParticipantType(Room $room, Participant $participant, int
* @throws ForbiddenException
*/
public function updatePermissions(Room $room, Participant $participant, string $method, int $newPermissions): bool {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return false;
}

Expand Down
19 changes: 15 additions & 4 deletions lib/Service/RoomService.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function prepareConversationName(string $objectName): string {
}

public function setPermissions(Room $room, string $level, string $method, int $permissions, bool $resetCustomPermissions): bool {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return false;
}

Expand Down Expand Up @@ -347,7 +347,7 @@ public function setLobby(Room $room, int $newState, ?\DateTime $dateTime, bool $
}

public function setAvatar(Room $room, string $avatar): bool {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return false;
}

Expand Down Expand Up @@ -412,7 +412,15 @@ public function setType(Room $room, int $newType, bool $allowSwitchingOneToOne =
return false;
}

if (!in_array($newType, [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
if ($room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
return false;
}

if (!in_array($newType, [Room::TYPE_GROUP, Room::TYPE_PUBLIC, Room::TYPE_ONE_TO_ONE_FORMER], true)) {
return false;
}

if ($newType === Room::TYPE_ONE_TO_ONE_FORMER && $room->getType() !== Room::TYPE_ONE_TO_ONE) {
return false;
}

Expand Down Expand Up @@ -466,7 +474,10 @@ public function setReadOnly(Room $room, int $newState): bool {
}

if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC, Room::TYPE_CHANGELOG], true)) {
return false;
if ($newState !== Room::READ_ONLY || $room->getType() !== Room::TYPE_ONE_TO_ONE_FORMER) {
// Allowed for the automated conversation of one-to-one chats to read only former
return false;
}
}

if (!in_array($newState, [Room::READ_ONLY, Room::READ_WRITE], true)) {
Expand Down
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export default {
*/
isOneToOne() {
return this.currentConversation?.type === CONVERSATION.TYPE.ONE_TO_ONE
|| this.currentConversation?.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER
},

disableKeyboardShortcuts() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/ConversationIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export default {
return 'icon-mail'
} else if (this.item.type === CONVERSATION.TYPE.CHANGELOG) {
return 'icon-changelog'
} else if (this.item.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER) {
return 'icon-user'
} else if (this.item.type === CONVERSATION.TYPE.GROUP) {
return 'icon-contacts'
} else if (this.item.type === CONVERSATION.TYPE.PUBLIC) {
Expand Down Expand Up @@ -169,6 +171,7 @@ $icon-size: 44px;

&.icon-public,
&.icon-contacts,
&.icon-user,
&.icon-password,
&.icon-file,
&.icon-mail {
Expand Down
Loading