migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,74 @@
<?php
namespace OCA\Circles\Activity;
use OCA\Circles\AppInfo\Application;
use OCP\Activity\IFilter;
use OCP\IL10N;
use OCP\IURLGenerator;
class Filter implements IFilter {
/** @var IL10N */
protected $l10n;
/** @var IURLGenerator */
protected $url;
public function __construct(IL10N $l10n, IURLGenerator $url) {
$this->l10n = $l10n;
$this->url = $url;
}
/**
* @return string Lowercase a-z only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return Application::APP_ID;
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l10n->t('Circles');
}
/**
* @return int
* @since 11.0.0
*/
public function getPriority() {
return 10;
}
/**
* @return string Full URL to an icon, empty string when none is given
* @since 11.0.0
*/
public function getIcon() {
return $this->url->getAbsoluteURL(
$this->url->imagePath(Application::APP_ID, 'circles.svg')
);
}
/**
* @param string[] $types
*
* @return string[] An array of allowed apps from which activities should be displayed
* @since 11.0.0
*/
public function filterTypes(array $types) {
return $types;
}
/**
* @return string[] An array of allowed apps from which activities should be displayed
* @since 11.0.0
*/
public function allowedApps() {
return [Application::APP_ID];
}
}
@@ -0,0 +1,275 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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 Exception;
use InvalidArgumentException;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Exceptions\FakeException;
use OCA\Circles\Model\DeprecatedCircle;
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\DeprecatedMember;
use OCA\Circles\Service\CirclesService;
use OCA\Circles\Service\MiscService;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
/**
* Class Provider
*
* @package OCA\Circles\Activity
*/
class Provider implements IProvider {
/** @var ProviderSubjectCircle */
private $parserCircle;
/** @var ProviderSubjectMember */
private $parserMember;
/** @var ProviderSubjectGroup */
private $parserGroup;
/** @var ProviderSubjectLink */
private $parserLink;
/** @var MiscService */
protected $miscService;
/** @var IManager */
protected $activityManager;
public function __construct(
IManager $activityManager, MiscService $miscService, ProviderSubjectCircle $parserCircle,
ProviderSubjectMember $parserMember, ProviderSubjectGroup $parserGroup,
ProviderSubjectLink $parserLink
) {
$this->activityManager = $activityManager;
$this->miscService = $miscService;
$this->parserCircle = $parserCircle;
$this->parserMember = $parserMember;
$this->parserGroup = $parserGroup;
$this->parserLink = $parserLink;
}
/**
* {@inheritdoc}
*/
public function parse($lang, IEvent $event, IEvent $previousEvent = null) {
try {
$params = $event->getSubjectParameters();
$this->initActivityParser($event, $params);
$circle = DeprecatedCircle::fromJSON($params['circle']);
$this->setIcon($event, $circle);
$this->parseAsNonMember($event, $circle, $params);
$this->parseAsMember($event, $circle, $params);
$this->parseAsModerator($event, $circle, $params);
} catch (FakeException $e) {
/** clean exit */
}
return $event;
}
/**
* @param IEvent $event
* @param array $params
*/
private function initActivityParser(IEvent $event, $params) {
if ($event->getApp() !== Application::APP_ID) {
throw new InvalidArgumentException();
}
if (!key_exists('circle', $params)) {
throw new InvalidArgumentException();
}
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
*/
private function setIcon(IEvent $event, DeprecatedCircle $circle) {
$event->setIcon(
CirclesService::getCircleIcon(
$circle->getType(),
(method_exists($this->activityManager, 'getRequirePNG')
&& $this->activityManager->getRequirePNG())
)
);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseAsNonMember(IEvent $event, DeprecatedCircle $circle, $params) {
if ($event->getType() !== 'circles_as_non_member') {
return;
}
$this->parserCircle->parseSubjectCircleCreate($event, $circle);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseAsMember(IEvent $event, DeprecatedCircle $circle, $params) {
if ($event->getType() !== 'circles_as_member') {
return;
}
// $this->parserCircle->parseSubjectCircleCreate($event, $circle);
$this->parserCircle->parseSubjectCircleDelete($event, $circle);
$this->parseMemberAsMember($event, $circle, $params);
}
/**
* @param DeprecatedCircle $circle
* @param IEvent $event
* @param array $params
*
* @throws Exception
*/
private function parseAsModerator(IEvent $event, DeprecatedCircle $circle, $params) {
if ($event->getType() !== 'circles_as_moderator') {
return;
}
$this->parseMemberAsModerator($event, $circle, $params);
$this->parseGroupAsModerator($event, $circle, $params);
$this->parseLinkAsModerator($event, $circle, $params);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseMemberAsMember(IEvent $event, DeprecatedCircle $circle, $params) {
if (!key_exists('member', $params)) {
return;
}
$member = DeprecatedMember::fromJSON($params['member']);
$this->parserMember->parseSubjectMemberJoin($event, $circle, $member);
$this->parserMember->parseSubjectMemberAdd($event, $circle, $member);
$this->parserMember->parseSubjectMemberLeft($event, $circle, $member);
$this->parserMember->parseSubjectMemberRemove($event, $circle, $member);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseGroupAsModerator(IEvent $event, DeprecatedCircle $circle, $params) {
if (!key_exists('group', $params)) {
return;
}
$group = DeprecatedMember::fromJSON($params['group']);
$this->parserGroup->parseGroupLink($event, $circle, $group);
$this->parserGroup->parseGroupUnlink($event, $circle, $group);
$this->parserGroup->parseGroupLevel($event, $circle, $group);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseMemberAsModerator(IEvent $event, DeprecatedCircle $circle, $params) {
if (!key_exists('member', $params)) {
return;
}
$member = DeprecatedMember::fromJSON($params['member']);
$this->parserMember->parseMemberInvited($event, $circle, $member);
$this->parserMember->parseMemberLevel($event, $circle, $member);
$this->parserMember->parseMemberRequestInvitation($event, $circle, $member);
$this->parserMember->parseMemberOwner($event, $circle, $member);
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param array $params
*
* @throws FakeException
*/
private function parseLinkAsModerator(IEvent $event, DeprecatedCircle $circle, $params) {
if (!key_exists('link', $params)) {
return;
}
$remote = FederatedLink::fromJSON($params['link']);
$this->parserLink->parseLinkRequestSent($event, $circle, $remote);
$this->parserLink->parseLinkRequestReceived($event, $circle, $remote);
$this->parserLink->parseLinkRequestRejected($event, $circle, $remote);
$this->parserLink->parseLinkRequestCanceled($event, $circle, $remote);
$this->parserLink->parseLinkRequestAccepted($event, $circle, $remote);
$this->parserLink->parseLinkRequestRemoved($event, $circle, $remote);
$this->parserLink->parseLinkRequestCanceling($event, $circle, $remote);
$this->parserLink->parseLinkRequestAccepting($event, $circle, $remote);
$this->parserLink->parseLinkUp($event, $circle, $remote);
$this->parserLink->parseLinkDown($event, $circle, $remote);
$this->parserLink->parseLinkRemove($event, $circle, $remote);
}
}
@@ -0,0 +1,376 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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\Api\v1\Circles;
use OCA\Circles\Model\DeprecatedCircle;
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\DeprecatedMember;
use OCA\Circles\Service\MiscService;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\IL10N;
use OCP\IURLGenerator;
class ProviderParser {
/** @var MiscService */
protected $miscService;
/** @var IL10N */
protected $l10n;
/** @var IURLGenerator */
protected $url;
/** @var IManager */
protected $activityManager;
public function __construct(
IURLGenerator $url, IManager $activityManager, IL10N $l10n, MiscService $miscService
) {
$this->url = $url;
$this->activityManager = $activityManager;
$this->l10n = $l10n;
$this->miscService = $miscService;
}
/**
* general function to generate Circle event.
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink|null $remote
* @param string $ownEvent
* @param string $othersEvent
*/
protected function parseCircleEvent(IEvent $event, DeprecatedCircle $circle, $remote, $ownEvent, $othersEvent
) {
$data = [
'author' => $this->generateViewerParameter($circle),
'circle' => $this->generateCircleParameter($circle)
];
$remoteCircle = $this->generateRemoteCircleParameter($remote);
if ($remoteCircle !== null) {
$data['remote'] = $remoteCircle;
}
if ($this->isViewerTheAuthor($circle, $this->activityManager->getCurrentUserId())) {
$this->setSubject($event, $ownEvent, $data);
return;
}
$this->setSubject($event, $othersEvent, $data);
}
/**
* @param IEvent $event
* @param string $line
* @param array $data
*/
protected function setSubject(IEvent $event, $line, $data) {
$this->setParsedSubject($event, $line, $data);
$this->setRichSubject($event, $line, $data);
}
/**
* @param IEvent $event
* @param string $line
* @param array $data
*/
protected function setRichSubject(IEvent $event, $line, $data) {
$ak = array_keys($data);
foreach ($ak as $k) {
$subAk = array_keys($data[$k]);
foreach ($subAk as $sK) {
if (substr($sK, 0, 1) === '_') {
unset($data[$k][$sK]);
}
}
}
$event->setRichSubject($line, $data);
}
/**
* @param IEvent $event
* @param string $line
* @param array $data
*/
protected function setParsedSubject(IEvent $event, $line, $data) {
$ak = array_keys($data);
$replace = [];
foreach ($ak as $k) {
if (!key_exists('_parsed', $data[$k])) {
continue;
}
$replace['{' . $k . '}'] = $data[$k]['_parsed'];
}
$line = strtr($line, $replace);
$event->setParsedSubject($line);
}
/**
* general function to generate Member event.
*
* @param DeprecatedCircle $circle
* @param $member
* @param IEvent $event
* @param $ownEvent
* @param $othersEvent
*/
protected function parseMemberEvent(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member, $ownEvent, $othersEvent
) {
$data = [
'circle' => $this->generateCircleParameter($circle),
'member' => $this->generateUserParameter($member)
];
if ($member->getUserId() === $this->activityManager->getCurrentUserId()
) {
$this->setSubject($event, $ownEvent, $data);
return;
}
$this->setSubject($event, $othersEvent, $data);
}
/**
* general function to generate Link event.
*
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
* @param IEvent $event
* @param string $line
*/
protected function parseLinkEvent(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote, $line
) {
$data = [
'circle' => $this->generateCircleParameter($circle),
'remote' => $this->generateRemoteCircleParameter($remote)
];
$this->setSubject($event, $line, $data);
}
/**
* general function to generate Circle+Member event.
*
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
* @param IEvent $event
* @param string $ownEvent
* @param string $othersEvent
*/
protected function parseCircleMemberEvent(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member, $ownEvent, $othersEvent
) {
$data = [
'author' => $this->generateViewerParameter($circle),
'circle' => $this->generateCircleParameter($circle),
'member' => $this->generateUserParameter($member),
'external' => $this->generateExternalMemberParameter($member),
'group' => $this->generateGroupParameter($member),
];
if ($this->isViewerTheAuthor($circle, $this->activityManager->getCurrentUserId())) {
$this->setSubject($event, $ownEvent, $data);
return;
}
$this->setSubject($event, $othersEvent, $data);
}
/**
* general function to generate Circle+Member advanced event.
*
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
* @param IEvent $event
* @param $ownEvent
* @param $targetEvent
* @param $othersEvent
*/
protected function parseCircleMemberAdvancedEvent(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member, $ownEvent, $targetEvent, $othersEvent
) {
$data = [
'author' => $this->generateViewerParameter($circle),
'circle' => $this->generateCircleParameter($circle),
'member' => $this->generateUserParameter($member)
];
if ($this->isViewerTheAuthor($circle, $this->activityManager->getCurrentUserId())) {
$this->setSubject($event, $ownEvent, $data);
return;
}
if ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
$this->setSubject($event, $targetEvent, $data);
return;
}
$this->setSubject($event, $othersEvent, $data);
}
/**
* @param DeprecatedCircle $circle
* @param string $userId
*
* @return bool
*/
protected function isViewerTheAuthor(DeprecatedCircle $circle, $userId) {
if ($circle->getViewer() === null) {
return false;
}
if ($circle->getViewer()
->getUserId() === $userId) {
return true;
}
return false;
}
/**
* @param DeprecatedCircle $circle
*
* @return string|array <string,string|integer>
*/
protected function generateViewerParameter(DeprecatedCircle $circle) {
if ($circle->getViewer() === null) {
return [];
}
return $this->generateUserParameter($circle->getViewer());
}
/**
* @param DeprecatedMember $member
*
* @return array|string <string,string|integer>
*/
protected function generateExternalMemberParameter(DeprecatedMember $member) {
return [
'type' => $member->getTypeName(),
'id' => $member->getUserId(),
'name' => $member->getCachedName() . ' (' . $member->getTypeString() . ')',
'_parsed' => $member->getCachedName()
];
}
/**
* @param DeprecatedCircle $circle
*
* @return array<string,string|integer>
*/
protected function generateCircleParameter(DeprecatedCircle $circle) {
return [
'type' => 'circle',
'id' => $circle->getId(),
'name' => $circle->getName(),
'_parsed' => $circle->getName(),
'link' => Circles::generateAbsoluteLink($circle->getUniqueId())
];
}
/**
* @param FederatedLink $link
*
* @return array<string,string|integer>
*/
protected function generateRemoteCircleParameter($link) {
if ($link === null) {
return null;
}
return [
'type' => 'circle',
'id' => $link->getUniqueId(),
'name' => $link->getToken() . '@' . $link->getAddress(),
'_parsed' => $link->getToken() . '@' . $link->getAddress()
];
}
/**
* @param DeprecatedMember $member
*
* @return array <string,string|integer>
*/
protected function generateUserParameter(DeprecatedMember $member) {
$display = $member->getCachedName();
if ($display === '') {
$display = $member->getUserId();
}
return [
'type' => 'user',
'id' => $member->getUserId(),
'name' => $display,
'_parsed' => $display
];
}
/**
* @param DeprecatedMember $group
*
* @return array <string,string|integer>
*/
protected function generateGroupParameter($group) {
return [
'type' => 'user-group',
'id' => $group->getUserId(),
'name' => $group->getUserId(),
'_parsed' => $group->getUserId()
];
}
}
@@ -0,0 +1,75 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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\DeprecatedCircle;
use OCP\Activity\IEvent;
class ProviderSubjectCircle extends ProviderParser {
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
*
* @throws FakeException
*/
public function parseSubjectCircleCreate(IEvent $event, DeprecatedCircle $circle) {
if ($event->getSubject() !== 'circle_create') {
return;
}
$this->parseCircleEvent(
$event, $circle, null,
$this->l10n->t('You created the circle {circle}'),
$this->l10n->t('{author} created the circle {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
*
* @throws FakeException
*/
public function parseSubjectCircleDelete(IEvent $event, DeprecatedCircle $circle) {
if ($event->getSubject() !== 'circle_delete') {
return;
}
$this->parseCircleEvent(
$event, $circle, null,
$this->l10n->t('You deleted {circle}'),
$this->l10n->t('{author} deleted {circle}')
);
throw new FakeException();
}
}
@@ -0,0 +1,101 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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\DeprecatedCircle;
use OCA\Circles\Model\DeprecatedMember;
use OCP\Activity\IEvent;
class ProviderSubjectGroup extends ProviderParser {
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $group
*
* @throws FakeException
*/
public function parseGroupLink(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $group) {
if ($event->getSubject() !== 'group_link') {
return;
}
$this->parseCircleMemberEvent(
$event, $circle, $group,
$this->l10n->t('You linked {group} to {circle}'),
$this->l10n->t('{group} has been linked to {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $group
*
* @throws FakeException
*/
public function parseGroupUnlink(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $group) {
if ($event->getSubject() !== 'group_unlink') {
return;
}
$this->parseCircleMemberEvent(
$event, $circle, $group,
$this->l10n->t('You unlinked {group} from {circle}'),
$this->l10n->t('{group} has been unlinked from {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $group
*
* @throws FakeException
*/
public function parseGroupLevel(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $group) {
if ($event->getSubject() !== 'group_level') {
return;
}
$l = $this->l10n;
$level = [$l->t($group->getLevelString())];
$this->parseCircleMemberEvent(
$event, $circle, $group,
$l->t('You changed the level of the linked group {group} in {circle} to %1$s', $level),
$l->t('{author} changed the level of the linked group {group} in {circle} to %1$s', $level)
);
throw new FakeException();
}
}
@@ -0,0 +1,273 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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\DeprecatedCircle;
use OCA\Circles\Model\FederatedLink;
use OCP\Activity\IEvent;
class ProviderSubjectLink extends ProviderParser {
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestSent(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_sent') {
return;
}
$this->parseCircleEvent(
$event, $circle, $remote,
$this->l10n->t('You sent a request to link {circle} with {remote}'),
$this->l10n->t('{author} sent a request to link {circle} with {remote}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestReceived(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_received') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote, $this->l10n->t('{remote} requested a link with {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestRejected(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_rejected') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote,
$this->l10n->t('The request to link {circle} with {remote} has been rejected')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestCanceled(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_canceled') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote,
$this->l10n->t(
'The request to link {remote} with {circle} has been canceled remotely'
)
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestAccepted(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_accepted') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote,
$this->l10n->t('The request to link {circle} with {remote} has been accepted')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestRemoved(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_removed') {
return;
}
$this->parseCircleEvent(
$event, $circle, $remote,
$this->l10n->t('You dismissed the request to link {remote} with {circle}'),
$this->l10n->t('{author} dismissed the request to link {remote} with {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestCanceling(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_canceling') {
return;
}
$this->parseCircleEvent(
$event, $circle, $remote,
$this->l10n->t('You canceled the request to link {circle} with {remote}'),
$this->l10n->t('{author} canceled the request to link {circle} with {remote}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRequestAccepting(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_request_accepting') {
return;
}
$this->parseCircleEvent(
$event, $circle, $remote,
$this->l10n->t('You accepted the request to link {remote} with {circle}'),
$this->l10n->t('{author} accepted the request to link {remote} with {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkUp(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_up') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote,
$this->l10n->t('A link between {circle} and {remote} is now up and running')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkDown(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_down') {
return;
}
$this->parseLinkEvent(
$event, $circle, $remote,
$this->l10n->t(
'The link between {circle} and {remote} has been shutdown remotely'
)
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param FederatedLink $remote
*
* @throws FakeException
*/
public function parseLinkRemove(IEvent $event, DeprecatedCircle $circle, FederatedLink $remote) {
if ($event->getSubject() !== 'link_remove') {
return;
}
$this->parseCircleEvent(
$event, $circle, $remote,
$this->l10n->t('You closed the link between {circle} and {remote}'),
$this->l10n->t('{author} closed the link between {circle} and {remote}')
);
throw new FakeException();
}
}
@@ -0,0 +1,410 @@
<?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 Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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\DeprecatedCircle;
use OCA\Circles\Model\DeprecatedMember;
use OCP\Activity\IEvent;
class ProviderSubjectMember extends ProviderParser {
/**
* Parse on Subject 'member_join'.
* If circle is closed, we say that user accepted his invitation.
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseSubjectMemberJoin(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_join') {
return;
}
$this->parseSubjectMemberJoinClosedCircle($event, $circle, $member);
$this->parseCircleMemberEvent(
$event, $circle, $member, $this->l10n->t('You joined {circle}'),
$this->l10n->t('{member} joined {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectMemberJoinClosedCircle(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($circle->getType() !== DeprecatedCircle::CIRCLES_CLOSED) {
return;
}
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t('You accepted the invitation to join {circle}'),
$this->l10n->t('{member} accepted the invitation to join {circle}')
);
throw new FakeException();
}
/**
* Parse on Subject 'member_add'.
* If circle is closed, we say that user's invitation was accepted.
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseSubjectMemberAdd(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_add') {
return;
}
$this->parseSubjectMemberAddNotLocalMember($event, $circle, $member);
$this->parseSubjectMemberAddClosedCircle($event, $circle, $member);
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t('You added {member} as member to {circle}'),
$this->l10n->t('You have been added as member to {circle} by {author}'),
$this->l10n->t('{member} has been added as member to {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectMemberAddNotLocalMember(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member
) {
if ($member->getType() === DeprecatedMember::TYPE_USER) {
return;
}
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t('You added {external} to {circle}'),
$this->l10n->t('{external} has been added to {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectMemberAddClosedCircle(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($circle->getType() !== DeprecatedCircle::CIRCLES_CLOSED) {
return;
}
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t("You accepted {member}'s request to join {circle}"),
$this->l10n->t('Your request to join {circle} has been accepted by {author}'),
$this->l10n->t("{member}'s request to join {circle} has been accepted by {author}")
);
throw new FakeException();
}
/**
* Parse on Subject 'member_left'.
* If circle is closed and member was not a real member, we send him to
* parseSubjectNonMemberLeftClosedCircle();
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseSubjectMemberLeft(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_left') {
return;
}
$this->parseSubjectNonMemberLeftClosedCircle($event, $circle, $member);
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t('You left {circle}'),
$this->l10n->t('{member} left {circle}')
);
throw new FakeException();
}
/**
* Parse on Subject 'member_left' on a closed circle when user were not yet a member.
* If status is Invited we say that member rejected his invitation.
* If status is Requested we say he dismissed his request.
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectNonMemberLeftClosedCircle(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member
) {
if ($circle->getType() !== DeprecatedCircle::CIRCLES_CLOSED
|| $member->getLevel() !== DeprecatedMember::LEVEL_NONE) {
return;
}
if ($member->getStatus() === DeprecatedMember::STATUS_INVITED) {
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t("You declined the invitation to join {circle}"),
$this->l10n->t("{member} declined an invitation to join {circle}")
);
} else {
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t("You cancelled your request to join {circle}"),
$this->l10n->t("{member} cancelled his request to join {circle}")
);
}
throw new FakeException();
}
/**
* Parse on Subject 'member_remove'.
* If circle is closed and member was not a real member, we send him to
* parseSubjectNonMemberRemoveClosedCircle();
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseSubjectMemberRemove(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_remove') {
return;
}
$this->parseSubjectMemberRemoveNotLocalMember($event, $circle, $member);
$this->parseSubjectMemberRemoveNotYetMember($event, $circle, $member);
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t('You removed {member} from {circle}'),
$this->l10n->t('You have been removed from {circle} by {author}'),
$this->l10n->t('{member} has been removed from {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectMemberRemoveNotLocalMember(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member
) {
if ($member->getType() === DeprecatedMember::TYPE_USER) {
return;
}
$this->parseCircleMemberEvent(
$event, $circle, $member,
$this->l10n->t('You removed {external} from {circle}'),
$this->l10n->t('{external} has been removed from {circle} by {author}')
);
throw new FakeException();
}
/**
* Parse on Subject 'member_remove' on a closed circle when user were not yet a member.
* If status is Invited we say that author cancelled his invitation.
* If status is Requested we say that his invitation was rejected.
*
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
private function parseSubjectMemberRemoveNotYetMember(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member
) {
if ($circle->getType() !== DeprecatedCircle::CIRCLES_CLOSED
|| $member->getLevel() !== DeprecatedMember::LEVEL_NONE) {
return;
}
$this->parseSubjectMemberRemoveNotYetMemberRequesting($event, $circle, $member);
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t("You cancelled {member}'s invitation to join {circle}"),
$this->l10n->t('Your invitation to join {circle} has been cancelled by {author}'),
$this->l10n->t("{author} cancelled {member}'s invitation to join {circle}")
);
throw new FakeException();
}
private function parseSubjectMemberRemoveNotYetMemberRequesting(
IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member
) {
if ($member->getStatus() !== DeprecatedMember::STATUS_REQUEST) {
return;
}
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t("You dismissed {member}'s request to join {circle}"),
$this->l10n->t('Your request to join {circle} has been dismissed by {author}'),
$this->l10n->t("{member}'s request to join {circle} has been dismissed by {author}")
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseMemberInvited(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_invited') {
return;
}
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t('You invited {member} to join {circle}'),
$this->l10n->t('You have been invited to join {circle} by {author}'),
$this->l10n->t('{member} has been invited to join {circle} by {author}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseMemberLevel(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_level') {
return;
}
$level = [$this->l10n->t($member->getLevelString())];
$this->parseCircleMemberAdvancedEvent(
$event, $circle, $member,
$this->l10n->t('You changed {member}\'s level in {circle} to %1$s', $level),
$this->l10n->t('{author} changed your level in {circle} to %1$s', $level),
$this->l10n->t('{author} changed {member}\'s level in {circle} to %1$s', $level)
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseMemberRequestInvitation(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_request_invitation') {
return;
}
$this->parseMemberEvent(
$event, $circle, $member,
$this->l10n->t('You sent a request to join {circle}'),
$this->l10n->t('{member} sent a request to join {circle}')
);
throw new FakeException();
}
/**
* @param IEvent $event
* @param DeprecatedCircle $circle
* @param DeprecatedMember $member
*
* @throws FakeException
*/
public function parseMemberOwner(IEvent $event, DeprecatedCircle $circle, DeprecatedMember $member) {
if ($event->getSubject() !== 'member_owner') {
return;
}
$this->parseMemberEvent(
$event, $circle, $member,
$this->l10n->t('You are the new owner of {circle}'),
$this->l10n->t('{member} is the new owner of {circle}')
);
throw new FakeException();
}
}
@@ -0,0 +1,84 @@
<?php
namespace OCA\Circles\Activity;
use OCP\Activity\ISetting;
use OCP\IL10N;
class SettingAsMember implements ISetting {
/** @var IL10N */
protected $l10n;
/**
* @param IL10N $l10n
*/
public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'circles_as_member';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l10n->t('On events happening in a <strong>Circle</strong> of which you are a member');
}
/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority() {
return 60;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function canChangeStream() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledStream() {
return true;
}
/**
* @return bool True when the option can be changed for the mail
* @since 11.0.0
*/
public function canChangeMail() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledMail() {
return false;
}
}
@@ -0,0 +1,76 @@
<?php
namespace OCA\Circles\Activity;
use OCP\Activity\ISetting;
use OCP\IL10N;
class SettingAsModerator implements ISetting {
/** @var IL10N */
protected $l10n;
/**
* @param IL10N $l10n
*/
public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'circles_as_moderator';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l10n->t('Any important event in a <strong>Circle</strong> you are moderating');
}
/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority() {
return 60;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function canChangeStream() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledStream() {
return true;
}
/**
* @return bool True when the option can be changed for the mail
* @since 11.0.0
*/
public function canChangeMail() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledMail() {
return true;
}
}
@@ -0,0 +1,89 @@
<?php
namespace OCA\Circles\Activity;
use OCP\Activity\ISetting;
use OCP\IL10N;
/**
* Class SettingAsNonMember
*
* @package OCA\Circles\Activity
*/
class SettingAsNonMember implements ISetting {
/** @var IL10N */
protected $l10n;
/**
* @param IL10N $l10n
*/
public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'circles_as_non_member';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l10n->t('On global events happening in any <strong>Circle</strong>');
}
/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority() {
return 60;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function canChangeStream() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledStream() {
return false;
}
/**
* @return bool True when the option can be changed for the mail
* @since 11.0.0
*/
public function canChangeMail() {
return true;
}
/**
* @return bool True when the option can be changed for the stream
* @since 11.0.0
*/
public function isDefaultEnabledMail() {
return false;
}
}