Skip to content

Commit

Permalink
Listen to potential defer/flush requests of the Talk app
Browse files Browse the repository at this point in the history
Talk app, good guys, they know what they are doing. Trust me.

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 8, 2020
1 parent b585d7e commit d54d5db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ public function markProcessed(INotification $notification): void {
$this->push->flushPayloads();
}
}

public function defer(): void {
$this->push->deferPayloads();
}

public function flush(): void {
$this->push->flushPayloads();
}
}
20 changes: 20 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
use OCA\Notifications\Capabilities;
use OCA\Notifications\Handler;
use OCA\Notifications\Notifier\AdminNotifications;
use OCA\Notifications\Push;
use OCP\AppFramework\IAppContainer;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Notification\IApp;
use OCP\Util;

class Application extends \OCP\AppFramework\App {
Expand All @@ -44,6 +47,7 @@ public function __construct() {

public function register(): void {
$this->registerNotificationApp();
$this->registerTalkDeferPushing();
$this->registerAdminNotifications();
$this->registerUserInterface();
$this->registerUserDeleteHook();
Expand Down Expand Up @@ -77,6 +81,22 @@ protected function registerUserInterface(): void {
}
}

protected function registerTalkDeferPushing(): void {
/** @var IEventDispatcher $dispatcher */
$dispatcher = $this->getContainer()->getServer()->query(IEventDispatcher::class);

$dispatcher->addListener(IApp::class . '::defer', function() {
/** @var App $app */
$app = $this->getContainer()->query(App::class);
$app->defer();
});
$dispatcher->addListener(IApp::class . '::flush', function() {
/** @var App $app */
$app = $this->getContainer()->query(App::class);
$app->flush();
});
}

protected function registerUserDeleteHook(): void {
Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser');
}
Expand Down

0 comments on commit d54d5db

Please sign in to comment.