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
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Oct 26, 2018
1 parent 87c63f1 commit bc3443f
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\IManager as ShareManager;

class Notifier implements INotifier {
Expand Down Expand Up @@ -462,19 +463,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 bc3443f

Please sign in to comment.