mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-18 05:20:45 +01:00
feat: add notification signed
Signed-off-by: Samuelson Brito <samuelsonma@gmail.com>
This commit is contained in:
parent
ed31177530
commit
8a6620595e
8 changed files with 96 additions and 32 deletions
|
|
@ -150,8 +150,12 @@ class Listener implements IEventListener {
|
|||
'link' => $this->url->linkToRouteAbsolute('libresign.page.validationFilePublic', [
|
||||
'uuid' => $libreSignFile->getUuid(),
|
||||
]),
|
||||
|
||||
]
|
||||
],
|
||||
'signedFile' => [
|
||||
'type' => 'signed-file',
|
||||
'id' => (string)$signRequest->getId(),
|
||||
'name' => $signRequest->getDisplayName(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->activityManager->publish($activityEvent);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,25 @@ class Signed implements IProvider {
|
|||
throw new UnknownActivityException('subject');
|
||||
}
|
||||
|
||||
$this->definitions->definitions['signed-file'] = [
|
||||
'author' => 'LibreSign',
|
||||
'since' => '28.0.0',
|
||||
'parameters' => [
|
||||
'id' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The id of SignRequest object',
|
||||
'example' => '12345',
|
||||
],
|
||||
'name' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The display name of signer',
|
||||
'example' => 'John Doe',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->activityManager->getRequirePNG()) {
|
||||
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.png')));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -111,9 +111,16 @@ class NotifyController extends AEnvironmentAwareController {
|
|||
*/
|
||||
#[NoAdminRequired]
|
||||
#[ApiRoute(verb: 'DELETE', url: '/api/{apiVersion}/notify/notification', requirements: ['apiVersion' => '(v1)'])]
|
||||
public function notificationDismiss(int $signRequestId, int $timestamp): DataResponse {
|
||||
public function notificationDismiss(
|
||||
string $objectType,
|
||||
int $objectId,
|
||||
string $subject,
|
||||
int $timestamp,
|
||||
): DataResponse {
|
||||
$this->notifyService->notificationDismiss(
|
||||
$signRequestId,
|
||||
$objectType,
|
||||
$objectId,
|
||||
$subject,
|
||||
$this->userSession->getUser(),
|
||||
$timestamp
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
|
||||
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ class NotificationListener implements IEventListener {
|
|||
$this->notificationManager->notify($notification);
|
||||
}
|
||||
|
||||
//TODO dados mockados para testar notificação
|
||||
private function sendSignedNotification(
|
||||
SignRequest $signRequest,
|
||||
FileEntity $libreSignFile,
|
||||
|
|
@ -125,6 +124,11 @@ class NotificationListener implements IEventListener {
|
|||
'uuid' => $libreSignFile->getUuid(),
|
||||
]),
|
||||
],
|
||||
'signedFile' => [
|
||||
'type' => 'signed-file',
|
||||
'id' => (string)$signRequest->getId(),
|
||||
'name' => $signRequest->getDisplayName(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->notificationManager->notify($notification);
|
||||
|
|
|
|||
|
|
@ -43,25 +43,6 @@ class Notifier implements INotifier {
|
|||
throw new UnknownActivityException();
|
||||
}
|
||||
|
||||
$this->definitions->definitions['sign-request'] = [
|
||||
'author' => 'LibreSign',
|
||||
'since' => '28.0.0',
|
||||
'parameters' => [
|
||||
'id' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The id of SignRequest object',
|
||||
'example' => '12345',
|
||||
],
|
||||
'name' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The display name of signer',
|
||||
'example' => 'John Doe',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$l = $this->factory->get(Application::APP_ID, $languageCode);
|
||||
|
||||
switch ($notification->getSubject()) {
|
||||
|
|
@ -81,6 +62,26 @@ class Notifier implements INotifier {
|
|||
IL10N $l,
|
||||
bool $update,
|
||||
): INotification {
|
||||
|
||||
$this->definitions->definitions['sign-request'] = [
|
||||
'author' => 'LibreSign',
|
||||
'since' => '28.0.0',
|
||||
'parameters' => [
|
||||
'id' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The id of SignRequest object',
|
||||
'example' => '12345',
|
||||
],
|
||||
'name' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The display name of signer',
|
||||
'example' => 'John Doe',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$parameters = $notification->getSubjectParameters();
|
||||
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg')));
|
||||
if (isset($parameters['file'])) {
|
||||
|
|
@ -120,7 +121,9 @@ class Notifier implements INotifier {
|
|||
[
|
||||
'apiVersion' => 'v1',
|
||||
'timestamp' => $notification->getDateTime()->getTimestamp(),
|
||||
'signRequestId' => $parameters['signRequest']['id'],
|
||||
'objectType' => 'signRequest',
|
||||
'objectId' => $parameters['signRequest']['id'],
|
||||
'subject' => 'new_sign_request',
|
||||
],
|
||||
),
|
||||
IAction::TYPE_DELETE
|
||||
|
|
@ -136,6 +139,25 @@ class Notifier implements INotifier {
|
|||
IL10N $l,
|
||||
): INotification {
|
||||
|
||||
$this->definitions->definitions['signed-file'] = [
|
||||
'author' => 'LibreSign',
|
||||
'since' => '28.0.0',
|
||||
'parameters' => [
|
||||
'id' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The id of SignRequest object',
|
||||
'example' => '12345',
|
||||
],
|
||||
'name' => [
|
||||
'since' => '28.0.0',
|
||||
'required' => true,
|
||||
'description' => 'The display name of signer',
|
||||
'example' => 'John Doe',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$parameters = $notification->getSubjectParameters();
|
||||
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg')));
|
||||
if (isset($parameters['file'])) {
|
||||
|
|
@ -162,6 +184,7 @@ class Notifier implements INotifier {
|
|||
->setRichSubject($subject, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($parameters['signedFile']) && isset($parameters['signedFile']['id'])) {
|
||||
$dismissAction = $notification->createAction()
|
||||
->setParsedLabel($l->t('Dismiss notification'))
|
||||
|
|
@ -171,7 +194,9 @@ class Notifier implements INotifier {
|
|||
[
|
||||
'apiVersion' => 'v1',
|
||||
'timestamp' => $notification->getDateTime()->getTimestamp(),
|
||||
'signRequestId' => $parameters['signedFile']['id'],
|
||||
'objectType' => 'signedFile',
|
||||
'objectId' => $parameters['signedFile']['id'],
|
||||
'subject' => 'file_signed',
|
||||
],
|
||||
),
|
||||
IAction::TYPE_DELETE
|
||||
|
|
|
|||
|
|
@ -53,13 +53,19 @@ class NotifyService {
|
|||
}
|
||||
}
|
||||
|
||||
public function notificationDismiss(int $signRequestId, IUser $user, int $timestamp): void {
|
||||
public function notificationDismiss(
|
||||
string $objectType,
|
||||
int $objectId,
|
||||
string $subject,
|
||||
IUser $user,
|
||||
int $timestamp,
|
||||
): void {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification->setApp(Application::APP_ID)
|
||||
->setObject('signRequest', (string)$signRequestId)
|
||||
->setObject($objectType, (string)$objectId)
|
||||
->setDateTime($this->timeFactory->getDateTime('@' . $timestamp))
|
||||
->setUser($user->getUID())
|
||||
->setSubject('new_sign_request');
|
||||
->setSubject($subject);
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ class SignFileService {
|
|||
$this->signRequest->setSignedHash($hash);
|
||||
if ($this->signRequest->getId()) {
|
||||
$this->signRequestMapper->update($this->signRequest);
|
||||
$this->eventDispatcher->dispatchTyped(new SignedEvent($this->signRequest, $this->libreSignFile, $this->identifyMethodService->getIdentifiedMethod($this->signRequest->getId())));
|
||||
} else {
|
||||
$this->signRequestMapper->insert($this->signRequest);
|
||||
}
|
||||
|
|
@ -324,8 +325,6 @@ class SignFileService {
|
|||
|
||||
$this->eventDispatcher->dispatchTyped(new SignedCallbackEvent($this, $signedFile, $allSigned));
|
||||
|
||||
$this->eventDispatcher->dispatchTyped(new SignedEvent($this->signRequest, $this->libreSignFile, $this->identifyMethodService->getIdentifiedMethod($this->signRequest->getId())));
|
||||
|
||||
return $signedFile;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue