commet all chat method and fix create direct message

This commit is contained in:
Peter Maquiran
2024-06-12 00:25:37 +01:00
parent 39bc8979a8
commit 703c3aaed6
5 changed files with 80 additions and 82 deletions
+25 -25
View File
@@ -408,36 +408,36 @@ export class MessageService {
}
async redefinedMessage(ChatMessage , update = true) {
ChatMessage = this.NfService.fix_updatedAt(ChatMessage)
// ChatMessage = this.NfService.fix_updatedAt(ChatMessage)
const message = this.getChatObj()
// const message = this.getChatObj()
this.manualRetry = false
this.messageSend = true
// this.manualRetry = false
// this.messageSend = true
ChatMessage = Object.assign(message, ChatMessage)
this.setData(ChatMessage)
// ChatMessage = Object.assign(message, ChatMessage)
// this.setData(ChatMessage)
const roomObject = this.ChatSystemService.getRoomById(this.rid)
const users = roomObject.getUsersByStatus('online')
for(const user of users) {
this.addReceived(user._id)
}
// const roomObject = this.ChatSystemService.getRoomById(this.rid)
// const users = roomObject.getUsersByStatus('online')
// for(const user of users) {
// this.addReceived(user._id)
// }
if(!roomObject.isGroup) {
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
} else {
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
var usersNames = [];
for(let i = 0; i < memeberTosend.length; i++) {
usersNames.push(memeberTosend[i].username)
}
this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
}
// if(!roomObject.isGroup) {
// var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
// this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
// } else {
// var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
// var usersNames = [];
// for(let i = 0; i < memeberTosend.length; i++) {
// usersNames.push(memeberTosend[i].username)
// }
// this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
// }
await this.saveChanges()
// await this.saveChanges()
}
sendNotificaton
@@ -458,8 +458,8 @@ export class MessageService {
if (this.file.type == "application/img") {
downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
} else if (this.file.type != "application/img") {
downloadFile = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
downloadUrl = event.url
console.log('downloaded file', downloadFile)
+35 -35
View File
@@ -400,22 +400,22 @@ export class RoomService {
async info() {
// set unread messages
const response: any = await this.chatService.GetSubscriptionRoomUnreadM(this.id).toPromise()
// const response: any = await this.chatService.GetSubscriptionRoomUnreadM(this.id).toPromise()
if(response?.subscription?.unread >= 1) {
this.messageUnread = true
}
// if(response?.subscription?.unread >= 1) {
// this.messageUnread = true
// }
}
getUsersByStatus(status: 'offline' | 'online') {
return this.getAllUsers().filter((user => {
for (const member of this.membersExcludeMe) {
if (user._id == member._id && user.status == status) {
return true
}
}
}))
// return this.getAllUsers().filter((user => {
// for (const member of this.membersExcludeMe) {
// if (user._id == member._id && user.status == status) {
// return true
// }
// }
// }))
}
@@ -430,40 +430,40 @@ export class RoomService {
getAllMemberThatIsNotOffline(): string[] {
const membersIds = this.getRoomMembersIds()
const allChatUsers = this.getAllUsers()
// const membersIds = this.getRoomMembersIds()
// const allChatUsers = this.getAllUsers()
const AllMemberThatIsNotOffline = []
// const AllMemberThatIsNotOffline = []
for (let user of allChatUsers) {
if (membersIds.includes(user._id)) {
// for (let user of allChatUsers) {
// if (membersIds.includes(user._id)) {
if (user.status != 'offline') {
AllMemberThatIsNotOffline.push(user._id)
}
}
}
// if (user.status != 'offline') {
// AllMemberThatIsNotOffline.push(user._id)
// }
// }
// }
return AllMemberThatIsNotOffline
return []
}
getAllMemberThatIsOffline(): string[] {
const membersIds = this.getRoomMembersIds()
const allChatUsers = this.getAllUsers()
// const membersIds = this.getRoomMembersIds()
// const allChatUsers = this.getAllUsers()
const AllMemberThatIsNotOffline = []
// const AllMemberThatIsNotOffline = []
for (let user of allChatUsers) {
if (membersIds.includes(user._id)) {
// for (let user of allChatUsers) {
// if (membersIds.includes(user._id)) {
if (user.status == 'offline') {
AllMemberThatIsNotOffline.push(user._id)
}
}
}
// if (user.status == 'offline') {
// AllMemberThatIsNotOffline.push(user._id)
// }
// }
// }
return AllMemberThatIsNotOffline
return []
}
@@ -997,7 +997,7 @@ export class RoomService {
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
if (messagesToSave != null) {
messagesToSave.received = users.map((user) => user._id)
// messagesToSave.received = users.map((user) => user._id)
messagesToSave.addMessageDB()
}
@@ -1008,7 +1008,7 @@ export class RoomService {
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
if (messagesToSave != null) {
messagesToSave.received = users.map((user) => user._id)
// messagesToSave.received = users.map((user) => user._id)
this.addMessageDB.push(messagesToSave)
}