Skip to content

Commit 0539acf

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

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/Migration/NotifyAdminsAfterUpgrade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use OCA\Libresign\AppInfo\Application as AppInfoApplication;
88
use OCP\App\IAppManager;
99
use OCP\IConfig;
10-
use OCP\IL10N;
1110
use OCP\IUserManager;
1211
use OCP\Migration\IOutput;
1312
use OCP\Migration\IRepairStep;
@@ -29,7 +28,7 @@ public function getName(): string {
2928
public function run(IOutput $output): void {
3029

3130
$currentVersion = $currentVersion = $this->appManager->getAppVersion(AppInfoApplication::APP_ID);
32-
$lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', '');
31+
$lastNotifiedVersion = $this->config->getAppValue(AppInfoApplication::APP_ID, 'last_notified_version', '');
3332

3433
if ($currentVersion === $lastNotifiedVersion) {
3534
return;
@@ -44,7 +43,8 @@ public function run(IOutput $output): void {
4443
->setDateTime(new \DateTime())
4544
->setObject('upgrade', '1')
4645
->setSubject('libresign_upgrade', [
47-
'message' => 'LibreSign has been updated to version ' . $currentVersion . '! Consider supporting the project: https://libresign.coop'
46+
'version' => $currentVersion,
47+
'message' => 'If LibreSign is useful to you or your organization, please consider supporting our cooperative by clicking the Donate button below.',
4848
]);
4949
$this->notificationManager->notify($notification);
5050
}

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)