Skip to content

Commit

Permalink
Merge pull request #226 from nextcloud/enh/225/notification-updates
Browse files Browse the repository at this point in the history
Update recommended app notifications
  • Loading branch information
rullzer authored Dec 18, 2019
2 parents 9af74f6 + cbac75d commit a401c3f
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 18 deletions.
2 changes: 1 addition & 1 deletion img/apps/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/apps/contacts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/apps/deck.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/apps/groupfolders.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions img/apps/mail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/apps/notes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/apps/social.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/apps/spreed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions img/apps/tasks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions lib/Notification/AppHint.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class AppHint {
/** @var string */
private $userId;

const APP_HINT_VERSION = '18';

public function __construct(INotificationManager $notificationManager, IGroupManager $groupManager, IAppManager $appManager, IConfig $config, IEventDispatcher $eventDispatcher, $userId) {
$this->notificationManager = $notificationManager;
$this->groupManager = $groupManager;
Expand All @@ -60,12 +62,13 @@ public function __construct(INotificationManager $notificationManager, IGroupMan
}

public function sendAppHintNotifications(): void {
if ($this->userId !== null && $this->groupManager->isAdmin($this->userId) && $this->config->getUserValue($this->userId, 'firstrunwizard', 'apphint') !== 'yes') {
$this->sendNotification('calendar', $this->userId);
$this->sendNotification('contacts', $this->userId);
$this->sendNotification('mail', $this->userId);
$this->sendNotification('spreed', $this->userId);
$this->config->setUserValue($this->userId, 'firstrunwizard', 'apphint', 'yes');
if ($this->userId !== null && $this->groupManager->isAdmin($this->userId) && $this->config->getUserValue($this->userId, 'firstrunwizard', 'apphint') !== self::APP_HINT_VERSION) {
$this->sendNotification('groupfolders', $this->userId);
$this->sendNotification('social', $this->userId);
$this->sendNotification('notes', $this->userId);
$this->sendNotification('deck', $this->userId);
$this->sendNotification('tasks', $this->userId);
$this->config->setUserValue($this->userId, 'firstrunwizard', 'apphint', self::APP_HINT_VERSION);
}
}

Expand All @@ -78,7 +81,7 @@ public function registerAppListener(): void {
protected function sendNotification(string $app, string $user): void {
$notification = $this->generateNotification($app, $user);
if (
$this->config->getUserValue($this->userId, 'firstrunwizard', 'apphint') !== 'yes'
$this->config->getUserValue($this->userId, 'firstrunwizard', 'apphint') !== self::APP_HINT_VERSION
&& $this->notificationManager->getCount($notification) === 0
&& !$this->appManager->isEnabledForUser($app)
) {
Expand Down
34 changes: 30 additions & 4 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public function prepare(INotification $notification, string $languageCode): INot
case 'apphint-contacts':
case 'apphint-mail':
case 'apphint-spreed':
case 'apphint-tasks':
case 'apphint-deck':
case 'apphint-notes':
case 'apphint-social':
case 'apphint-groupfolders':
$app = $notification->getObjectId();
return $this->setAppHintDetails($notification, $languageCode, $app);
default:
Expand Down Expand Up @@ -166,10 +171,31 @@ protected function setAppHintDetails(INotification $notification, $languageCode,
$notification->setParsedMessage($l->t('Simple email app nicely integrated with Files, Contacts and Calendar.'));
$appLink = '/social/mail';
break;
case 'spreed':
$notification->setParsedSubject($l->t('App recommendation: Nextcloud Talk'));
$notification->setParsedMessage($l->t('Screensharing, online meetings and web conferencing – on desktop and with mobile apps.'));
$appLink = '/social/spreed';

case 'tasks':
$notification->setParsedSubject($l->t('App recommendation: Tasks'));
$notification->setParsedMessage($l->t('Sync tasks from various devices with your Nextcloud and edit them online.'));
$appLink = '/organization/tasks';
break;
case 'deck':
$notification->setParsedSubject($l->t('App recommendation: Deck'));
$notification->setParsedMessage($l->t('Kanban style organization for personal planning and team projects.'));
$appLink = '/organization/deck';
break;
case 'notes':
$notification->setParsedSubject($l->t('App recommendation: Notes'));
$notification->setParsedMessage($l->t('Distraction-free notes and writing.'));
$appLink = '/organization/notes';
break;
case 'social':
$notification->setParsedSubject($l->t('App recommendation: Social'));
$notification->setParsedMessage($l->t('Nextcloud becomes part of the federated social networks.'));
$appLink = '/social/social';
break;
case 'groupfolders':
$notification->setParsedSubject($l->t('App recommendation: Group folders'));
$notification->setParsedMessage($l->t('Admin-configured folders shared by everyone in a group.'));
$appLink = '/files/groupfolders';
break;
}
$notification
Expand Down

0 comments on commit a401c3f

Please sign in to comment.