summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/Notifier.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-11-18 20:22:31 +0100
committerGitHub <noreply@github.com>2019-11-18 20:22:31 +0100
commit5195be108f1f6bc90d0413cf732361e64982f001 (patch)
tree5cd3dbe22102145602f0ca5ae94824f40dfa21e0 /apps/federatedfilesharing/lib/Notifier.php
parentccc0a5e0d586c8df25edb1a0f3cef20860d71e4f (diff)
parent17fae47bdba84ed520fee2cbf1a9485cc14fbbcb (diff)
downloadnextcloud-server-5195be108f1f6bc90d0413cf732361e64982f001.tar.gz
nextcloud-server-5195be108f1f6bc90d0413cf732361e64982f001.zip
Merge pull request #17985 from nextcloud/enh/use_displayname_federated_share
Use the displayname for federated notifications
Diffstat (limited to 'apps/federatedfilesharing/lib/Notifier.php')
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php28
1 files changed, 20 insertions, 8 deletions
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index 1916390a1ad..0e1f1eae87b 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 = '';
}