Navigation Menu

Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
[fix] emails
Browse files Browse the repository at this point in the history
  • Loading branch information
albancrommer committed Jun 21, 2014
1 parent e0e720c commit 1a5f5bc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
30 changes: 30 additions & 0 deletions models/collections.js
Expand Up @@ -3,3 +3,33 @@
Items = new Meteor.Collection("items");
Versions = new Meteor.Collection("versions");
Drafts = new Meteor.Collection("drafts");

/*
* @todo : build lists when Items collection ready
distinct = function( options ){
var field = options["field"],
distinctList = options["distinctList"] || [],
srcList = options["srcList"] || [],
idList = options["idList"] || {}
;
_.each(srcList,function(a,b){
var f = a[field]
if ( f && distinctList.indexOf( f ) === -1 ) {
distinctList.push(f);
idList[f] = [];
}
idList[f].push(a.name);
})
}
var categoryList = []
var categoryIdList = {}
var itemList = Items.find().fetch()
distinct( {
field: "category",
srcList: itemList,
distinctList : categoryList,
idList : categoryIdList
})
*/
2 changes: 1 addition & 1 deletion models/item.js
Expand Up @@ -35,4 +35,4 @@ Item = function(name){
return addslashes(instance.name);
}
return instance;
}
}
13 changes: 6 additions & 7 deletions models/itemsMapper.js
Expand Up @@ -88,7 +88,8 @@ ItemsMapper = {
newItem = newItem || null,
user = Meteor.user(),
item_name = currentItem.name,
email
email,
link = Router.url("item",{"name":item_name})
;
// Attempts to retrieve user email
if( "emails" in user && user.emails.length && "address" in user.emails[0] ){
Expand Down Expand Up @@ -130,9 +131,8 @@ ItemsMapper = {
// send email to admin team
Meteor.call('sendEmail',
email,
'admin@nsa-observer.net',
'NSAOBS : '+item_name+' VERSION by '+email,
JSON.stringify(draftVersion)
'NSAOBS : VERSION '+item_name+' by '+email,
link
);
}catch(err){
alert("An error occured : failed to send admin team the notification email.");
Expand All @@ -156,9 +156,8 @@ ItemsMapper = {
// send email to admin team
Meteor.call('sendEmail',
email,
'admin@nsa-observer.net',
'NSAOBS : '+item_name+' DRAFT by '+email,
JSON.stringify(draftVersion)
'NSAOBS : DRAFT '+item_name+' by '+email,
link
);
}catch(err){
alert("An error occured : failed to send admin team the notification email.");
Expand Down
4 changes: 2 additions & 2 deletions server/main.js
@@ -1,7 +1,7 @@
// In your server code: define a method that the client can call
Meteor.methods({
sendEmail: function (from, to, subject, text) {
check([from, subject, text], [String]);
sendEmail: function (from, subject, text) {
// check([from, subject, text], [String]);

// Let other method calls from the same client start running,
// without waiting for the email sending to complete.
Expand Down

0 comments on commit 1a5f5bc

Please sign in to comment.