mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Chat optimization (#15545)
* fix(content): textual tweaks and updates * fix(link): direct to FAQ instead of wiki * fix(faq): correct Markdown * Show orb of rebirth confirmation modal after use (window refresh) * Set and check rebirth confirmation modal from localstorage Set and check rebirth confirmation modal from localstorage after window reload * Don't show orb of rebirth confirmation modal until page reloads * message effective limit optimization * Keep max limit for web (400 recent messages) * Fix amount of messages initially being shown * PM_PER_PAGE set to 50 * Increases number of messages in inbox test * Increases number of messages for inbox pagination test * Set and check rebirth confirmation modal from localstorage Set and check rebirth confirmation modal from localstorage after window reload * Don't show orb of rebirth confirmation modal until page reloads * message effective limit optimization * Keep max limit for web (400 recent messages) * Add UUID validation for 'before' query parameter * add party message stress test tool in admin panel * lint * add MAX_PM_COUNT of 400, admin tool for stress testing messages * comment * update stress test inbox message tool to use logged in user * comment --------- Co-authored-by: Kalista Payne <kalista@habitica.com>
This commit is contained in:
@@ -37,7 +37,9 @@ export async function sentMessage (sender, receiver, message, translate) {
|
||||
|
||||
return messageSent;
|
||||
}
|
||||
const PM_PER_PAGE = 10;
|
||||
// Paginate per every 50
|
||||
const PM_PER_PAGE = 50;
|
||||
const MAX_PM_COUNT = 400;
|
||||
|
||||
const getUserInboxDefaultOptions = {
|
||||
asArray: true,
|
||||
@@ -61,12 +63,18 @@ export async function getUserInbox (user, optionParams = getUserInboxDefaultOpti
|
||||
.sort({ timestamp: -1 });
|
||||
|
||||
if (typeof options.page !== 'undefined') {
|
||||
const page = Number(options.page);
|
||||
const skip = PM_PER_PAGE * page;
|
||||
if (skip >= MAX_PM_COUNT) {
|
||||
return options.asArray ? [] : {};
|
||||
}
|
||||
const remainingAllowed = MAX_PM_COUNT - skip;
|
||||
const limit = Math.min(PM_PER_PAGE, remainingAllowed);
|
||||
query = query
|
||||
.skip(PM_PER_PAGE * Number(options.page))
|
||||
.limit(PM_PER_PAGE);
|
||||
.skip(skip)
|
||||
.limit(limit);
|
||||
} else {
|
||||
// Limit for legacy calls that are not paginated to prevent database issues
|
||||
query = query.limit(200);
|
||||
query = query.limit(MAX_PM_COUNT);
|
||||
}
|
||||
|
||||
const messages = (await query.lean().exec()).map(msgObj => {
|
||||
|
||||
Reference in New Issue
Block a user