mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
|
|
import { chatUser } from '../models/chatMethod'
|
||
|
|
import { ChatController } from './chat'
|
||
|
|
export class EventController {
|
||
|
|
static create() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
static edit() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
static async createOrFindGroupFromEvent(name, attendees) {
|
||
|
|
// chatController.
|
||
|
|
const {data, roomName} = await ChatController.createGroup(name)
|
||
|
|
|
||
|
|
const roomId = data.rid
|
||
|
|
|
||
|
|
if (data.error.error == "error-duplicate-channel-name") {
|
||
|
|
const getGroupByName = ChatController.ChatSystemService.getGroupByName(roomName)
|
||
|
|
if(getGroupByName) {
|
||
|
|
return getGroupByName
|
||
|
|
}
|
||
|
|
} else if (roomId) {
|
||
|
|
const room = await ChatController.ChatSystemService.waitRoomToCreate(roomId)
|
||
|
|
|
||
|
|
const chatUsers: chatUser[] = []
|
||
|
|
|
||
|
|
for (let webTRIXUser of attendees ) {
|
||
|
|
const username = webTRIXUser.EmailAddress.split("@")[0];
|
||
|
|
const name = webTRIXUser.Name
|
||
|
|
|
||
|
|
const findChatUser = ChatController.ChatSystemService.searchContact(name, username)
|
||
|
|
if(findChatUser) {
|
||
|
|
chatUsers.push(findChatUser)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
for (let chatUser of chatUsers) {
|
||
|
|
room.addContacts(chatUser._id)
|
||
|
|
}
|
||
|
|
|
||
|
|
return room
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|