Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
f76f249e
W
wechaty
项目概览
.Veneno.
/
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,发现更多精彩内容 >>
提交
f76f249e
编写于
10月 24, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make room-join event more reliable for invitee contact instance
上级
d48aab92
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
15 deletion
+60
-15
src/contact.ts
src/contact.ts
+1
-1
src/puppet-web/firer.ts
src/puppet-web/firer.ts
+28
-14
src/puppet-web/wechaty-bro.js
src/puppet-web/wechaty-bro.js
+31
-0
未找到文件。
src/contact.ts
浏览文件 @
f76f249e
...
...
@@ -99,7 +99,7 @@ export class Contact implements Sayable {
public
get
(
prop
)
{
return
this
.
obj
&&
this
.
obj
[
prop
]
}
public
isReady
():
boolean
{
return
!!
(
this
.
obj
&&
this
.
obj
.
id
)
return
!!
(
this
.
obj
&&
this
.
obj
.
id
&&
this
.
obj
.
name
!==
undefined
)
}
public
async
refresh
():
Promise
<
this
>
{
...
...
src/puppet-web/firer.ts
浏览文件 @
f76f249e
...
...
@@ -166,8 +166,7 @@ async function fireRoomJoin(m: Message): Promise<void> {
[
inviteeList
,
inviter
]
=
checkRoomJoin
(
content
)
}
catch
(
e
)
{
log
.
silly
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() "%s" is not a join message
'
,
content
)
// not a room join message
return
return
// not a room join message
}
log
.
silly
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() inviteeList: %s, inviter: %s
'
,
inviteeList
.
join
(
'
,
'
)
...
...
@@ -193,28 +192,43 @@ async function fireRoomJoin(m: Message): Promise<void> {
log
.
silly
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() retryPromise() attempt %d with timeout %d
'
,
attempt
,
timeout
)
await
room
.
refresh
()
let
i
Done
,
a
llDone
=
true
let
i
nviteeListA
llDone
=
true
for
(
let
i
in
inviteeList
)
{
iDone
=
inviteeContactList
[
i
]
instanceof
Contact
if
(
!
iDone
)
{
const
loaded
=
inviteeContactList
[
i
]
instanceof
Contact
if
(
!
loaded
)
{
let
c
=
room
.
member
(
inviteeList
[
i
])
if
(
c
)
{
inviteeContactList
[
i
]
=
await
c
.
ready
()
if
(
!
c
.
isReady
())
{
allDone
=
false
}
}
else
{
allDone
=
false
if
(
!
c
)
{
inviteeListAllDone
=
false
continue
}
inviteeContactList
[
i
]
=
await
c
.
ready
()
const
isReady
=
c
.
isReady
()
if
(
!
isReady
)
{
inviteeListAllDone
=
false
continue
}
}
if
(
inviteeContactList
[
i
]
instanceof
Contact
)
{
const
isReady
=
inviteeContactList
[
i
].
isReady
()
if
(
!
isReady
)
{
log
.
warn
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() retryPromise() isReady false for contact %s
'
,
inviteeContactList
[
i
].
id
)
inviteeListAllDone
=
false
await
inviteeContactList
[
i
].
refresh
()
continue
}
}
}
if
(
!
inviterContact
)
{
inviterContact
=
room
.
member
(
inviter
)
}
if
(
a
llDone
&&
inviterContact
)
{
if
(
inviteeListA
llDone
&&
inviterContact
)
{
log
.
silly
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() resolve() inviteeContactList: %s, inviterContact: %s
'
,
inviteeContactList
.
map
((
c
:
Contact
)
=>
c
.
name
()).
join
(
'
,
'
)
,
inviterContact
.
name
()
...
...
@@ -228,7 +242,7 @@ async function fireRoomJoin(m: Message): Promise<void> {
log
.
silly
(
'
PuppetWebFirer
'
,
'
fireRoomJoin() reject() inviteeContactList: %s, inviterContact: %s
'
,
inviteeContactList
.
map
((
c
:
Contact
)
=>
c
.
name
()).
join
(
'
,
'
)
,
inviter
)
)
})
if
(
!
inviterContact
)
{
...
...
src/puppet-web/wechaty-bro.js
浏览文件 @
f76f249e
...
...
@@ -440,6 +440,37 @@
contactWithoutFunction
[
k
]
=
c
[
k
]
}
})
}
else
{
/**
* when `id` does not exist in _contact Array, maybe it is belongs to a stranger in a room.
* try to find in room's member list for this `id`, and return the contact info, if any.
*/
c
=
Object
.
keys
(
_contacts
)
.
filter
(
id
=>
id
.
match
(
/^@@/
))
// only search in room
.
map
(
id
=>
_contacts
[
id
])
// map to room array
.
filter
(
r
=>
r
.
MemberList
.
length
)
// get rid of room without member list
.
filter
(
r
=>
r
.
MemberList
.
filter
(
m
=>
m
.
UserName
===
id
)
.
length
)
.
map
(
c
=>
c
.
MemberList
.
filter
(
m
=>
m
.
UserName
===
id
)
[
0
]
)
[
0
]
if
(
c
)
{
c
.
stranger
=
true
Object
.
keys
(
c
).
forEach
(
function
(
k
)
{
if
(
typeof
c
[
k
]
!==
'
function
'
)
{
contactWithoutFunction
[
k
]
=
c
[
k
]
}
})
}
}
return
contactWithoutFunction
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录