Skip to content
Closed
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 appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
<author>Jan-Christoph Borchardt</author>
<author>Jennifer Piperek</author>
<author>Joas Schilling</author>
<author>Mario Danic</author>
<author>Marco Ambrosini</author>

<namespace>Talk</namespace>
Expand Down
3 changes: 3 additions & 0 deletions css/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
.icon-changelog {
background-image: url('../img/changelog.svg');
}
.icon-notes {
background-image: url('../img/notes.svg');
}

// "forced-white" needs to be included in the class name as the UserBubble
// does not accept several classes.
Expand Down
1 change: 1 addition & 0 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ title: Capabilities
* `force-mute` - "forceMute" signaling messages can be sent to mute other participants.
* `conversation-v2` - The conversations API v2 is less load heavy and should be used by clients when available. Check the difference in the [Conversation API documentation](conversation.md).
* `chat-reference-id` - an optional referenceId can be sent with a chat message to be able to identify it in parallel get requests to earlier fade out a temporary message
* `notes` - The notes conversation type is available and users can toggle on and off the conversation
3 changes: 2 additions & 1 deletion docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Constants
* `2` group
* `3` public
* `4` changelog
* `5` notes

## Read-only states
* `0` read-write
Expand Down Expand Up @@ -35,7 +36,7 @@ title: Constants
## Actor types of chat messages
* `guests` - guest users
* `users` - logged-in users
* `bots` - used by commands (actor-id is the used `/command`) and the changelog conversation (actor-id is `changelog`)
* `bots` - used by commands (actor-id is the used `/command`), the changelog conversation (actor-id is `changelog`) and the notes conversation (actor-id is `notes`)

## Webinary lobby states
* `0` no lobby
Expand Down
2 changes: 1 addition & 1 deletion docs/conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

