mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
send email on invitation. Facebook/Twitter support.
This commit is contained in:
@@ -8,3 +8,6 @@ accounts-ui
|
||||
accounts-password
|
||||
d3
|
||||
bootstrap
|
||||
email
|
||||
accounts-facebook
|
||||
accounts-twitter
|
||||
|
||||
@@ -34,14 +34,12 @@ Template.details.creatorName = function () {
|
||||
var owner = Meteor.users.findOne(this.owner);
|
||||
if (owner._id === Meteor.userId())
|
||||
return "me";
|
||||
// XXX this (not having 'emails' just be an array of string, for the
|
||||
// common case) really kind of sucks
|
||||
return owner.emails[0].address;
|
||||
return displayName(owner);
|
||||
};
|
||||
|
||||
Template.attendance.rsvpEmail = function () {
|
||||
Template.attendance.rsvpName = function () {
|
||||
var user = Meteor.users.findOne(this.user);
|
||||
return user.emails[0].address;
|
||||
return displayName(user);
|
||||
};
|
||||
|
||||
Template.attendance.outstandingInvitations = function () {
|
||||
@@ -51,8 +49,8 @@ Template.attendance.outstandingInvitations = function () {
|
||||
return Meteor.users.find({_id: {$in: people}});
|
||||
};
|
||||
|
||||
Template.attendance.invitationEmail = function () {
|
||||
return this.emails[0].address;
|
||||
Template.attendance.invitationName = function () {
|
||||
return displayName(this);
|
||||
};
|
||||
|
||||
Template.attendance.rsvpIs = function (what) {
|
||||
@@ -299,6 +297,6 @@ Template.inviteDialog.uninvited = function () {
|
||||
return Meteor.users.find({_id: {$nin: invited}});
|
||||
};
|
||||
|
||||
Template.inviteDialog.email = function () {
|
||||
return this.emails[0].address;
|
||||
Template.inviteDialog.displayName = function () {
|
||||
return displayName(this);
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ Parties.allow({
|
||||
}
|
||||
});
|
||||
|
||||
var attending = function(party) {
|
||||
var attending = function (party) {
|
||||
return _.reduce(party.rsvps, function (memo, rsvp) {
|
||||
if (rsvp.rsvp === 'yes')
|
||||
return memo + 1;
|
||||
@@ -38,6 +38,20 @@ Parties.deny({
|
||||
}
|
||||
});
|
||||
|
||||
var displayName = function (user) {
|
||||
if (user.profile && user.profile.name)
|
||||
return user.profile.name;
|
||||
return user.emails[0].address;
|
||||
};
|
||||
|
||||
var contactEmail = function (user) {
|
||||
if (user.emails && user.emails.length)
|
||||
return user.emails[0].address;
|
||||
if (user.services.facebook && user.services.facebook.email)
|
||||
return user.services.facebook.email;
|
||||
return null;
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
// title, description, x, y, public
|
||||
// XXX limit a user to a certain number of parties
|
||||
@@ -78,8 +92,24 @@ Meteor.methods({
|
||||
if (party.public)
|
||||
throw new Meteor.Error(400,
|
||||
"That party is public. No need to invite people.");
|
||||
if (userId !== party.owner)
|
||||
if (userId !== party.owner && ! _.contains(party.invited, userId)) {
|
||||
Parties.update(partyId, { $addToSet: { invited: userId } });
|
||||
|
||||
var from = contactEmail(Meteor.users.findOne(this.userId));
|
||||
var to = contactEmail(Meteor.users.findOne(userId));
|
||||
if (Meteor.isServer && to) {
|
||||
Email.send({
|
||||
from: "noreply@example.com",
|
||||
to: to,
|
||||
replyTo: from || undefined,
|
||||
subject: "PARTY: " + party.title,
|
||||
text:
|
||||
"Hey, I just invited you to '" + party.title + "' on All Tomorrow's Parties.\n" +
|
||||
"\n" +
|
||||
"Come check it out at: " + Meteor.absoluteUrl() + "\n"
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
rsvp: function (partyId, rsvp) {
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
{{#each uninvited}}
|
||||
<div class="invite-row">
|
||||
<a href="#" class="btn invite">Invite</a>
|
||||
{{email}}
|
||||
{{displayName}}
|
||||
</div>
|
||||
{{else}}
|
||||
Everyone on the site has been invited.
|
||||
@@ -180,7 +180,7 @@
|
||||
|
||||
{{#each rsvps}}
|
||||
<div>
|
||||
{{rsvpEmail}}
|
||||
{{rsvpName}}
|
||||
{{#if rsvpIs "yes"}}
|
||||
<span class="label label-success pull-right">Going</span>
|
||||
{{/if}}
|
||||
@@ -196,7 +196,7 @@
|
||||
{{#unless public}}
|
||||
{{#each outstandingInvitations}}
|
||||
<div>
|
||||
{{invitationEmail}}
|
||||
{{invitationName}}
|
||||
<span class="label label-inverse pull-right">Invited</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XXX autopublish warning is printed on each restart. super spammy!
|
||||
|
||||
Meteor.publish("directory", function () {
|
||||
return Meteor.users.find({}, {fields: {emails: 1}});
|
||||
return Meteor.users.find({}, {fields: {emails: 1, profile: 1}});
|
||||
});
|
||||
|
||||
Meteor.publish("parties", function () {
|
||||
|
||||
Reference in New Issue
Block a user