Fixed incorrect handling of message unread notifications. Dependency audit fixes

This commit is contained in:
Jemma
2023-10-23 21:08:10 -05:00
parent 3df8b6748a
commit e16342997d
2 changed files with 1782 additions and 1576 deletions

3338
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -34,18 +34,14 @@ const ConversationSchema = new Schema({
users: [user]
});
ConversationSchema.methods.newMessage = async function(message, fromPid) {
if(this.users[0].pid === fromPid) {
this.users[1].read = false;
this.markModified('users[1].read');
}
else {
this.users[0].read = false;
this.markModified('users[0].read');
}
this.set('last_updated', moment(new Date()));
this.set('message_preview', message);
await this.save();
ConversationSchema.methods.newMessage = async function(message, senderPID) {
this.last_updated = new Date();
this.message_preview = message;
const sender = this.users.find(user => user.pid === senderPID);
if (sender) {
sender.read = false;
}
await this.save();
}
ConversationSchema.methods.markAsRead = async function(pid) {