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());
|
->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue