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
11 changes: 6 additions & 5 deletions 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>17.1.0-dev.1</version>
<version>17.1.0-dev.2</version>
<licence>agpl</licence>

<author>Daniel Calviño Sánchez</author>
Expand Down Expand Up @@ -56,13 +56,14 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
</dependencies>

<background-jobs>
<job>OCA\Talk\BackgroundJob\ExpireSignalingMessage</job>
<job>OCA\Talk\BackgroundJob\RemoveEmptyRooms</job>
<job>OCA\Talk\BackgroundJob\ResetAssignedSignalingServer</job>
<job>OCA\Talk\BackgroundJob\CheckReferenceIdColumn</job>
<job>OCA\Talk\BackgroundJob\CheckHostedSignalingServer</job>
<job>OCA\Talk\BackgroundJob\CheckMatterbridges</job>
<job>OCA\Talk\BackgroundJob\CheckReferenceIdColumn</job>
<job>OCA\Talk\BackgroundJob\ExpireChatMessages</job>
<job>OCA\Talk\BackgroundJob\ExpireSignalingMessage</job>
<job>OCA\Talk\BackgroundJob\Reminder</job>
<job>OCA\Talk\BackgroundJob\RemoveEmptyRooms</job>
<job>OCA\Talk\BackgroundJob\ResetAssignedSignalingServer</job>
</background-jobs>

