Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/circles.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2022-10-20 11:50:05 +0300
committerMaxence Lange <maxence@artificial-owl.com>2022-10-20 12:35:41 +0300
commit8951f84563b49947f4b3c9ec6397d337f335cd03 (patch)
tree9897b755391704aae52b7883a4174476bd1d6abe
parentad8e19380bfb329128f3d82191b49c7771595081 (diff)
emulate user on cron
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--.github/workflows/phpunit.yml2
-rw-r--r--lib/Notification/Notifier.php7
-rw-r--r--lib/Service/FederatedUserService.php8
3 files changed, 9 insertions, 8 deletions
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
index b31612a9..4572d4ba 100644
--- a/.github/workflows/phpunit.yml
+++ b/.github/workflows/phpunit.yml
@@ -150,7 +150,7 @@ jobs:
services:
postgres:
- image: postgres
+ image: postgres:14
ports:
- 4444:5432/tcp
env:
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;
}