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:
negue
2019-07-15 11:25:22 +02:00
committed by Matteo Pagliazzi
parent d28e1708c5
commit c9a56e8f3e
12 changed files with 387 additions and 126 deletions

View File

@@ -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;
}