mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 12:08:52 +08:00
notification
This commit is contained in:
parent
0071252777
commit
9c594dacde
@ -3,7 +3,7 @@ package msgtransfer
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
|
||||
@ -68,7 +69,7 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(ctx context.Context, cMsg *sarama
|
||||
}
|
||||
ctx = mcontext.SetOperationID(ctx, operationID)
|
||||
if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageModifier {
|
||||
notification := &apistruct.ReactionMessageModifierNotification{}
|
||||
notification := &sdkws.ReactionMessageModifierNotification{}
|
||||
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
||||
continue
|
||||
}
|
||||
@ -102,7 +103,7 @@ func (mmc *ModifyMsgConsumerHandler) ModifyMsg(ctx context.Context, cMsg *sarama
|
||||
}
|
||||
}
|
||||
} else if msgDataToMQ.MsgData.ContentType == constant.ReactionMessageDeleter {
|
||||
notification := &apistruct.ReactionMessageDeleteNotification{}
|
||||
notification := &sdkws.ReactionMessageDeleteNotification{}
|
||||
if err := json.Unmarshal(msgDataToMQ.MsgData.Content, notification); err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.Ge
|
||||
return nil, err
|
||||
}
|
||||
resp = &pbFriend.GetPaginationBlacksResp{}
|
||||
resp.Blacks, err = (*convert.NewDBBlack(nil, s.RegisterCenter)).DB2PB(ctx, blacks)
|
||||
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package msg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
)
|
||||
@ -11,7 +12,6 @@ func (m *msgServer) DelMsgs(ctx context.Context, req *msg.DelMsgsReq) (*msg.DelM
|
||||
if _, err := m.MsgDatabase.DelMsgBySeqs(ctx, req.UserID, req.Seqs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//DeleteMessageNotification(ctx, req.UserID, req.Seqs)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
@ -112,26 +112,6 @@ type DeleteMessageReactionExtensionsResp struct {
|
||||
Data []*msg.KeyValueResp
|
||||
}
|
||||
|
||||
type ReactionMessageModifierNotification struct {
|
||||
SourceID string `json:"sourceID" binding:"required"`
|
||||
OpUserID string `json:"opUserID" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
SuccessReactionExtensions map[string]*sdkws.KeyValue `json:"reactionExtensionList,omitempty" binding:"required"`
|
||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
||||
IsReact bool `json:"isReact"`
|
||||
IsExternalExtensions bool `json:"isExternalExtensions"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
||||
type ReactionMessageDeleteNotification struct {
|
||||
SourceID string `json:"sourceID" binding:"required"`
|
||||
OpUserID string `json:"opUserID" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
SuccessReactionExtensions map[string]*sdkws.KeyValue `json:"reactionExtensionList,omitempty" binding:"required"`
|
||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
UUID string `mapstructure:"uuid"`
|
||||
Type string `mapstructure:"type" `
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -57,8 +57,7 @@ message PublicUserInfo{
|
||||
string userID = 1;
|
||||
string nickname = 2;
|
||||
string faceURL = 3;
|
||||
int32 gender = 4;
|
||||
string ex = 5;
|
||||
string ex = 4;
|
||||
}
|
||||
|
||||
message UserInfo{
|
||||
@ -108,18 +107,16 @@ message FriendRequest{
|
||||
string fromUserID = 1;
|
||||
string fromNickname = 2;
|
||||
string fromFaceURL = 3;
|
||||
int32 fromGender = 4;
|
||||
string toUserID = 5;
|
||||
string toNickname = 6;
|
||||
string toFaceURL = 7;
|
||||
int32 toGender = 8;
|
||||
int32 handleResult = 9;
|
||||
string reqMsg = 10;
|
||||
int64 createTime = 11;
|
||||
string handlerUserID = 12;
|
||||
string handleMsg = 13;
|
||||
int64 handleTime = 14;
|
||||
string ex = 15;
|
||||
string toUserID = 4;
|
||||
string toNickname = 5;
|
||||
string toFaceURL = 6;
|
||||
int32 handleResult = 7;
|
||||
string reqMsg = 8;
|
||||
int64 createTime = 9;
|
||||
string handlerUserID = 10;
|
||||
string handleMsg = 11;
|
||||
int64 handleTime = 12;
|
||||
string ex = 13;
|
||||
}
|
||||
|
||||
|
||||
@ -623,3 +620,22 @@ message KeyValue {
|
||||
int64 latestUpdateTime = 3;
|
||||
}
|
||||
|
||||
message ReactionMessageModifierNotification {
|
||||
string sourceID = 1;
|
||||
string opUserID = 2;
|
||||
int32 sessionType = 3;
|
||||
map <string, KeyValue>successReactionExtensions = 4;
|
||||
string clientMsgID = 5;
|
||||
bool isReact = 6;
|
||||
bool isExternalExtensions = 7;
|
||||
int64 msgFirstModifyTime = 8;
|
||||
}
|
||||
|
||||
message ReactionMessageDeleteNotification {
|
||||
string sourceID = 1;
|
||||
string opUserID = 2;
|
||||
int32 sessionType = 3;
|
||||
map <string, KeyValue>successReactionExtensions = 4;
|
||||
string clientMsgID = 5;
|
||||
int64 msgFirstModifyTime = 6;
|
||||
}
|
37
pkg/rpcclient/convert/black.go
Normal file
37
pkg/rpcclient/convert/black.go
Normal file
@ -0,0 +1,37 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
sdk "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
)
|
||||
|
||||
func BlackDB2Pb(ctx context.Context, blackDBs []*relation.BlackModel, f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) (blackPbs []*sdk.BlackInfo, err error) {
|
||||
var userIDs []string
|
||||
for _, blackDB := range blackDBs {
|
||||
userIDs = append(userIDs, blackDB.BlockUserID)
|
||||
}
|
||||
userInfos, err := f(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, blackDB := range blackDBs {
|
||||
blackPb := &sdk.BlackInfo{
|
||||
OwnerUserID: blackDB.OwnerUserID,
|
||||
CreateTime: blackDB.CreateTime.Unix(),
|
||||
AddSource: blackDB.AddSource,
|
||||
Ex: blackDB.Ex,
|
||||
OperatorUserID: blackDB.OperatorUserID,
|
||||
BlackUserInfo: &sdkws.PublicUserInfo{
|
||||
UserID: userInfos[blackDB.BlockUserID].UserID,
|
||||
Nickname: userInfos[blackDB.BlockUserID].Nickname,
|
||||
FaceURL: userInfos[blackDB.BlockUserID].FaceURL,
|
||||
Ex: userInfos[blackDB.BlockUserID].Ex,
|
||||
},
|
||||
}
|
||||
blackPbs = append(blackPbs, blackPb)
|
||||
}
|
||||
return blackPbs, nil
|
||||
}
|
@ -2,15 +2,17 @@ package notification2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type ExtendMsgNotificationSender struct {
|
||||
@ -23,7 +25,7 @@ func NewExtendMsgNotificationSender(client discoveryregistry.SvcDiscoveryRegistr
|
||||
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx context.Context, sendID string, sourceID string, sessionType int32,
|
||||
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||
var content apistruct.ReactionMessageModifierNotification
|
||||
var content sdkws.ReactionMessageModifierNotification
|
||||
content.SourceID = req.SourceID
|
||||
content.OpUserID = mcontext.GetOpUserID(ctx)
|
||||
content.SessionType = req.SessionType
|
||||
@ -41,11 +43,11 @@ func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx conte
|
||||
content.IsReact = resp.IsReact
|
||||
content.IsExternalExtensions = req.IsExternalExtensions
|
||||
content.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
||||
e.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(content), isHistory, isReactionFromCache)
|
||||
e.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageModifier, &content, isHistory, isReactionFromCache)
|
||||
}
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx context.Context, sendID string, sourceID string, sessionType int32,
|
||||
req *msg.DeleteMessagesReactionExtensionsReq, resp *msg.DeleteMessagesReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||
var content apistruct.ReactionMessageDeleteNotification
|
||||
var content sdkws.ReactionMessageDeleteNotification
|
||||
content.SourceID = req.SourceID
|
||||
content.OpUserID = req.OpUserID
|
||||
content.SessionType = req.SessionType
|
||||
@ -61,9 +63,9 @@ func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx contex
|
||||
content.SuccessReactionExtensions = keyMap
|
||||
content.ClientMsgID = req.ClientMsgID
|
||||
content.MsgFirstModifyTime = req.MsgFirstModifyTime
|
||||
e.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(content), isHistory, isReactionFromCache)
|
||||
e.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, &content, isHistory, isReactionFromCache)
|
||||
}
|
||||
func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) error {
|
||||
func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context, sendID string, sourceID string, sessionType, contentType int32, m proto.Message, isHistory bool, isReactionFromCache bool) error {
|
||||
options := make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
@ -74,6 +76,10 @@ func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context,
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
}
|
||||
bytes, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return errs.ErrData.Wrap(err.Error())
|
||||
}
|
||||
pbData := msg.SendMsgReq{
|
||||
MsgData: &sdkws.MsgData{
|
||||
SendID: sendID,
|
||||
@ -81,7 +87,7 @@ func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context,
|
||||
SessionType: sessionType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: contentType,
|
||||
Content: []byte(content),
|
||||
Content: bytes,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
},
|
||||
@ -92,6 +98,6 @@ func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context,
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
pbData.MsgData.GroupID = sourceID
|
||||
}
|
||||
_, err := e.SendMsg(ctx, &pbData)
|
||||
_, err = e.SendMsg(ctx, &pbData)
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user