Send a notification on accept share request

This commit is contained in:
brantje 2016-10-02 18:47:02 +02:00
parent a7eb15d2d8
commit 5395566053
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
3 changed files with 31 additions and 0 deletions

View file

@ -176,6 +176,18 @@ class ShareController extends ApiController {
->setUser($this->userId->getUID()); ->setUser($this->userId->getUID());
$manager->markProcessed($notification); $manager->markProcessed($notification);
$notification = array(
'from_user' => ucfirst($this->userId->getDisplayName()),
'credential_label' => $this->credentialService->getCredentialLabelById($sr->getItemId())->getLabel(),
'target_user' => $sr->getFromUserId(),
'req_id' => $sr->getId()
);
$this->notificationService->credentialAcceptedSharedNotification(
$notification
);
$this->shareService->applyShare($item_guid, $target_vault_guid, $final_shared_key); $this->shareService->applyShare($item_guid, $target_vault_guid, $final_shared_key);
} }

View file

@ -81,12 +81,20 @@ class Notifier implements INotifier {
} }
return $notification; return $notification;
break; break;
case 'credential_share_denied': case 'credential_share_denied':
$notification->setParsedSubject( $notification->setParsedSubject(
(string) $l->t('%s has declined your share request for "%s".', $notification->getSubjectParameters()) (string) $l->t('%s has declined your share request for "%s".', $notification->getSubjectParameters())
); );
return $notification; return $notification;
break; break;
case 'credential_share_accepted':
$notification->setParsedSubject(
(string) $l->t('%s has accepted your share request for "%s".', $notification->getSubjectParameters())
);
return $notification;
break;
default: default:
// Unknown subject => Unknown notification => throw // Unknown subject => Unknown notification => throw
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();

View file

@ -83,4 +83,15 @@ class NotificationService {
$this->manager->notify($notification); $this->manager->notify($notification);
} }
function credentialAcceptedSharedNotification($data){
$notification = $this->manager->createNotification();
$notification->setApp('passman')
->setUser($data['target_user'])
->setDateTime(new \DateTime())
->setObject('passman_share_request', $data['req_id']) // $type and $id
->setSubject('credential_share_accepted', [$data['from_user'], $data['credential_label']]); // $subject and $parameters
$this->manager->notify($notification);
}
} }