-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathSignRequestCanceled.php
More file actions
83 lines (72 loc) · 2.17 KB
/
SignRequestCanceled.php
File metadata and controls
83 lines (72 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Activity\Provider;
use OCA\Libresign\AppInfo\Application;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\RichObjectStrings\Definitions;
class SignRequestCanceled implements IProvider {
public function __construct(
protected IFactory $languageFactory,
protected IURLGenerator $url,
protected Definitions $definitions,
protected IManager $activityManager,
protected IUserManager $userManager,
) {
}
#[\Override]
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== Application::APP_ID) {
throw new UnknownActivityException('app');
}
if ($event->getSubject() !== 'sign_request_canceled') {
throw new UnknownActivityException('subject');
}
$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',
],
],
];
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg')));
}
$l = $this->languageFactory->get(Application::APP_ID, $language);
$parameters = $event->getSubjectParameters();
$subject = $l->t('{from} canceled the signature request for {file}');
$event->setParsedSubject(
str_replace(
['{from}', '{file}'],
[
$parameters['from']['name'],
$parameters['file']['name'],
],
$subject
))
->setRichSubject($subject, $parameters);
return $event;
}
}