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,100 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
*
* @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\Files_Sharing\Activity;
use OCP\Activity\IFilter;
use OCP\IL10N;
use OCP\IURLGenerator;
class Filter implements IFilter {
public const TYPE_REMOTE_SHARE = 'remote_share';
public const TYPE_SHARED = 'shared';
/** @var IL10N */
protected $l;
/** @var IURLGenerator */
protected $url;
public function __construct(IL10N $l, IURLGenerator $url) {
$this->l = $l;
$this->url = $url;
}
/**
* @return string Lowercase a-z only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'files_sharing';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l->t('File shares');
}
/**
* @return int
* @since 11.0.0
*/
public function getPriority() {
return 31;
}
/**
* @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('core', 'actions/share.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 array_intersect([
self::TYPE_SHARED,
self::TYPE_REMOTE_SHARE,
'file_downloaded',
], $types);
}
/**
* @return string[] An array of allowed apps from which activities should be displayed
* @since 11.0.0
*/
public function allowedApps() {
return [
'files_sharing',
'files_downloadactivity',
];
}
}
@@ -0,0 +1,228 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\Contacts\IManager as IContactsManager;
use OCP\Federation\ICloudIdManager;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\L10N\IFactory;
abstract class Base implements IProvider {
/** @var IFactory */
protected $languageFactory;
/** @var IL10N */
protected $l;
/** @var IURLGenerator */
protected $url;
/** @var IManager */
protected $activityManager;
/** @var IUserManager */
protected $userManager;
/** @var IEventMerger */
protected $eventMerger;
/** @var IContactsManager */
protected $contactsManager;
/** @var ICloudIdManager */
protected $cloudIdManager;
/** @var array */
protected $displayNames = [];
public function __construct(IFactory $languageFactory,
IURLGenerator $url,
IManager $activityManager,
IUserManager $userManager,
ICloudIdManager $cloudIdManager,
IContactsManager $contactsManager,
IEventMerger $eventMerger) {
$this->languageFactory = $languageFactory;
$this->url = $url;
$this->activityManager = $activityManager;
$this->userManager = $userManager;
$this->cloudIdManager = $cloudIdManager;
$this->contactsManager = $contactsManager;
$this->eventMerger = $eventMerger;
}
/**
* @param string $language
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
if ($event->getApp() !== 'files_sharing') {
throw new \InvalidArgumentException();
}
$this->l = $this->languageFactory->get('files_sharing', $language);
if ($this->activityManager->isFormattingFilteredObject()) {
try {
return $this->parseShortVersion($event);
} catch (\InvalidArgumentException $e) {
// Ignore and simply use the long version...
}
}
return $this->parseLongVersion($event, $previousEvent);
}
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
abstract protected function parseShortVersion(IEvent $event);
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
abstract protected function parseLongVersion(IEvent $event, IEvent $previousEvent = null);
/**
* @throws \InvalidArgumentException
*/
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
$event->setRichSubject($subject, $parameters);
}
/**
* @param array|string $parameter
* @param IEvent|null $event
* @return array
* @throws \InvalidArgumentException
*/
protected function getFile($parameter, IEvent $event = null) {
if (is_array($parameter)) {
$path = reset($parameter);
$id = (string) key($parameter);
} elseif ($event !== null) {
// Legacy from before ownCloud 8.2
$path = $parameter;
$id = $event->getObjectId();
} else {
throw new \InvalidArgumentException('Could not generate file parameter');
}
return [
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
/**
* @param string $uid
* @param string $overwriteDisplayName - overwrite display name, only if user is not local
*
* @return array
*/
protected function getUser(string $uid, string $overwriteDisplayName = '') {
// First try local user
$displayName = $this->userManager->getDisplayName($uid);
if ($displayName !== null) {
return [
'type' => 'user',
'id' => $uid,
'name' => $displayName,
];
}
// Then a contact from the addressbook
if ($this->cloudIdManager->isValidCloudId($uid)) {
$cloudId = $this->cloudIdManager->resolveCloudId($uid);
return [
'type' => 'user',
'id' => $cloudId->getUser(),
'name' => (($overwriteDisplayName !== '') ? $overwriteDisplayName : $this->getDisplayNameFromAddressBook($cloudId->getDisplayId())),
'server' => $cloudId->getRemote(),
];
}
// Fallback to empty dummy data
return [
'type' => 'user',
'id' => $uid,
'name' => (($overwriteDisplayName !== '') ? $overwriteDisplayName : $uid),
];
}
protected function getDisplayNameFromAddressBook(string $search): string {
if (isset($this->displayNames[$search])) {
return $this->displayNames[$search];
}
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD'], [
'limit' => 1,
'enumeration' => false,
'fullmatch' => false,
'strict_search' => true,
]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
}
if (isset($contact['CLOUD'])) {
$cloudIds = $contact['CLOUD'];
if (is_string($cloudIds)) {
$cloudIds = [$cloudIds];
}
$lowerSearch = strtolower($search);
foreach ($cloudIds as $cloudId) {
if (strtolower($cloudId) === $lowerSearch) {
$this->displayNames[$search] = $contact['FN'] . " ($cloudId)";
return $this->displayNames[$search];
}
}
}
}
return $search;
}
}
@@ -0,0 +1,141 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
class Downloads extends Base {
public const SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED = 'public_shared_file_downloaded';
public const SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED = 'public_shared_folder_downloaded';
public const SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED = 'file_shared_with_email_downloaded';
public const SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED = 'folder_shared_with_email_downloaded';
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
$event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
$subject = $this->l->t('Downloaded via public link');
} elseif ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
$event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
$subject = $this->l->t('Downloaded by {email}');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
$event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
if (!isset($parsedParameters['remote-address-hash']['type'])) {
$subject = $this->l->t('{file} downloaded via public link');
$this->setSubjects($event, $subject, $parsedParameters);
} else {
$subject = $this->l->t('{file} downloaded via public link');
$this->setSubjects($event, $subject, $parsedParameters);
$event = $this->eventMerger->mergeEvents('file', $event, $previousEvent);
}
} elseif ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
$event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
$subject = $this->l->t('{email} downloaded {file}');
$this->setSubjects($event, $subject, $parsedParameters);
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
}
return $event;
}
/**
* @param IEvent $event
* @return array
* @throws \InvalidArgumentException
*/
protected function getParsedParameters(IEvent $event) {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
switch ($subject) {
case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
if (isset($parameters[1])) {
return [
'file' => $this->getFile($parameters[0], $event),
'remote-address-hash' => [
'type' => 'highlight',
'id' => $parameters[1],
'name' => $parameters[1],
'link' => '',
],
];
}
return [
'file' => $this->getFile($parameters[0], $event),
];
case self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED:
case self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED:
return [
'file' => $this->getFile($parameters[0], $event),
'email' => [
'type' => 'email',
'id' => $parameters[1],
'name' => $parameters[1],
],
];
}
throw new \InvalidArgumentException();
}
}
@@ -0,0 +1,182 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
use OCP\Contacts\IManager as IContactsManager;
use OCP\Federation\ICloudIdManager;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\L10N\IFactory;
class Groups extends Base {
public const SUBJECT_SHARED_GROUP_SELF = 'shared_group_self';
public const SUBJECT_RESHARED_GROUP_BY = 'reshared_group_by';
public const SUBJECT_UNSHARED_GROUP_SELF = 'unshared_group_self';
public const SUBJECT_UNSHARED_GROUP_BY = 'unshared_group_by';
public const SUBJECT_EXPIRED_GROUP = 'expired_group';
/** @var IGroupManager */
protected $groupManager;
/** @var string[] */
protected $groupDisplayNames = [];
public function __construct(IFactory $languageFactory,
IURLGenerator $url,
IManager $activityManager,
IUserManager $userManager,
ICloudIdManager $cloudIdManager,
IContactsManager $contactsManager,
IEventMerger $eventMerger,
IGroupManager $groupManager) {
parent::__construct($languageFactory, $url, $activityManager, $userManager, $cloudIdManager, $contactsManager, $eventMerger);
$this->groupManager = $groupManager;
}
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_GROUP_SELF) {
$subject = $this->l->t('Shared with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_GROUP_SELF) {
$subject = $this->l->t('Removed share for group {group}');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_GROUP_BY) {
$subject = $this->l->t('{actor} shared with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_GROUP_BY) {
$subject = $this->l->t('{actor} removed share for group {group}');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_GROUP) {
$subject = $this->l->t('Share for group {group} expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_GROUP_SELF) {
$subject = $this->l->t('You shared {file} with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_GROUP_SELF) {
$subject = $this->l->t('You removed group {group} from {file}');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_GROUP_BY) {
$subject = $this->l->t('{actor} shared {file} with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_GROUP_BY) {
$subject = $this->l->t('{actor} removed group {group} from {file}');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_GROUP) {
$subject = $this->l->t('Share for file {file} with group {group} expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
protected function getParsedParameters(IEvent $event) {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
switch ($subject) {
case self::SUBJECT_RESHARED_GROUP_BY:
case self::SUBJECT_UNSHARED_GROUP_BY:
return [
'file' => $this->getFile($parameters[0], $event),
'group' => $this->generateGroupParameter($parameters[2]),
'actor' => $this->getUser($parameters[1]),
];
case self::SUBJECT_SHARED_GROUP_SELF:
case self::SUBJECT_UNSHARED_GROUP_SELF:
case self::SUBJECT_EXPIRED_GROUP:
return [
'file' => $this->getFile($parameters[0], $event),
'group' => $this->generateGroupParameter($parameters[1]),
];
}
return [];
}
/**
* @param string $gid
* @return array
*/
protected function generateGroupParameter($gid) {
if (!isset($this->groupDisplayNames[$gid])) {
$this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid);
}
return [
'type' => 'user-group',
'id' => $gid,
'name' => $this->groupDisplayNames[$gid],
];
}
/**
* @param string $gid
* @return string
*/
protected function getGroupDisplayName($gid) {
$group = $this->groupManager->get($gid);
if ($group instanceof IGroup) {
return $group->getDisplayName();
}
return $gid;
}
}
@@ -0,0 +1,128 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
class PublicLinks extends Base {
public const SUBJECT_SHARED_LINK_SELF = 'shared_link_self';
public const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by';
public const SUBJECT_UNSHARED_LINK_SELF = 'unshared_link_self';
public const SUBJECT_UNSHARED_LINK_BY = 'unshared_link_by';
public const SUBJECT_LINK_EXPIRED = 'link_expired';
public const SUBJECT_LINK_BY_EXPIRED = 'link_by_expired';
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
$subject = $this->l->t('Shared as public link');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
$subject = $this->l->t('Removed public link');
} elseif ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
$subject = $this->l->t('Public link expired');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
$subject = $this->l->t('{actor} shared as public link');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
$subject = $this->l->t('{actor} removed public link');
} elseif ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
$subject = $this->l->t('Public link of {actor} expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
$subject = $this->l->t('You shared {file} as public link');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
$subject = $this->l->t('You removed public link for {file}');
} elseif ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
$subject = $this->l->t('Public link expired for {file}');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
$subject = $this->l->t('{actor} shared {file} as public link');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
$subject = $this->l->t('{actor} removed public link for {file}');
} elseif ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
$subject = $this->l->t('Public link of {actor} for {file} expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
protected function getParsedParameters(IEvent $event) {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
switch ($subject) {
case self::SUBJECT_SHARED_LINK_SELF:
case self::SUBJECT_UNSHARED_LINK_SELF:
case self::SUBJECT_LINK_EXPIRED:
return [
'file' => $this->getFile($parameters[0], $event),
];
case self::SUBJECT_RESHARED_LINK_BY:
case self::SUBJECT_UNSHARED_LINK_BY:
case self::SUBJECT_LINK_BY_EXPIRED:
return [
'file' => $this->getFile($parameters[0], $event),
'actor' => $this->getUser($parameters[1]),
];
}
return [];
}
}
@@ -0,0 +1,140 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
use OCP\Contacts\IManager as IContactsManager;
use OCP\Federation\ICloudIdManager;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\L10N\IFactory;
class RemoteShares extends Base {
public const SUBJECT_REMOTE_SHARE_ACCEPTED = 'remote_share_accepted';
public const SUBJECT_REMOTE_SHARE_DECLINED = 'remote_share_declined';
public const SUBJECT_REMOTE_SHARE_RECEIVED = 'remote_share_received';
public const SUBJECT_REMOTE_SHARE_UNSHARED = 'remote_share_unshared';
public function __construct(IFactory $languageFactory,
IURLGenerator $url,
IManager $activityManager,
IUserManager $userManager,
ICloudIdManager $cloudIdManager,
IContactsManager $contactsManager,
IEventMerger $eventMerger) {
parent::__construct($languageFactory, $url, $activityManager, $userManager, $cloudIdManager, $contactsManager, $eventMerger);
}
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_ACCEPTED) {
$subject = $this->l->t('{user} accepted the remote share');
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_DECLINED) {
$subject = $this->l->t('{user} declined the remote share');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_RECEIVED) {
$subject = $this->l->t('You received a new remote share {file} from {user}');
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_ACCEPTED) {
$subject = $this->l->t('{user} accepted the remote share of {file}');
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_DECLINED) {
$subject = $this->l->t('{user} declined the remote share of {file}');
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_UNSHARED) {
$subject = $this->l->t('{user} unshared {file} from you');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
protected function getParsedParameters(IEvent $event) {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
switch ($subject) {
case self::SUBJECT_REMOTE_SHARE_RECEIVED:
case self::SUBJECT_REMOTE_SHARE_UNSHARED:
$displayName = (count($parameters) > 2) ? $parameters[2] : '';
return [
'file' => [
'type' => 'pending-federated-share',
'id' => $parameters[1],
'name' => $parameters[1],
],
'user' => $this->getUser($parameters[0], $displayName)
];
case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
case self::SUBJECT_REMOTE_SHARE_DECLINED:
$fileParameter = $parameters[1];
if (!is_array($fileParameter)) {
$fileParameter = [$event->getObjectId() => $event->getObjectName()];
}
return [
'file' => $this->getFile($fileParameter),
'user' => $this->getUser($parameters[0]),
];
}
throw new \InvalidArgumentException();
}
}
@@ -0,0 +1,162 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Kevin Ndung'u <kevgathuku@gmail.com>
*
* @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\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
class Users extends Base {
public const SUBJECT_SHARED_USER_SELF = 'shared_user_self';
public const SUBJECT_RESHARED_USER_BY = 'reshared_user_by';
public const SUBJECT_UNSHARED_USER_SELF = 'unshared_user_self';
public const SUBJECT_UNSHARED_USER_BY = 'unshared_user_by';
public const SUBJECT_SHARED_WITH_BY = 'shared_with_by';
public const SUBJECT_UNSHARED_BY = 'unshared_by';
public const SUBJECT_SELF_UNSHARED = 'self_unshared';
public const SUBJECT_SELF_UNSHARED_BY = 'self_unshared_by';
public const SUBJECT_EXPIRED_USER = 'expired_user';
public const SUBJECT_EXPIRED = 'expired';
/**
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) {
$subject = $this->l->t('Shared with {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) {
$subject = $this->l->t('Removed share for {user}');
} elseif ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) {
$subject = $this->l->t('You removed yourself');
} elseif ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) {
$subject = $this->l->t('{actor} removed themselves');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) {
$subject = $this->l->t('{actor} shared with {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) {
$subject = $this->l->t('{actor} removed share for {user}');
} elseif ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) {
$subject = $this->l->t('Shared by {actor}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_BY) {
$subject = $this->l->t('{actor} removed share');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_USER) {
$subject = $this->l->t('Share for {user} expired');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED) {
$subject = $this->l->t('Share expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event);
if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) {
$subject = $this->l->t('You shared {file} with {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) {
$subject = $this->l->t('You removed {user} from {file}');
} elseif ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) {
$subject = $this->l->t('You removed yourself from {file}');
} elseif ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) {
$subject = $this->l->t('{actor} removed themselves from {file}');
} elseif ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) {
$subject = $this->l->t('{actor} shared {file} with {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) {
$subject = $this->l->t('{actor} removed {user} from {file}');
} elseif ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) {
$subject = $this->l->t('{actor} shared {file} with you');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARED_BY) {
$subject = $this->l->t('{actor} removed you from the share named {file}');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_USER) {
$subject = $this->l->t('Share for file {file} with {user} expired');
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED) {
$subject = $this->l->t('Share for file {file} expired');
} else {
throw new \InvalidArgumentException();
}
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
}
protected function getParsedParameters(IEvent $event) {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
switch ($subject) {
case self::SUBJECT_SHARED_USER_SELF:
case self::SUBJECT_UNSHARED_USER_SELF:
case self::SUBJECT_EXPIRED_USER:
case self::SUBJECT_EXPIRED:
return [
'file' => $this->getFile($parameters[0], $event),
'user' => $this->getUser($parameters[1]),
];
case self::SUBJECT_SHARED_WITH_BY:
case self::SUBJECT_UNSHARED_BY:
case self::SUBJECT_SELF_UNSHARED:
case self::SUBJECT_SELF_UNSHARED_BY:
return [
'file' => $this->getFile($parameters[0], $event),
'actor' => $this->getUser($parameters[1]),
];
case self::SUBJECT_RESHARED_USER_BY:
case self::SUBJECT_UNSHARED_USER_BY:
return [
'file' => $this->getFile($parameters[0], $event),
'user' => $this->getUser($parameters[2]),
'actor' => $this->getUser($parameters[1]),
];
}
return [];
}
}
@@ -0,0 +1,84 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @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\Files_Sharing\Activity\Settings;
class PublicLinks extends ShareActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'public_links';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l->t('A file or folder shared by mail or by public link was <strong>downloaded</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 20;
}
/**
* @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,85 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @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\Files_Sharing\Activity\Settings;
class RemoteShare extends ShareActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'remote_share';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l->t('A file or folder was shared from <strong>another server</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 11;
}
/**
* @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,49 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @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\Files_Sharing\Activity\Settings;
use OCP\Activity\ActivitySettings;
use OCP\IL10N;
abstract class ShareActivitySettings extends ActivitySettings {
/** @var IL10N */
protected $l;
/**
* @param IL10N $l
*/
public function __construct(IL10N $l) {
$this->l = $l;
}
public function getGroupIdentifier() {
return 'files';
}
public function getGroupName() {
return $this->l->t('Files');
}
}
@@ -0,0 +1,85 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @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\Files_Sharing\Activity\Settings;
class Shared extends ShareActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
*/
public function getIdentifier() {
return 'shared';
}
/**
* @return string A translated string
* @since 11.0.0
*/
public function getName() {
return $this->l->t('A file or folder has been <strong>shared</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 10;
}
/**
* @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;
}
}