Skip to content

Commit 1bad813

Browse files
feat: add donate button
Signed-off-by: Samuelson Brito <[email protected]>
1 parent 0e44f5f commit 1bad813

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
@@ -229,12 +229,20 @@ private function parseUpgrade(
229229
): INotification {
230230

231231
$parameters = $notification->getSubjectParameters();
232+
$version = $parameters['version'] ?? '';
232233
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_ID, 'app-dark.svg')));
233-
$subject = $l->t('LibreSign has been updated!');
234+
$subject = $l->t('LibreSign has been updated to version %s!', [$version]);
234235
$message = $parameters['message'] ?? '';
235236
$notification->setParsedSubject($subject)
236237
->setParsedMessage($message);
237238

239+
$donateAction = $notification->createAction()
240+
->setParsedLabel($l->t('Donate'))
241+
->setPrimary(true)
242+
->setLink('https://libresign.coop', \OCP\Notification\IAction::TYPE_WEB);
243+
244+
$notification->addParsedAction($donateAction);
245+
238246
$dismissAction = $notification->createAction()
239247
->setParsedLabel($l->t('Dismiss notification'))
240248
->setPrimary(false)
@@ -250,7 +258,8 @@ private function parseUpgrade(
250258
],
251259
),
252260
IAction::TYPE_DELETE
253-
);
261+
);
262+
254263
$notification->addParsedAction($dismissAction);
255264

256265
return $notification;

0 commit comments

Comments
 (0)