Files
doneit-web/src/app/controller/event.ts
T

49 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-06-22 12:53:35 +01:00
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
}
}
}