27
27
use OCA \Libresign \AppInfo \Application as AppInfoApplication ;
28
28
use OCA \Libresign \Db \File as FileEntity ;
29
29
use OCA \Libresign \Db \SignRequest ;
30
+ use OCA \Libresign \Db \SignRequestMapper ;
30
31
use OCA \Libresign \Events \SendSignNotificationEvent ;
31
32
use OCA \Libresign \Service \IdentifyMethod \IIdentifyMethod ;
32
33
use OCP \AppFramework \Utility \ITimeFactory ;
@@ -46,25 +47,24 @@ public function __construct(
46
47
protected IUserSession $ userSession ,
47
48
private ITimeFactory $ timeFactory ,
48
49
protected IURLGenerator $ url ,
50
+ private SignRequestMapper $ signRequestMapper ,
49
51
) {
50
52
}
51
53
52
54
public function handle (Event $ event ): void {
53
55
if ($ event instanceof SendSignNotificationEvent) {
54
- $ this ->sendNewSignNotification (
56
+ $ this ->sendSignNotification (
55
57
$ event ->getSignRequest (),
56
58
$ event ->getLibreSignFile (),
57
59
$ event ->getIdentifyMethod (),
58
- $ event ->isNew ()
59
60
);
60
61
}
61
62
}
62
63
63
- private function sendNewSignNotification (
64
+ private function sendSignNotification (
64
65
SignRequest $ signRequest ,
65
66
FileEntity $ libreSignFile ,
66
67
IIdentifyMethod $ identifyMethod ,
67
- bool $ isNew
68
68
): void {
69
69
$ actor = $ this ->userSession ->getUser ();
70
70
if (!$ actor instanceof IUser) {
@@ -79,7 +79,8 @@ private function sendNewSignNotification(
79
79
->setObject ('signRequest ' , (string ) $ signRequest ->getId ())
80
80
->setDateTime ((new \DateTime ())->setTimestamp ($ this ->timeFactory ->now ()->getTimestamp ()))
81
81
->setUser ($ identifyMethod ->getEntity ()->getIdentifierValue ());
82
- if ($ isNew ) {
82
+ $ isFirstNotification = $ this ->signRequestMapper ->incrementNotificationCounter ($ signRequest , 'notify ' );
83
+ if ($ isFirstNotification ) {
83
84
$ subject = 'new_sign_request ' ;
84
85
} else {
85
86
$ subject = 'update_sign_request ' ;
0 commit comments