mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
conversation add fields
This commit is contained in:
parent
20000ac670
commit
a525db7088
@ -93,6 +93,6 @@ func UserToken(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||||
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
||||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
@ -576,6 +577,22 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
chat.MemberQuitNotification(req)
|
chat.MemberQuitNotification(req)
|
||||||
|
//modify quitter conversation info
|
||||||
|
var reqPb pbUser.SetConversationReq
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.Conversation.OwnerUserID = req.OpUserID
|
||||||
|
reqPb.Conversation.ConversationID = utils.GetConversationIDBySessionType(req.OpUserID, constant.GroupChatType)
|
||||||
|
reqPb.Conversation.ConversationType = constant.GroupChatType
|
||||||
|
reqPb.Conversation.GroupID = req.GroupID
|
||||||
|
reqPb.Conversation.IsNotInGroup = true
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
|
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||||
|
} else {
|
||||||
|
log.NewDebug(req.OpUserID, utils.GetSelfFuncName(), respPb.String())
|
||||||
|
}
|
||||||
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
|
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
|
||||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
}
|
}
|
||||||
@ -988,13 +1005,35 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
|||||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
chat.GroupDismissedNotification(req)
|
chat.GroupDismissedNotification(req)
|
||||||
|
memberList, err := imdb.GetGroupMemberListByGroupID(req.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GetGroupMemberListByGroupID failed,", err.Error(), req.GroupID)
|
||||||
|
}
|
||||||
|
//modify quitter conversation info
|
||||||
|
var reqPb pbUser.SetConversationReq
|
||||||
|
for _, v := range memberList {
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.Conversation.OwnerUserID = v.UserID
|
||||||
|
reqPb.Conversation.ConversationID = utils.GetConversationIDBySessionType(v.UserID, constant.GroupChatType)
|
||||||
|
reqPb.Conversation.ConversationType = constant.GroupChatType
|
||||||
|
reqPb.Conversation.GroupID = req.GroupID
|
||||||
|
reqPb.Conversation.IsNotInGroup = true
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
|
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error(), v.UserID)
|
||||||
|
} else {
|
||||||
|
log.NewDebug(req.OpUserID, utils.GetSelfFuncName(), respPb.String(), v.UserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
err = imdb.DeleteGroupMemberByGroupID(req.GroupID)
|
err = imdb.DeleteGroupMemberByGroupID(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "DeleteGroupMemberByGroupID failed ", req.GroupID)
|
log.NewError(req.OperationID, "DeleteGroupMemberByGroupID failed ", req.GroupID)
|
||||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
||||||
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.DismissGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func (s *userServer) Run() {
|
|||||||
func syncPeerUserConversation(conversation *pbUser.Conversation, operationID string) error {
|
func syncPeerUserConversation(conversation *pbUser.Conversation, operationID string) error {
|
||||||
peerUserConversation := db.Conversation{
|
peerUserConversation := db.Conversation{
|
||||||
OwnerUserID: conversation.UserID,
|
OwnerUserID: conversation.UserID,
|
||||||
ConversationID: "single_" + conversation.OwnerUserID,
|
ConversationID: utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType),
|
||||||
ConversationType: constant.SingleChatType,
|
ConversationType: constant.SingleChatType,
|
||||||
UserID: conversation.OwnerUserID,
|
UserID: conversation.OwnerUserID,
|
||||||
GroupID: "",
|
GroupID: "",
|
||||||
@ -129,6 +129,7 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
|||||||
if err := utils.CopyStructFields(&conversation, v); err != nil {
|
if err := utils.CopyStructFields(&conversation, v); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), v.String(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), v.String(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
|
//redis op
|
||||||
if err := db.DB.SetSingleConversationRecvMsgOpt(req.OwnerUserID, v.ConversationID, v.RecvMsgOpt); err != nil {
|
if err := db.DB.SetSingleConversationRecvMsgOpt(req.OwnerUserID, v.ConversationID, v.RecvMsgOpt); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
@ -43,6 +43,8 @@ type Conversation struct {
|
|||||||
DraftTextTime int64 `json:"draftTextTime"`
|
DraftTextTime int64 `json:"draftTextTime"`
|
||||||
IsPinned bool `json:"isPinned" binding:"omitempty"`
|
IsPinned bool `json:"isPinned" binding:"omitempty"`
|
||||||
IsPrivateChat bool `json:"isPrivateChat"`
|
IsPrivateChat bool `json:"isPrivateChat"`
|
||||||
|
GroupAtType int32 `json:"groupAtType"`
|
||||||
|
IsNotInGroup bool `json:"isNotInGroup"`
|
||||||
AttachedInfo string `json:"attachedInfo"`
|
AttachedInfo string `json:"attachedInfo"`
|
||||||
Ex string `json:"ex"`
|
Ex string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,8 @@ type Conversation struct {
|
|||||||
DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
|
DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
|
||||||
IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
|
IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
|
||||||
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
||||||
|
GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
|
||||||
|
IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"`
|
||||||
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
||||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,8 @@ func SetConversation(conversation db.Conversation) error {
|
|||||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
|
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "exist in db, update")
|
||||||
//force update
|
//force update
|
||||||
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
return dbConn.Model(conversation).Where("owner_user_id = ? and conversation_id = ?", conversation.OwnerUserID, conversation.ConversationID).
|
||||||
Update(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt, "is_pinned": conversation.IsPinned, "is_private_chat": conversation.IsPrivateChat}).Error
|
Update(map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt, "is_pinned": conversation.IsPinned, "is_private_chat": conversation.IsPrivateChat,
|
||||||
|
"group_at_type": conversation.GroupAtType, "is_not_in_group": conversation.IsNotInGroup}).Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ func GetConversationIDBySessionType(sourceID string, sessionType int) string {
|
|||||||
return "single_" + sourceID
|
return "single_" + sourceID
|
||||||
case constant.GroupChatType:
|
case constant.GroupChatType:
|
||||||
return "group_" + sourceID
|
return "group_" + sourceID
|
||||||
|
case constant.NotificationChatType:
|
||||||
|
return "notification_" + sourceID
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user