fix check for Cloud ID, missing return statements, wrong param use

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2020-07-30 21:10:54 +02:00
parent dd60e3282d
commit 69a3829940
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 13 additions and 9 deletions

View File

@ -107,9 +107,7 @@ class Notifier implements INotifier {
); );
$initiator = $params[0]; $initiator = $params[0];
$initiatorDisplay = isset($params[3]) ? $params[3] : null;
$owner = $params[1]; $owner = $params[1];
$ownerDisplay = isset($params[4]) ? $params[4] : null;
$notification->setRichSubject( $notification->setRichSubject(
$l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'), $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
@ -119,8 +117,8 @@ class Notifier implements INotifier {
'id' => $notification->getObjectId(), 'id' => $notification->getObjectId(),
'name' => $params[2], 'name' => $params[2],
], ],
'user' => $this->createRemoteUser($initiator, $initiatorDisplay), 'user' => $this->createRemoteUser($initiator),
'behalf' => $this->createRemoteUser($owner, $ownerDisplay), 'behalf' => $this->createRemoteUser($owner),
] ]
); );
} else { } else {
@ -129,7 +127,6 @@ class Notifier implements INotifier {
); );
$owner = $params[0]; $owner = $params[0];
$ownerDisplay = isset($params[3]) ? $params[3] : null;
$notification->setRichSubject( $notification->setRichSubject(
$l->t('You received {share} as a remote share from {user}'), $l->t('You received {share} as a remote share from {user}'),
@ -139,7 +136,7 @@ class Notifier implements INotifier {
'id' => $notification->getObjectId(), 'id' => $notification->getObjectId(),
'name' => $params[2], 'name' => $params[2],
], ],
'user' => $this->createRemoteUser($owner, $ownerDisplay), 'user' => $this->createRemoteUser($owner),
] ]
); );
} }
@ -203,7 +200,7 @@ class Notifier implements INotifier {
* @param ICloudId $cloudId * @param ICloudId $cloudId
* @return string * @return string
*/ */
protected function getDisplayName(ICloudId $cloudId) { protected function getDisplayName(ICloudId $cloudId): string {
$server = $cloudId->getRemote(); $server = $cloudId->getRemote();
$user = $cloudId->getUser(); $user = $cloudId->getUser();
if (strpos($server, 'http://') === 0) { if (strpos($server, 'http://') === 0) {
@ -213,17 +210,24 @@ class Notifier implements INotifier {
} }
try { try {
// contains protocol in the ID
return $this->getDisplayNameFromContact($cloudId->getId()); return $this->getDisplayNameFromContact($cloudId->getId());
} catch (\OutOfBoundsException $e) { } catch (\OutOfBoundsException $e) {
} }
try { try {
$this->getDisplayNameFromContact($user . '@http://' . $server); // does not include protocol, as stored in addressbooks
return $this->getDisplayNameFromContact($cloudId->getDisplayId());
} catch (\OutOfBoundsException $e) { } catch (\OutOfBoundsException $e) {
} }
try { try {
$this->getDisplayNameFromContact($user . '@https://' . $server); return $this->getDisplayNameFromContact($user . '@http://' . $server);
} catch (\OutOfBoundsException $e) {
}
try {
return $this->getDisplayNameFromContact($user . '@https://' . $server);
} catch (\OutOfBoundsException $e) { } catch (\OutOfBoundsException $e) {
} }