mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
herald integration
This commit is contained in:
parent
b6becdab3a
commit
9be1bd7169
31 changed files with 217 additions and 214 deletions
|
@ -1 +1 @@
|
||||||
METEOR@0.9.3
|
METEOR@0.9.3.1
|
||||||
|
|
|
@ -5,7 +5,7 @@ accounts-password@1.0.2
|
||||||
accounts-twitter@1.0.1
|
accounts-twitter@1.0.1
|
||||||
accounts-ui-unstyled@1.1.2
|
accounts-ui-unstyled@1.1.2
|
||||||
accounts-ui@1.1.1
|
accounts-ui@1.1.1
|
||||||
aldeed:autoform@2.0.2
|
aldeed:autoform@3.1.0
|
||||||
aldeed:collection2@2.1.0
|
aldeed:collection2@2.1.0
|
||||||
aldeed:simple-schema@1.0.3
|
aldeed:simple-schema@1.0.3
|
||||||
application-configuration@1.0.2
|
application-configuration@1.0.2
|
||||||
|
@ -40,9 +40,11 @@ id-map@1.0.0
|
||||||
iron:core@0.3.4
|
iron:core@0.3.4
|
||||||
iron:dynamic-template@0.4.1
|
iron:dynamic-template@0.4.1
|
||||||
iron:layout@0.4.1
|
iron:layout@0.4.1
|
||||||
iron:router@0.9.3
|
iron:router@0.9.4
|
||||||
jquery@1.0.0
|
jquery@1.0.0
|
||||||
json@1.0.0
|
json@1.0.0
|
||||||
|
kestanous:herald-email@0.2.1
|
||||||
|
kestanous:herald@0.6.0
|
||||||
less@1.0.9
|
less@1.0.9
|
||||||
livedata@1.0.10
|
livedata@1.0.10
|
||||||
localstorage@1.0.0
|
localstorage@1.0.0
|
||||||
|
@ -52,8 +54,7 @@ meteor-platform@1.1.1
|
||||||
meteor@1.1.1
|
meteor@1.1.1
|
||||||
meteorhacks:async@1.0.0
|
meteorhacks:async@1.0.0
|
||||||
meteorhacks:fast-render@1.1.2
|
meteorhacks:fast-render@1.1.2
|
||||||
meteorhacks:kadira-binary-deps@1.0.1
|
meteorhacks:kadira@2.5.0
|
||||||
meteorhacks:kadira@2.9.2
|
|
||||||
meteorhacks:npm@1.2.0
|
meteorhacks:npm@1.2.0
|
||||||
meteorhacks:subs-manager@1.1.0
|
meteorhacks:subs-manager@1.1.0
|
||||||
minifiers@1.1.0
|
minifiers@1.1.0
|
||||||
|
@ -89,8 +90,8 @@ softwarerero:accounts-t9n@1.0.0
|
||||||
spacebars-compiler@1.0.2
|
spacebars-compiler@1.0.2
|
||||||
spacebars@1.0.2
|
spacebars@1.0.2
|
||||||
spiderable@1.0.3
|
spiderable@1.0.3
|
||||||
splendido:accounts-templates-core@0.9.5
|
splendido:accounts-templates-core@0.9.8
|
||||||
splendido:accounts-templates-unstyled@0.9.5
|
splendido:accounts-templates-unstyled@0.9.8
|
||||||
srp@1.0.0
|
srp@1.0.0
|
||||||
standard-app-packages@1.0.2
|
standard-app-packages@1.0.2
|
||||||
telescope-api@0.0.0
|
telescope-api@0.0.0
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -86,6 +86,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -82,6 +82,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -82,7 +82,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -210,6 +210,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -18,6 +18,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -74,6 +74,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -72,10 +72,6 @@
|
||||||
"livedata",
|
"livedata",
|
||||||
"1.0.10"
|
"1.0.10"
|
||||||
],
|
],
|
||||||
[
|
|
||||||
"localstorage",
|
|
||||||
"1.0.0"
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"logging",
|
"logging",
|
||||||
"1.0.3"
|
"1.0.3"
|
||||||
|
@ -86,11 +82,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"meteorhacks:kadira",
|
"meteorhacks:kadira",
|
||||||
"2.9.2"
|
"2.5.0"
|
||||||
],
|
|
||||||
[
|
|
||||||
"meteorhacks:kadira-binary-deps",
|
|
||||||
"1.0.1"
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"minimongo",
|
"minimongo",
|
||||||
|
@ -154,6 +146,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -14,6 +14,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -98,6 +98,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -90,6 +90,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -90,7 +90,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -214,6 +214,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
// Notifications - only load if user is logged in
|
|
||||||
// Not mandatory, because server won't publish anything even if we try to load.
|
|
||||||
// Remember about Deps.autorun - user can log in and log out several times
|
|
||||||
Tracker.autorun(function() {
|
|
||||||
// userId() can be changed before user(), because loading profile takes time
|
|
||||||
if(Meteor.userId()) {
|
|
||||||
Meteor.subscribe('notifications');
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -5,4 +5,4 @@
|
||||||
{{{notificationHTML}}}
|
{{{notificationHTML}}}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,17 +3,17 @@ Template[getTemplate('notificationItem')].helpers({
|
||||||
return moment(this.timestamp).fromNow();
|
return moment(this.timestamp).fromNow();
|
||||||
},
|
},
|
||||||
properties: function(){
|
properties: function(){
|
||||||
return this.properties;
|
return this.data;
|
||||||
},
|
},
|
||||||
notificationHTML: function(){
|
notificationHTML: function(){
|
||||||
return buildSiteNotification(this);
|
return this.message();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template[getTemplate('notificationItem')].events({
|
Template[getTemplate('notificationItem')].events({
|
||||||
'click .action-link': function(event, instance){
|
'click .action-link': function(event, instance){
|
||||||
var notificationId=instance.data._id;
|
var notificationId=instance.data._id;
|
||||||
Notifications.update(
|
Herald.collection.update(
|
||||||
{_id: notificationId},
|
{_id: notificationId},
|
||||||
{
|
{
|
||||||
$set:{
|
$set:{
|
||||||
|
@ -27,4 +27,4 @@ Template[getTemplate('notificationItem')].events({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
left a new comment on
|
left a new comment on
|
||||||
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
|
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template name="notificationNewReply">
|
<template name="notificationNewReply">
|
||||||
<p>
|
<p>
|
||||||
<a href="{{profileUrl}}">{{author}}</a>
|
<a href="{{profileUrl}}">{{author}}</a>
|
||||||
has replied to your comment on
|
has replied to your comment on
|
||||||
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
|
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,13 +3,13 @@ Template[getTemplate('notificationsMenu')].helpers({
|
||||||
return getTemplate('notificationItem');
|
return getTemplate('notificationItem');
|
||||||
},
|
},
|
||||||
notifications: function(){
|
notifications: function(){
|
||||||
return Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}});
|
return Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}});
|
||||||
},
|
},
|
||||||
hasNotifications: function () {
|
hasNotifications: function () {
|
||||||
return !!Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count();
|
return !!Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count();
|
||||||
},
|
},
|
||||||
notification_count: function(){
|
notification_count: function(){
|
||||||
var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch();
|
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch();
|
||||||
if(notifications.length==0){
|
if(notifications.length==0){
|
||||||
return i18n.t('No notifications');
|
return i18n.t('No notifications');
|
||||||
}else if(notifications.length==1){
|
}else if(notifications.length==1){
|
||||||
|
@ -19,7 +19,7 @@ Template[getTemplate('notificationsMenu')].helpers({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
notification_class: function(){
|
notification_class: function(){
|
||||||
var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch();
|
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch();
|
||||||
if(notifications.length==0)
|
if(notifications.length==0)
|
||||||
return 'no-notifications';
|
return 'no-notifications';
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,4 @@ Template[getTemplate('notificationsMenu')].events({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
101
packages/telescope-notifications/lib/herald.js
Normal file
101
packages/telescope-notifications/lib/herald.js
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
Herald.collection.deny({
|
||||||
|
update: ! can.editById,
|
||||||
|
remove: ! can.editById
|
||||||
|
});
|
||||||
|
|
||||||
|
var commentEmail = function (userToNotify) {
|
||||||
|
var notification = this;
|
||||||
|
// put in setTimeout so it doesn't hold up the rest of the method
|
||||||
|
Meteor.setTimeout(function () {
|
||||||
|
notificationEmail = buildEmailNotification(notification);
|
||||||
|
sendEmail(getEmail(userToNotify), notificationEmail.subject, notificationEmail.html);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Herald.addCourier('newPost', {
|
||||||
|
media: {
|
||||||
|
email: {
|
||||||
|
emailRunner: function (user) {
|
||||||
|
var p = getPostProperties(this.data);
|
||||||
|
var subject = p.postAuthorName+' has created a new post: '+p.postTitle;
|
||||||
|
var html = buildEmailTemplate(getEmailTemplate('emailNewPost')(p));
|
||||||
|
sendEmail(getEmail(user), subject, html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// message: function (user) { return 'email template?' }
|
||||||
|
});
|
||||||
|
|
||||||
|
Herald.addCourier('newComment', {
|
||||||
|
media: {
|
||||||
|
onsite: {},
|
||||||
|
email: {
|
||||||
|
emailRunner: commentEmail
|
||||||
|
}
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
default: function (user) {
|
||||||
|
return Blaze.toHTML(Blaze.With(this, function(){
|
||||||
|
return Template[getTemplate('notificationNewComment')]
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
profileUrl: function () {
|
||||||
|
var user = Meteor.users.findOne(this.data.comment.userId);
|
||||||
|
if(user)
|
||||||
|
return getProfileUrl(user);
|
||||||
|
},
|
||||||
|
postCommentUrl: function () {
|
||||||
|
return '/posts/'+ this.data.post._id;
|
||||||
|
},
|
||||||
|
author: function () {
|
||||||
|
var user = Meteor.users.findOne(this.data.comment.userId);
|
||||||
|
if(user)
|
||||||
|
return getUserName(user);
|
||||||
|
},
|
||||||
|
postTitle: function () {
|
||||||
|
return this.data.post.title;
|
||||||
|
},
|
||||||
|
url: function () {
|
||||||
|
return /comments/ + this.comment._id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Herald.addCourier('newReply', {
|
||||||
|
media: {
|
||||||
|
onsite: {},
|
||||||
|
email: {
|
||||||
|
emailRunner: commentEmail
|
||||||
|
}
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
default: function (user) {
|
||||||
|
return Blaze.toHTML(Blaze.With(this, function(){
|
||||||
|
return Template[getTemplate('notificationNewReply')]
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
profileUrl: function () {
|
||||||
|
var user = Meteor.users.findOne(this.data.comment.userId);
|
||||||
|
if(user)
|
||||||
|
return getProfileUrl(user);
|
||||||
|
},
|
||||||
|
postCommentUrl: function () {
|
||||||
|
return '/posts/'+ this.data.post._id;
|
||||||
|
},
|
||||||
|
author: function () {
|
||||||
|
var user = Meteor.users.findOne(this.data.comment.userId);
|
||||||
|
if(user)
|
||||||
|
return getUserName(user);
|
||||||
|
},
|
||||||
|
postTitle: function () {
|
||||||
|
return this.data.post.title;
|
||||||
|
},
|
||||||
|
url: function () {
|
||||||
|
return /comments/ + this.parentComment._id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,111 +1,10 @@
|
||||||
Notifications = new Meteor.Collection('notifications');
|
|
||||||
|
|
||||||
// Notifications = new Meteor.Collection("notifications", {
|
|
||||||
// schema: new SimpleSchema({
|
|
||||||
// properties: {
|
|
||||||
// type: Object
|
|
||||||
// },
|
|
||||||
// event: {
|
|
||||||
// type: String
|
|
||||||
// },
|
|
||||||
// read: {
|
|
||||||
// type: Boolean
|
|
||||||
// },
|
|
||||||
// createdAt: {
|
|
||||||
// type: Date
|
|
||||||
// },
|
|
||||||
// userId: {
|
|
||||||
// type: "???"
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// });
|
|
||||||
|
|
||||||
Notifications.allow({
|
|
||||||
insert: function(userId, doc){
|
|
||||||
// new notifications can only be created via a Meteor method
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
update: can.editById,
|
|
||||||
remove: can.editById
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification = function(event, properties, userToNotify) {
|
|
||||||
// 1. Store notification in database
|
|
||||||
var notification = {
|
|
||||||
timestamp: new Date().getTime(),
|
|
||||||
userId: userToNotify._id,
|
|
||||||
event: event,
|
|
||||||
properties: properties,
|
|
||||||
read: false
|
|
||||||
};
|
|
||||||
var newNotificationId = Notifications.insert(notification);
|
|
||||||
|
|
||||||
// 2. Send notification by email (if on server)
|
|
||||||
if(Meteor.isServer && getUserSetting('notifications.replies', false, userToNotify)){
|
|
||||||
// put in setTimeout so it doesn't hold up the rest of the method
|
|
||||||
Meteor.setTimeout(function () {
|
|
||||||
notificationEmail = buildEmailNotification(notification);
|
|
||||||
sendEmail(getEmail(userToNotify), notificationEmail.subject, notificationEmail.html);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
buildSiteNotification = function (notification) {
|
|
||||||
var event = notification.event,
|
|
||||||
comment = notification.properties.comment,
|
|
||||||
post = notification.properties.post,
|
|
||||||
userToNotify = Meteor.users.findOne(notification.userId),
|
|
||||||
template,
|
|
||||||
html;
|
|
||||||
|
|
||||||
var properties = {
|
|
||||||
profileUrl: getProfileUrlById(comment.userId),
|
|
||||||
author: comment.author,
|
|
||||||
postCommentUrl: getPostCommentUrl(post._id, comment._id),
|
|
||||||
postTitle: post.title
|
|
||||||
};
|
|
||||||
|
|
||||||
switch(event){
|
|
||||||
case 'newReply':
|
|
||||||
template = 'notificationNewReply';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'newComment':
|
|
||||||
template = 'notificationNewComment';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
html = Blaze.toHTML(Blaze.With(properties, function(){
|
|
||||||
return Template[getTemplate(template)]
|
|
||||||
}));
|
|
||||||
|
|
||||||
return html;
|
|
||||||
};
|
|
||||||
|
|
||||||
Meteor.methods({
|
|
||||||
markAllNotificationsAsRead: function() {
|
|
||||||
Notifications.update(
|
|
||||||
{userId: Meteor.userId()},
|
|
||||||
{
|
|
||||||
$set:{
|
|
||||||
read: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{multi: true}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// add new post notification callback on post submit
|
// add new post notification callback on post submit
|
||||||
postAfterSubmitMethodCallbacks.push(function (post) {
|
postAfterSubmitMethodCallbacks.push(function (post) {
|
||||||
if(Meteor.isServer && !!getSetting('emailNotifications', false)){
|
if(Meteor.isServer && !!getSetting('emailNotifications', false)){
|
||||||
// we don't want emails to hold up the post submission, so we make the whole thing async with setTimeout
|
var userIds = Meteor.users.find({'profile.notifications.posts': 1}, {fields: {}}).map(function (user) {
|
||||||
Meteor.setTimeout(function () {
|
return user._id
|
||||||
newPostNotification(post, [post.userId])
|
});
|
||||||
}, 1);
|
Herald.createNotification(userIds, {courier: 'newPost', data: post})
|
||||||
}
|
}
|
||||||
return post;
|
return post;
|
||||||
});
|
});
|
||||||
|
@ -119,7 +18,7 @@ commentAfterSubmitMethodCallbacks.push(function (comment) {
|
||||||
var post = Posts.findOne(comment.postId);
|
var post = Posts.findOne(comment.postId);
|
||||||
var postUser = Meteor.users.findOne(post.userId);
|
var postUser = Meteor.users.findOne(post.userId);
|
||||||
|
|
||||||
var notificationProperties = {
|
var notificationData = {
|
||||||
comment: _.pick(comment, '_id', 'userId', 'author', 'body'),
|
comment: _.pick(comment, '_id', 'userId', 'author', 'body'),
|
||||||
post: _.pick(post, '_id', 'title', 'url')
|
post: _.pick(post, '_id', 'title', 'url')
|
||||||
};
|
};
|
||||||
|
@ -129,25 +28,25 @@ commentAfterSubmitMethodCallbacks.push(function (comment) {
|
||||||
var parentComment = Comments.findOne(parentCommentId);
|
var parentComment = Comments.findOne(parentCommentId);
|
||||||
var parentUser = Meteor.users.findOne(parentComment.userId);
|
var parentUser = Meteor.users.findOne(parentComment.userId);
|
||||||
|
|
||||||
notificationProperties.parentComment = _.pick(parentComment, '_id', 'userId', 'author');
|
notificationData.parentComment = _.pick(parentComment, '_id', 'userId', 'author');
|
||||||
|
|
||||||
// reply notification
|
// reply notification
|
||||||
// do not notify users of their own actions (i.e. they're replying to themselves)
|
// do not notify users of their own actions (i.e. they're replying to themselves)
|
||||||
if(parentUser._id != user._id)
|
if(parentUser._id != user._id)
|
||||||
createNotification('newReply', notificationProperties, parentUser);
|
Herald.createNotification(parentUser._id, {courier: 'newReply', data: notificationData})
|
||||||
|
|
||||||
// comment notification
|
// comment notification
|
||||||
// if the original poster is different from the author of the parent comment, notify them too
|
// if the original poster is different from the author of the parent comment, notify them too
|
||||||
if(postUser._id != user._id && parentComment.userId != post.userId)
|
if(postUser._id != user._id && parentComment.userId != post.userId)
|
||||||
createNotification('newComment', notificationProperties, postUser);
|
Herald.createNotification(postUser._id, {courier: 'newComment', data: notificationData})
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// root comment
|
// root comment
|
||||||
// don't notify users of their own comments
|
// don't notify users of their own comments
|
||||||
if(postUser._id != user._id)
|
if(postUser._id != user._id)
|
||||||
createNotification('newComment', notificationProperties, postUser);
|
Herald.createNotification(postUser._id, {courier: 'newComment', data: notificationData})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return comment;
|
return comment;
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,10 +6,10 @@ getUnsubscribeLink = function(user){
|
||||||
buildEmailNotification = function (notification) {
|
buildEmailNotification = function (notification) {
|
||||||
|
|
||||||
var subject, template;
|
var subject, template;
|
||||||
var post = notification.properties.post;
|
var post = notification.data.post;
|
||||||
var comment = notification.properties.comment;
|
var comment = notification.data.comment;
|
||||||
|
|
||||||
switch(notification.event){
|
switch(notification.courier){
|
||||||
case 'newReply':
|
case 'newReply':
|
||||||
subject = 'Someone replied to your comment on "'+post.title+'"';
|
subject = 'Someone replied to your comment on "'+post.title+'"';
|
||||||
template = 'emailNewReply';
|
template = 'emailNewReply';
|
||||||
|
@ -24,7 +24,7 @@ buildEmailNotification = function (notification) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var emailProperties = _.extend(notification.properties, {
|
var emailProperties = _.extend(notification.data, {
|
||||||
body: marked(comment.body),
|
body: marked(comment.body),
|
||||||
profileUrl: getProfileUrlById(comment.userId),
|
profileUrl: getProfileUrlById(comment.userId),
|
||||||
postCommentUrl: getPostCommentUrl(post._id, comment._id),
|
postCommentUrl: getPostCommentUrl(post._id, comment._id),
|
||||||
|
@ -42,20 +42,6 @@ buildEmailNotification = function (notification) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
newPostNotification = function(post, excludedIDs){
|
|
||||||
var excludedIDs = typeof excludedIDs == 'undefined' ? [] : excludedIDs;
|
|
||||||
var p = getPostProperties(post);
|
|
||||||
var subject = p.postAuthorName+' has created a new post: '+p.postTitle;
|
|
||||||
var html = buildEmailTemplate(getEmailTemplate('emailNewPost')(p));
|
|
||||||
|
|
||||||
// send a notification to every user according to their notifications settings
|
|
||||||
Meteor.users.find({'profile.notifications.posts': 1}).forEach(function(user) {
|
|
||||||
// don't send user a notification if their ID is in excludedIDs
|
|
||||||
if(excludedIDs.indexOf(user._id) == -1)
|
|
||||||
sendEmail(getEmail(user), subject, html);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
unsubscribeUser : function(hash){
|
unsubscribeUser : function(hash){
|
||||||
// TO-DO: currently, if you have somebody's email you can unsubscribe them
|
// TO-DO: currently, if you have somebody's email you can unsubscribe them
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
Meteor.publish('notifications', function() {
|
|
||||||
// only publish notifications belonging to the current user
|
|
||||||
if(canViewById(this.userId)){
|
|
||||||
return Notifications.find({userId:this.userId});
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
|
|
@ -10,13 +10,14 @@ Package.onUse(function (api) {
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
'telescope-email',
|
'telescope-email',
|
||||||
'aldeed:simple-schema'
|
'kestanous:herald@0.6.0',
|
||||||
|
'kestanous:herald-email@0.2.1'
|
||||||
], ['client', 'server']);
|
], ['client', 'server']);
|
||||||
|
|
||||||
api.use([
|
api.use([
|
||||||
|
'iron:router',
|
||||||
'jquery',
|
'jquery',
|
||||||
'underscore',
|
'underscore',
|
||||||
'iron:router',
|
|
||||||
'templating',
|
'templating',
|
||||||
'tracker'
|
'tracker'
|
||||||
], 'client');
|
], 'client');
|
||||||
|
@ -27,10 +28,10 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
'lib/notifications.js',
|
'lib/notifications.js',
|
||||||
|
'lib/herald.js'
|
||||||
], ['client', 'server']);
|
], ['client', 'server']);
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
'lib/client/notifications-client.js',
|
|
||||||
'lib/client/templates/notification_item.html',
|
'lib/client/templates/notification_item.html',
|
||||||
'lib/client/templates/notification_item.js',
|
'lib/client/templates/notification_item.js',
|
||||||
'lib/client/templates/notification_new_comment.html',
|
'lib/client/templates/notification_new_comment.html',
|
||||||
|
@ -42,19 +43,14 @@ Package.onUse(function (api) {
|
||||||
], ['client']);
|
], ['client']);
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
'lib/server/notifications-server.js',
|
'lib/server/notifications-server.js'
|
||||||
'lib/server/publication.js'
|
|
||||||
], ['server']);
|
], ['server']);
|
||||||
|
|
||||||
api.export([
|
api.export([
|
||||||
'Notifications',
|
'Herald',
|
||||||
'createNotification',
|
|
||||||
'buildSiteNotification',
|
|
||||||
'newPostNotification',
|
|
||||||
'buildEmailNotification',
|
'buildEmailNotification',
|
||||||
'getUnsubscribeLink',
|
'getUnsubscribeLink'
|
||||||
'postSubmitMethodCallbacks'
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: once user profile edit form is generated dynamically, add notification options from this package as well.
|
// TODO: once user profile edit form is generated dynamically, add notification options from this package as well.
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
[
|
|
||||||
"aldeed:simple-schema",
|
|
||||||
"1.0.3"
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"application-configuration",
|
"application-configuration",
|
||||||
"1.0.2"
|
"1.0.2"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"autoupdate",
|
||||||
|
"1.1.1"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"base64",
|
"base64",
|
||||||
"1.0.0"
|
"1.0.0"
|
||||||
|
@ -52,6 +52,10 @@
|
||||||
"ejson",
|
"ejson",
|
||||||
"1.0.3"
|
"1.0.3"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"fastclick",
|
||||||
|
"1.0.0"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"follower-livedata",
|
"follower-livedata",
|
||||||
"1.0.1"
|
"1.0.1"
|
||||||
|
@ -72,6 +76,10 @@
|
||||||
"htmljs",
|
"htmljs",
|
||||||
"1.0.1"
|
"1.0.1"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"http",
|
||||||
|
"1.0.6"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"id-map",
|
"id-map",
|
||||||
"1.0.0"
|
"1.0.0"
|
||||||
|
@ -90,7 +98,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -100,6 +108,18 @@
|
||||||
"json",
|
"json",
|
||||||
"1.0.0"
|
"1.0.0"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"kestanous:herald",
|
||||||
|
"0.6.0"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"kestanous:herald-email",
|
||||||
|
"0.2.1"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"livedata",
|
||||||
|
"1.0.10"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"logging",
|
"logging",
|
||||||
"1.0.3"
|
"1.0.3"
|
||||||
|
@ -108,6 +128,10 @@
|
||||||
"meteor",
|
"meteor",
|
||||||
"1.1.1"
|
"1.1.1"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"meteor-platform",
|
||||||
|
"1.1.1"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"minifiers",
|
"minifiers",
|
||||||
"1.1.0"
|
"1.1.0"
|
||||||
|
@ -116,6 +140,10 @@
|
||||||
"minimongo",
|
"minimongo",
|
||||||
"1.0.3"
|
"1.0.3"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"mobile-status-bar",
|
||||||
|
"1.0.0"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"mongo",
|
"mongo",
|
||||||
"1.0.6"
|
"1.0.6"
|
||||||
|
@ -140,6 +168,10 @@
|
||||||
"reactive-var",
|
"reactive-var",
|
||||||
"1.0.2"
|
"1.0.2"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"reload",
|
||||||
|
"1.1.0"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"retry",
|
"retry",
|
||||||
"1.0.0"
|
"1.0.0"
|
||||||
|
@ -148,6 +180,10 @@
|
||||||
"routepolicy",
|
"routepolicy",
|
||||||
"1.0.1"
|
"1.0.1"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"session",
|
||||||
|
"1.0.2"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"spacebars",
|
"spacebars",
|
||||||
"1.0.2"
|
"1.0.2"
|
||||||
|
@ -156,6 +192,10 @@
|
||||||
"spacebars-compiler",
|
"spacebars-compiler",
|
||||||
"1.0.2"
|
"1.0.2"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"standard-app-packages",
|
||||||
|
"1.0.2"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"telescope-base",
|
"telescope-base",
|
||||||
"0.0.0"
|
"0.0.0"
|
||||||
|
@ -188,6 +228,10 @@
|
||||||
"underscore",
|
"underscore",
|
||||||
"1.0.0"
|
"1.0.0"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"url",
|
||||||
|
"1.0.0"
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"webapp",
|
"webapp",
|
||||||
"1.1.2"
|
"1.1.2"
|
||||||
|
@ -198,6 +242,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -86,6 +86,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -82,7 +82,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -186,6 +186,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -82,7 +82,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -186,6 +186,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -86,6 +86,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -86,6 +86,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
|
@ -82,7 +82,7 @@
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"0.9.3"
|
"0.9.4"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"jquery",
|
"jquery",
|
||||||
|
@ -190,6 +190,6 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"pluginDependencies": [],
|
"pluginDependencies": [],
|
||||||
"toolVersion": "meteor-tool@1.0.32",
|
"toolVersion": "meteor-tool@1.0.33",
|
||||||
"format": "1.0"
|
"format": "1.0"
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue