Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix check for Cloud ID, missing return statements, wrong param use
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and backportbot[bot] committed Aug 4, 2020
commit 815d7ceeddacb701306ada5da39971b9d5e80a66
22 changes: 13 additions & 9 deletions apps/federatedfilesharing/lib/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ public function prepare(INotification $notification, string $languageCode): INot
);

$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})'),
Expand All @@ -119,8 +117,8 @@ public function prepare(INotification $notification, string $languageCode): INot
'id' => $notification->getObjectId(),
'name' => $params[2],
],
'user' => $this->createRemoteUser($initiator, $initiatorDisplay),
'behalf' => $this->createRemoteUser($owner, $ownerDisplay),
'user' => $this->createRemoteUser($initiator),
'behalf' => $this->createRemoteUser($owner),
]
);
} else {
Expand All @@ -129,7 +127,6 @@ public function prepare(INotification $notification, string $languageCode): INot
);

$owner = $params[0];
$ownerDisplay = isset($params[3]) ? $params[3] : null;

$notification->setRichSubject(
$l->t('You received {share} as a remote share from {user}'),
Expand All @@ -139,7 +136,7 @@ public function prepare(INotification $notification, string $languageCode): INot
'id' => $notification->getObjectId(),
'name' => $params[2],
],
'user' => $this->createRemoteUser($owner, $ownerDisplay),
'user' => $this->createRemoteUser($owner),
]
);
}
Expand Down Expand Up @@ -203,7 +200,7 @@ protected function createRemoteUser($cloudId, $displayName = null) {
* @param ICloudId $cloudId
* @return string
*/
protected function getDisplayName(ICloudId $cloudId) {
protected function getDisplayName(ICloudId $cloudId): string {
$server = $cloudId->getRemote();
$user = $cloudId->getUser();
if (strpos($server, 'http://') === 0) {
Expand All @@ -213,17 +210,24 @@ protected function getDisplayName(ICloudId $cloudId) {
}

try {
// contains protocol in the ID
return $this->getDisplayNameFromContact($cloudId->getId());
} catch (\OutOfBoundsException $e) {
}

try {
$this->getDisplayNameFromContact($user . '@http://' . $server);
// does not include protocol, as stored in addressbooks
return $this->getDisplayNameFromContact($cloudId->getDisplayId());
} catch (\OutOfBoundsException $e) {
}

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) {
}

Expand Down