forked from nextcloud/circles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable audit by configuration nextcloud#163
- audit of following actions: - user X created circle Z; - user X removed circle Z; - user X change name of circle Z for circle W; - user X was added to circle U by user Z; - user X shared file/folder with circle Y; - user X, that created circle, unshared file/folder with circle Y - member X accepted invitation to circle Y by user Z; - member X left circle Y; - user X change role of member Y in circle Z for W. - user X was invited to circle U by user Z - adjust circles to emit signals of sharing to activity
- Loading branch information
Flávio Gomes da Silva Lisboa
committed
Aug 16, 2018
1 parent
8a2fdbb
commit 6a6ce03
Showing
19 changed files
with
670 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
/** | ||
* Circles - Bring cloud-users closer together. | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Flávio Gomes da Silva Lisboa <flavio.lisboa@fgsl.eti.br> | ||
* @copyright 2018 | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\Circles\Activity; | ||
|
||
use OCP\Activity\IConsumer; | ||
use OCP\Activity\IManager; | ||
use OCA\Activity\Data; | ||
use OCA\Activity\UserSettings; | ||
use OCP\L10N\IFactory; | ||
use OCP\Activity\IEvent; | ||
|
||
class Consumer implements IConsumer { | ||
/** @var Data */ | ||
protected $data; | ||
/** @var IManager */ | ||
protected $manager; | ||
|
||
/** @var UserSettings */ | ||
protected $userSettings; | ||
|
||
/** @var IFactory */ | ||
protected $l10nFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Data $data | ||
* @param IManager $manager | ||
* @param UserSettings $userSettings | ||
* @param IFactory $l10nFactory | ||
*/ | ||
public function __construct(Data $data, IManager $manager, UserSettings $userSettings, IFactory $l10nFactory) { | ||
$this->data = $data; | ||
$this->manager = $manager; | ||
$this->userSettings = $userSettings; | ||
$this->l10nFactory = $l10nFactory; | ||
} | ||
|
||
/** | ||
* Send an event to the notifications of a user | ||
* | ||
* @param IEvent $event | ||
* @return null | ||
*/ | ||
public function receive(IEvent $event) { | ||
$selfAction = $event->getAffectedUser() === $event->getAuthor(); | ||
$emailSetting = $this->userSettings->getUserSetting($event->getAffectedUser(), 'email', $event->getType()); | ||
$emailSetting = ($emailSetting) ? $this->userSettings->getUserSetting($event->getAffectedUser(), 'setting', 'batchtime') : false; | ||
|
||
// User is not the author or wants to see their own actions | ||
$createStream = !$selfAction || $this->userSettings->getUserSetting($event->getAffectedUser(), 'setting', 'self'); | ||
|
||
// Add activity to stream | ||
try { | ||
$this->data->send($event); | ||
} catch (\Exception $e) { | ||
OC::$server->getLogger()->logException($e); | ||
} | ||
// User is not the author or wants to see their own actions | ||
$createEmail = !$selfAction || $this->userSettings->getUserSetting($event->getAffectedUser(), 'setting', 'selfemail'); | ||
|
||
// Add activity to mail queue | ||
if ($emailSetting !== false && $createEmail) { | ||
$latestSend = $event->getTimestamp() + $emailSetting; | ||
$this->data->storeMail($event, $latestSend); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.