aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/Hooks.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-03-02 10:38:24 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2021-03-03 11:33:33 +0100
commitf492a6aac38828304ecc2ec3a32202aaa36d25d2 (patch)
treec49e3c7a35da927815825cedcab7621a4a32e9af /apps/settings/lib/Hooks.php
parenta1be5f33af7e65a80b2e39d7c28c727c6f3ef6fe (diff)
downloadnextcloud-server-f492a6aac38828304ecc2ec3a32202aaa36d25d2.tar.gz
nextcloud-server-f492a6aac38828304ecc2ec3a32202aaa36d25d2.zip
Move group activities to events
Use the fancy events. Nicer code Nicely isolated code win-win Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/settings/lib/Hooks.php')
-rw-r--r--apps/settings/lib/Hooks.php76
1 files changed, 0 insertions, 76 deletions
diff --git a/apps/settings/lib/Hooks.php b/apps/settings/lib/Hooks.php
index 62eddcd1c0b..c8fa5609914 100644
--- a/apps/settings/lib/Hooks.php
+++ b/apps/settings/lib/Hooks.php
@@ -27,11 +27,9 @@
namespace OCA\Settings;
-use OCA\Settings\Activity\GroupProvider;
use OCA\Settings\Activity\Provider;
use OCP\Activity\IManager as IActivityManager;
use OCP\IConfig;
-use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
@@ -214,78 +212,4 @@ class Hooks {
$this->mailer->send($message);
}
}
-
- /**
- * @param IGroup $group
- * @param IUser $user
- * @throws \InvalidArgumentException
- * @throws \BadMethodCallException
- */
- public function addUserToGroup(IGroup $group, IUser $user): void {
- $subAdminManager = $this->groupManager->getSubAdmin();
- $usersToNotify = $subAdminManager->getGroupsSubAdmins($group);
- $usersToNotify[] = $user;
-
-
- $event = $this->activityManager->generateEvent();
- $event->setApp('settings')
- ->setType('group_settings');
-
- $actor = $this->userSession->getUser();
- if ($actor instanceof IUser) {
- $event->setAuthor($actor->getUID())
- ->setSubject(GroupProvider::ADDED_TO_GROUP, [
- 'user' => $user->getUID(),
- 'group' => $group->getGID(),
- 'actor' => $actor->getUID(),
- ]);
- } else {
- $event->setSubject(GroupProvider::ADDED_TO_GROUP, [
- 'user' => $user->getUID(),
- 'group' => $group->getGID(),
- ]);
- }
-
- foreach ($usersToNotify as $userToNotify) {
- $event->setAffectedUser($userToNotify->getUID());
- $this->activityManager->publish($event);
- }
- }
-
- /**
- * @param IGroup $group
- * @param IUser $user
- * @throws \InvalidArgumentException
- * @throws \BadMethodCallException
- */
- public function removeUserFromGroup(IGroup $group, IUser $user): void {
- $subAdminManager = $this->groupManager->getSubAdmin();
- $usersToNotify = $subAdminManager->getGroupsSubAdmins($group);
- $usersToNotify[] = $user;
-
-
- $event = $this->activityManager->generateEvent();
- $event->setApp('settings')
- ->setType('group_settings');
-
- $actor = $this->userSession->getUser();
- if ($actor instanceof IUser) {
- $event->setAuthor($actor->getUID())
- ->setSubject(GroupProvider::REMOVED_FROM_GROUP, [
- 'user' => $user->getUID(),
- 'group' => $group->getGID(),
- 'actor' => $actor->getUID(),
- ]);
- } else {
- $event->setSubject(GroupProvider::REMOVED_FROM_GROUP, [
- 'user' => $user->getUID(),
- 'group' => $group->getGID(),
- ]);
- }
-
- foreach ($usersToNotify as $userToNotify) {
- $event->setAffectedUser($userToNotify->getUID());
- $this->activityManager->publish($event);
- }
- }
}