From 964a24c6fd4d553b0ce09ea5a2513cbd0b88609e Mon Sep 17 00:00:00 2001 From: Huan LI Date: Thu, 26 Jul 2018 02:16:59 +0800 Subject: [PATCH] check contactList number when create new room (#1505) --- src/user/room.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/user/room.ts b/src/user/room.ts index 609c3ec8..69f18354 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) -- GitLab