mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-10 13:09:51 +08:00
message reaction
This commit is contained in:
parent
a0520ce5d8
commit
ac55951c74
@ -61,7 +61,7 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(cMsg *sarama.Con
|
|||||||
if unexistSeqList, err := db.DB.DelMsgBySeqList(DeleteMessageTips.UserID, DeleteMessageTips.SeqList, v.OperationID); err != nil {
|
if unexistSeqList, err := db.DB.DelMsgBySeqList(DeleteMessageTips.UserID, DeleteMessageTips.SeqList, v.OperationID); err != nil {
|
||||||
log.NewError(v.OperationID, utils.GetSelfFuncName(), "DelMsgBySeqList args: ", DeleteMessageTips.UserID, DeleteMessageTips.SeqList, v.OperationID, err.Error(), unexistSeqList)
|
log.NewError(v.OperationID, utils.GetSelfFuncName(), "DelMsgBySeqList args: ", DeleteMessageTips.UserID, DeleteMessageTips.SeqList, v.OperationID, err.Error(), unexistSeqList)
|
||||||
}
|
}
|
||||||
} else if v.MsgData.ContentType == constant.ReactionMessageModifierNotification {
|
} else if v.MsgData.ContentType == constant.ReactionMessageModifier {
|
||||||
var req pbMsg.ModifyMessageReactionExtensionsReq
|
var req pbMsg.ModifyMessageReactionExtensionsReq
|
||||||
if req.IsExternalExtensions {
|
if req.IsExternalExtensions {
|
||||||
log.NewInfo(req.OperationID, "msg:", req.String(), "this is external extensions")
|
log.NewInfo(req.OperationID, "msg:", req.String(), "this is external extensions")
|
||||||
@ -98,7 +98,7 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(cMsg *sarama.Con
|
|||||||
log.NewError(req.OperationID, "InsertOrUpdateReactionExtendMsgSet failed")
|
log.NewError(req.OperationID, "InsertOrUpdateReactionExtendMsgSet failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if v.MsgData.ContentType == 2301 {
|
} else if v.MsgData.ContentType == constant.ReactionMessageDeleter {
|
||||||
var req pbMsg.OperateMessageListReactionExtensionsReq
|
var req pbMsg.OperateMessageListReactionExtensionsReq
|
||||||
for _, v := range req.MessageReactionKeyList {
|
for _, v := range req.MessageReactionKeyList {
|
||||||
if err := db.DB.DeleteReactionExtendMsgSet(req.SourceID, req.SessionType, v.ClientMsgID, v.MsgFirstModifyTime, v.ReactionExtensionList); err != nil {
|
if err := db.DB.DeleteReactionExtendMsgSet(req.SourceID, req.SessionType, v.ClientMsgID, v.MsgFirstModifyTime, v.ReactionExtensionList); err != nil {
|
||||||
|
@ -109,12 +109,19 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.M
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oneExtendMsg.ReactionExtensionList = oneSuccessReactionExtensionList
|
oneExtendMsg.ReactionExtensionList = oneSuccessReactionExtensionList
|
||||||
extendMsgResp.ExtendMsg = &oneExtendMsg
|
extendMsgResp.ExtendMsg = &oneExtendMsg
|
||||||
failedExtendMsg.ReactionExtensionList = oneFailedReactionExtensionList
|
failedExtendMsg.ReactionExtensionList = oneFailedReactionExtensionList
|
||||||
failedExtendMsgResp.ExtendMsg = &failedExtendMsg
|
failedExtendMsgResp.ExtendMsg = &failedExtendMsg
|
||||||
rResp.FailedList = append(rResp.FailedList, &failedExtendMsgResp)
|
rResp.FailedList = append(rResp.FailedList, &failedExtendMsgResp)
|
||||||
rResp.SuccessList = append(rResp.FailedList, &extendMsgResp)
|
rResp.SuccessList = append(rResp.FailedList, &extendMsgResp)
|
||||||
|
if !isExists && !req.IsReact {
|
||||||
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, true)
|
||||||
|
} else {
|
||||||
|
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false)
|
||||||
|
|
||||||
|
}
|
||||||
return &rResp, nil
|
return &rResp, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,66 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
"Open_IM/pkg/proto/msg"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExtendMessageUpdatedNotification(operationID, changedUserID string, needNotifiedUserID string, opUserID string) {
|
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32,
|
||||||
selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: changedUserID}
|
req *msg.ModifyMessageReactionExtensionsReq, resp *msg.ModifyMessageReactionExtensionsResp, isHistory bool) {
|
||||||
commID := pbFriend.CommID{FromUserID: opUserID, ToUserID: needNotifiedUserID, OpUserID: opUserID, OperationID: operationID}
|
m := make(map[string]interface{})
|
||||||
friendNotification(&commID, constant.ReactionMessageModifierNotification, &selfInfoUpdatedTips)
|
m["rep"] = req
|
||||||
|
m["resp"] = resp
|
||||||
|
messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory)
|
||||||
|
}
|
||||||
|
func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool) {
|
||||||
|
options := make(map[string]bool, 5)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||||
|
if !isHistory {
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||||
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||||
|
}
|
||||||
|
pbData := msg.SendMsgReq{
|
||||||
|
OperationID: operationID,
|
||||||
|
MsgData: &open_im_sdk.MsgData{
|
||||||
|
SendID: sendID,
|
||||||
|
ClientMsgID: utils.GetMsgID(sendID),
|
||||||
|
SessionType: sessionType,
|
||||||
|
MsgFrom: constant.SysMsgType,
|
||||||
|
ContentType: contentType,
|
||||||
|
Content: []byte(content),
|
||||||
|
// ForceList: params.ForceList,
|
||||||
|
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||||
|
Options: options,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
switch sessionType {
|
||||||
|
case constant.SingleChatType, constant.NotificationChatType:
|
||||||
|
pbData.MsgData.RecvID = sourceID
|
||||||
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
|
pbData.MsgData.GroupID = sourceID
|
||||||
|
}
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, operationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(operationID, errMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := msg.NewMsgClient(etcdConn)
|
||||||
|
reply, err := client.SendMsg(context.Background(), &pbData)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), err.Error())
|
||||||
|
} else if reply.ErrCode != 0 {
|
||||||
|
log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), reply.ErrCode, reply.ErrMsg)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ const (
|
|||||||
AdvancedRevoke = 118 //影响前者消息
|
AdvancedRevoke = 118 //影响前者消息
|
||||||
CustomNotTriggerConversation = 119
|
CustomNotTriggerConversation = 119
|
||||||
CustomOnlineOnly = 120
|
CustomOnlineOnly = 120
|
||||||
|
ReactionMessageModifier = 121
|
||||||
|
ReactionMessageDeleter = 122
|
||||||
|
|
||||||
Common = 200
|
Common = 200
|
||||||
GroupMsg = 201
|
GroupMsg = 201
|
||||||
@ -99,11 +101,10 @@ const (
|
|||||||
SignalingNotification = 1601
|
SignalingNotification = 1601
|
||||||
SignalingNotificationEnd = 1649
|
SignalingNotificationEnd = 1649
|
||||||
|
|
||||||
SuperGroupNotificationBegin = 1650
|
SuperGroupNotificationBegin = 1650
|
||||||
SuperGroupUpdateNotification = 1651
|
SuperGroupUpdateNotification = 1651
|
||||||
MsgDeleteNotification = 1652
|
MsgDeleteNotification = 1652
|
||||||
ReactionMessageModifierNotification = 1653
|
SuperGroupNotificationEnd = 1699
|
||||||
SuperGroupNotificationEnd = 1699
|
|
||||||
|
|
||||||
ConversationPrivateChatNotification = 1701
|
ConversationPrivateChatNotification = 1701
|
||||||
ConversationUnreadNotification = 1702
|
ConversationUnreadNotification = 1702
|
||||||
|
Loading…
x
Reference in New Issue
Block a user