summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federatedfilesharing/lib')
-rw-r--r--apps/federatedfilesharing/lib/AppInfo/Application.php1
-rw-r--r--apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php1
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php1
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php12
-rw-r--r--apps/federatedfilesharing/lib/Notifications.php1
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php30
-rw-r--r--apps/federatedfilesharing/lib/TokenHandler.php1
-rw-r--r--apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php10
8 files changed, 32 insertions, 25 deletions
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index 73ac062be09..158ef1f4c18 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -23,7 +23,6 @@
*
*/
-
namespace OCA\FederatedFileSharing\AppInfo;
diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
index e3d7028ef65..02c21020b70 100644
--- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
+++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
@@ -24,7 +24,6 @@
*
*/
-
namespace OCA\FederatedFileSharing\BackgroundJob;
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index d54f24d97fe..febd43c554c 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -26,7 +26,6 @@
*
*/
-
namespace OCA\FederatedFileSharing\Controller;
use OC\Files\Filesystem;
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 4d93dec18f7..a95320daf48 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -29,24 +29,24 @@
namespace OCA\FederatedFileSharing;
+use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Node;
+use OCP\Files\NotFoundException;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Share\Exceptions\GenericShareException;
+use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
-use OC\Share20\Exception\InvalidShare;
-use OCP\Share\Exceptions\ShareNotFound;
-use OCP\Files\NotFoundException;
-use OCP\IDBConnection;
-use OCP\Files\Node;
/**
* Class FederatedShareProvider
diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php
index 70733bc9e2c..fc820abb584 100644
--- a/apps/federatedfilesharing/lib/Notifications.php
+++ b/apps/federatedfilesharing/lib/Notifications.php
@@ -22,7 +22,6 @@
*
*/
-
namespace OCA\FederatedFileSharing;
use OCP\AppFramework\Http;
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index 02a46d65bba..0e1f1eae87b 100644
--- a/apps/federatedfilesharing/lib/Notifier.php
+++ b/apps/federatedfilesharing/lib/Notifier.php
@@ -86,7 +86,7 @@ class Notifier implements INotifier {
* @throws \InvalidArgumentException
*/
public function prepare(INotification $notification, string $languageCode): INotification {
- if ($notification->getApp() !== 'files_sharing') {
+ if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') {
// Not my app => throw
throw new \InvalidArgumentException();
}
@@ -102,8 +102,14 @@ class Notifier implements INotifier {
$params = $notification->getSubjectParameters();
if ($params[0] !== $params[1] && $params[1] !== null) {
$notification->setParsedSubject(
- $l->t('You received "%3$s" as a remote share from %1$s (on behalf of %2$s)', $params)
+ $l->t('You received "%3$s" as a remote share from %4$s (%1$s) (on behalf of %5$s (%2$s))', $params)
);
+
+ $initiator = $params[0];
+ $initiatorDisplay = isset($params[3]) ? $params[3] : null;
+ $owner = $params[1];
+ $ownerDisplay = isset($params[4]) ? $params[4] : null;
+
$notification->setRichSubject(
$l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
[
@@ -112,14 +118,18 @@ class Notifier implements INotifier {
'id' => $notification->getObjectId(),
'name' => $params[2],
],
- 'user' => $this->createRemoteUser($params[0]),
- 'behalf' => $this->createRemoteUser($params[1]),
+ 'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
+ 'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
]
);
} else {
$notification->setParsedSubject(
- $l->t('You received "%3$s" as a remote share from %1$s', $params)
+ $l->t('You received "%3$s" as a remote share from %4$s (%1$s)', $params)
);
+
+ $owner = $params[0];
+ $ownerDisplay = isset($params[3]) ? $params[3] : null;
+
$notification->setRichSubject(
$l->t('You received {share} as a remote share from {user}'),
[
@@ -128,7 +138,7 @@ class Notifier implements INotifier {
'id' => $notification->getObjectId(),
'name' => $params[2],
],
- 'user' => $this->createRemoteUser($params[0]),
+ 'user' => $this->createRemoteUser($owner, $ownerDisplay),
]
);
}
@@ -164,15 +174,17 @@ class Notifier implements INotifier {
* @param string $cloudId
* @return array
*/
- protected function createRemoteUser($cloudId) {
- $displayName = $cloudId;
+ protected function createRemoteUser($cloudId, $displayName = null) {
try {
$resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
- $displayName = $this->getDisplayName($resolvedId);
+ if ($displayName === null) {
+ $displayName = $this->getDisplayName($resolvedId);
+ }
$user = $resolvedId->getUser();
$server = $resolvedId->getRemote();
} catch (HintException $e) {
$user = $cloudId;
+ $displayName = $cloudId;
$server = '';
}
diff --git a/apps/federatedfilesharing/lib/TokenHandler.php b/apps/federatedfilesharing/lib/TokenHandler.php
index bfe02169fbd..85a65fae1d9 100644
--- a/apps/federatedfilesharing/lib/TokenHandler.php
+++ b/apps/federatedfilesharing/lib/TokenHandler.php
@@ -20,7 +20,6 @@
*
*/
-
namespace OCA\FederatedFileSharing;
diff --git a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
index 1d922ce60ba..fa3e17271cf 100644
--- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
@@ -23,9 +23,9 @@ namespace OCA\FederatedFileSharing\OCM;
use OC\AppFramework\Http;
use OC\Files\Filesystem;
-use OCA\Files_Sharing\Activity\Providers\RemoteShares;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\Files_Sharing\Activity\Providers\RemoteShares;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\IAppManager;
use OCP\Constants;
@@ -245,7 +245,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
->setAffectedUser($shareWith)
->setObject('remote_share', (int)$shareId, $name);
\OC::$server->getActivityManager()->publish($event);
- $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
+ $this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $sharedBy, $owner);
} else {
$groupMembers = $this->groupManager->get($shareWith)->getUsers();
foreach ($groupMembers as $user) {
@@ -256,7 +256,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
->setAffectedUser($user->getUID())
->setObject('remote_share', (int)$shareId, $name);
\OC::$server->getActivityManager()->publish($event);
- $this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name);
+ $this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $sharedBy, $owner);
}
}
return $shareId;
@@ -333,13 +333,13 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
* @param $sharedByFederatedId
* @param $name
*/
- private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name) {
+ private function notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $sharedBy, $owner) {
$notification = $this->notificationManager->createNotification();
$notification->setApp('files_sharing')
->setUser($shareWith)
->setDateTime(new \DateTime())
->setObject('remote_share', $shareId)
- ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]);
+ ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/'), $sharedBy, $owner]);
$declineAction = $notification->createAction();
$declineAction->setLabel('decline')