-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(wechaty-bro): resolved emit RECALLED type msg (fix #8) #744
Conversation
There is a small problem with this way, after the recall message, the web page displays a blank message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your implement is clean and straight forward, Awesome job!
And the message usage is what I thought it should be: a message with RECALLED MsgType set.
I leave some questions & suggestions in the review message, please let me know what you think.
Thanks!
src/puppet-web/wechaty-bro.js
Outdated
@@ -76,6 +76,7 @@ | |||
glueToAngular() | |||
connectSocket() | |||
hookEvents() | |||
hookProcess() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to suggest we name this function to hookRecalledMsgProcess
because that would look more straight forward than hookProcess
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use hookProcess
because I think in the future may add other hooks. But for now, the term is not clear, I will modify it.
src/puppet-web/wechaty-bro.js
Outdated
|
||
function hookProcess() { | ||
var chatFactory = WechatyBro.glue.chatFactory | ||
var rootScope = WechatyBro.glue.rootScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootScope
is not needed at here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will remove it.
src/puppet-web/wechaty-bro.js
Outdated
// hook chatFactory._recalledMsgProcess, resolve emit RECALLED type msg | ||
chatFactory.__recalledMsgProcess = chatFactory._recalledMsgProcess | ||
chatFactory._recalledMsgProcess = function (msg) { | ||
var _this = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason that you save this
to _this
?
IMHO, It seems not necessary to do that inside this function?
src/puppet-web/wechaty-bro.js
Outdated
chatFactory.__recalledMsgProcess = chatFactory._recalledMsgProcess | ||
chatFactory._recalledMsgProcess = function (msg) { | ||
var _this = this | ||
_this.__recalledMsgProcess(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use chatFactory
at here instead of this
?
Like: chatFactory.__recalledMsgProcess
and __recalledMsgProcess.addChatMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it, it can work:
chatFactory._recalledMsgProcess = function (msg) {
chatFactory.__recalledMsgProcess(msg)
chatFactory.addChatMessage(msg)
}
src/message.ts
Outdated
* }) | ||
* ``` | ||
*/ | ||
public getRevokeId(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to add this new method?
I did not think it's necessary.
Please correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RECALLED msg, content:
<sysmsg type="revokemsg"><revokemsg><session>binsee</session><oldmsgid>1056815127</oldmsgid><msgid>6991717488370193149</msgid><replacemsg><![CDATA["杉木" 撤回了一条消息]]></replacemsg></revokemsg></sysmsg>
use UtilLib.unescapeHtml(this.obj.content)
// the content has been formatted
<sysmsg type="revokemsg">
<revokemsg>
<session>binsee</session>
<oldmsgid>1056815127</oldmsgid>
<msgid>6991717488370193149</msgid>
<replacemsg>
<![CDATA["杉木" 撤回了一条消息]]>
</replacemsg>
</revokemsg>
</sysmsg>
We need to use getRevokeId () package to extract the code msgId
const ret = UtilLib.unescapeHtml(this.obj.content).match(/<msgid>(\w+)<\/msgid>/)
modify `_this` to `chatFactory`
RECALLED msg, content: <sysmsg type="revokemsg"><revokemsg><session>binsee</session><oldmsgid>1056815127</oldmsgid><msgid>6991717488370193149</msgid><replacemsg><![CDATA["杉木" 撤回了一条消息]]></replacemsg></revokemsg></sysmsg> use // the content has been formatted
<sysmsg type="revokemsg">
<revokemsg>
<session>binsee</session>
<oldmsgid>1056815127</oldmsgid>
<msgid>6991717488370193149</msgid>
<replacemsg>
<![CDATA["杉木" 撤回了一条消息]]>
</replacemsg>
</revokemsg>
</sysmsg> We need to use getRevokeId () package to extract the code const ret = UtilLib.unescapeHtml(this.obj.content).match(/<msgid>(\w+)<\/msgid>/) |
I see. As my understanding now, the parameter of If so, I think the better design to do this might be(in wechaty-bro.js):
The above design could let the end-user receive a How about this idea, what do you think? |
must use |
Could you do those works in the browser, as my last suggestion? |
Sorry, I read your reply repeatedly and found that I did not fully understand what you meant. I will think again and then update it |
In the The order in which the code is called will produce a different return effect. Which do we choose? Description: dev_tag is my added field for debugging notes Option 1First Recalled the WebWxApp received the message, rawObj data:
{"MsgId":"3066610148686027451","FromUserName":"@d4d830178e30550380be2175c454951f","ToUserName":"@ae39ddd7f22214f8f330b68aaa8ec0190702c0c33467b2a23338a77221e6f431",
"MsgType":10002,
"Content":"接收到的消息内容","Status":3,"ImgStatus":1,"CreateTime":1503162116,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":3066610148686027300,"OriContent":"","MMPeerUserName":"@d4d830178e30550380be2175c454951f",
"MMDigest":"杉木撤回了一条消息","MMIsSend":false,"MMIsChatRoom":false,"MMUnread":true,"LocalID":"3066610148686027451",
"ClientMsgId":"3066610148686027451",
"MMActualContent":"杉木撤回了一条消息",
"MMActualSender":"@d4d830178e30550380be2175c454951f","MMDigestTime":"1:01","MMDisplayTime":1503162116,"MMTime":"1:01","_h":0,
"MMRecall":true,
"dev_tag":"这是基于原先的消息体"} Recalled the WebWxApp did not received the message, rawObj data:
{"MsgId":"443731713080375307","FromUserName":"@d4d830178e30550380be2175c454951f","ToUserName":"@ae39ddd7f22214f8f330b68aaa8ec0190702c0c33467b2a23338a77221e6f431",
"MsgType":10002,
"Content":"杉木 撤回了一条消息","Status":4,"ImgStatus":1,"CreateTime":1503162122,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":1357981904162237700,"OriContent":"","MMPeerUserName":"@d4d830178e30550380be2175c454951f",
"MMDigest":"","MMIsSend":false,"MMIsChatRoom":false,"MMUnread":true,"LocalID":"1357981904162237688",
"ClientMsgId":"1357981904162237688",
"MMActualContent":"杉木 撤回了一条消息",
"MMActualSender":"@d4d830178e30550380be2175c454951f","MMDigestTime":"1:02","MMDisplayTime":1503162116,"MMTime":"",
"dev_tag":"这是基于撤消操作消息体"} Option 2First Recalled the WebWxApp received the message, rawObj data:
{"MsgId":"5026368840711665152","FromUserName":"@d4d830178e30550380be2175c454951f","ToUserName":"@ae39ddd7f22214f8f330b68aaa8ec0190702c0c33467b2a23338a77221e6f431",
"MsgType":10002,
"Content":"接收到的消息内容","Status":3,"ImgStatus":1,"CreateTime":1503162474,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":5026368840711666000,"OriContent":"","MMPeerUserName":"@d4d830178e30550380be2175c454951f",
"MMDigest":"接收到的消息内容","MMIsSend":false,"MMIsChatRoom":false,"MMUnread":false,"LocalID":"5026368840711665152",
"ClientMsgId":"5026368840711665152",
"MMActualContent":"接收到的消息内容","MMActualSender":"@d4d830178e30550380be2175c454951f","MMDigestTime":"1:07","MMDisplayTime":1503162297,"MMTime":"","_index":33,"_h":56,"_calcing":false,"_offsetTop":1853,"$$hashKey":"0CO",
"dev_tag":"这是基于原先的消息体"} Recalled the WebWxApp did not received the message, rawObj data:
{"MsgId":"3684395441945462470","FromUserName":"@d4d830178e30550380be2175c454951f","ToUserName":"@ae39ddd7f22214f8f330b68aaa8ec0190702c0c33467b2a23338a77221e6f431",
"MsgType":10002,
"":"杉木 撤回了一条消息","Status":4,"ImgStatus":1,"CreateTime":1503162479,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":8699756819766069000,"OriContent":"","MMPeerUserName":"@d4d830178e30550380be2175c454951f",
"MMDigest":"","MMIsSend":false,"MMIsChatRoom":false,"MMUnread":true,"LocalID":"8699756819766068805",
"ClientMsgId":"8699756819766068805",
"MMActualContent":"杉木 撤回了一条消息","MMActualSender":"@d4d830178e30550380be2175c454951f","MMDigestTime":"1:07","MMDisplayTime":1503162479,"MMTime":"1:07",
"dev_tag":"这是基于撤消操作消息体"} I think Recalled type of message, using type () to judge, only through the I recommend choosing |
remove Message.getRevokeId function
I think the code is perfect, no need to change. |
Yes, the code is very good, that's exactly what's I suggest. 👍 And about the two options, I would like to think it by intuition: when a message is revoked, the orignal message should be fired again, with the MsgType set to In detail:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great to me.
I'll merge this PR after you get another two approvements from our contributors.
Thank you for implementing issue #8 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@hczhcz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me.
Thanks all for reviewing the code! |
fix #8