mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
save
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as FIFOProcessQueue from 'fifo-process-queue';
|
||||
import { RoomService } from './room.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ViewedMessageService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
viewQueue = FIFOProcessQueue(async ({room, userId, statusNum, statusText}, callback) => {
|
||||
|
||||
if(room.membersExcludeMe?.map) {
|
||||
const membersIds = room.membersExcludeMe.map((user)=> user._id)
|
||||
|
||||
if(membersIds.includes(userId)) {
|
||||
|
||||
if(statusText != 'offline') {
|
||||
room.deleteMessageToReceive(userId)
|
||||
}
|
||||
|
||||
await room.messages.forEach(async (message, index) => {
|
||||
if(!message.messageOwnerById(userId)) {
|
||||
|
||||
if(!room.messages[index]?.received?.includes(userId)) {
|
||||
|
||||
if(room.messages[index]._id) {
|
||||
try {
|
||||
if(!room.messages[index].received.includes(userId)) {
|
||||
room.messages[index].received.push(userId)
|
||||
}
|
||||
} catch(e) {
|
||||
room.messages[index].received = [userId]
|
||||
}
|
||||
room.messages[index].save()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(function () {
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
request(room:RoomService, userId, statusNum, statusText) {
|
||||
this.viewQueue.push({room, userId, statusNum, statusText})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user