зеркало из https://github.com/nextcloud/spreed.git
Kill notifications when the user enters a room
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
d985c7f58c
Коммит
24b2f86980
|
@ -35,13 +35,10 @@
|
|||
|
||||
$manager = \OC::$server->getNotificationManager();
|
||||
$manager->registerNotifier(function() {
|
||||
return new \OCA\Spreed\Notification\Notifier(
|
||||
\OC::$server->getL10NFactory(),
|
||||
\OC::$server->getURLGenerator(),
|
||||
\OC::$server->getUserManager()
|
||||
);
|
||||
return \OC::$server->query('OCA\Spreed\Notification\Notifier');
|
||||
}, function() {
|
||||
$l = \OC::$server->getL10N('spreed');
|
||||
|
||||
return [
|
||||
'id' => 'spreed',
|
||||
'name' => $l->t('Spreed'),
|
||||
|
|
|
@ -33,6 +33,7 @@ use OCP\IL10N;
|
|||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Notification\IManager;
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class ApiController extends Controller {
|
||||
|
@ -46,6 +47,8 @@ class ApiController extends Controller {
|
|||
private $userManager;
|
||||
/** @var ISecureRandom */
|
||||
private $secureRandom;
|
||||
/** @var IManager */
|
||||
private $notificationManager;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
|
@ -55,6 +58,7 @@ class ApiController extends Controller {
|
|||
* @param IL10N $l10n
|
||||
* @param IUserManager $userManager
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param IManager $notificationManager
|
||||
*/
|
||||
public function __construct($appName,
|
||||
$UserId,
|
||||
|
@ -62,13 +66,15 @@ class ApiController extends Controller {
|
|||
IDBConnection $dbConnection,
|
||||
IL10N $l10n,
|
||||
IUserManager $userManager,
|
||||
ISecureRandom $secureRandom) {
|
||||
ISecureRandom $secureRandom,
|
||||
IManager $notificationManager) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $UserId;
|
||||
$this->dbConnection = $dbConnection;
|
||||
$this->l10n = $l10n;
|
||||
$this->userManager = $userManager;
|
||||
$this->secureRandom = $secureRandom;
|
||||
$this->notificationManager = $notificationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,14 +273,13 @@ class ApiController extends Controller {
|
|||
->execute();
|
||||
}
|
||||
|
||||
$notification = \OC::$server->getNotificationManager()->createNotification();
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification->setApp('spreed')
|
||||
->setUser($targetUser->getUID())
|
||||
->setDateTime(new \DateTime())
|
||||
->setObject('one2one', $roomId)
|
||||
->setSubject('invitation', [$this->userId]);
|
||||
|
||||
\OC::$server->getNotificationManager()->notify($notification);
|
||||
$this->notificationManager->notify($notification);
|
||||
|
||||
return new JSONResponse(['roomId' => $roomId], Http::STATUS_CREATED);
|
||||
}
|
||||
|
@ -287,6 +292,12 @@ class ApiController extends Controller {
|
|||
* @return JSONResponse
|
||||
*/
|
||||
public function ping($currentRoom) {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification->setApp('spreed')
|
||||
->setUser($this->userId)
|
||||
->setObject('one2one', $currentRoom);
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->update('spreedme_room_participants')
|
||||
->set('lastPing', $qb->createNamedParameter(time()))
|
||||
|
|
Загрузка…
Ссылка в новой задаче