summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-18 15:00:33 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-18 15:00:33 +0100
commit17fae47bdba84ed520fee2cbf1a9485cc14fbbcb (patch)
treeddbeccd9d9a2800877b5679e58872915f358076d /apps
parentbb77c1447b7e2b1e16c85bc4ee313a48db109cce (diff)
downloadnextcloud-server-17fae47bdba84ed520fee2cbf1a9485cc14fbbcb.tar.gz
nextcloud-server-17fae47bdba84ed520fee2cbf1a9485cc14fbbcb.zip
Use the displayname for federated notifications
Since we have the showing this is a lot nicer. Especially on alrge isntances where the uid can be totally random. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php28
-rw-r--r--apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php8
2 files changed, 24 insertions, 12 deletions
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index 02a46d65bba..9c0f9080781 100644
--- a/apps/federatedfilesharing/lib/Notifier.php
+++ b/apps/federatedfilesharing/lib/Notifier.php
@@ -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/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
index 1d922ce60ba..062c79ad97d 100644
--- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php
@@ -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')