mirror of
https://github.com/nextcloud/passman.git
synced 2025-09-29 00:04:50 +08:00
Send a notification on accept share request
This commit is contained in:
parent
a7eb15d2d8
commit
5395566053
3 changed files with 31 additions and 0 deletions
|
@ -176,6 +176,18 @@ class ShareController extends ApiController {
|
|||
->setUser($this->userId->getUID());
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,12 +81,20 @@ class Notifier implements INotifier {
|
|||
}
|
||||
return $notification;
|
||||
break;
|
||||
|
||||
case 'credential_share_denied':
|
||||
$notification->setParsedSubject(
|
||||
(string) $l->t('%s has declined your share request for "%s".', $notification->getSubjectParameters())
|
||||
);
|
||||
return $notification;
|
||||
break;
|
||||
|
||||
case 'credential_share_accepted':
|
||||
$notification->setParsedSubject(
|
||||
(string) $l->t('%s has accepted your share request for "%s".', $notification->getSubjectParameters())
|
||||
);
|
||||
return $notification;
|
||||
break;
|
||||
default:
|
||||
// Unknown subject => Unknown notification => throw
|
||||
throw new \InvalidArgumentException();
|
||||
|
|
|
@ -83,4 +83,15 @@ class NotificationService {
|
|||
$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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue