Skip to content
Snippets Groups Projects
Commit a9648a76 authored by Julien Veyssier's avatar Julien Veyssier
Browse files

refs #179 NC notification to A when B adds/deletes a session share to A

parent 85de89b8
No related branches found
No related tags found
No related merge requests found
Pipeline #38944169 passed
......@@ -3284,6 +3284,29 @@ class PageController extends Controller {
$req->closeCursor();
$ok = 1;
// SEND NOTIFICATION
$manager = \OC::$server->getNotificationManager();
$notification = $manager->createNotification();
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink('/apps/phonetrack', 'GET');
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink('/apps/phonetrack', 'GET');
$notification->setApp('phonetrack')
->setUser($username)
->setDateTime(new \DateTime())
->setObject('addusershare', $dbtoken)
->setSubject('add_user_share', [$this->userId, $dbname])
->addAction($acceptAction)
->addAction($declineAction)
;
$manager->notify($notification);
}
else {
$ok = 2;
......@@ -3429,6 +3452,29 @@ class PageController extends Controller {
$req->closeCursor();
$ok = 1;
// SEND NOTIFICATION
$manager = \OC::$server->getNotificationManager();
$notification = $manager->createNotification();
$acceptAction = $notification->createAction();
$acceptAction->setLabel('accept')
->setLink('/apps/phonetrack', 'GET');
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')
->setLink('/apps/phonetrack', 'GET');
$notification->setApp('phonetrack')
->setUser($username)
->setDateTime(new \DateTime())
->setObject('deleteusershare', $dbtoken)
->setSubject('delete_user_share', [$this->userId, $dbname])
->addAction($acceptAction)
->addAction($declineAction)
;
$manager->notify($notification);
}
else {
$ok = 2;
......
......@@ -100,6 +100,22 @@ class Notifier implements INotifier {
->setLink($this->url->linkToRouteAbsolute('phonetrack.page.index'));
return $notification;
case 'add_user_share':
$p = $notification->getSubjectParameters();
$content = $l->t('User "%s" shared PhoneTrack session "%s" with you.', [$p[0], $p[1]]);
$notification->setParsedSubject($content)
->setLink($this->url->linkToRouteAbsolute('phonetrack.page.index'));
return $notification;
case 'delete_user_share':
$p = $notification->getSubjectParameters();
$content = $l->t('User "%s" stopped sharing PhoneTrack session "%s" with you.', [$p[0], $p[1]]);
$notification->setParsedSubject($content)
->setLink($this->url->linkToRouteAbsolute('phonetrack.page.index'));
return $notification;
default:
// Unknown subject => Unknown notification => throw
throw new \InvalidArgumentException();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment