Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
75a980fd
W
wechaty
项目概览
weixin_46011646
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75a980fd
编写于
12月 03, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add boolean return value to FriendRequest.{send,accept}
上级
c99fc3a2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
21 deletion
+36
-21
src/friend-request.ts
src/friend-request.ts
+2
-2
src/puppet-web/bridge.ts
src/puppet-web/bridge.ts
+4
-4
src/puppet-web/friend-request.ts
src/puppet-web/friend-request.ts
+10
-11
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+2
-2
src/puppet-web/wechaty-bro.js
src/puppet-web/wechaty-bro.js
+18
-2
未找到文件。
src/friend-request.ts
浏览文件 @
75a980fd
...
...
@@ -30,7 +30,7 @@ export abstract class FriendRequest {
}
}
public
abstract
send
(
contact
:
Contact
,
hello
:
string
):
Promise
<
void
>
public
abstract
accept
():
Promise
<
void
>
public
abstract
send
(
contact
:
Contact
,
hello
:
string
):
Promise
<
boolean
>
public
abstract
accept
():
Promise
<
boolean
>
}
src/puppet-web/bridge.ts
浏览文件 @
75a980fd
...
...
@@ -216,26 +216,26 @@ export class Bridge {
})
}
public
verifyUserRequest
(
contactId
,
hello
):
Promise
<
void
>
{
public
verifyUserRequest
(
contactId
,
hello
):
Promise
<
boolean
>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
verifyUserRequest(%s, %s)
'
,
contactId
,
hello
)
if
(
!
contactId
)
{
throw
new
Error
(
'
no valid contactId
'
)
}
return
this
.
proxyWechaty
(
'
verifyUserRequest
'
,
contactId
,
hello
)
return
this
.
proxyWechaty
(
'
verifyUserRequest
Async
'
,
contactId
,
hello
)
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWebBridge
'
,
'
verifyUserRequest(%s, %s) exception: %s
'
,
contactId
,
hello
,
e
.
message
)
throw
e
})
}
public
verifyUserOk
(
contactId
,
ticket
):
Promise
<
void
>
{
public
verifyUserOk
(
contactId
,
ticket
):
Promise
<
boolean
>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
verifyUserOk(%s, %s)
'
,
contactId
,
ticket
)
if
(
!
contactId
||
!
ticket
)
{
throw
new
Error
(
'
no valid contactId or ticket
'
)
}
return
this
.
proxyWechaty
(
'
verifyUserOk
'
,
contactId
,
ticket
)
return
this
.
proxyWechaty
(
'
verifyUserOk
Async
'
,
contactId
,
ticket
)
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWebBridge
'
,
'
verifyUserOk(%s, %s) exception: %s
'
,
contactId
,
ticket
,
e
.
message
)
throw
e
...
...
src/puppet-web/friend-request.ts
浏览文件 @
75a980fd
...
...
@@ -21,9 +21,9 @@ const retryPromise = require('retry-promise').default
import
{
Contact
}
from
'
../contact
'
import
{
Config
,
RecommendInfo
,
log
Config
,
RecommendInfo
,
log
,
}
from
'
../config
'
import
{
FriendRequest
}
from
'
../friend-request
'
...
...
@@ -75,7 +75,7 @@ class PuppetWebFriendRequest extends FriendRequest {
this
.
type
=
'
confirm
'
}
public
async
send
(
contact
:
Contact
,
hello
=
'
Hi
'
):
Promise
<
void
>
{
public
async
send
(
contact
:
Contact
,
hello
=
'
Hi
'
):
Promise
<
boolean
>
{
log
.
verbose
(
'
PuppetWebFriendRequest
'
,
'
send(%s)
'
,
contact
)
if
(
!
contact
)
{
...
...
@@ -88,20 +88,19 @@ class PuppetWebFriendRequest extends FriendRequest {
this
.
hello
=
hello
}
await
Config
.
puppetInstance
()
return
Config
.
puppetInstance
()
.
friendRequestSend
(
contact
,
hello
)
return
}
public
async
accept
():
Promise
<
void
>
{
public
async
accept
():
Promise
<
boolean
>
{
log
.
verbose
(
'
FriendRequest
'
,
'
accept() %s
'
,
this
.
contact
)
if
(
this
.
type
!==
'
receive
'
)
{
throw
new
Error
(
'
request
on
a
'
+
this
.
type
+
'
type
'
)
throw
new
Error
(
'
request
is not a `receive` type. it is
a
'
+
this
.
type
+
'
type
'
)
}
await
Config
.
puppetInstance
()
.
friendRequestAccept
(
this
.
contact
,
this
.
ticket
)
const
ret
=
await
Config
.
puppetInstance
()
.
friendRequestAccept
(
this
.
contact
,
this
.
ticket
)
const
max
=
20
const
backoff
=
300
...
...
@@ -127,7 +126,7 @@ class PuppetWebFriendRequest extends FriendRequest {
log
.
warn
(
'
PuppetWebFriendRequest
'
,
'
accept() rejected for contact %s because %s
'
,
this
.
contact
,
e
&&
e
.
message
||
e
)
})
return
return
ret
}
}
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
75a980fd
...
...
@@ -477,7 +477,7 @@ export class PuppetWeb extends Puppet {
/**
* FriendRequest
*/
public
async
friendRequestSend
(
contact
:
Contact
,
hello
:
string
):
Promise
<
any
>
{
public
async
friendRequestSend
(
contact
:
Contact
,
hello
:
string
):
Promise
<
boolean
>
{
if
(
!
this
.
bridge
)
{
return
Promise
.
reject
(
new
Error
(
'
fail: no bridge(yet)!
'
))
}
...
...
@@ -494,7 +494,7 @@ export class PuppetWeb extends Puppet {
}
}
public
async
friendRequestAccept
(
contact
:
Contact
,
ticket
:
string
):
Promise
<
any
>
{
public
async
friendRequestAccept
(
contact
:
Contact
,
ticket
:
string
):
Promise
<
boolean
>
{
if
(
!
this
.
bridge
)
{
return
Promise
.
reject
(
new
Error
(
'
fail: no bridge(yet)!
'
))
}
...
...
src/puppet-web/wechaty-bro.js
浏览文件 @
75a980fd
...
...
@@ -667,7 +667,13 @@
})
}
function
verifyUserRequest
(
UserName
,
VerifyContent
)
{
function
verifyUserRequestAsync
(
UserName
,
VerifyContent
)
{
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
'
)
}
VerifyContent
=
VerifyContent
||
''
;
var
contactFactory
=
WechatyBro
.
glue
.
contactFactory
...
...
@@ -685,13 +691,21 @@
.
then
(
function
()
{
// succ
// alert('ok')
log
(
'
friendAdd(
'
+
UserName
+
'
,
'
+
VerifyContent
+
'
) done
'
)
callback
(
true
)
},
function
(
t
)
{
// fail
// alert('not ok')
log
(
'
friendAdd(
'
+
UserName
+
'
,
'
+
VerifyContent
+
'
) fail:
'
+
t
)
callback
(
false
)
})
}
function
verifyUserOk
(
UserName
,
Ticket
)
{
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
contactFactory
=
WechatyBro
.
glue
.
contactFactory
var
confFactory
=
WechatyBro
.
glue
.
confFactory
...
...
@@ -703,9 +717,11 @@
}).
then
(
function
()
{
// succ
// alert('ok')
log
(
'
friendVerify(
'
+
UserName
+
'
,
'
+
Ticket
+
'
) done
'
)
},
function
()
{
// fail
callback
(
true
)
},
function
(
err
)
{
// fail
// alert('err')
log
(
'
friendVerify(
'
+
UserName
+
'
,
'
+
Ticket
+
'
) fail
'
)
callback
(
false
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录