Skip to content

Commit

Permalink
Add support for link shares in "share:password" rooms
Browse files Browse the repository at this point in the history
Until now only the e-mail shares had support for sending the password by
Talk. In Nextcloud 15 that feature was added to link shares too, so the
room name and the notification sent for "share:password" rooms has to be
adjusted accordingly.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Nov 7, 2018
1 parent 2efcc06 commit 0a8dce9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
9 changes: 8 additions & 1 deletion lib/Controller/PublicShareAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\Notification\IManager as NotificationManager;
use OCP\Share;
use OCP\Share\IManager as ShareManager;
use OCP\Share\Exceptions\ShareNotFound;

Expand Down Expand Up @@ -106,8 +107,14 @@ public function createRoom(string $shareToken): DataResponse {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}

if ($share->getShareType() === Share::SHARE_TYPE_EMAIL) {
$roomName = $share->getSharedWith();
} else {
$roomName = $share->getTarget();
}

// Create the room
$room = $this->manager->createPublicRoom($share->getSharedWith(), 'share:password', $shareToken);
$room = $this->manager->createPublicRoom($roomName, 'share:password', $shareToken);
$room->addUsers([
'userId' => $sharerUser->getUID(),
'participantType' => Participant::OWNER,
Expand Down
28 changes: 17 additions & 11 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\RichObjectStrings\Definitions;
use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as IShareManager;

Expand Down Expand Up @@ -463,19 +464,24 @@ protected function parsePasswordRequest(INotification $notification, Room $room,
throw new \InvalidArgumentException('Unknown share');
}

$sharedWith = $share->getSharedWith();
if ($share->getShareType() === Share::SHARE_TYPE_EMAIL) {
$sharedWith = $share->getSharedWith();

$notification
->setParsedSubject(str_replace('{email}', $sharedWith, $l->t('{email} requested the password to access a share')))
->setRichSubject(
$l->t('{email} requested the password to access a share'), [
'email' => [
'type' => 'email',
'id' => $sharedWith,
'name' => $sharedWith,
$notification
->setParsedSubject(str_replace('{email}', $sharedWith, $l->t('{email} requested the password to access a share')))
->setRichSubject(
$l->t('{email} requested the password to access a share'), [
'email' => [
'type' => 'email',
'id' => $sharedWith,
'name' => $sharedWith,
]
]
]
);
);
} else {
$notification
->setParsedSubject($l->t('Someone requested the password to access a share'));
}

return $notification;
}
Expand Down

0 comments on commit 0a8dce9

Please sign in to comment.