修复单聊渲染消息的bug - #2
Open
smileexpression wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
现有用户A,B和C,每个用户互相添加了另外两个用户。当A发送消息给B时,B会渲染出A和C发送同一条消息给B。发现是 app/view/chat/main.html 文件中,对单聊消息渲染的判断条件出了问题。
原判断条件
如果消息是我发的 (
ismine为真),那么消息的目标dstid必须等于当前聊天上下文msgcontext.dstid;如果消息不是我发的,那么消息的目标dstid必须等于我的用户 IDuserid。这个逻辑的问题在于,对于我收到的消息,只检查了消息是否发送给我,但没有检查消息的发送者是否是当前的聊天对象。因此会出现B看到A发送的消息同时渲染在了A和C里面的问题。
修改后判断条件
如果消息不是我发的,那么消息的发送者
userid必须等于当前聊天上下文dstid。那为什么原判断条件不需要了呢?
服务端分配消息时,已经根据消息的dstid,分配到该用户的管道中,因此,用户收到的消息一定是满足该条件的(前提是:消息不是我发的 (
ismine为假))。