diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2022-10-13 11:29:52 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2022-10-13 11:29:52 +0300 |
commit | 440ba7fb0ddeb18d3aea2134eefe5cd26824a71c (patch) | |
tree | d8c56b979ff616093468564c6a6675101f069eda | |
parent | bf3d806655a2c6457f1bbbb7ccd73ed3645e3397 (diff) |
emulate user on cronbackport/1168/24-1168
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | lib/Notification/Notifier.php | 7 | ||||
-rw-r--r-- | lib/Service/FederatedUserService.php | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index a43d5740..98641b0b 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -31,7 +31,6 @@ declare(strict_types=1); namespace OCA\Circles\Notification; -use OCA\Circles\Tools\Traits\TNCLogger; use Exception; use InvalidArgumentException; use OCA\Circles\AppInfo\Application; @@ -60,8 +59,6 @@ use OCP\Notification\INotifier; * @package OCA\Circles\Notification */ class Notifier implements INotifier { - use TNCLogger; - /** @var IL10N */ private $l10n; @@ -111,8 +108,6 @@ class Notifier implements INotifier { $this->federatedUserService = $federatedUserService; $this->memberService = $memberService; $this->configService = $configService; - - $this->setup('app', Application::APP_ID); } /** @@ -176,7 +171,7 @@ class Notifier implements INotifier { * @throws SingleCircleNotFoundException */ private function prepareMemberNotification(INotification $notification) { - $this->federatedUserService->initCurrentUser(); + $this->federatedUserService->initCurrentUser($notification->getUser()); $probe = new CircleProbe(); $probe->initiatorAsDirectMember() diff --git a/lib/Service/FederatedUserService.php b/lib/Service/FederatedUserService.php index e9433656..e3fd406b 100644 --- a/lib/Service/FederatedUserService.php +++ b/lib/Service/FederatedUserService.php @@ -215,15 +215,21 @@ class FederatedUserService { /** + * specify $defaultUser in case a session is not opened but user needs to be emulated (ie. cron) + * * @throws FederatedUserException * @throws FederatedUserNotFoundException * @throws InvalidIdException * @throws SingleCircleNotFoundException * @throws RequestBuilderException */ - public function initCurrentUser() { + public function initCurrentUser(string $defaultUser = ''): void { $user = $this->userSession->getUser(); if ($user === null) { + if ($defaultUser !== '') { + $this->setLocalCurrentUserId($defaultUser); + } + return; } |