field | type | Description
------|------|------------
`roomType` | int |
`roomType` | int | See [list of conversation types](constants.md#Conversation-types), but changelog and notes are not supported on this endpoint
`invite` | string | user id (`roomType = 1`), group id (`roomType = 2` - optional), circle id (`roomType = 2`, `source = 'circles'`], only available with `circles-support` capability))
`source` | string | The source for the invite, only supported on `roomType = 2` for `groups` and `circles` (only available with `circles-support` capability)
`roomName` | string | conversation name (Not available for `roomType = 1`)
Expand Down
60 changes: 60 additions & 0 deletions img/notes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use OCA\Talk\Activity\Listener as ActivityListener;
use OCA\Talk\Capabilities;
use OCA\Talk\Chat\Changelog\Listener as ChangelogListener;
use OCA\Talk\Chat\SpecialRoom\Listener as SpecialRoomListener;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\Command\Listener as CommandListener;
use OCA\Talk\Chat\Parser\Listener as ParserListener;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function register(): void {
CommandListener::register($dispatcher);
CollaboratorsListener::register($dispatcher);
ResourceListener::register($dispatcher);
ChangelogListener::register($dispatcher);
SpecialRoomListener::register($dispatcher);
ShareListener::register($dispatcher);
Operation::register($dispatcher);

Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/RemoveEmptyRooms.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function run($argument): void {
}

public function callback(Room $room): void {
if ($room->getType() === Room::CHANGELOG_CONVERSATION) {
if ($room->getType() === Room::CHANGELOG_CONVERSATION || $room->getType() === Room::NOTES_CONVERSATION) {
return;
}

Expand Down
47 changes: 22 additions & 25 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@

class Capabilities implements IPublicCapability {

/** @var IConfig */
protected $serverConfig;
/** @var Config */
protected $talkConfig;
/** @var IUserSession */
protected $userSession;

public function __construct(IConfig $serverConfig,
Config $talkConfig,
public function __construct(Config $talkConfig,
IUserSession $userSession) {
$this->serverConfig = $serverConfig;
$this->talkConfig = $talkConfig;
$this->userSession = $userSession;
}
Expand All @@ -53,23 +49,7 @@ public function getCapabilities(): array {
return [];
}

$maxChatLength = 1000;
if (version_compare($this->serverConfig->getSystemValueString('version', '0.0.0'), '16.0.2', '>=')) {
$maxChatLength = ChatManager::MAX_CHAT_LENGTH;
}

$attachments = [
'allowed' => $user instanceof IUser,
];
if ($user instanceof IUser) {
$attachments['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID());
}

$conversations = [
'can-create' => $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user),
];

return [
$capabilities = [
'spreed' => [
'features' => [
'audio',
Expand Down Expand Up @@ -99,13 +79,30 @@ public function getCapabilities(): array {
'chat-reference-id',
],
'config' => [
'attachments' => $attachments,
'attachments' => [
'allowed' => false,
],
'chat' => [
'max-length' => $maxChatLength,
'max-length' => ChatManager::MAX_CHAT_LENGTH,
],
'conversations' => [
'can-create' => false
],
'conversations' => $conversations,
],
],
];

if ($user instanceof IUser) {
$capabilities['spreed']['features'][] = 'notes';

$capabilities['spreed']['config']['attachments'] = [
'allowed' => true,
'folder' => $this->talkConfig->getAttachmentFolder($user->getUID()),
];

$capabilities['spreed']['config']['conversations']['can-create'] = !$this->talkConfig->isNotAllowedToCreateConversations($user);
}

return $capabilities;
}
}
4 changes: 2 additions & 2 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public function addSystemMessage(Room $chat, string $actorType, string $actorId,
* @param string $message
* @return IComment
*/
public function addChangelogMessage(Room $chat, string $message): IComment {
$comment = $this->commentsManager->create('guests', 'changelog', 'chat', (string) $chat->getId());
public function addSpecialMessage(Room $chat, string $type, string $message): IComment {
$comment = $this->commentsManager->create('guests', $type, 'chat', (string) $chat->getId());

$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($this->timeFactory->getDateTime());
Expand Down
14 changes: 12 additions & 2 deletions lib/Chat/Parser/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ public static function register(IEventDispatcher $dispatcher): void {
}

/** @var Changelog $parser */
$parser = \OC::$server->query(Changelog::class);
$changelogParser = \OC::$server->query(Changelog::class);
try {
$parser->parseMessage($message);
$changelogParser->parseMessage($message);
$event->stopPropagation();
} catch (\OutOfBoundsException $e) {
// Unknown message, ignore
}

/** @var Notes $parser */
$notesParser = \OC::$server->query(Notes::class);
try {
$notesParser->parseMessage($message);
$event->stopPropagation();
} catch (\OutOfBoundsException $e) {
// Unknown message, ignore
}

}, -75);

$dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function(ChatMessageEvent $event) {
Expand Down
43 changes: 43 additions & 0 deletions lib/Chat/Parser/Notes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Mario Danic <[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\Chat\Parser;

use OCA\Talk\Model\Message;

class Notes {

/**
* @param Message $chatMessage
* @throws \OutOfBoundsException
*/
public function parseMessage(Message $chatMessage): void {

if ($chatMessage->getActorType() !== 'guests' ||
$chatMessage->getActorId() !== 'notes') {
throw new \OutOfBoundsException('Not notes');
}

$l = $chatMessage->getL10n();
$chatMessage->setActor('bots', 'notes', $l->t('My notes'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

namespace OCA\Talk\Chat\Changelog;
namespace OCA\Talk\Chat\SpecialRoom;

use OCA\Talk\Controller\RoomController;
use OCA\Talk\Events\UserEvent;
Expand All @@ -46,6 +46,8 @@ public function __construct(Manager $manager) {
}

public function preGetRooms(string $userId): void {
$this->manager->createNotesIfNeeded($userId);

if (!$this->manager->userHasNewChangelog($userId)) {
return;
}
Expand Down
Loading