Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Listen to potential defer/flush requests of the Talk app
Talk app, good guys, they know what they are doing. Trust me.

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jul 8, 2020
commit d54d5db30856bd6670a83c880dbe94ffbbf5be0b
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