mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-28 04:48:44 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
8435508f35
@ -1,16 +1,16 @@
|
|||||||
package notification
|
package notification
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/apistruct"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/proto/msg"
|
"Open_IM/pkg/proto/msg"
|
||||||
sdkws "Open_IM/pkg/proto/sdkws"
|
sdkws "Open_IM/pkg/proto/sdkws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func (c *Check) ExtendMessageUpdatedNotification(ctx context.Context, sendID string, sourceID string, sessionType int32,
|
||||||
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m apistruct.ReactionMessageModifierNotification
|
var m apistruct.ReactionMessageModifierNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
@ -23,7 +23,6 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(keyMap) == 0 {
|
if len(keyMap) == 0 {
|
||||||
log.NewWarn(operationID, "all key set failed can not send notification", *req)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.SuccessReactionExtensionList = keyMap
|
m.SuccessReactionExtensionList = keyMap
|
||||||
@ -31,9 +30,9 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin
|
|||||||
m.IsReact = resp.IsReact
|
m.IsReact = resp.IsReact
|
||||||
m.IsExternalExtensions = req.IsExternalExtensions
|
m.IsExternalExtensions = req.IsExternalExtensions
|
||||||
m.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
m.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
||||||
messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
c.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
||||||
}
|
}
|
||||||
func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32,
|
func (c *Check) ExtendMessageDeleteNotification(ctx context.Context, sendID string, sourceID string, sessionType int32,
|
||||||
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||||
var m apistruct.ReactionMessageDeleteNotification
|
var m apistruct.ReactionMessageDeleteNotification
|
||||||
m.SourceID = req.SourceID
|
m.SourceID = req.SourceID
|
||||||
@ -46,16 +45,20 @@ func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(keyMap) == 0 {
|
if len(keyMap) == 0 {
|
||||||
log.NewWarn(operationID, "all key set failed can not send notification", *req)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.SuccessReactionExtensionList = keyMap
|
m.SuccessReactionExtensionList = keyMap
|
||||||
m.ClientMsgID = req.ClientMsgID
|
m.ClientMsgID = req.ClientMsgID
|
||||||
m.MsgFirstModifyTime = req.MsgFirstModifyTime
|
m.MsgFirstModifyTime = req.MsgFirstModifyTime
|
||||||
|
|
||||||
messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
c.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache)
|
||||||
}
|
}
|
||||||
func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) {
|
func (c *Check) messageReactionSender(ctx context.Context, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) {
|
||||||
|
var err error
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sendID", sendID, "sourceID", sourceID, "sessionType", sessionType)
|
||||||
|
}()
|
||||||
|
|
||||||
options := make(map[string]bool, 5)
|
options := make(map[string]bool, 5)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||||
@ -67,7 +70,6 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT
|
|||||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||||
}
|
}
|
||||||
pbData := msg.SendMsgReq{
|
pbData := msg.SendMsgReq{
|
||||||
OperationID: operationID,
|
|
||||||
MsgData: &sdkws.MsgData{
|
MsgData: &sdkws.MsgData{
|
||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
ClientMsgID: utils.GetMsgID(sendID),
|
ClientMsgID: utils.GetMsgID(sendID),
|
||||||
@ -75,9 +77,8 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT
|
|||||||
MsgFrom: constant.SysMsgType,
|
MsgFrom: constant.SysMsgType,
|
||||||
ContentType: contentType,
|
ContentType: contentType,
|
||||||
Content: []byte(content),
|
Content: []byte(content),
|
||||||
// ForceList: params.ForceList,
|
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
Options: options,
|
||||||
Options: options,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
switch sessionType {
|
switch sessionType {
|
||||||
@ -86,15 +87,5 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT
|
|||||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
pbData.MsgData.GroupID = sourceID
|
pbData.MsgData.GroupID = sourceID
|
||||||
}
|
}
|
||||||
etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
|
_, err = c.msg.SendMsg(ctx, &pbData)
|
||||||
if err != nil {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"Open_IM/internal/common/check"
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/internal/common/convert"
|
"Open_IM/internal/common/convert"
|
||||||
chat "Open_IM/internal/common/notification"
|
|
||||||
"Open_IM/pkg/common/db/table/relation"
|
"Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/tokenverify"
|
"Open_IM/pkg/common/tokenverify"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
@ -47,7 +46,7 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlac
|
|||||||
if err := s.BlackInterface.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
if err := s.BlackInterface.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.BlackDeletedNotification(ctx, req)
|
s.notification.BlackDeletedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +59,6 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
|
|||||||
if err := s.BlackInterface.Create(ctx, []*relation.BlackModel{&black}); err != nil {
|
if err := s.BlackInterface.Create(ctx, []*relation.BlackModel{&black}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.BlackAddedNotification(ctx, req)
|
s.notification.BlackAddedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user