Skip to content

Commit 0042aa2

Browse files
feat: add donate button
Signed-off-by: Samuelson Brito <samuelsonma@gmail.com>
1 parent b7cfd99 commit 0042aa2

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/Migration/NotifyAdminsAfterUpgrade.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
48

59
namespace OCA\Libresign\Migration;
610

711
use OCA\Libresign\AppInfo\Application as AppInfoApplication;
812
use OCP\App\IAppManager;
913
use OCP\IConfig;
10-
use OCP\IL10N;
1114
use OCP\IUserManager;
1215
use OCP\Migration\IOutput;
1316
use OCP\Migration\IRepairStep;
@@ -29,7 +32,7 @@ public function getName(): string {
2932
public function run(IOutput $output): void {
3033

3134
$currentVersion = $currentVersion = $this->appManager->getAppVersion(AppInfoApplication::APP_ID);
32-
$lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', '');
35+
$lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', '');
3336

3437
if ($currentVersion === $lastNotifiedVersion) {
3538
return;
@@ -44,7 +47,8 @@ public function run(IOutput $output): void {
4447
->setDateTime(new \DateTime())
4548
->setObject('upgrade', '1')
4649
->setSubject('libresign_upgrade', [
47-
'message' => 'LibreSign has been updated to version ' . $currentVersion . '! Consider supporting the project: https://libresign.coop'
50+
'version' => $currentVersion,
51+
'message' => 'If LibreSign is useful to you or your organization, please consider supporting our cooperative by clicking the Donate button below.',
4852
]);
4953
$this->notificationManager->notify($notification);
5054
}

lib/Notification/Notifier.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,20 @@ private function parseUpgrade(
214214
): INotification {
215215

216216
$parameters = $notification->getSubjectParameters();
217+
$version = $parameters['version'] ?? '';
217218
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg')));
218-
$subject = $l->t('LibreSign has been updated!');
219+
$subject = $l->t('LibreSign has been updated to version %s!', [$version]);
219220
$message = $parameters['message'] ?? '';
220221
$notification->setParsedSubject($subject)
221222
->setParsedMessage($message);
222223

224+
$donateAction = $notification->createAction()
225+
->setParsedLabel($l->t('Donate'))
226+
->setPrimary(true)
227+
->setLink('https://github.com/sponsors/LibreSign', \OCP\Notification\IAction::TYPE_WEB);
228+
229+
$notification->addParsedAction($donateAction);
230+
223231
$dismissAction = $notification->createAction()
224232
->setParsedLabel($l->t('Dismiss notification'))
225233
->setPrimary(false)
@@ -235,7 +243,8 @@ private function parseUpgrade(
235243
],
236244
),
237245
IAction::TYPE_DELETE
238-
);
246+
);
247+
239248
$notification->addParsedAction($dismissAction);
240249

241250
return $notification;

0 commit comments

Comments
 (0)