mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-07-10 06:41:08 +08:00
好友静音
This commit is contained in:
parent
e9e15b9e5d
commit
24d15d5e36
@ -39,6 +39,7 @@ import (
|
|||||||
conversationpb "github.com/openimsdk/protocol/conversation"
|
conversationpb "github.com/openimsdk/protocol/conversation"
|
||||||
"github.com/openimsdk/protocol/relation"
|
"github.com/openimsdk/protocol/relation"
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
|
"github.com/openimsdk/protocol/wrapperspb"
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
@ -531,6 +532,9 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *relatio
|
|||||||
OperatorUserID: friend.OperatorUserID,
|
OperatorUserID: friend.OperatorUserID,
|
||||||
Ex: friend.Ex,
|
Ex: friend.Ex,
|
||||||
IsPinned: friend.IsPinned,
|
IsPinned: friend.IsPinned,
|
||||||
|
IsMute: friend.IsMuted,
|
||||||
|
MuteDuration: friend.MuteDuration,
|
||||||
|
MuteEndTime: friend.MuteEndTime,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,6 +590,15 @@ func (s *friendServer) UpdateFriends(
|
|||||||
if req.Ex != nil {
|
if req.Ex != nil {
|
||||||
val["ex"] = req.Ex.Value
|
val["ex"] = req.Ex.Value
|
||||||
}
|
}
|
||||||
|
if req.IsMute != nil {
|
||||||
|
val["is_muted"] = req.IsMute.Value
|
||||||
|
}
|
||||||
|
if req.MuteDuration != nil {
|
||||||
|
val["mute_duration"] = req.MuteDuration.Value
|
||||||
|
}
|
||||||
|
if req.MuteEndTime != nil {
|
||||||
|
val["mute_end_time"] = req.MuteEndTime.Value
|
||||||
|
}
|
||||||
if err = s.db.UpdateFriends(ctx, req.OwnerUserID, req.FriendUserIDs, val); err != nil {
|
if err = s.db.UpdateFriends(ctx, req.OwnerUserID, req.FriendUserIDs, val); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -606,6 +619,26 @@ func (s *friendServer) UpdateFriends(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.IsMute != nil {
|
||||||
|
recvMsgOpt := int32(constant.ReceiveNotNotifyMessage)
|
||||||
|
if !req.IsMute.Value {
|
||||||
|
recvMsgOpt = constant.ReceiveMessage
|
||||||
|
}
|
||||||
|
for _, friendUserID := range req.FriendUserIDs {
|
||||||
|
convID := conversationutil.GenConversationIDForSingle(req.OwnerUserID, friendUserID)
|
||||||
|
if err := s.conversationClient.SetConversations(ctx, []string{req.OwnerUserID},
|
||||||
|
&conversationpb.ConversationReq{
|
||||||
|
ConversationID: convID,
|
||||||
|
ConversationType: constant.SingleChatType,
|
||||||
|
UserID: friendUserID,
|
||||||
|
RecvMsgOpt: &wrapperspb.Int32Value{Value: recvMsgOpt},
|
||||||
|
}); err != nil {
|
||||||
|
log.ZWarn(ctx, "sync conversation recvMsgOpt failed", err,
|
||||||
|
"ownerUserID", req.OwnerUserID, "friendUserID", friendUserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp := &relation.UpdateFriendsResp{}
|
resp := &relation.UpdateFriendsResp{}
|
||||||
|
|
||||||
s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
|
s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||||
|
|||||||
@ -80,6 +80,9 @@ func FriendsDB2Pb(ctx context.Context, friendsDB []*model.Friend, getUsers func(
|
|||||||
friendPb.FriendUser.Ex = users[friend.FriendUserID].Ex
|
friendPb.FriendUser.Ex = users[friend.FriendUserID].Ex
|
||||||
friendPb.CreateTime = friend.CreateTime.Unix()
|
friendPb.CreateTime = friend.CreateTime.Unix()
|
||||||
friendPb.IsPinned = friend.IsPinned
|
friendPb.IsPinned = friend.IsPinned
|
||||||
|
friendPb.IsMute = friend.IsMuted
|
||||||
|
friendPb.MuteDuration = friend.MuteDuration
|
||||||
|
friendPb.MuteEndTime = friend.MuteEndTime
|
||||||
friendsPb = append(friendsPb, friendPb)
|
friendsPb = append(friendsPb, friendPb)
|
||||||
}
|
}
|
||||||
return friendsPb, nil
|
return friendsPb, nil
|
||||||
@ -96,6 +99,9 @@ func FriendOnlyDB2PbOnly(friendsDB []*model.Friend) []*relation.FriendInfoOnly {
|
|||||||
OperatorUserID: f.OperatorUserID,
|
OperatorUserID: f.OperatorUserID,
|
||||||
Ex: f.Ex,
|
Ex: f.Ex,
|
||||||
IsPinned: f.IsPinned,
|
IsPinned: f.IsPinned,
|
||||||
|
IsMute: f.IsMuted,
|
||||||
|
MuteDuration: f.MuteDuration,
|
||||||
|
MuteEndTime: f.MuteEndTime,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,4 +30,7 @@ type Friend struct {
|
|||||||
OperatorUserID string `bson:"operator_user_id"`
|
OperatorUserID string `bson:"operator_user_id"`
|
||||||
Ex string `bson:"ex"`
|
Ex string `bson:"ex"`
|
||||||
IsPinned bool `bson:"is_pinned"`
|
IsPinned bool `bson:"is_pinned"`
|
||||||
|
IsMuted bool `bson:"is_muted"`
|
||||||
|
MuteDuration int64 `bson:"mute_duration"` // 单位:秒
|
||||||
|
MuteEndTime int64 `bson:"mute_end_time"` // Unix 毫秒时间戳,0 表示永久
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user