diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-10 15:26:47 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-03-10 15:26:47 +0100 |
commit | a6882deebc0b4ab3bc181f97e5adb35f1bb4fcd0 (patch) | |
tree | 0f274d2dd8fc4250684bd222fe09c6626b2d1af0 /apps | |
parent | f98044ddce437eda32f5aa40df505c5bfaf46714 (diff) | |
download | nextcloud-server-a6882deebc0b4ab3bc181f97e5adb35f1bb4fcd0.tar.gz nextcloud-server-a6882deebc0b4ab3bc181f97e5adb35f1bb4fcd0.zip |
Differenciate the activity depending on admin vs user action
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Activity/Provider.php | 6 | ||||
-rw-r--r-- | apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php index 2d5c858f5e8..a6314fdfb11 100644 --- a/apps/settings/lib/Activity/Provider.php +++ b/apps/settings/lib/Activity/Provider.php @@ -115,7 +115,11 @@ class Provider implements IProvider { } elseif ($event->getSubject() === self::EMAIL_CHANGED) { $subject = $this->l->t('Your email address was changed by an administrator'); } elseif ($event->getSubject() === self::APP_TOKEN_CREATED) { - $subject = $this->l->t('You created app password "{token}"'); + if ($event->getAffectedUser() === $event->getAuthor()) { + $subject = $this->l->t('You created app password "{token}"'); + } else { + $subject = $this->l->t('An administrator created app password "{token}"'); + } } elseif ($event->getSubject() === self::APP_TOKEN_DELETED) { $subject = $this->l->t('You deleted app password "{token}"'); } elseif ($event->getSubject() === self::APP_TOKEN_RENAMED) { diff --git a/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php b/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php index 3eec74f4604..587d626ef97 100644 --- a/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php +++ b/apps/settings/lib/Listener/AppPasswordCreatedActivityListener.php @@ -31,6 +31,7 @@ use OCA\Settings\Activity\Provider; use OCP\Activity\IManager as IActivityManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\IUserSession; use Psr\Log\LoggerInterface; /** @@ -40,12 +41,17 @@ class AppPasswordCreatedActivityListener implements IEventListener { /** @var IActivityManager */ private $activityManager; + /** @var IUserSession */ + private $userSession; + /** @var LoggerInterface */ private $logger; public function __construct(IActivityManager $activityManager, + IUserSession $userSession, LoggerInterface $logger) { $this->activityManager = $activityManager; + $this->userSession = $userSession; $this->logger = $logger; } @@ -58,7 +64,7 @@ class AppPasswordCreatedActivityListener implements IEventListener { $activity->setApp('settings') ->setType('security') ->setAffectedUser($event->getToken()->getUID()) - ->setAuthor($event->getToken()->getUID()) + ->setAuthor($this->userSession->getUser() ? $this->userSession->getUser()->getUID() : '') ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $event->getToken()->getName()]) ->setObject('app_token', $event->getToken()->getId()); |