diff --git a/common/script/content/spells.js b/common/script/content/spells.js index 9381ba89d5..a4632dbea4 100644 --- a/common/script/content/spells.js +++ b/common/script/content/spells.js @@ -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; }, }, diff --git a/website/client/js/services/chatServices.js b/website/client/js/services/chatServices.js index a79de22b85..4020c9dd92 100644 --- a/website/client/js/services/chatServices.js +++ b/website/client/js/services/chatServices.js @@ -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}); - } }]); diff --git a/website/server/controllers/api-v3/chat.js b/website/server/controllers/api-v3/chat.js index 7be628f0df..7738189b6f 100644 --- a/website/server/controllers/api-v3/chat.js +++ b/website/server/controllers/api-v3/chat.js @@ -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;