<repair-steps>
Expand Down
10 changes: 6 additions & 4 deletions appinfo/routes/routesChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
['name' => 'Chat#deleteMessage', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}', 'verb' => 'DELETE', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::getMessageContext() */
['name' => 'Chat#getMessageContext', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/context', 'verb' => 'GET', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::remindLater() */
['name' => 'Chat#remindLater', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/reminder', 'verb' => 'POST', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::dismissReminder() */
['name' => 'Chat#dismissReminder', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/reminder', 'verb' => 'DELETE', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::setReminder() */
['name' => 'Chat#setReminder', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/reminder', 'verb' => 'POST', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::getReminder() */
['name' => 'Chat#getReminder', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/reminder', 'verb' => 'GET', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::deleteReminder() */
['name' => 'Chat#deleteReminder', 'url' => '/api/{apiVersion}/chat/{token}/{messageId}/reminder', 'verb' => 'DELETE', 'requirements' => $requirementsWithMessageId],
/** @see \OCA\Talk\Controller\ChatController::setReadMarker() */
['name' => 'Chat#setReadMarker', 'url' => '/api/{apiVersion}/chat/{token}/read', 'verb' => 'POST', 'requirements' => $requirements],
/** @see \OCA\Talk\Controller\ChatController::markUnread() */
Expand Down
71 changes: 52 additions & 19 deletions docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`: since Nextcloud 13
| `limit` | int | Number of chat messages to receive into each direction (50 by default, 100 at most) |

* Response:
- Status code:
+ `200 OK`
+ `404 Not Found` When the conversation could not be found for the participant
+ `412 Precondition Failed` When the lobby is active and the user is not a moderator
- Status code:
+ `200 OK`
+ `404 Not Found` When the conversation could not be found for the participant
+ `412 Precondition Failed` When the lobby is active and the user is not a moderator

- Header:
- Header:

| field | type | Description |
|---------------------------|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -300,7 +300,7 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
The parent message is the object of the deleted message with the replaced text "Message deleted by you".
This message should **NOT** be displayed to the user but instead be used to remove the original message from any cache/storage of the device.

## Remind me later
## Set reminder for chat message

* Required capability: `remind-me-later`
* Method: `POST`
Expand All @@ -312,26 +312,59 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
| `timestamp` | int | Timestamp when the notification should be triggered. Preferable options for 6pm today, 8am tomorrow, Saturday 8am and Monday 8am should be offered. |

* Response:
- Status code:
+ `201 Created`
+ `401 Unauthorized` when the user is not logged in
+ `404 Not Found` When the message could not be found in the room
+ `404 Not Found` When the room could not be found for the participant,
or the participant is a guest.
- Status code:
+ `201 Created`
+ `401 Unauthorized` when the user is not logged in
+ `404 Not Found` When the message could not be found in the room
+ `404 Not Found` When the room could not be found for the participant,
or the participant is a guest.
- Data:
Array with the details of the reminder

| field | type | Description |
|-------------|--------|----------------------------------------------|
| `userId` | string | The user id of the user |
| `token` | string | The token of the conversation of the message |
| `messageId` | int | The message id this reminder is for |
| `timestamp` | int | The timestamp when the reminder is triggered |

## Delete reminder notification
## Get reminder for chat message

* Required capability: `remind-me-later`
* Method: `GET`
* Endpoint: `/chat/{token}/{messageId}/reminder`

* Response:
- Status code:
+ `200 OK`
+ `401 Unauthorized` when the user is not logged in
+ `404 Not Found` When the message could not be found in the room
+ `404 Not Found` When the room could not be found for the participant,
or the participant is a guest.
+ `404 Not Found` When the user has no reminder for this message
- Data:
Array with the details of the reminder

| field | type | Description |
|-------------|--------|----------------------------------------------|
| `userId` | string | The user id of the user |
| `token` | string | The token of the conversation of the message |
| `messageId` | int | The message id this reminder is for |
| `timestamp` | int | The timestamp when the reminder is triggered |

## Delete reminder for chat message

* Required capability: `remind-me-later`
* Method: `DELETE`
* Endpoint: `/chat/{token}/{messageId}/reminder`

* Response:
- Status code:
+ `200 OK`
+ `401 Unauthorized` when the user is not logged in
+ `404 Not Found` When the message could not be found in the room
+ `404 Not Found` When the room could not be found for the participant,
or the participant is a guest.
- Status code:
+ `200 OK`
+ `401 Unauthorized` when the user is not logged in
+ `404 Not Found` When the message could not be found in the room
+ `404 Not Found` When the room could not be found for the participant,
or the participant is a guest.

## Mark chat as read

Expand Down
97 changes: 0 additions & 97 deletions lib/BackgroundJob/ChatMessageReminder.php

This file was deleted.

49 changes: 49 additions & 0 deletions lib/BackgroundJob/Reminder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

/*
* @copyright Copyright (c) 2023 Joas Schilling <[email protected]>
*
* @author Joas Schilling <[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\BackgroundJob;

use OCA\Talk\Service\ReminderService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;

class Reminder extends TimedJob {
public function __construct(
ITimeFactory $time,
protected ReminderService $reminderService,
) {
parent::__construct($time);
// Every minute
$this->setInterval(60);
}

/**
* @inheritDoc
*/
protected function run($argument): void {
$this->reminderService->executeReminders($this->time->getDateTime());
}
}
37 changes: 10 additions & 27 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
use DateInterval;
use OC\Memcache\ArrayCache;
use OC\Memcache\NullCache;
use OCA\Talk\AppInfo\Application;
use OCA\Talk\BackgroundJob\ChatMessageReminder;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\ChatParticipantEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
Expand All @@ -43,10 +41,8 @@
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICache;
Expand Down Expand Up @@ -117,7 +113,6 @@ public function __construct(
ITimeFactory $timeFactory,
AttachmentService $attachmentService,
IReferenceManager $referenceManager,
protected IJobList $jobList,
) {
$this->commentsManager = $commentsManager;
$this->dispatcher = $dispatcher;
Expand Down Expand Up @@ -739,13 +734,13 @@ public function deleteMessages(Room $chat): void {
}

/**
* Search for comments with a given content
* Get messages for the given chat by ID
*
* @param Room $chat
* @param int[] $commentIds
* @return IComment[]
*/
public function getMessagesById(Room $chat, array $commentIds): array {
public function getMessagesForRoomById(Room $chat, array $commentIds): array {
$comments = $this->commentsManager->getCommentsById(array_map('strval', $commentIds));

$comments = array_filter($comments, static function (IComment $comment) use ($chat) {
Expand All @@ -756,26 +751,14 @@ public function getMessagesById(Room $chat, array $commentIds): array {
return $comments;
}

public function queueRemindLaterBackgroundJob(Room $chat, IComment $comment, Attendee $attendee, int $timestamp): void {
$this->jobList->add(ChatMessageReminder::class, [
'execute-after' => $timestamp,
'token' => $chat->getToken(),
'message_id' => $comment->getId(),
'message_actor_type' => $comment->getActorType(),
'message_actor_id' => $comment->getActorId(),
'user' => $attendee->getActorId(),
]);
}

public function dismissReminderNotification(Room $chat, IComment $comment, Attendee $attendee): void {
$notification = $this->notificationManager->createNotification();
$notification->setApp(Application::APP_ID)
->setUser($attendee->getActorId())
->setObject('reminder', $chat->getToken())
->setMessage('reminder', [
'commentId' => $comment->getId(),
]);
$this->notificationManager->markProcessed($notification);
/**
* Get messages by ID
*
* @param int[] $commentIds
* @return IComment[] Key is the message id
*/
public function getMessagesById(array $commentIds): array {
return $this->commentsManager->getCommentsById(array_map('strval', $commentIds));
}

/**
Expand Down
Loading