mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00

Using jshint and and fixmyjs I went through and removed 220 trivial Javascript errors – mostly missing semicolons, and some properties that weren’t written in dot notation. You can view the diff of jshint’s output here: https://gist.github.com/christianbundy/7b37c51bb6f7c8d739e7/revisions
39 lines
No EOL
1.3 KiB
JavaScript
39 lines
No EOL
1.3 KiB
JavaScript
Meteor.methods({
|
|
inviteUser: function (userId) {
|
|
var currentUser = Meteor.user(),
|
|
invitedUser = Meteor.users.findOne(userId),
|
|
invite = {
|
|
invitedId: userId,
|
|
invitedName: getDisplayName(invitedUser),
|
|
time: new Date()
|
|
},
|
|
currentUserCanInvite = (currentUser.inviteCount > 0 && canInvite(currentUser)),
|
|
currentUserIsAdmin = isAdmin(currentUser);
|
|
|
|
// if the current user is logged in, still has available invites and is himself invited (or an admin), and the target user is not invited
|
|
if(currentUser && !isInvited(invitedUser) && (currentUserIsAdmin || currentUserCanInvite)){
|
|
|
|
// update invinting user
|
|
Meteor.users.update(Meteor.userId(), {$inc:{inviteCount: -1}, $inc:{invitedCount: 1}, $push:{invites: invite}});
|
|
|
|
// update invited user
|
|
var a=Meteor.users.update(userId, {$set: {
|
|
isInvited: true,
|
|
invitedBy: currentUser._id,
|
|
invitedByName: getDisplayName(currentUser)
|
|
}});
|
|
console.log(a);
|
|
|
|
createNotification({
|
|
event: 'accountApproved',
|
|
properties: {},
|
|
userToNotify: invitedUser,
|
|
userDoingAction: currentUser,
|
|
sendEmail: true
|
|
});
|
|
|
|
}else{
|
|
throw new Meteor.Error(701, "You can't invite this user, sorry.");
|
|
}
|
|
}
|
|
}); |