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

#119

上级 a972102f
......@@ -2916,12 +2916,14 @@ angular.module("Services", []),
},
addMember: function(e, t, o) {
var n = r.getContact(e);
n.MemberList.length + t.split(",").length >= 40 ? (console.log("invite", n.MemberList.length + t.split(",").length),
this._update("invitemember", e, {
inviteMembers: t
}, o)) : this._update("addmember", e, {
n.MemberList.length + t.split(",").length >= 40
? (console.log("invite", n.MemberList.length + t.split(",").length),
this._update("invitemember", e, {
inviteMembers: t
}, o))
: this._update("addmember", e, {
addMembers: t
}, o)
}, o)
},
delMember: function(e, t) {
this._update("delmember", e, {
......
......@@ -220,6 +220,7 @@ export class Contact implements Sayable {
public remark(): string | null
/**
* set the remark for contact
* @return {Promise<boolean>} A promise to the result. true for success, false for failure
*/
public remark(newRemark: string): Promise<boolean>
/**
......
......@@ -177,7 +177,7 @@ export class Bridge {
if (!roomId || !contactId) {
throw new Error('no roomId or contactId')
}
return this.proxyWechaty('roomAddMember', roomId, contactId)
return this.proxyWechaty('roomAddMemberAsync', roomId, contactId)
.catch(e => {
log.error('PuppetWebBridge', 'roomAddMember(%s, %s) exception: %s', roomId, contactId, e.message)
throw e
......
......@@ -611,12 +611,33 @@
return chatroomFactory.delMember(ChatRoomName, UserName)
}
function roomAddMember(ChatRoomName, UserName) {
function roomAddMemberAsync(ChatRoomName, UserName) {
var callback = arguments[arguments.length - 1]
if (typeof callback !== 'function') {
// here we should in sync mode, because there's no callback
throw new Error('async method need to be called via webdriver.executeAsyncScript')
}
var chatroomFactory = WechatyBro.glue.chatroomFactory
// XXX
// log(ChatRoomName)
// log(UserName)
return chatroomFactory.addMember(ChatRoomName, UserName)
// There's no return value of addMember :(
// https://github.com/wechaty/webwx-app-tracker/blob/f22cb043ff4201ee841990dbeb59e22643092f92/formatted/webwxApp.js#L2404-L2413
var timer = setTimeout(function() {
log('roomAddMemberAsync() timeout')
callback(0)
}, 10 * 1000)
chatroomFactory.addMember(ChatRoomName, UserName, function(result) {
clearTimeout(timer)
callback(1)
log('roomAddMemberAsync() return: ')
log(result)
})
}
function roomModTopic(ChatRoomName, topic) {
......
......@@ -235,16 +235,16 @@ export class Room extends EventEmitter implements Sayable {
Object.keys(this.obj).forEach(k => console.error(`${k}: ${this.obj && this.obj[k]}`))
}
public async add(contact: Contact): Promise<any> {
public async add(contact: Contact): Promise<number> {
log.verbose('Room', 'add(%s)', contact)
if (!contact) {
throw new Error('contact not found')
}
await Config.puppetInstance()
.roomAdd(this, contact)
return
const n = Config.puppetInstance()
.roomAdd(this, contact)
return n
}
public async del(contact: Contact): Promise<number> {
......@@ -254,8 +254,8 @@ export class Room extends EventEmitter implements Sayable {
throw new Error('contact not found')
}
const n = await Config.puppetInstance()
.roomDel(this, contact)
.then(_ => this.delLocal(contact))
.roomDel(this, contact)
.then(_ => this.delLocal(contact))
return n
}
......
......@@ -112,12 +112,12 @@ export class UtilLib {
if (protocol === 'https:') {
// request = https.request.bind(https)
get = https.get
options = u as https.RequestOptions
options = u as any as https.RequestOptions
options.agent = https.globalAgent
} else if (protocol === 'http:') {
// request = http.request.bind(http)
get = http.get
options = u as http.RequestOptions
options = u as any as http.RequestOptions
options.agent = http.globalAgent
} else {
throw new Error('protocol unknown: ' + protocol)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册