@@ -45,130 +45,130 @@ |
||
45 | 45 | */ |
46 | 46 | class RemoteWipeEmailListener implements IEventListener { |
47 | 47 | |
48 | - /** @var IMailer */ |
|
49 | - private $mailer; |
|
50 | - |
|
51 | - /** @var IUserManager */ |
|
52 | - private $userManager; |
|
53 | - |
|
54 | - /** @var IL10N */ |
|
55 | - private $l10n; |
|
56 | - |
|
57 | - /** @var LoggerInterface */ |
|
58 | - private $logger; |
|
59 | - |
|
60 | - public function __construct(IMailer $mailer, |
|
61 | - IUserManager $userManager, |
|
62 | - IL10nFactory $l10nFactory, |
|
63 | - LoggerInterface $logger) { |
|
64 | - $this->mailer = $mailer; |
|
65 | - $this->userManager = $userManager; |
|
66 | - $this->l10n = $l10nFactory->get('core'); |
|
67 | - $this->logger = $logger; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @param Event $event |
|
72 | - */ |
|
73 | - public function handle(Event $event): void { |
|
74 | - if ($event instanceof RemoteWipeStarted) { |
|
75 | - $uid = $event->getToken()->getUID(); |
|
76 | - $user = $this->userManager->get($uid); |
|
77 | - if ($user === null) { |
|
78 | - $this->logger->warning("not sending a wipe started email because user <$uid> does not exist (anymore)"); |
|
79 | - return; |
|
80 | - } |
|
81 | - if ($user->getEMailAddress() === null) { |
|
82 | - $this->logger->info("not sending a wipe started email because user <$uid> has no email set"); |
|
83 | - return; |
|
84 | - } |
|
85 | - |
|
86 | - try { |
|
87 | - $this->mailer->send( |
|
88 | - $this->getWipingStartedMessage($event, $user) |
|
89 | - ); |
|
90 | - } catch (Exception $e) { |
|
91 | - $this->logger->error("Could not send remote wipe started email to <$uid>", [ |
|
92 | - 'exception' => $e, |
|
93 | - ]); |
|
94 | - } |
|
95 | - } elseif ($event instanceof RemoteWipeFinished) { |
|
96 | - $uid = $event->getToken()->getUID(); |
|
97 | - $user = $this->userManager->get($uid); |
|
98 | - if ($user === null) { |
|
99 | - $this->logger->warning("not sending a wipe finished email because user <$uid> does not exist (anymore)"); |
|
100 | - return; |
|
101 | - } |
|
102 | - if ($user->getEMailAddress() === null) { |
|
103 | - $this->logger->info("not sending a wipe finished email because user <$uid> has no email set"); |
|
104 | - return; |
|
105 | - } |
|
106 | - |
|
107 | - try { |
|
108 | - $this->mailer->send( |
|
109 | - $this->getWipingFinishedMessage($event, $user) |
|
110 | - ); |
|
111 | - } catch (Exception $e) { |
|
112 | - $this->logger->error("Could not send remote wipe finished email to <$uid>", [ |
|
113 | - 'exception' => $e, |
|
114 | - ]); |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - private function getWipingStartedMessage(RemoteWipeStarted $event, IUser $user): IMessage { |
|
120 | - $message = $this->mailer->createMessage(); |
|
121 | - $emailTemplate = $this->mailer->createEMailTemplate('auth.RemoteWipeStarted'); |
|
122 | - $plainHeading = $this->l10n->t('Wiping of device %s has started', [$event->getToken()->getName()]); |
|
123 | - $htmlHeading = $this->l10n->t('Wiping of device »%s« has started', [$event->getToken()->getName()]); |
|
124 | - $emailTemplate->setSubject( |
|
125 | - $this->l10n->t( |
|
126 | - '»%s« started remote wipe', |
|
127 | - [ |
|
128 | - substr($event->getToken()->getName(), 0, 15) |
|
129 | - ] |
|
130 | - ) |
|
131 | - ); |
|
132 | - $emailTemplate->addHeader(); |
|
133 | - $emailTemplate->addHeading( |
|
134 | - $htmlHeading, |
|
135 | - $plainHeading |
|
136 | - ); |
|
137 | - $emailTemplate->addBodyText( |
|
138 | - $this->l10n->t('Device or application »%s« has started the remote wipe process. You will receive another email once the process has finished', [$event->getToken()->getName()]) |
|
139 | - ); |
|
140 | - $emailTemplate->addFooter(); |
|
141 | - $message->setTo([$user->getEMailAddress()]); |
|
142 | - $message->useTemplate($emailTemplate); |
|
143 | - |
|
144 | - return $message; |
|
145 | - } |
|
146 | - |
|
147 | - private function getWipingFinishedMessage(RemoteWipeFinished $event, IUser $user): IMessage { |
|
148 | - $message = $this->mailer->createMessage(); |
|
149 | - $emailTemplate = $this->mailer->createEMailTemplate('auth.RemoteWipeFinished'); |
|
150 | - $plainHeading = $this->l10n->t('Wiping of device %s has finished', [$event->getToken()->getName()]); |
|
151 | - $htmlHeading = $this->l10n->t('Wiping of device »%s« has finished', [$event->getToken()->getName()]); |
|
152 | - $emailTemplate->setSubject( |
|
153 | - $this->l10n->t( |
|
154 | - '»%s« finished remote wipe', |
|
155 | - [ |
|
156 | - substr($event->getToken()->getName(), 0, 15) |
|
157 | - ] |
|
158 | - ) |
|
159 | - ); |
|
160 | - $emailTemplate->addHeader(); |
|
161 | - $emailTemplate->addHeading( |
|
162 | - $htmlHeading, |
|
163 | - $plainHeading |
|
164 | - ); |
|
165 | - $emailTemplate->addBodyText( |
|
166 | - $this->l10n->t('Device or application »%s« has finished the remote wipe process.', [$event->getToken()->getName()]) |
|
167 | - ); |
|
168 | - $emailTemplate->addFooter(); |
|
169 | - $message->setTo([$user->getEMailAddress()]); |
|
170 | - $message->useTemplate($emailTemplate); |
|
171 | - |
|
172 | - return $message; |
|
173 | - } |
|
48 | + /** @var IMailer */ |
|
49 | + private $mailer; |
|
50 | + |
|
51 | + /** @var IUserManager */ |
|
52 | + private $userManager; |
|
53 | + |
|
54 | + /** @var IL10N */ |
|
55 | + private $l10n; |
|
56 | + |
|
57 | + /** @var LoggerInterface */ |
|
58 | + private $logger; |
|
59 | + |
|
60 | + public function __construct(IMailer $mailer, |
|
61 | + IUserManager $userManager, |
|
62 | + IL10nFactory $l10nFactory, |
|
63 | + LoggerInterface $logger) { |
|
64 | + $this->mailer = $mailer; |
|
65 | + $this->userManager = $userManager; |
|
66 | + $this->l10n = $l10nFactory->get('core'); |
|
67 | + $this->logger = $logger; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @param Event $event |
|
72 | + */ |
|
73 | + public function handle(Event $event): void { |
|
74 | + if ($event instanceof RemoteWipeStarted) { |
|
75 | + $uid = $event->getToken()->getUID(); |
|
76 | + $user = $this->userManager->get($uid); |
|
77 | + if ($user === null) { |
|
78 | + $this->logger->warning("not sending a wipe started email because user <$uid> does not exist (anymore)"); |
|
79 | + return; |
|
80 | + } |
|
81 | + if ($user->getEMailAddress() === null) { |
|
82 | + $this->logger->info("not sending a wipe started email because user <$uid> has no email set"); |
|
83 | + return; |
|
84 | + } |
|
85 | + |
|
86 | + try { |
|
87 | + $this->mailer->send( |
|
88 | + $this->getWipingStartedMessage($event, $user) |
|
89 | + ); |
|
90 | + } catch (Exception $e) { |
|
91 | + $this->logger->error("Could not send remote wipe started email to <$uid>", [ |
|
92 | + 'exception' => $e, |
|
93 | + ]); |
|
94 | + } |
|
95 | + } elseif ($event instanceof RemoteWipeFinished) { |
|
96 | + $uid = $event->getToken()->getUID(); |
|
97 | + $user = $this->userManager->get($uid); |
|
98 | + if ($user === null) { |
|
99 | + $this->logger->warning("not sending a wipe finished email because user <$uid> does not exist (anymore)"); |
|
100 | + return; |
|
101 | + } |
|
102 | + if ($user->getEMailAddress() === null) { |
|
103 | + $this->logger->info("not sending a wipe finished email because user <$uid> has no email set"); |
|
104 | + return; |
|
105 | + } |
|
106 | + |
|
107 | + try { |
|
108 | + $this->mailer->send( |
|
109 | + $this->getWipingFinishedMessage($event, $user) |
|
110 | + ); |
|
111 | + } catch (Exception $e) { |
|
112 | + $this->logger->error("Could not send remote wipe finished email to <$uid>", [ |
|
113 | + 'exception' => $e, |
|
114 | + ]); |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + private function getWipingStartedMessage(RemoteWipeStarted $event, IUser $user): IMessage { |
|
120 | + $message = $this->mailer->createMessage(); |
|
121 | + $emailTemplate = $this->mailer->createEMailTemplate('auth.RemoteWipeStarted'); |
|
122 | + $plainHeading = $this->l10n->t('Wiping of device %s has started', [$event->getToken()->getName()]); |
|
123 | + $htmlHeading = $this->l10n->t('Wiping of device »%s« has started', [$event->getToken()->getName()]); |
|
124 | + $emailTemplate->setSubject( |
|
125 | + $this->l10n->t( |
|
126 | + '»%s« started remote wipe', |
|
127 | + [ |
|
128 | + substr($event->getToken()->getName(), 0, 15) |
|
129 | + ] |
|
130 | + ) |
|
131 | + ); |
|
132 | + $emailTemplate->addHeader(); |
|
133 | + $emailTemplate->addHeading( |
|
134 | + $htmlHeading, |
|
135 | + $plainHeading |
|
136 | + ); |
|
137 | + $emailTemplate->addBodyText( |
|
138 | + $this->l10n->t('Device or application »%s« has started the remote wipe process. You will receive another email once the process has finished', [$event->getToken()->getName()]) |
|
139 | + ); |
|
140 | + $emailTemplate->addFooter(); |
|
141 | + $message->setTo([$user->getEMailAddress()]); |
|
142 | + $message->useTemplate($emailTemplate); |
|
143 | + |
|
144 | + return $message; |
|
145 | + } |
|
146 | + |
|
147 | + private function getWipingFinishedMessage(RemoteWipeFinished $event, IUser $user): IMessage { |
|
148 | + $message = $this->mailer->createMessage(); |
|
149 | + $emailTemplate = $this->mailer->createEMailTemplate('auth.RemoteWipeFinished'); |
|
150 | + $plainHeading = $this->l10n->t('Wiping of device %s has finished', [$event->getToken()->getName()]); |
|
151 | + $htmlHeading = $this->l10n->t('Wiping of device »%s« has finished', [$event->getToken()->getName()]); |
|
152 | + $emailTemplate->setSubject( |
|
153 | + $this->l10n->t( |
|
154 | + '»%s« finished remote wipe', |
|
155 | + [ |
|
156 | + substr($event->getToken()->getName(), 0, 15) |
|
157 | + ] |
|
158 | + ) |
|
159 | + ); |
|
160 | + $emailTemplate->addHeader(); |
|
161 | + $emailTemplate->addHeading( |
|
162 | + $htmlHeading, |
|
163 | + $plainHeading |
|
164 | + ); |
|
165 | + $emailTemplate->addBodyText( |
|
166 | + $this->l10n->t('Device or application »%s« has finished the remote wipe process.', [$event->getToken()->getName()]) |
|
167 | + ); |
|
168 | + $emailTemplate->addFooter(); |
|
169 | + $message->setTo([$user->getEMailAddress()]); |
|
170 | + $message->useTemplate($emailTemplate); |
|
171 | + |
|
172 | + return $message; |
|
173 | + } |
|
174 | 174 | } |
@@ -38,38 +38,38 @@ |
||
38 | 38 | */ |
39 | 39 | class UserDeletedTokenCleanupListener implements IEventListener { |
40 | 40 | |
41 | - /** @var Manager */ |
|
42 | - private $manager; |
|
41 | + /** @var Manager */ |
|
42 | + private $manager; |
|
43 | 43 | |
44 | - /** @var LoggerInterface */ |
|
45 | - private $logger; |
|
44 | + /** @var LoggerInterface */ |
|
45 | + private $logger; |
|
46 | 46 | |
47 | - public function __construct(Manager $manager, |
|
48 | - LoggerInterface $logger) { |
|
49 | - $this->manager = $manager; |
|
50 | - $this->logger = $logger; |
|
51 | - } |
|
47 | + public function __construct(Manager $manager, |
|
48 | + LoggerInterface $logger) { |
|
49 | + $this->manager = $manager; |
|
50 | + $this->logger = $logger; |
|
51 | + } |
|
52 | 52 | |
53 | - public function handle(Event $event): void { |
|
54 | - if (!($event instanceof UserDeletedEvent)) { |
|
55 | - // Unrelated |
|
56 | - return; |
|
57 | - } |
|
53 | + public function handle(Event $event): void { |
|
54 | + if (!($event instanceof UserDeletedEvent)) { |
|
55 | + // Unrelated |
|
56 | + return; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Catch any exception during this process as any failure here shouldn't block the |
|
61 | - * user deletion. |
|
62 | - */ |
|
63 | - try { |
|
64 | - $uid = $event->getUser()->getUID(); |
|
65 | - $tokens = $this->manager->getTokenByUser($uid); |
|
66 | - foreach ($tokens as $token) { |
|
67 | - $this->manager->invalidateTokenById($uid, $token->getId()); |
|
68 | - } |
|
69 | - } catch (Throwable $e) { |
|
70 | - $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
71 | - 'exception' => $e, |
|
72 | - ]); |
|
73 | - } |
|
74 | - } |
|
59 | + /** |
|
60 | + * Catch any exception during this process as any failure here shouldn't block the |
|
61 | + * user deletion. |
|
62 | + */ |
|
63 | + try { |
|
64 | + $uid = $event->getUser()->getUID(); |
|
65 | + $tokens = $this->manager->getTokenByUser($uid); |
|
66 | + foreach ($tokens as $token) { |
|
67 | + $this->manager->invalidateTokenById($uid, $token->getId()); |
|
68 | + } |
|
69 | + } catch (Throwable $e) { |
|
70 | + $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
71 | + 'exception' => $e, |
|
72 | + ]); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
@@ -40,35 +40,35 @@ |
||
40 | 40 | */ |
41 | 41 | class RemoteWipeNotificationsListener implements IEventListener { |
42 | 42 | |
43 | - /** @var INotificationManager */ |
|
44 | - private $notificationManager; |
|
43 | + /** @var INotificationManager */ |
|
44 | + private $notificationManager; |
|
45 | 45 | |
46 | - /** @var ITimeFactory */ |
|
47 | - private $timeFactory; |
|
46 | + /** @var ITimeFactory */ |
|
47 | + private $timeFactory; |
|
48 | 48 | |
49 | - public function __construct(INotificationManager $notificationManager, |
|
50 | - ITimeFactory $timeFactory) { |
|
51 | - $this->notificationManager = $notificationManager; |
|
52 | - $this->timeFactory = $timeFactory; |
|
53 | - } |
|
49 | + public function __construct(INotificationManager $notificationManager, |
|
50 | + ITimeFactory $timeFactory) { |
|
51 | + $this->notificationManager = $notificationManager; |
|
52 | + $this->timeFactory = $timeFactory; |
|
53 | + } |
|
54 | 54 | |
55 | - public function handle(Event $event): void { |
|
56 | - if ($event instanceof RemoteWipeStarted) { |
|
57 | - $this->sendNotification('remote_wipe_start', $event->getToken()); |
|
58 | - } elseif ($event instanceof RemoteWipeFinished) { |
|
59 | - $this->sendNotification('remote_wipe_finish', $event->getToken()); |
|
60 | - } |
|
61 | - } |
|
55 | + public function handle(Event $event): void { |
|
56 | + if ($event instanceof RemoteWipeStarted) { |
|
57 | + $this->sendNotification('remote_wipe_start', $event->getToken()); |
|
58 | + } elseif ($event instanceof RemoteWipeFinished) { |
|
59 | + $this->sendNotification('remote_wipe_finish', $event->getToken()); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - private function sendNotification(string $event, IToken $token): void { |
|
64 | - $notification = $this->notificationManager->createNotification(); |
|
65 | - $notification->setApp('auth') |
|
66 | - ->setUser($token->getUID()) |
|
67 | - ->setDateTime($this->timeFactory->getDateTime()) |
|
68 | - ->setObject('token', (string) $token->getId()) |
|
69 | - ->setSubject($event, [ |
|
70 | - 'name' => $token->getName(), |
|
71 | - ]); |
|
72 | - $this->notificationManager->notify($notification); |
|
73 | - } |
|
63 | + private function sendNotification(string $event, IToken $token): void { |
|
64 | + $notification = $this->notificationManager->createNotification(); |
|
65 | + $notification->setApp('auth') |
|
66 | + ->setUser($token->getUID()) |
|
67 | + ->setDateTime($this->timeFactory->getDateTime()) |
|
68 | + ->setObject('token', (string) $token->getId()) |
|
69 | + ->setSubject($event, [ |
|
70 | + 'name' => $token->getName(), |
|
71 | + ]); |
|
72 | + $this->notificationManager->notify($notification); |
|
73 | + } |
|
74 | 74 | } |
@@ -40,30 +40,30 @@ |
||
40 | 40 | */ |
41 | 41 | class LoginFailedListener implements IEventListener { |
42 | 42 | |
43 | - /** @var IEventDispatcher */ |
|
44 | - private $dispatcher; |
|
43 | + /** @var IEventDispatcher */ |
|
44 | + private $dispatcher; |
|
45 | 45 | |
46 | - /** @var IUserManager */ |
|
47 | - private $userManager; |
|
46 | + /** @var IUserManager */ |
|
47 | + private $userManager; |
|
48 | 48 | |
49 | - public function __construct(IEventDispatcher $dispatcher, IUserManager $userManager) { |
|
50 | - $this->dispatcher = $dispatcher; |
|
51 | - $this->userManager = $userManager; |
|
52 | - } |
|
49 | + public function __construct(IEventDispatcher $dispatcher, IUserManager $userManager) { |
|
50 | + $this->dispatcher = $dispatcher; |
|
51 | + $this->userManager = $userManager; |
|
52 | + } |
|
53 | 53 | |
54 | - public function handle(Event $event): void { |
|
55 | - if (!($event instanceof LoginFailed)) { |
|
56 | - return; |
|
57 | - } |
|
54 | + public function handle(Event $event): void { |
|
55 | + if (!($event instanceof LoginFailed)) { |
|
56 | + return; |
|
57 | + } |
|
58 | 58 | |
59 | - $uid = $event->getLoginName(); |
|
60 | - Util::emitHook( |
|
61 | - '\OCA\Files_Sharing\API\Server2Server', |
|
62 | - 'preLoginNameUsedAsUserName', |
|
63 | - ['uid' => &$uid] |
|
64 | - ); |
|
65 | - if ($this->userManager->userExists($uid)) { |
|
66 | - $this->dispatcher->dispatchTyped(new LoginFailedEvent($uid)); |
|
67 | - } |
|
68 | - } |
|
59 | + $uid = $event->getLoginName(); |
|
60 | + Util::emitHook( |
|
61 | + '\OCA\Files_Sharing\API\Server2Server', |
|
62 | + 'preLoginNameUsedAsUserName', |
|
63 | + ['uid' => &$uid] |
|
64 | + ); |
|
65 | + if ($this->userManager->userExists($uid)) { |
|
66 | + $this->dispatcher->dispatchTyped(new LoginFailedEvent($uid)); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | } |
@@ -36,23 +36,23 @@ |
||
36 | 36 | */ |
37 | 37 | class UserLoggedInListener implements IEventListener { |
38 | 38 | |
39 | - /** @var Manager */ |
|
40 | - private $manager; |
|
39 | + /** @var Manager */ |
|
40 | + private $manager; |
|
41 | 41 | |
42 | - public function __construct(Manager $manager) { |
|
43 | - $this->manager = $manager; |
|
44 | - } |
|
42 | + public function __construct(Manager $manager) { |
|
43 | + $this->manager = $manager; |
|
44 | + } |
|
45 | 45 | |
46 | - public function handle(Event $event): void { |
|
47 | - if (!($event instanceof PostLoginEvent)) { |
|
48 | - return; |
|
49 | - } |
|
46 | + public function handle(Event $event): void { |
|
47 | + if (!($event instanceof PostLoginEvent)) { |
|
48 | + return; |
|
49 | + } |
|
50 | 50 | |
51 | - // If this is already a token login there is nothing to do |
|
52 | - if ($event->isTokenLogin()) { |
|
53 | - return; |
|
54 | - } |
|
51 | + // If this is already a token login there is nothing to do |
|
52 | + if ($event->isTokenLogin()) { |
|
53 | + return; |
|
54 | + } |
|
55 | 55 | |
56 | - $this->manager->updatePasswords($event->getUser()->getUID(), $event->getPassword()); |
|
57 | - } |
|
56 | + $this->manager->updatePasswords($event->getUser()->getUID(), $event->getPassword()); |
|
57 | + } |
|
58 | 58 | } |
@@ -36,18 +36,18 @@ |
||
36 | 36 | */ |
37 | 37 | class UserDeletedStoreCleanupListener implements IEventListener { |
38 | 38 | |
39 | - /** @var Registry */ |
|
40 | - private $registry; |
|
39 | + /** @var Registry */ |
|
40 | + private $registry; |
|
41 | 41 | |
42 | - public function __construct(Registry $registry) { |
|
43 | - $this->registry = $registry; |
|
44 | - } |
|
42 | + public function __construct(Registry $registry) { |
|
43 | + $this->registry = $registry; |
|
44 | + } |
|
45 | 45 | |
46 | - public function handle(Event $event): void { |
|
47 | - if (!($event instanceof UserDeletedEvent)) { |
|
48 | - return; |
|
49 | - } |
|
46 | + public function handle(Event $event): void { |
|
47 | + if (!($event instanceof UserDeletedEvent)) { |
|
48 | + return; |
|
49 | + } |
|
50 | 50 | |
51 | - $this->registry->deleteUserData($event->getUser()); |
|
52 | - } |
|
51 | + $this->registry->deleteUserData($event->getUser()); |
|
52 | + } |
|
53 | 53 | } |
@@ -40,42 +40,42 @@ |
||
40 | 40 | */ |
41 | 41 | class RemoteWipeActivityListener implements IEventListener { |
42 | 42 | |
43 | - /** @var IActvityManager */ |
|
44 | - private $activityManager; |
|
43 | + /** @var IActvityManager */ |
|
44 | + private $activityManager; |
|
45 | 45 | |
46 | - /** @var LoggerInterface */ |
|
47 | - private $logger; |
|
46 | + /** @var LoggerInterface */ |
|
47 | + private $logger; |
|
48 | 48 | |
49 | - public function __construct(IActvityManager $activityManager, |
|
50 | - LoggerInterface $logger) { |
|
51 | - $this->activityManager = $activityManager; |
|
52 | - $this->logger = $logger; |
|
53 | - } |
|
49 | + public function __construct(IActvityManager $activityManager, |
|
50 | + LoggerInterface $logger) { |
|
51 | + $this->activityManager = $activityManager; |
|
52 | + $this->logger = $logger; |
|
53 | + } |
|
54 | 54 | |
55 | - public function handle(Event $event): void { |
|
56 | - if ($event instanceof RemoteWipeStarted) { |
|
57 | - $this->publishActivity('remote_wipe_start', $event->getToken()); |
|
58 | - } elseif ($event instanceof RemoteWipeFinished) { |
|
59 | - $this->publishActivity('remote_wipe_finish', $event->getToken()); |
|
60 | - } |
|
61 | - } |
|
55 | + public function handle(Event $event): void { |
|
56 | + if ($event instanceof RemoteWipeStarted) { |
|
57 | + $this->publishActivity('remote_wipe_start', $event->getToken()); |
|
58 | + } elseif ($event instanceof RemoteWipeFinished) { |
|
59 | + $this->publishActivity('remote_wipe_finish', $event->getToken()); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - private function publishActivity(string $event, IToken $token): void { |
|
64 | - $activity = $this->activityManager->generateEvent(); |
|
65 | - $activity->setApp('core') |
|
66 | - ->setType('security') |
|
67 | - ->setAuthor($token->getUID()) |
|
68 | - ->setAffectedUser($token->getUID()) |
|
69 | - ->setSubject($event, [ |
|
70 | - 'name' => $token->getName(), |
|
71 | - ]); |
|
72 | - try { |
|
73 | - $this->activityManager->publish($activity); |
|
74 | - } catch (BadMethodCallException $e) { |
|
75 | - $this->logger->warning('could not publish activity', [ |
|
76 | - 'app' => 'core', |
|
77 | - 'exception' => $e, |
|
78 | - ]); |
|
79 | - } |
|
80 | - } |
|
63 | + private function publishActivity(string $event, IToken $token): void { |
|
64 | + $activity = $this->activityManager->generateEvent(); |
|
65 | + $activity->setApp('core') |
|
66 | + ->setType('security') |
|
67 | + ->setAuthor($token->getUID()) |
|
68 | + ->setAffectedUser($token->getUID()) |
|
69 | + ->setSubject($event, [ |
|
70 | + 'name' => $token->getName(), |
|
71 | + ]); |
|
72 | + try { |
|
73 | + $this->activityManager->publish($activity); |
|
74 | + } catch (BadMethodCallException $e) { |
|
75 | + $this->logger->warning('could not publish activity', [ |
|
76 | + 'app' => 'core', |
|
77 | + 'exception' => $e, |
|
78 | + ]); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | } |
@@ -33,11 +33,11 @@ |
||
33 | 33 | */ |
34 | 34 | interface IEventListener { |
35 | 35 | |
36 | - /** |
|
37 | - * @param Event $event |
|
38 | - * @psalm-param T $event |
|
39 | - * |
|
40 | - * @since 17.0.0 |
|
41 | - */ |
|
42 | - public function handle(Event $event): void; |
|
36 | + /** |
|
37 | + * @param Event $event |
|
38 | + * @psalm-param T $event |
|
39 | + * |
|
40 | + * @since 17.0.0 |
|
41 | + */ |
|
42 | + public function handle(Event $event): void; |
|
43 | 43 | } |
@@ -34,59 +34,59 @@ |
||
34 | 34 | */ |
35 | 35 | interface IEventDispatcher { |
36 | 36 | |
37 | - /** |
|
38 | - * @template T of \OCP\EventDispatcher\Event |
|
39 | - * @param string $eventName preferably the fully-qualified class name of the Event sub class |
|
40 | - * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class |
|
41 | - * @param callable $listener the object that is invoked when a matching event is dispatched |
|
42 | - * @param int $priority |
|
43 | - * |
|
44 | - * @since 17.0.0 |
|
45 | - */ |
|
46 | - public function addListener(string $eventName, callable $listener, int $priority = 0): void; |
|
37 | + /** |
|
38 | + * @template T of \OCP\EventDispatcher\Event |
|
39 | + * @param string $eventName preferably the fully-qualified class name of the Event sub class |
|
40 | + * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class |
|
41 | + * @param callable $listener the object that is invoked when a matching event is dispatched |
|
42 | + * @param int $priority |
|
43 | + * |
|
44 | + * @since 17.0.0 |
|
45 | + */ |
|
46 | + public function addListener(string $eventName, callable $listener, int $priority = 0): void; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @template T of \OCP\EventDispatcher\Event |
|
50 | - * @param string $eventName preferably the fully-qualified class name of the Event sub class |
|
51 | - * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class |
|
52 | - * @param callable $listener the object that is invoked when a matching event is dispatched |
|
53 | - * |
|
54 | - * @since 19.0.0 |
|
55 | - */ |
|
56 | - public function removeListener(string $eventName, callable $listener): void; |
|
48 | + /** |
|
49 | + * @template T of \OCP\EventDispatcher\Event |
|
50 | + * @param string $eventName preferably the fully-qualified class name of the Event sub class |
|
51 | + * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class |
|
52 | + * @param callable $listener the object that is invoked when a matching event is dispatched |
|
53 | + * |
|
54 | + * @since 19.0.0 |
|
55 | + */ |
|
56 | + public function removeListener(string $eventName, callable $listener): void; |
|
57 | 57 | |
58 | - /** |
|
59 | - * @template T of \OCP\EventDispatcher\Event |
|
60 | - * @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for |
|
61 | - * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class to listen for |
|
62 | - * @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container |
|
63 | - * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $className fully qualified class name that can be built by the DI container |
|
64 | - * @param int $priority |
|
65 | - * |
|
66 | - * @since 17.0.0 |
|
67 | - */ |
|
68 | - public function addServiceListener(string $eventName, string $className, int $priority = 0): void; |
|
58 | + /** |
|
59 | + * @template T of \OCP\EventDispatcher\Event |
|
60 | + * @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for |
|
61 | + * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class to listen for |
|
62 | + * @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container |
|
63 | + * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $className fully qualified class name that can be built by the DI container |
|
64 | + * @param int $priority |
|
65 | + * |
|
66 | + * @since 17.0.0 |
|
67 | + */ |
|
68 | + public function addServiceListener(string $eventName, string $className, int $priority = 0): void; |
|
69 | 69 | |
70 | - /** |
|
71 | - * @template T of \OCP\EventDispatcher\Event |
|
72 | - * @param string $eventName |
|
73 | - * @psalm-param string|class-string<T> $eventName |
|
74 | - * @param Event $event |
|
75 | - * @psalm-param T $event |
|
76 | - * |
|
77 | - * @since 17.0.0 |
|
78 | - */ |
|
79 | - public function dispatch(string $eventName, Event $event): void; |
|
70 | + /** |
|
71 | + * @template T of \OCP\EventDispatcher\Event |
|
72 | + * @param string $eventName |
|
73 | + * @psalm-param string|class-string<T> $eventName |
|
74 | + * @param Event $event |
|
75 | + * @psalm-param T $event |
|
76 | + * |
|
77 | + * @since 17.0.0 |
|
78 | + */ |
|
79 | + public function dispatch(string $eventName, Event $event): void; |
|
80 | 80 | |
81 | - /** |
|
82 | - * Dispatch a typed event |
|
83 | - * |
|
84 | - * Only use this with subclasses of ``\OCP\EventDispatcher\Event``. |
|
85 | - * The object's class will determine the event name. |
|
86 | - * |
|
87 | - * @param Event $event |
|
88 | - * |
|
89 | - * @since 18.0.0 |
|
90 | - */ |
|
91 | - public function dispatchTyped(Event $event): void; |
|
81 | + /** |
|
82 | + * Dispatch a typed event |
|
83 | + * |
|
84 | + * Only use this with subclasses of ``\OCP\EventDispatcher\Event``. |
|
85 | + * The object's class will determine the event name. |
|
86 | + * |
|
87 | + * @param Event $event |
|
88 | + * |
|
89 | + * @since 18.0.0 |
|
90 | + */ |
|
91 | + public function dispatchTyped(Event $event): void; |
|
92 | 92 | } |