mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-07-03 00:50:22 +08:00
消息发送bugfix
This commit is contained in:
parent
d28dd965f2
commit
3e5bf3a4e0
@ -164,18 +164,16 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
||||
isNotification := msgprocessor.IsNotificationByMsg(req.MsgData)
|
||||
log.ZInfo(ctx, "sendMsgSingleChat", "isNotification", isNotification, "msgdata", req.MsgData)
|
||||
|
||||
if !isNotification {
|
||||
// 非通知类消息:执行发送权限校验 + 接收偏好校验(含 blacklist / MsgReceiveSetting / webhook / FriendVerify / globalOpt / convOpt)
|
||||
isSend, err = m.modifyMessageByUserMessageReceiveOpt(
|
||||
ctx,
|
||||
req.MsgData.RecvID,
|
||||
conversationutil.GenConversationIDForSingle(req.MsgData.SendID, req.MsgData.RecvID),
|
||||
constant.SingleChatType,
|
||||
req,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 单聊一律校验接收方消息设置(含「仅好友可发」)、黑名单、会话接收偏好等;不再因通知类 Options 跳过
|
||||
isSend, err = m.modifyMessageByUserMessageReceiveOpt(
|
||||
ctx,
|
||||
req.MsgData.RecvID,
|
||||
conversationutil.GenConversationIDForSingle(req.MsgData.SendID, req.MsgData.RecvID),
|
||||
constant.SingleChatType,
|
||||
req,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !isSend {
|
||||
prommetrics.SingleChatMsgProcessFailedCounter.Inc()
|
||||
|
||||
@ -226,7 +226,7 @@ func (m *msgServer) modifyMessageByUserMessageReceiveOpt(ctx context.Context, us
|
||||
}
|
||||
|
||||
// 第二优先级:单聊发送权限校验(从 messageVerification 迁移)
|
||||
// 仅对非通知类消息生效(调用方已通过 !isNotification 做过前置过滤)
|
||||
// 单聊路径下由 sendMsgSingleChat 始终调用本函数(含通知类),以校验接收方 MsgReceiveSetting 等
|
||||
if sessionType == constant.SingleChatType {
|
||||
// 管理员跳过发送权限拦截,直接进入接收偏好校验
|
||||
if !datautil.Contain(pb.MsgData.SendID, m.config.Share.IMAdminUserID...) {
|
||||
@ -255,10 +255,12 @@ func (m *msgServer) modifyMessageByUserMessageReceiveOpt(ctx context.Context, us
|
||||
// skipFriendVerify: MsgReceiveSetting=1 已确认好友关系,无需再做 FriendVerify 重复查询
|
||||
skipFriendVerify := false
|
||||
switch recvUserInfo.MsgReceiveSetting {
|
||||
case 2: // MsgReceiveSettingNobody
|
||||
case model.MsgReceiveSettingNobody:
|
||||
return false, servererrs.ErrMsgReceiveNotAllowed.Wrap()
|
||||
case 1: // MsgReceiveSettingFriends
|
||||
isFriend, err := m.FriendLocalCache.IsFriend(ctx, pb.MsgData.RecvID, pb.MsgData.SendID)
|
||||
case model.MsgReceiveSettingFriends:
|
||||
// FriendLocalCache.IsFriend(possibleFriendUserID, userID) 对应「userID 的好友列表里是否有 possibleFriendUserID」
|
||||
// 此处须判断:接收方 recv 的好友列表里是否有发送方 send
|
||||
isFriend, err := m.FriendLocalCache.IsFriend(ctx, pb.MsgData.SendID, pb.MsgData.RecvID)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "modifyMessageByUserMessageReceiveOpt: IsFriend failed (MsgReceiveSetting)", err,
|
||||
"sendID", pb.MsgData.SendID, "recvID", pb.MsgData.RecvID,
|
||||
|
||||
2
protocol
2
protocol
@ -1 +1 @@
|
||||
Subproject commit 2e1f23fe06d15adcabf07ef72c1e8b08bca0f2c1
|
||||
Subproject commit eaf121f66a1529357897cf48f0a19643deb043f6
|
||||
Loading…
x
Reference in New Issue
Block a user