From 0042aa23cef0fbedeccaee941a0f91693c54bd36 Mon Sep 17 00:00:00 2001 From: Samuelson Brito Date: Sun, 25 May 2025 01:56:42 -0400 Subject: [PATCH] feat: add donate button Signed-off-by: Samuelson Brito --- lib/Migration/NotifyAdminsAfterUpgrade.php | 10 +++++++--- lib/Notification/Notifier.php | 13 +++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Migration/NotifyAdminsAfterUpgrade.php b/lib/Migration/NotifyAdminsAfterUpgrade.php index ee5fea941..a20082a1c 100644 --- a/lib/Migration/NotifyAdminsAfterUpgrade.php +++ b/lib/Migration/NotifyAdminsAfterUpgrade.php @@ -1,13 +1,16 @@ appManager->getAppVersion(AppInfoApplication::APP_ID); - $lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', ''); + $lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', ''); if ($currentVersion === $lastNotifiedVersion) { return; @@ -44,7 +47,8 @@ class NotifyAdminsAfterUpgrade implements IRepairStep { ->setDateTime(new \DateTime()) ->setObject('upgrade', '1') ->setSubject('libresign_upgrade', [ - 'message' => 'LibreSign has been updated to version ' . $currentVersion . '! Consider supporting the project: https://libresign.coop' + 'version' => $currentVersion, + 'message' => 'If LibreSign is useful to you or your organization, please consider supporting our cooperative by clicking the Donate button below.', ]); $this->notificationManager->notify($notification); } diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index e1f0a910e..0f1b2aca2 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -214,12 +214,20 @@ class Notifier implements INotifier { ): INotification { $parameters = $notification->getSubjectParameters(); + $version = $parameters['version'] ?? ''; $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg'))); - $subject = $l->t('LibreSign has been updated!'); + $subject = $l->t('LibreSign has been updated to version %s!', [$version]); $message = $parameters['message'] ?? ''; $notification->setParsedSubject($subject) ->setParsedMessage($message); + $donateAction = $notification->createAction() + ->setParsedLabel($l->t('Donate')) + ->setPrimary(true) + ->setLink('https://github.com/sponsors/LibreSign', \OCP\Notification\IAction::TYPE_WEB); + + $notification->addParsedAction($donateAction); + $dismissAction = $notification->createAction() ->setParsedLabel($l->t('Dismiss notification')) ->setPrimary(false) @@ -235,7 +243,8 @@ class Notifier implements INotifier { ], ), IAction::TYPE_DELETE - ); + ); + $notification->addParsedAction($dismissAction); return $notification;