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
5 changes: 5 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace OCA\Talk\AppInfo;

use OCA\Talk\Collaboration\Reference\ReferenceInvalidationListener;
use OCA\Talk\Collaboration\Reference\TalkReferenceProvider;
use OCP\Util;
use OCA\Circles\Events\AddingCircleMemberEvent;
use OCA\Circles\Events\CircleDestroyedEvent;
Expand Down Expand Up @@ -145,6 +147,8 @@ public function register(IRegistrationContext $context): void {

$context->registerProfileLinkAction(TalkAction::class);

$context->registerReferenceProvider(TalkReferenceProvider::class);

$context->registerTalkBackend(TalkBackend::class);
}

Expand Down Expand Up @@ -172,6 +176,7 @@ public function boot(IBootContext $context): void {
CommandListener::register($dispatcher);
CollaboratorsListener::register($dispatcher);
ResourceListener::register($dispatcher);
ReferenceInvalidationListener::register($dispatcher);
// Register only when Talk Updates are not disabled
if ($server->getConfig()->getAppValue('spreed', 'changelog', 'yes') === 'yes') {
ChangelogListener::register($dispatcher);
Expand Down
11 changes: 7 additions & 4 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCA\Talk\Service\PollService;
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
Expand Down Expand Up @@ -86,7 +87,6 @@ class ChatManager {
private IDBConnection $connection;
private INotificationManager $notificationManager;
private IManager $shareManager;
private Manager $manager;
private RoomShareProvider $shareProvider;
private ParticipantService $participantService;
private PollService $pollService;
Expand All @@ -95,26 +95,26 @@ class ChatManager {
protected ICache $cache;
protected ICache $unreadCountCache;
protected AttachmentService $attachmentService;
protected IReferenceManager $referenceManager;

public function __construct(CommentsManager $commentsManager,
IEventDispatcher $dispatcher,
IDBConnection $connection,
INotificationManager $notificationManager,
IManager $shareManager,
Manager $manager,
RoomShareProvider $shareProvider,
ParticipantService $participantService,
PollService $pollService,
Notifier $notifier,
ICacheFactory $cacheFactory,
ITimeFactory $timeFactory,
AttachmentService $attachmentService) {
AttachmentService $attachmentService,
IReferenceManager $referenceManager) {
$this->commentsManager = $commentsManager;
$this->dispatcher = $dispatcher;
$this->connection = $connection;
$this->notificationManager = $notificationManager;
$this->shareManager = $shareManager;
$this->manager = $manager;
$this->shareProvider = $shareProvider;
$this->participantService = $participantService;
$this->pollService = $pollService;
Expand All @@ -123,6 +123,7 @@ public function __construct(CommentsManager $commentsManager,
$this->unreadCountCache = $cacheFactory->createDistributed('talk/unreadcount');
$this->timeFactory = $timeFactory;
$this->attachmentService = $attachmentService;
$this->referenceManager = $referenceManager;
}

/**
Expand Down Expand Up @@ -378,6 +379,8 @@ public function deleteMessage(Room $chat, IComment $comment, Participant $partic

$this->attachmentService->deleteAttachmentByMessageId((int) $comment->getId());

$this->referenceManager->invalidateCache($chat->getToken());

return $this->addSystemMessage(
$chat,
$participant->getAttendee()->getActorType(),
Expand Down
52 changes: 52 additions & 0 deletions lib/Collaboration/Reference/ReferenceInvalidationListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 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\Collaboration\Reference;

use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Room;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Server;

class ReferenceInvalidationListener {
public static function register(IEventDispatcher $dispatcher): void {
$listener = static function (RoomEvent $event): void {
$room = $event->getRoom();
$referenceManager = Server::get(IReferenceManager::class);

$referenceManager->invalidateCache($room->getToken());
};

$dispatcher->addListener(Room::EVENT_AFTER_ROOM_DELETE, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_DESCRIPTION_SET, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_LISTABLE_SET, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_LOBBY_STATE_SET, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_NAME_SET, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, $listener);
$dispatcher->addListener(Room::EVENT_AFTER_SET_MESSAGE_EXPIRATION, $listener);
}
}
Loading