Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(federation): Fix retrying to send OCM notifications with a proper scaling background job #11780

Merged
merged 5 commits into from
Mar 13, 2024
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
3 changes: 2 additions & 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>19.0.0-beta.1</version>
<version>19.0.0-beta.1.1</version>
<licence>agpl</licence>

<author>Daniel Calviño Sánchez</author>
Expand Down Expand Up @@ -65,6 +65,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
<job>OCA\Talk\BackgroundJob\Reminder</job>
<job>OCA\Talk\BackgroundJob\RemoveEmptyRooms</job>
<job>OCA\Talk\BackgroundJob\ResetAssignedSignalingServer</job>
<job>OCA\Talk\BackgroundJob\RetryNotificationsJob</job>
</background-jobs>

<repair-steps>
Expand Down
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
use OCA\Talk\Events\SystemMessagesMultipleSentEvent;
use OCA\Talk\Events\UserJoinedRoomEvent;
use OCA\Talk\Federation\CloudFederationProviderTalk;
use OCA\Talk\Federation\Proxy\TalkV1\Notifier\CancelRetryOCMListener as TalkV1CancelRetryOCMListener;
use OCA\Talk\Federation\Proxy\TalkV1\Notifier\MessageSentListener as TalkV1MessageSentListener;
use OCA\Talk\Federation\Proxy\TalkV1\Notifier\RoomModifiedListener as TalkV1RoomModifiedListener;
use OCA\Talk\Files\Listener as FilesListener;
Expand Down Expand Up @@ -284,6 +285,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(ChatMessageSentEvent::class, TalkV1MessageSentListener::class);
$context->registerEventListener(SystemMessageSentEvent::class, TalkV1MessageSentListener::class);
$context->registerEventListener(SystemMessagesMultipleSentEvent::class, TalkV1MessageSentListener::class);
$context->registerEventListener(AttendeeRemovedEvent::class, TalkV1CancelRetryOCMListener::class);

// Signaling listeners (External)
$context->registerEventListener(AttendeesAddedEvent::class, SignalingListener::class);
Expand Down
100 changes: 0 additions & 100 deletions lib/BackgroundJob/RetryJob.php

This file was deleted.

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

declare(strict_types=1);

/**
* @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @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\Federation\BackendNotifier;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;

/**
* Retry to send OCM notifications
*/
class RetryNotificationsJob extends TimedJob {
public function __construct(
private BackendNotifier $backendNotifier,
ITimeFactory $timeFactory,
) {
parent::__construct($timeFactory);

// Every time the jobs run
$this->setInterval(1);
}

protected function run($argument): void {
$this->backendNotifier->retrySendingFailedNotifications($this->time->getDateTime());
}
}
10 changes: 3 additions & 7 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Exceptions\UnauthorizedException;
use OCA\Talk\Federation\Authenticator;
use OCA\Talk\Federation\BackendNotifier;
use OCA\Talk\Federation\FederationManager;
use OCA\Talk\GuestManager;
use OCA\Talk\Manager;
use OCA\Talk\MatterbridgeManager;
Expand Down Expand Up @@ -126,7 +126,7 @@ public function __construct(
protected LoggerInterface $logger,
protected Authenticator $federationAuthenticator,
protected Capabilities $capabilities,
protected BackendNotifier $federationBackendNotifier,
protected FederationManager $federationManager,
) {
parent::__construct($appName, $request);
}
Expand Down Expand Up @@ -1263,11 +1263,7 @@ public function removeSelfFromRoom(): DataResponse {
*/
protected function removeSelfFromRoomLogic(Room $room, Participant $participant): DataResponse {
if ($room->getRemoteServer() !== '') {
$this->federationBackendNotifier->sendShareDeclined(
$room->getRemoteServer(),
(int) $participant->getAttendee()->getRemoteId(),
$participant->getAttendee()->getAccessToken(),
);
$this->federationManager->rejectByRemoveSelf($room, $this->userId);
}

if ($room->getType() !== Room::TYPE_ONE_TO_ONE && $room->getType() !== Room::TYPE_ONE_TO_ONE_FORMER) {
Expand Down
Loading
Loading