From d303dea6c7cf88dce15a8ca0be2066c8b148209c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 29 Sep 2014 12:30:03 -0400 Subject: [PATCH] closes #1986 --- src/notifications.js | 3 +++ src/routes/authentication.js | 2 ++ src/user/notifications.js | 20 ++++++++++++++++++++ src/views/admin/header.tpl | 1 + src/views/admin/settings/notifications.tpl | 13 +++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 src/views/admin/settings/notifications.tpl diff --git a/src/notifications.js b/src/notifications.js index 3a10a5da37..6db7f6381e 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -80,6 +80,9 @@ var async = require('async'), break; } + return next(null, notification); + } else { + notification.image = meta.config['brand:logo'] || nconf.get('relative_path') + '/logo.png'; return next(null, notification); } diff --git a/src/routes/authentication.js b/src/routes/authentication.js index cfe9e71462..f2ceb97859 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -126,6 +126,8 @@ require('../socket.io').emitUserCount(); + user.notifications.sendWelcomeNotification(uid); + plugins.fireHook('filter:register.complete', uid, req.body.referrer, function(err, uid, destination) { if (destination) { res.redirect(nconf.get('relative_path') + destination); diff --git a/src/user/notifications.js b/src/user/notifications.js index 63d1ccc82f..2edaadb763 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -8,6 +8,7 @@ var async = require('async'), user = require('../user'), utils = require('../../public/src/utils'), db = require('../database'), + meta = require('../meta'), notifications = require('../notifications'), posts = require('../posts'), postTools = require('../postTools'), @@ -295,6 +296,25 @@ var async = require('async'), }); }; + UserNotifications.sendWelcomeNotification = function(uid) { + if (!meta.config.welcomeNotification) { + return; + } + + var path = meta.config.welcomeLink ? meta.config.welcomeLink : '#'; + + notifications.create({ + bodyShort: meta.config.welcomeNotification, + bodyLong: meta.config.welcomeNotification, + path: path, + nid: 'welcome_' + uid + }, function(err, notification) { + if (!err && notification) { + notifications.push(notification, [uid]); + } + }); + }; + UserNotifications.pushCount = function(uid) { var websockets = require('./../socket.io'); UserNotifications.getUnreadCount(uid, function(err, count) { diff --git a/src/views/admin/header.tpl b/src/views/admin/header.tpl index a188b71f31..216f91bd5d 100644 --- a/src/views/admin/header.tpl +++ b/src/views/admin/header.tpl @@ -115,6 +115,7 @@
  • Post
  • Pagination
  • Tags
  • +
  • Notifications
  • Web Crawler
  • Sockets
  • Advanced
  • diff --git a/src/views/admin/settings/notifications.tpl b/src/views/admin/settings/notifications.tpl new file mode 100644 index 0000000000..9ba21c6830 --- /dev/null +++ b/src/views/admin/settings/notifications.tpl @@ -0,0 +1,13 @@ + + +
    +
    Notifications
    +
    +
    + Welcome Notification

    + Welcome Notification Link

    +
    +
    +
    + + \ No newline at end of file