mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
Performance/inbox paging (#11258)
* merge all changes to one commit of PR #11157 / #11226 * rename the new paged messages route * rename event, move map-method to the Inbox schema, fix lint * move `mapMessage`-call to `getUserInbox` * revert schema.method back to a normal one
This commit is contained in:
@@ -98,8 +98,14 @@ export function setUserStyles (newMessage, user) {
|
||||
}
|
||||
}
|
||||
|
||||
let contributorCopy = user.contributor;
|
||||
if (contributorCopy && contributorCopy.toObject) {
|
||||
contributorCopy = contributorCopy.toObject();
|
||||
}
|
||||
|
||||
newMessage.contributor = contributorCopy;
|
||||
newMessage.userStyles = userStyles;
|
||||
newMessage.markModified('userStyles');
|
||||
newMessage.markModified('userStyles contributor');
|
||||
}
|
||||
|
||||
export function messageDefaults (msg, user, client, info = {}) {
|
||||
@@ -130,3 +136,20 @@ export function messageDefaults (msg, user, client, info = {}) {
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
export function mapInboxMessage (msg, user) {
|
||||
if (msg.sent) {
|
||||
msg.toUUID = msg.uuid;
|
||||
msg.toUser = msg.user;
|
||||
msg.toUserName = msg.username;
|
||||
msg.toUserContributor = msg.contributor;
|
||||
msg.toUserBacker = msg.backer;
|
||||
msg.uuid = user._id;
|
||||
msg.user = user.profile.name;
|
||||
msg.username = user.auth.local.username;
|
||||
msg.contributor = user.contributor;
|
||||
msg.backer = user.backer;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user