Notifications for group shares
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e96c9e0e4a
commit
c79a56481b
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||||
namespace OCA\Files_Sharing\Notification;
|
namespace OCA\Files_Sharing\Notification;
|
||||||
|
|
||||||
use OC\Share\Share;
|
use OC\Share\Share;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use OCP\Notification\IManager;
|
use OCP\Notification\IManager;
|
||||||
use OCP\Notification\INotification;
|
use OCP\Notification\INotification;
|
||||||
use OCP\Share\IShare;
|
use OCP\Share\IShare;
|
||||||
|
@ -34,11 +35,15 @@ class Listener {
|
||||||
|
|
||||||
/** @var IManager */
|
/** @var IManager */
|
||||||
protected $notificationManager;
|
protected $notificationManager;
|
||||||
|
/** @var IGroupManager */
|
||||||
|
protected $groupManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IManager $notificationManager
|
IManager $notificationManager,
|
||||||
|
IGroupManager $groupManager
|
||||||
) {
|
) {
|
||||||
$this->notificationManager = $notificationManager;
|
$this->notificationManager = $notificationManager;
|
||||||
|
$this->groupManager = $groupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +58,14 @@ class Listener {
|
||||||
$notification->setSubject('incoming_user_share')
|
$notification->setSubject('incoming_user_share')
|
||||||
->setUser($share->getSharedWith());
|
->setUser($share->getSharedWith());
|
||||||
$this->notificationManager->notify($notification);
|
$this->notificationManager->notify($notification);
|
||||||
|
} else if ($share->getShareType() === Share::SHARE_TYPE_GROUP) {
|
||||||
|
$notification->setSubject('incoming_group_share');
|
||||||
|
$group = $this->groupManager->get($share->getSharedWith());
|
||||||
|
|
||||||
|
foreach ($group->getUsers() as $user) {
|
||||||
|
$notification->setUser($user->getUID());
|
||||||
|
$this->notificationManager->notify($notification);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue