Improve Adminpanel with local logs (#15404)

* log armoire, quoest response and cron events to history

* show user history in admin panel

* allow stats to be edited from admin panel

* Improve admin panel stats input

* improve setting client in history

* fix tests

* fix lint

* fix armoire buying issue

* Improve hero saving

* Formatting fix

* Improve user history logging

* allow class to be changed from admin panel

* make terminating subscriptions easier

* support decimal extraMonths

* Fix editing some achievements in admin panel

* log if a user invites party to quest

* Log more quest events into user history

* make userhistory length configurable

* fix some numbered achievements

* fix extraMonths field

* Automatically set up group plan subs with admin panel

* show party info nicer in admin panel

* improve admin panel sub handling

* add missing brace

* display when there are unsaved changes

* fix setting group plan

* fix showing group id

* Display group plan info in admin panel

* fix setting hourglass promo date

* Improve termination handling in admin panel

* reload data after certain save events in admin panel

* remove console

* fix plan.extraMonths not being reset if terminating a sub

* add more options when cancelling subs

* reload data after group plan change

* Add a way to remove users from a party

* fix issue with removing user from party

* pass party id correctly

* correctly call async function

* Improve sub display in admin panel

* fix line length

* fix line

* shorter

* plaid

* fix(lint): vue code style

---------

Co-authored-by: Kalista Payne <sabrecat@gmail.com>
This commit is contained in:
Phillip Thelen
2025-03-17 22:48:21 +01:00
committed by GitHub
parent dbc23e89b8
commit 379afa9554
32 changed files with 1743 additions and 201 deletions

View File

@@ -19,6 +19,7 @@ import common from '../../../common';
import { sendNotification as sendPushNotification } from '../../libs/pushNotifications';
import { apiError } from '../../libs/apiError';
import { questActivityWebhook } from '../../libs/webhook';
import { model as UserHistory } from '../../models/userHistory';
const analytics = getAnalyticsServiceByEnvironment();
@@ -172,6 +173,10 @@ api.inviteToQuest = {
uuid: user._id,
headers: req.headers,
});
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(group.quest.key, 'invite')
.commit();
},
};
@@ -233,6 +238,10 @@ api.acceptQuest = {
uuid: user._id,
headers: req.headers,
});
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(group.quest.key, 'accept')
.commit();
},
};
@@ -294,6 +303,10 @@ api.rejectQuest = {
uuid: user._id,
headers: req.headers,
});
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(group.quest.key, 'reject')
.commit();
},
};
@@ -399,13 +412,14 @@ api.cancelQuest = {
}
if (group.quest.active) throw new NotAuthorized(res.t('cantCancelActiveQuest'));
const questName = questScrolls[group.quest.key].text('en');
const questKey = group.quest.key;
const questName = questScrolls[questKey].text('en');
const newChatMessage = await group.sendChat({
message: `\`${user.profile.name} cancelled the party quest ${questName}.\``,
info: {
type: 'quest_cancel',
user: user.profile.name,
quest: group.quest.key,
quest: questKey,
},
});
@@ -422,6 +436,15 @@ api.cancelQuest = {
]);
res.respond(200, savedGroup.quest);
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(questKey, 'cancel')
.commit();
if (group.quest.leader !== user._id) {
await UserHistory.beginUserHistoryUpdate(group.quest.leader, req.headers)
.withQuestInviteResponse(questKey, 'cancelByLeader')
.commit();
}
},
};
@@ -461,13 +484,14 @@ api.abortQuest = {
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'));
const questName = questScrolls[group.quest.key].text('en');
const questKey = group.quest.key;
const questName = questScrolls[questKey].text('en');
const newChatMessage = await group.sendChat({
message: `\`${common.i18n.t('chatQuestAborted', { username: user.profile.name, questName }, 'en')}\``,
info: {
type: 'quest_abort',
user: user.profile.name,
quest: group.quest.key,
quest: questKey,
},
});
await newChatMessage.save();
@@ -480,7 +504,7 @@ api.abortQuest = {
_id: group.quest.leader,
}, {
$inc: {
[`items.quests.${group.quest.key}`]: 1, // give back the quest to the quest leader
[`items.quests.${questKey}`]: 1, // give back the quest to the quest leader
},
}).exec();
@@ -490,6 +514,15 @@ api.abortQuest = {
const [groupSaved] = await Promise.all([group.save(), memberUpdates, questLeaderUpdate]);
res.respond(200, groupSaved.quest);
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(questKey, 'abort')
.commit();
if (group.quest.leader !== user._id) {
await UserHistory.beginUserHistoryUpdate(group.quest.leader, req.headers)
.withQuestInviteResponse(questKey, 'abortByLeader')
.commit();
}
},
};
@@ -537,6 +570,10 @@ api.leaveQuest = {
]);
res.respond(200, savedGroup.quest);
await UserHistory.beginUserHistoryUpdate(user._id, req.headers)
.withQuestInviteResponse(group.quest.key, 'leave')
.commit();
},
};