Skip to content
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

Release v3.5 conversation's info update #471

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions internal/conversation_msg/conversation_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ func (c *Conversation) doUpdateConversation(c2v common.Cmd2Value) {
case constant.SuperGroupChatType:
conversationID, conversationType, err := c.getConversationTypeByGroupID(ctx, st.SourceID)
if err != nil {
// log.Error("internal", "getConversationTypeByGroupID database err:", err.Error())
return
}
lc.GroupID = st.SourceID
lc.ConversationID = conversationID
lc.ConversationType = conversationType
case constant.NotificationChatType:
lc.UserID = st.SourceID
lc.ConversationID = c.getConversationIDBySessionType(st.SourceID, constant.NotificationChatType)
lc.ConversationType = constant.NotificationChatType
default:
log.ZError(ctx, "not support sessionType", nil, "sessionType", st.SessionType)
return
Expand Down Expand Up @@ -273,7 +276,8 @@ func (c *Conversation) doUpdateMessage(c2v common.Cmd2Value) {
switch node.Action {
case constant.UpdateMsgFaceUrlAndNickName:
args := node.Args.(common.UpdateMessageInfo)
if args.GroupID == "" {
switch args.SessionType {
case constant.SingleChatType:
if args.UserID == c.loginUserID {
conversationIDList, err := c.db.GetAllSingleConversationIDList(ctx)
if err != nil {
Expand All @@ -298,14 +302,22 @@ func (c *Conversation) doUpdateMessage(c2v common.Cmd2Value) {
}

}
} else {
case constant.SuperGroupChatType:
conversationID := c.getConversationIDBySessionType(args.GroupID, constant.SuperGroupChatType)
err := c.db.UpdateMsgSenderFaceURLAndSenderNickname(ctx, conversationID, args.UserID, args.FaceURL, args.Nickname)
if err != nil {
log.ZError(ctx, "UpdateMsgSenderFaceURLAndSenderNickname err", err)
}
case constant.NotificationChatType:
conversationID := c.getConversationIDBySessionType(args.UserID, constant.NotificationChatType)
err := c.db.UpdateMsgSenderFaceURLAndSenderNickname(ctx, conversationID, args.UserID, args.FaceURL, args.Nickname)
if err != nil {
log.ZError(ctx, "UpdateMsgSenderFaceURLAndSenderNickname err", err)
}
default:
log.ZError(ctx, "not support sessionType", nil, "args", args)
return
}

}

}
Expand Down
2 changes: 1 addition & 1 deletion internal/conversation_msg/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (c *Conversation) getConversationIDBySessionType(sourceID string, sessionTy
case constant.SuperGroupChatType:
return "sg_" + sourceID // super group chat
case constant.NotificationChatType:
return "sn_" + sourceID // server notification chat
return "sn_" + sourceID + "_" + c.loginUserID // server notification chat
}
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion internal/friend/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (f *Friend) initSyncer() {
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName,
Args: common.SourceIDAndSessionType{SourceID: server.FriendUserID, SessionType: constant.SingleChatType, FaceURL: server.FaceURL, Nickname: server.Nickname}}, f.conversationCh)
_ = common.TriggerCmdUpdateMessage(ctx, common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{UserID: server.FriendUserID, FaceURL: server.FaceURL, Nickname: server.Nickname}}, f.conversationCh)
Args: common.UpdateMessageInfo{SessionType: constant.SingleChatType, UserID: server.FriendUserID, FaceURL: server.FaceURL, Nickname: server.Nickname}}, f.conversationCh)
}

}
Expand Down
8 changes: 4 additions & 4 deletions internal/full/open_im_sdk_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func (u *Full) GetUsersInfo(ctx context.Context, userIDs []string) ([]*api.FullU
log.ZDebug(ctx, "GetConversationByUserID", "conversation", conversation)
if conversation.ShowName != info.Nickname || conversation.FaceURL != info.FaceURL {
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName,
Args: common.SourceIDAndSessionType{SourceID: userID, SessionType: constant.SingleChatType, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
Args: common.SourceIDAndSessionType{SourceID: userID, SessionType: conversation.ConversationType, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
_ = common.TriggerCmdUpdateMessage(ctx, common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{UserID: userID, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
Args: common.UpdateMessageInfo{SessionType: conversation.ConversationType, UserID: userID, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
}
}
}
Expand Down Expand Up @@ -189,9 +189,9 @@ func (u *Full) GetUsersInfoWithCache(ctx context.Context, userIDs []string, grou
log.ZDebug(ctx, "GetConversationByUserID", "conversation", conversation)
if conversation.ShowName != info.Nickname || conversation.FaceURL != info.FaceURL {
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName,
Args: common.SourceIDAndSessionType{SourceID: userID, SessionType: constant.SingleChatType, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
Args: common.SourceIDAndSessionType{SourceID: userID, SessionType: conversation.ConversationType, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
_ = common.TriggerCmdUpdateMessage(ctx, common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{UserID: userID, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
Args: common.UpdateMessageInfo{SessionType: conversation.ConversationType, UserID: userID, FaceURL: info.FaceURL, Nickname: info.Nickname}}, u.ch)
}
}
}
Expand Down
23 changes: 18 additions & 5 deletions internal/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ func (g *Group) initSyncer() {
}, nil, func(ctx context.Context, state int, server, local *model_struct.LocalGroup) error {
switch state {
case syncer.Insert:
//when a user kicked to the group and invited to the group again, group info maybe updated,so conversation
//info need to be updated
g.listener().OnJoinedGroupAdded(utils.StructToJsonString(server))
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName,
Args: common.SourceIDAndSessionType{SourceID: server.GroupID, SessionType: constant.SuperGroupChatType,
FaceURL: server.FaceURL, Nickname: server.GroupName}}, g.conversationCh)
case syncer.Delete:
g.listener().OnJoinedGroupDeleted(utils.StructToJsonString(local))
case syncer.Update:
log.ZInfo(ctx, "groupSyncer trigger update", "groupID", server.GroupID, "data", server, "isDismissed", server.Status == constant.GroupStatusDismissed)
log.ZInfo(ctx, "groupSyncer trigger update", "groupID",
server.GroupID, "data", server, "isDismissed", server.Status == constant.GroupStatusDismissed)
if server.Status == constant.GroupStatusDismissed {
if err := g.db.DeleteGroupAllMembers(ctx, server.GroupID); err != nil {
log.ZError(ctx, "delete group all members failed", err)
Expand All @@ -89,8 +95,8 @@ func (g *Group) initSyncer() {
} else {
g.listener().OnGroupInfoChanged(utils.StructToJsonString(server))
if server.GroupName != local.GroupName || local.FaceURL != server.FaceURL {
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName, Args: common.SourceIDAndSessionType{SourceID: server.GroupID,
SessionType: constant.SuperGroupChatType, FaceURL: server.FaceURL, Nickname: server.GroupName}}, g.conversationCh)
_ = common.TriggerCmdUpdateConversation(ctx, common.UpdateConNode{Action: constant.UpdateConFaceUrlAndNickName,
Args: common.SourceIDAndSessionType{SourceID: server.GroupID, SessionType: constant.SuperGroupChatType, FaceURL: server.FaceURL, Nickname: server.GroupName}}, g.conversationCh)
}
}
}
Expand All @@ -110,13 +116,20 @@ func (g *Group) initSyncer() {
switch state {
case syncer.Insert:
g.listener().OnGroupMemberAdded(utils.StructToJsonString(server))
//when a user kicked and invited to the group again, group member info will be updated
_ = common.TriggerCmdUpdateMessage(ctx,
common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{SessionType: constant.SuperGroupChatType, UserID: server.UserID, FaceURL: server.FaceURL,
Nickname: server.Nickname, GroupID: server.GroupID}}, g.conversationCh)
case syncer.Delete:
g.listener().OnGroupMemberDeleted(utils.StructToJsonString(local))
case syncer.Update:
g.listener().OnGroupMemberInfoChanged(utils.StructToJsonString(server))
if server.Nickname != local.Nickname || server.FaceURL != local.FaceURL {
_ = common.TriggerCmdUpdateMessage(ctx, common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName, Args: common.UpdateMessageInfo{UserID: server.UserID, FaceURL: server.FaceURL,
Nickname: server.Nickname, GroupID: server.GroupID}}, g.conversationCh)
_ = common.TriggerCmdUpdateMessage(ctx,
common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{SessionType: constant.SuperGroupChatType, UserID: server.UserID, FaceURL: server.FaceURL,
Nickname: server.Nickname, GroupID: server.GroupID}}, g.conversationCh)
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (u *User) initSyncer() {
u.listener().OnSelfInfoUpdated(utils.StructToJsonString(server))
if server.Nickname != local.Nickname || server.FaceURL != local.FaceURL {
_ = common.TriggerCmdUpdateMessage(ctx, common.UpdateMessageNode{Action: constant.UpdateMsgFaceUrlAndNickName,
Args: common.UpdateMessageInfo{UserID: server.UserID, FaceURL: server.FaceURL, Nickname: server.Nickname}}, u.conversationCh)
Args: common.UpdateMessageInfo{SessionType: constant.SingleChatType, UserID: server.UserID, FaceURL: server.FaceURL, Nickname: server.Nickname}}, u.conversationCh)
}
}
return nil
Expand Down
11 changes: 6 additions & 5 deletions pkg/common/trigger_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,16 @@ type UpdateConInfo struct {
GroupID string
}
type UpdateMessageInfo struct {
UserID string
FaceURL string
Nickname string
GroupID string
SessionType int32
UserID string
FaceURL string
Nickname string
GroupID string
}

type SourceIDAndSessionType struct {
SourceID string
SessionType int
SessionType int32
FaceURL string
Nickname string
}
Expand Down
Loading