v3 client: fix ability to send cards

This commit is contained in:
Matteo Pagliazzi
2016-05-17 17:35:49 +02:00
parent bb6809fd6b
commit d293b2d6ee
3 changed files with 23 additions and 6 deletions

View File

@@ -396,7 +396,10 @@ spells.special = {
if (!target.items.special.nyeReceived) target.items.special.nyeReceived = [];
target.items.special.nyeReceived.push(user.profile.name);
if (!target.flags) target.flags = {};
target.flags.cardReceived = true;
user.stats.gp -= 10;
},
},
@@ -421,7 +424,10 @@ spells.special = {
if (!target.items.special.valentineReceived) target.items.special.valentineReceived = [];
target.items.special.valentineReceived.push(user.profile.name);
if (!target.flags) target.flags = {};
target.flags.cardReceived = true;
user.stats.gp -= 10;
},
},
@@ -445,7 +451,10 @@ spells.special = {
if (!target.items.special.greetingReceived) target.items.special.greetingReceived = [];
target.items.special.greetingReceived.push(user.profile.name);
if (!target.flags) target.flags = {};
target.flags.cardReceived = true;
user.stats.gp -= 10;
},
},
@@ -470,7 +479,10 @@ spells.special = {
if (!target.items.special.thankyouReceived) target.items.special.thankyouReceived = [];
target.items.special.thankyouReceived.push(user.profile.name);
if (!target.flags) target.flags = {};
target.flags.cardReceived = true;
user.stats.gp -= 10;
},
},
@@ -492,9 +504,13 @@ spells.special = {
u.achievements.birthday++;
});
}
if (!target.items.special.birthdayReceived) target.items.special.birthdayReceived = [];
target.items.special.birthdayReceived.push(user.profile.name);
if (!target.flags) target.flags = {};
target.flags.cardReceived = true;
user.stats.gp -= 10;
},
},

View File

@@ -70,6 +70,10 @@ angular.module('habitrpg')
});
}
function clearCards () {
User.user._wrapped && User.set({'flags.cardReceived':false});
}
return {
getChat: getChat,
postChat: postChat,
@@ -80,8 +84,4 @@ angular.module('habitrpg')
markChatSeen: markChatSeen,
clearCards: clearCards,
}
function clearCards() {
User.user._wrapped && User.set({'flags.cardReceived':false});
}
}]);

View File

@@ -327,8 +327,9 @@ api.seenChat = {
let validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors;
let group = await Group.getGroup({user, groupId});
if (!group) throw new NotFound(res.t('groupNotFound'));
// Do not validate group existence, it doesn't really matter and make it works if the group gets deleted
// let group = await Group.getGroup({user, groupId});
// if (!group) throw new NotFound(res.t('groupNotFound'));
let update = {$unset: {}};
update.$unset[`newMessages.${groupId}`] = true;