diff --git a/src/user/room.ts b/src/user/room.ts index 609c3ec8f07a7b41cdd43dfa88b9aca85fba75a0..69f1835436158c49e6754f79ed3ea9bada569576 100644 --- a/src/user/room.ts +++ b/src/user/room.ts @@ -86,10 +86,16 @@ export class Room extends Accessory implements Sayable { public static async create (contactList: Contact[], topic?: string): Promise { log.verbose('Room', 'create(%s, %s)', contactList.join(','), topic) - if (!contactList || !Array.isArray(contactList)) { + if ( !contactList + || !Array.isArray(contactList) + ) { throw new Error('contactList not found') } + if (contactList.length < 2) { + throw new Error('contactList need at least 2 contact to create a new room') + } + try { const contactIdList = contactList.map(contact => contact.id) const roomId = await this.puppet.roomCreate(contactIdList, topic)