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
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m

]]></description>

<version>11.0.0-dev.7</version>
<version>11.0.0-dev.8</version>
<licence>agpl</licence>

<author>Daniel Calviño Sánchez</author>
Expand Down
9 changes: 9 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@
'token' => '^[a-z0-9]{4,30}$',
],
],
[
'name' => 'Room#setDescription',
'url' => '/api/{apiVersion}/room/{token}/description',
'verb' => 'PUT',
'requirements' => [
'apiVersion' => 'v3',
'token' => '^[a-z0-9]{4,30}$',
],
],
[
'name' => 'Room#setReadOnly',
'url' => '/api/{apiVersion}/room/{token}/read-only',
Expand Down
20 changes: 20 additions & 0 deletions docs/conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
`type` | int | * | See list of conversation types in the [constants list](constants.md#Conversation-types)
`name` | string | * | Name of the conversation (can also be empty)
`displayName` | string | * | `name` if non empty, otherwise it falls back to a list of participants
`description` | string | v3 | Description of the conversation (can also be empty)
`participantType` | int | * | Permissions level of the current user
`attendeeId` | int | v3 | Unique attendee id
`attendeePin` | string | v3 | Unique dial-in authentication code for this user, when the conversation has SIP enabled (see `sipEnabled` attribute)
Expand Down Expand Up @@ -132,6 +133,25 @@
+ `403 Forbidden` When the current user is not a moderator/owner
+ `404 Not Found` When the conversation could not be found for the participant

## Set description for a conversation

* Method: `PUT`
* API: v3
* Endpoint: `/room/{token}/description`
* Data:

field | type | Description
------|------|------------
`description` | string | New description for the conversation

* Response:
- Status code:
+ `200 OK`
+ `400 Bad Request` When the description is too long
+ `400 Bad Request` When the conversation is a one to one conversation
+ `403 Forbidden` When the current user is not a moderator/owner
+ `404 Not Found` When the conversation could not be found for the participant

## Allow guests in a conversation (public conversation)

* Method: `POST`
Expand Down
14 changes: 14 additions & 0 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ public function parseMessage(Message $chatMessage): void {
} elseif ($cliIsActor) {
$parsedMessage = $this->l->t('An administrator renamed the conversation from "%1$s" to "%2$s"', [$parameters['oldName'], $parameters['newName']]);
}
} elseif ($message === 'description_set') {
$parsedMessage = $this->l->t('{actor} set the description to "%1$s"', [$parameters['newDescription']]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not put the description into the system message.
It can be potentially long and also contain " and then look broken.

Whatsapp and others just write "{actor} updated the description" alike messages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can then use this for create, update and remove at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ma12-co checked other platforms and asked for the description to be shown in the message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be shown, given that:

  1. It's likely to be very important information for the conversation participants;
  2. It's s going to be relatively concise since we're capping the max length to 500 chars, so it's not going to be disruptive;

if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You set the description to "%1$s"', [$parameters['newDescription']]);
} elseif ($cliIsActor) {
$parsedMessage = $this->l->t('An administrator set the description to "%1$s"', [$parameters['newDescription']]);
}
} elseif ($message === 'description_removed') {
$parsedMessage = $this->l->t('{actor} removed the description');
if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You removed the description');
} elseif ($cliIsActor) {
$parsedMessage = $this->l->t('An administrator removed the description');
}
} elseif ($message === 'call_started') {
$parsedMessage = $this->l->t('{actor} started a call');
if ($currentUserIsActor) {
Expand Down
13 changes: 13 additions & 0 deletions lib/Chat/SystemMessage/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ public static function register(IEventDispatcher $dispatcher): void {
'oldName' => $event->getOldValue(),
]);
});
$dispatcher->addListener(Room::EVENT_AFTER_DESCRIPTION_SET, static function (ModifyRoomEvent $event) {
$room = $event->getRoom();
/** @var self $listener */
$listener = \OC::$server->get(self::class);

if ($event->getNewValue() !== '') {
$listener->sendSystemMessage($room, 'description_set', [
'newDescription' => $event->getNewValue(),
]);
} else {
$listener->sendSystemMessage($room, 'description_removed');
}
});
$dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, static function (ModifyRoomEvent $event) {
$room = $event->getRoom();
/** @var self $listener */
Expand Down
10 changes: 10 additions & 0 deletions lib/Command/Room/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ protected function configure(): void {
'name',
InputArgument::REQUIRED,
'The name of the room to create'
)->addOption(
'description',
null,
InputOption::VALUE_REQUIRED,
'The description of the room to create'
)->addOption(
'user',
null,
Expand Down Expand Up @@ -85,6 +90,7 @@ protected function configure(): void {

protected function execute(InputInterface $input, OutputInterface $output): int {
$name = $input->getArgument('name');
$description = $input->getOption('description');
$users = $input->getOption('user');
$groups = $input->getOption('group');
$public = $input->getOption('public');
Expand All @@ -105,6 +111,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

try {
if ($description !== null) {
$this->setRoomDescription($room, $description);
}

$this->setRoomReadOnly($room, $readonly);

if ($password !== null) {
Expand Down
14 changes: 14 additions & 0 deletions lib/Command/Room/TRoomCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ protected function validateRoomName(string $name): bool {
return (($name !== '') && !isset($name[255]));
}

/**
* @param Room $room
* @param string $description
*
* @throws InvalidArgumentException
*/
protected function setRoomDescription(Room $room, string $description): void {
try {
$room->setDescription($description);
} catch (\LengthException $e) {
throw new InvalidArgumentException('Invalid room description.');
}
}

/**
* @param Room $room
* @param bool $public
Expand Down
10 changes: 10 additions & 0 deletions lib/Command/Room/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ protected function configure(): void {
null,
InputOption::VALUE_REQUIRED,
'Sets a new name for the room'
)->addOption(
'description',
null,
InputOption::VALUE_REQUIRED,
'Sets a new description for the room'
)->addOption(
'public',
null,
Expand All @@ -77,6 +82,7 @@ protected function configure(): void {
protected function execute(InputInterface $input, OutputInterface $output): int {
$token = $input->getArgument('token');
$name = $input->getOption('name');
$description = $input->getOption('description');
$public = $input->getOption('public');
$readOnly = $input->getOption('readonly');
$password = $input->getOption('password');
Expand Down Expand Up @@ -109,6 +115,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->setRoomName($room, $name);
}

if ($description !== null) {
$this->setRoomDescription($room, $description);
}

if ($public !== null) {
$this->setRoomPublic($room, ($public === '1'));
}
Expand Down
23 changes: 23 additions & 0 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ protected function formatRoomV2andV3(Room $room, ?Participant $currentParticipan
'attendeeId' => 0,
'canEnableSIP' => false,
'attendeePin' => '',
'description' => '',
]);
}

Expand Down Expand Up @@ -616,6 +617,7 @@ protected function formatRoomV2andV3(Room $room, ?Participant $currentParticipan
'actorType' => $attendee->getActorType(),
'actorId' => $attendee->getActorId(),
'attendeeId' => $attendee->getId(),
'description' => $room->getDescription(),
]);
}

Expand Down Expand Up @@ -997,6 +999,27 @@ public function renameRoom(string $roomName): DataResponse {
return new DataResponse();
}

/**
* @PublicPage
* @RequireModeratorParticipant
*
* @param string $description
* @return DataResponse
*/
public function setDescription(string $description): DataResponse {
if ($this->room->getType() === Room::ONE_TO_ONE_CALL) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

try {
$this->room->setDescription($description);
} catch (\LengthException $exception) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

return new DataResponse();
}

/**
* @PublicPage
* @RequireModeratorParticipant
Expand Down
1 change: 1 addition & 0 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function createRoomObject(array $row): Room {
$assignedSignalingServer,
(string) $row['token'],
(string) $row['name'],
(string) $row['description'],
(string) $row['password'],
(int) $row['active_guests'],
$activeSince,
Expand Down
58 changes: 58 additions & 0 deletions lib/Migration/Version11000Date20201011082810.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Daniel Calviño Sánchez <[email protected]>
*
* @author Daniel Calviño Sánchez <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Talk\Migration;

use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version11000Date20201011082810 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$table = $schema->getTable('talk_rooms');
if (!$table->hasColumn('description')) {
$table->addColumn('description', Type::TEXT, [
'notnull' => false,
'default' => '',
]);

return $schema;
}

return null;
}
}
Loading