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
7 changes: 7 additions & 0 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
Expand Down Expand Up @@ -71,6 +72,8 @@ class ChatManager {
private $notificationManager;
/** @var ParticipantService */
private $participantService;
/** @var RoomShareProvider */
private $shareProvider;
/** @var Notifier */
private $notifier;
/** @var ITimeFactory */
Expand All @@ -85,13 +88,15 @@ public function __construct(CommentsManager $commentsManager,
IDBConnection $connection,
INotificationManager $notificationManager,
ParticipantService $participantService,
RoomShareProvider $shareProvider,
Notifier $notifier,
ICacheFactory $cacheFactory,
ITimeFactory $timeFactory) {
$this->commentsManager = $commentsManager;
$this->dispatcher = $dispatcher;
$this->connection = $connection;
$this->notificationManager = $notificationManager;
$this->shareProvider = $shareProvider;
$this->participantService = $participantService;
$this->notifier = $notifier;
$this->cache = $cacheFactory->createDistributed('talk/lastmsgid');
Expand Down Expand Up @@ -483,6 +488,8 @@ protected function waitForNewMessagesWithDatabase(Room $chat, int $offset, int $
public function deleteMessages(Room $chat): void {
$this->commentsManager->deleteCommentsAtObject('chat', (string) $chat->getId());

$this->shareProvider->deleteInRoom($chat->getToken());

$this->notifier->removePendingNotificationsForRoom($chat);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public function deleteMessage(int $messageId): DataResponse {

$bridge = $this->matterbridgeManager->getBridgeOfRoom($this->room);

$response = new DataResponse($data, $bridge['enabled'] ? Http::STATUS_ACCEPTED: Http::STATUS_OK);
$response = new DataResponse($data, $bridge['enabled'] ? Http::STATUS_ACCEPTED : Http::STATUS_OK);
if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) {
$response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/features/chat/delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Feature: chat/reply
Then user "participant2" received a system messages in room "group room" to delete "Message 1"

Scenario: Can only delete own messages in one-to-one
Given user "participant1" creates room "room1"
Given user "participant1" creates room "room1" (v4)
| roomType | 1 |
| invite | participant2 |
And user "participant1" sends message "Message 1" to room "room1" with 201
Expand Down
5 changes: 5 additions & 0 deletions tests/php/Chat/ChatManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
Expand All @@ -51,6 +52,8 @@ class ChatManagerTest extends TestCase {
protected $dispatcher;
/** @var INotificationManager|MockObject */
protected $notificationManager;
/** @var RoomShareProvider|MockObject */
protected $shareProvider;
/** @var ParticipantService|MockObject */
protected $participantService;
/** @var Notifier|MockObject */
Expand All @@ -66,6 +69,7 @@ public function setUp(): void {
$this->commentsManager = $this->createMock(CommentsManager::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->notificationManager = $this->createMock(INotificationManager::class);
$this->shareProvider = $this->createMock(RoomShareProvider::class);
$this->participantService = $this->createMock(ParticipantService::class);
$this->notifier = $this->createMock(Notifier::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
Expand All @@ -77,6 +81,7 @@ public function setUp(): void {
\OC::$server->getDatabaseConnection(),
$this->notificationManager,
$this->participantService,
$this->shareProvider,
$this->notifier,
$cacheFactory,
$this->timeFactory
Expand Down