-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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 8bf3788
Showing
15 changed files
with
621 additions
and
36 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
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
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,109 @@ | ||
<?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 OCA\Circles\Exceptions\FakeException; | ||
use OCA\Circles\Model\Circle; | ||
use OCA\Circles\Model\FederatedLink; | ||
use OCA\Circles\Model\Member; | ||
use OCP\Activity\IEvent; | ||
use OCA\Circles\Api\v1\Circles; | ||
|
||
class ProviderSubjectShared extends ProviderParser { | ||
/** | ||
* @param IEvent $event | ||
* @param array $params | ||
* | ||
* @throws FakeException | ||
*/ | ||
public function parseSubjectSharedWithCircle(IEvent &$event, array $params) { | ||
$this->parseSharedEvent( | ||
$event, $params, null, | ||
$this->l10n->t('You shared {file} with circle {circle}'), | ||
$this->l10n->t('{author} shared {file} with the circle {circle}') | ||
); | ||
} | ||
|
||
/** | ||
* @param IEvent $event | ||
* @param array $params | ||
* | ||
* @throws FakeException | ||
*/ | ||
public function parseSubjectUnsharedWithCircle(IEvent &$event, array $params) { | ||
$this->parseSharedEvent( | ||
$event, $params, null, | ||
$this->l10n->t('You unshared {file} with the circle {circle}'), | ||
$this->l10n->t('{author} unshared {file} with the circle {circle}') | ||
); | ||
} | ||
|
||
/** | ||
* general function to generate Circle event. | ||
* | ||
* @param IEvent $event | ||
* @param array $params | ||
* @param FederatedLink|null $remote | ||
* @param string $ownEvent | ||
* @param string $othersEvent | ||
*/ | ||
protected function parseSharedEvent(IEvent &$event, array $params, $remote, $ownEvent, $othersEvent | ||
) { | ||
$circle = Circles::infoCircleByName($params['circle']['name']); | ||
$path = Circles::getViewPath($params['file']['id']); | ||
|
||
$data = [ | ||
'author' => [ | ||
'type' => 'user', | ||
'id' => $params['author']['id'], | ||
'name' => $params['author']['name'], | ||
'_parsed' => $params['author']['name'] | ||
], | ||
'circle' => [ | ||
'type' => 'circle', | ||
'id' => $circle->getId(), | ||
'name' => $circle->getName(), | ||
'_parsed' => $circle->getName(), | ||
'link' => Circles::generateLink($circle->getUniqueId()) | ||
], | ||
'file' => [ | ||
'type' => 'file', | ||
'id' => $params['file']['id'], | ||
'name' => $params['file']['name'], | ||
'path' => $path, | ||
'link' => \OC::$server->getURLGenerator ()->linkToRouteAbsolute('files.view.index', array ( | ||
'dir' => ($params['file']['type'] !== 'file') ? dirname($path) : $path) ) | ||
] | ||
]; | ||
|
||
if ($this->isViewerTheAuthor($circle, $this->activityManager->getCurrentUserId())) { | ||
$this->setSubject($event, $ownEvent, $data); | ||
return; | ||
} | ||
|
||
$this->setSubject($event, $othersEvent, $data); | ||
} | ||
} |
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.