mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
commet all chat method and fix create direct message
This commit is contained in:
@@ -651,11 +651,11 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
async getChatMembers() {
|
async getChatMembers() {
|
||||||
|
|
||||||
this.chatService.getAllUsers().subscribe(res => {
|
// this.chatService.getAllUsers().subscribe(res => {
|
||||||
//
|
// //
|
||||||
this.transformDataUserList(res['users'])
|
// this.transformDataUserList(res['users'])
|
||||||
|
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupsDB() {
|
getGroupsDB() {
|
||||||
|
|||||||
@@ -408,36 +408,36 @@ export class MessageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async redefinedMessage(ChatMessage , update = true) {
|
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.manualRetry = false
|
||||||
this.messageSend = true
|
// this.messageSend = true
|
||||||
|
|
||||||
ChatMessage = Object.assign(message, ChatMessage)
|
// ChatMessage = Object.assign(message, ChatMessage)
|
||||||
this.setData(ChatMessage)
|
// this.setData(ChatMessage)
|
||||||
|
|
||||||
const roomObject = this.ChatSystemService.getRoomById(this.rid)
|
// const roomObject = this.ChatSystemService.getRoomById(this.rid)
|
||||||
const users = roomObject.getUsersByStatus('online')
|
// const users = roomObject.getUsersByStatus('online')
|
||||||
for(const user of users) {
|
// for(const user of users) {
|
||||||
this.addReceived(user._id)
|
// this.addReceived(user._id)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(!roomObject.isGroup) {
|
// if(!roomObject.isGroup) {
|
||||||
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
// var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
||||||
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
// this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
||||||
} else {
|
// } else {
|
||||||
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
// var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
||||||
var usersNames = [];
|
// var usersNames = [];
|
||||||
for(let i = 0; i < memeberTosend.length; i++) {
|
// for(let i = 0; i < memeberTosend.length; i++) {
|
||||||
usersNames.push(memeberTosend[i].username)
|
// usersNames.push(memeberTosend[i].username)
|
||||||
}
|
// }
|
||||||
this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
// this.notificationService.ChatSendMessageNotificationGrup(usersNames,ChatMessage.u.name,ChatMessage.msg || "Anexo",this.rid)
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
await this.saveChanges()
|
// await this.saveChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
sendNotificaton
|
sendNotificaton
|
||||||
|
|||||||
@@ -400,22 +400,22 @@ export class RoomService {
|
|||||||
async info() {
|
async info() {
|
||||||
|
|
||||||
// set unread messages
|
// 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) {
|
// if(response?.subscription?.unread >= 1) {
|
||||||
this.messageUnread = true
|
// this.messageUnread = true
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
getUsersByStatus(status: 'offline' | 'online') {
|
getUsersByStatus(status: 'offline' | 'online') {
|
||||||
|
|
||||||
return this.getAllUsers().filter((user => {
|
// return this.getAllUsers().filter((user => {
|
||||||
for (const member of this.membersExcludeMe) {
|
// for (const member of this.membersExcludeMe) {
|
||||||
if (user._id == member._id && user.status == status) {
|
// if (user._id == member._id && user.status == status) {
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}))
|
// }))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,40 +430,40 @@ export class RoomService {
|
|||||||
|
|
||||||
getAllMemberThatIsNotOffline(): string[] {
|
getAllMemberThatIsNotOffline(): string[] {
|
||||||
|
|
||||||
const membersIds = this.getRoomMembersIds()
|
// const membersIds = this.getRoomMembersIds()
|
||||||
const allChatUsers = this.getAllUsers()
|
// const allChatUsers = this.getAllUsers()
|
||||||
|
|
||||||
const AllMemberThatIsNotOffline = []
|
// const AllMemberThatIsNotOffline = []
|
||||||
|
|
||||||
for (let user of allChatUsers) {
|
// for (let user of allChatUsers) {
|
||||||
if (membersIds.includes(user._id)) {
|
// if (membersIds.includes(user._id)) {
|
||||||
|
|
||||||
if (user.status != 'offline') {
|
// if (user.status != 'offline') {
|
||||||
AllMemberThatIsNotOffline.push(user._id)
|
// AllMemberThatIsNotOffline.push(user._id)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return AllMemberThatIsNotOffline
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllMemberThatIsOffline(): string[] {
|
getAllMemberThatIsOffline(): string[] {
|
||||||
|
|
||||||
const membersIds = this.getRoomMembersIds()
|
// const membersIds = this.getRoomMembersIds()
|
||||||
const allChatUsers = this.getAllUsers()
|
// const allChatUsers = this.getAllUsers()
|
||||||
|
|
||||||
const AllMemberThatIsNotOffline = []
|
// const AllMemberThatIsNotOffline = []
|
||||||
|
|
||||||
for (let user of allChatUsers) {
|
// for (let user of allChatUsers) {
|
||||||
if (membersIds.includes(user._id)) {
|
// if (membersIds.includes(user._id)) {
|
||||||
|
|
||||||
if (user.status == 'offline') {
|
// if (user.status == 'offline') {
|
||||||
AllMemberThatIsNotOffline.push(user._id)
|
// AllMemberThatIsNotOffline.push(user._id)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return AllMemberThatIsNotOffline
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -997,7 +997,7 @@ export class RoomService {
|
|||||||
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
|
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
|
||||||
if (messagesToSave != null) {
|
if (messagesToSave != null) {
|
||||||
|
|
||||||
messagesToSave.received = users.map((user) => user._id)
|
// messagesToSave.received = users.map((user) => user._id)
|
||||||
messagesToSave.addMessageDB()
|
messagesToSave.addMessageDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1008,7 +1008,7 @@ export class RoomService {
|
|||||||
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
|
const messagesToSave = await this.prepareMessageCreateIfNotExist({ message: message });
|
||||||
if (messagesToSave != null) {
|
if (messagesToSave != null) {
|
||||||
|
|
||||||
messagesToSave.received = users.map((user) => user._id)
|
// messagesToSave.received = users.map((user) => user._id)
|
||||||
|
|
||||||
this.addMessageDB.push(messagesToSave)
|
this.addMessageDB.push(messagesToSave)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<ion-label>{{ header }}</ion-label>
|
<ion-label>{{ header }}</ion-label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div (click)="openMessagesPage(user.wxFullName)" *virtualItem="let user" class="item-user cursor-pointer">
|
<div (click)="openMessagesPage(user.wxFullName, user.wxUserId)" *virtualItem="let user" class="item-user cursor-pointer">
|
||||||
<p>{{ user.wxFullName }}</p>
|
<p>{{ user.wxFullName }}</p>
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<ion-icon [class]="user.status" slot="end" name="ellipse"></ion-icon>
|
<ion-icon [class]="user.status" slot="end" name="ellipse"></ion-icon>
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/
|
|||||||
import { UserContacts } from 'src/app/services/Repositorys/contacts/data-source/contacts-data-source.service';
|
import { UserContacts } from 'src/app/services/Repositorys/contacts/data-source/contacts-data-source.service';
|
||||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||||
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
|
|
||||||
class UserToSelect {
|
class UserToSelect {
|
||||||
|
|
||||||
@@ -45,11 +46,12 @@ export class ContactsPage implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
private chatService: ChatService,
|
|
||||||
public ThemeService: ThemeService,
|
public ThemeService: ThemeService,
|
||||||
public ChatSystemService: ChatSystemService,
|
public ChatSystemService: ChatSystemService,
|
||||||
private contactsRepositoryService: ContactRepositoryService,
|
private contactsRepositoryService: ContactRepositoryService,
|
||||||
private roomRepositoryService: RoomRepositoryService
|
private roomRepositoryService: RoomRepositoryService,
|
||||||
|
private httpErrorHandle: HttpErrorHandle,
|
||||||
|
private toastService: ToastService,
|
||||||
) {
|
) {
|
||||||
this.loggedUser = SessionStore.user.ChatData['data'];
|
this.loggedUser = SessionStore.user.ChatData['data'];
|
||||||
this.textSearch = "";
|
this.textSearch = "";
|
||||||
@@ -72,8 +74,8 @@ export class ContactsPage implements OnInit {
|
|||||||
this.userList.sort((a, b) => a.wxFullName.toLowerCase().localeCompare(b.wxFullName.toLowerCase()));
|
this.userList.sort((a, b) => a.wxFullName.toLowerCase().localeCompare(b.wxFullName.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
openMessagesPage(username: string) {
|
openMessagesPage(username: string, wxUserId: number) {
|
||||||
this.createRoom(username);
|
this.createRoom(username, wxUserId);
|
||||||
/* if (window.innerWidth < 701) {
|
/* if (window.innerWidth < 701) {
|
||||||
this.createRoom(username);
|
this.createRoom(username);
|
||||||
}
|
}
|
||||||
@@ -150,12 +152,13 @@ export class ContactsPage implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async createRoom(username: string) {
|
async createRoom(username: string, wxUserId: number) {
|
||||||
const result = await this.roomRepositoryService.create({
|
const result = await this.roomRepositoryService.create({
|
||||||
roomName: username,
|
roomName: username,
|
||||||
createdBy: SessionStore.user.UserId,
|
createdBy: SessionStore.user.UserId,
|
||||||
roomType: 0,
|
roomType: 0,
|
||||||
expirationDate: null
|
expirationDate: null,
|
||||||
|
members: [wxUserId]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -163,10 +166,13 @@ export class ContactsPage implements OnInit {
|
|||||||
|
|
||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
|
|
||||||
// this.addGroupMessage.emit(result);
|
this.openMessage.emit(result.value.data.id);
|
||||||
|
|
||||||
} else if(result.error instanceof HttpErrorResponse) {
|
} else if(result.error instanceof HttpErrorResponse) {
|
||||||
|
this.httpErrorHandle.httpStatusHandle(result.error)
|
||||||
|
} else {
|
||||||
|
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
|
||||||
|
console.log(result.error)
|
||||||
}
|
}
|
||||||
/* this.chatService.createRoom(body).subscribe(res => {
|
/* this.chatService.createRoom(body).subscribe(res => {
|
||||||
|
|
||||||
@@ -192,13 +198,5 @@ export class ContactsPage implements OnInit {
|
|||||||
await modal.present();
|
await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
async openMessages(username: string) {
|
|
||||||
/* this.close(); */
|
|
||||||
|
|
||||||
let dm: any;
|
|
||||||
//Create new room
|
|
||||||
this.createRoom(username);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user