l10nFactory->get('survey_client')->t('Usage survey'); } /** * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification * @return INotification * @throws UnknownNotificationException When the notification was not prepared by a notifier */ public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== 'survey_client') { // Not my app => throw throw new UnknownNotificationException(); } // Read the language from the notification $l = $this->l10nFactory->get('survey_client', $languageCode); $notification->setParsedSubject($l->t('Help improve Nextcloud')) ->setParsedMessage($l->t('Do you want to help us to improve Nextcloud by providing some anonymized data about your setup and usage? You can disable it at any time in the admin settings again.')) ->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index', ['section' => 'survey_client'])) ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('survey_client', 'app-dark.svg'))); $enableAction = $notification->createAction(); $enableAction->setLabel('enable') ->setParsedLabel($l->t('Send usage')) ->setLink($this->url->linkToOCSRouteAbsolute('survey_client.Endpoint.enableMonthly'), 'POST') ->setPrimary(true); $notification->addParsedAction($enableAction); $disableAction = $notification->createAction(); $disableAction->setLabel('disable') ->setParsedLabel($l->t('Not now')) ->setLink($this->url->linkToOCSRouteAbsolute('survey_client.Endpoint.disableMonthly'), 'DELETE') ->setPrimary(false); $notification->addParsedAction($disableAction); return $notification; } }