提交 964a24c6 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

check contactList number when create new room (#1505)

上级 63fabaf3
......@@ -86,10 +86,16 @@ export class Room extends Accessory implements Sayable {
public static async create (contactList: Contact[], topic?: string): Promise<Room> {
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册