mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
* Send a message to the party chat when a quest is aborted * Added test cases for sending a message to party when quest is aborted * Restore Group.prototype.sendChat after aborted quest test
This commit is contained in:
@@ -412,12 +412,16 @@ api.abortQuest = {
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
let group = await Group.getGroup({user, groupId, fields: 'type quest leader'});
|
||||
let group = await Group.getGroup({user, groupId, fields: 'type quest leader chat'});
|
||||
|
||||
if (!group) throw new NotFound(res.t('groupNotFound'));
|
||||
if (group.type !== 'party') throw new NotAuthorized(res.t('guildQuestsNotSupported'));
|
||||
if (!group.quest.active) throw new NotFound(res.t('noActiveQuestToAbort'));
|
||||
if (user._id !== group.leader && user._id !== group.quest.leader) throw new NotAuthorized(res.t('onlyLeaderAbortQuest'));
|
||||
|
||||
let questName = questScrolls[group.quest.key].text('en');
|
||||
group.sendChat(`\`${user.profile.name} aborted the party quest ${questName}.\``);
|
||||
|
||||
let memberUpdates = User.update({
|
||||
'party._id': groupId,
|
||||
}, {
|
||||
|
||||
Reference in New Issue
Block a user