Better notifications for password shares

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-10-22 12:01:11 +02:00
parent 62e7465a6d
commit d612e845f9
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA
2 changed files with 7 additions and 22 deletions

View file

@ -116,18 +116,6 @@ class PublicShareAuthController extends OCSController {
'participantType' => Participant::OWNER,
]);
// Notify the owner
$notification = $this->notificationManager->createNotification();
$notification
->setApp('spreed')
->setObject('room', $room->getToken())
->setUser($sharerUser->getUID())
->setSubject('share:password', [
'sharedWith' => $share->getSharedWith(),
])
->setDateTime(new \DateTime());
$this->notificationManager->notify($notification);
return new DataResponse([
'token' => $room->getToken(),
'name' => $room->getName(),

View file

@ -112,14 +112,14 @@ class Notifier implements INotifier {
return $this->parseInvitation($notification, $room, $l);
}
if ($subject === 'call') {
if ($room->getObjectType() === 'share:password') {
return $this->parsePasswordRequest($notification, $room, $l);
}
return $this->parseCall($notification, $room, $l);
}
if ($subject === 'mention' || $subject === 'chat') {
return $this->parseChatMessage($notification, $room, $l);
}
if ($subject === 'share:password') {
return $this->parsePasswordRequest($notification, $room, $l);
}
throw new \InvalidArgumentException('Unknown subject');
}
@ -445,18 +445,15 @@ class Notifier implements INotifier {
* @return INotification
* @throws \InvalidArgumentException
*/
protected function parsePasswordRequest(INotification $notification, Room $room, IL10N $l) {
if ($notification->getObjectType() !== 'room') {
protected function parsePasswordRequest(INotification $notification, Room $room, IL10N $l): INotification {
if ($notification->getObjectType() !== 'call') {
throw new \InvalidArgumentException('Unknown object type');
}
$parameters = $notification->getSubjectParameters();
$sharedWith = $parameters['sharedWith'];
$sharedWith = $room->getName();
$notification
->setParsedSubject(
$l->t('Password request by %s', [$sharedWith])
)
->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' => [