mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-20 23:08:25 +08:00
阅后即焚
This commit is contained in:
parent
f268d91db6
commit
f85a6a0bd1
@ -171,6 +171,8 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co
|
||||
userRouterGroup.POST("/set_call_accept_setting", u.SetCallAcceptSetting)
|
||||
userRouterGroup.POST("/set_msg_receive_setting", u.SetMsgReceiveSetting)
|
||||
userRouterGroup.POST("/set_group_invite_setting", u.SetGroupInviteSetting)
|
||||
// 设置用户全局阅后即焚时长(秒),0 表示关闭
|
||||
userRouterGroup.POST("/set_user_msg_burn_duration", u.SetUserMsgBurnDuration)
|
||||
// 根据手机号精确查找用户(phoneSearchVisibility=true 时遵守 phone_visibility 设置)
|
||||
userRouterGroup.POST("/get_user_by_phone", u.GetUserByPhone)
|
||||
// 根据昵称精确查询用户(可多结果,与 getPaginationUsers 模糊搜索不同)
|
||||
|
||||
@ -355,6 +355,10 @@ func (u *UserApi) SetGroupInviteSetting(c *gin.Context) {
|
||||
a2r.Call(c, user.UserClient.SetGroupInviteSetting, u.Client)
|
||||
}
|
||||
|
||||
func (u *UserApi) SetUserMsgBurnDuration(c *gin.Context) {
|
||||
a2r.Call(c, user.UserClient.SetUserMsgBurnDuration, u.Client)
|
||||
}
|
||||
|
||||
func (u *UserApi) GetUserByPhone(c *gin.Context) {
|
||||
a2r.Call(c, user.UserClient.GetUserByPhone, u.Client)
|
||||
}
|
||||
|
||||
@ -424,6 +424,37 @@ func (s *userServer) SetGroupInviteSetting(ctx context.Context, req *pbuser.SetG
|
||||
return &pbuser.SetGroupInviteSettingResp{}, nil
|
||||
}
|
||||
|
||||
// SetUserMsgBurnDuration 设置用户全局消息阅后即焚时长(秒);0 表示关闭,要求 >=0。
|
||||
// 只允许本人或管理员操作。
|
||||
func (s *userServer) SetUserMsgBurnDuration(ctx context.Context, req *pbuser.SetUserMsgBurnDurationReq) (*pbuser.SetUserMsgBurnDurationResp, error) {
|
||||
if req.UserID == "" {
|
||||
return nil, errs.ErrArgs.WrapMsg("userID is required")
|
||||
}
|
||||
if req.MsgBurnDuration < 0 {
|
||||
return nil, errs.ErrArgs.WrapMsg("msgBurnDuration must be >= 0 (seconds)")
|
||||
}
|
||||
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
||||
log.ZWarn(ctx, "SetUserMsgBurnDuration: access denied", err,
|
||||
"opUserID", mcontext.GetOpUserID(ctx), "targetUserID", req.UserID)
|
||||
return nil, err
|
||||
}
|
||||
if _, err := s.db.FindWithError(ctx, []string{req.UserID}); err != nil {
|
||||
log.ZError(ctx, "SetUserMsgBurnDuration: user not found or db error", err,
|
||||
"opUserID", mcontext.GetOpUserID(ctx), "targetUserID", req.UserID)
|
||||
return nil, err
|
||||
}
|
||||
if err := s.db.UpdateByMap(ctx, req.UserID, map[string]any{
|
||||
"msg_burn_duration": req.MsgBurnDuration,
|
||||
}); err != nil {
|
||||
log.ZError(ctx, "SetUserMsgBurnDuration: UpdateByMap failed", err,
|
||||
"opUserID", mcontext.GetOpUserID(ctx), "targetUserID", req.UserID,
|
||||
"msgBurnDuration", req.MsgBurnDuration)
|
||||
return nil, err
|
||||
}
|
||||
s.friendNotificationSender.UserInfoUpdatedNotification(ctx, req.UserID)
|
||||
return &pbuser.SetUserMsgBurnDurationResp{}, nil
|
||||
}
|
||||
|
||||
// GetUserByPhone 根据精确手机号查询用户。
|
||||
//
|
||||
// phone_visibility 仅控制用户资料中手机号字段是否展示,不影响搜索本身:
|
||||
|
||||
@ -52,6 +52,7 @@ func UserDB2Pb(user *relationtb.User) *sdkws.UserInfo {
|
||||
MsgReceiveSetting: user.MsgReceiveSetting,
|
||||
GroupInviteSetting: user.GroupInviteSetting,
|
||||
CallRingtoneURL: user.CallRingtoneURL,
|
||||
MsgBurnDuration: user.MsgBurnDuration,
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,6 +93,7 @@ func UserPb2DBMap(user *sdkws.UserInfo) map[string]any {
|
||||
"app_manager_level": user.AppMangerLevel,
|
||||
"global_recv_msg_opt": user.GlobalRecvMsgOpt,
|
||||
"call_ringtone_url": user.CallRingtoneURL,
|
||||
"msg_burn_duration": user.MsgBurnDuration,
|
||||
}
|
||||
for key, value := range fields {
|
||||
if v, ok := value.(string); ok && v != "" {
|
||||
@ -163,5 +165,8 @@ func UserPb2DBMapEx(user *sdkws.UserInfoWithEx) map[string]any {
|
||||
if user.CallRingtoneURL != nil {
|
||||
val["call_ringtone_url"] = user.CallRingtoneURL.Value
|
||||
}
|
||||
if user.MsgBurnDuration != nil {
|
||||
val["msg_burn_duration"] = user.MsgBurnDuration.Value
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
@ -79,6 +79,8 @@ type User struct {
|
||||
CallRingtoneURL string `bson:"call_ringtone_url"`
|
||||
// Status 账号状态:0=正常,1=冻结,2=黑名单
|
||||
Status int32 `bson:"status"`
|
||||
// MsgBurnDuration 用户全局消息阅后即焚时长(秒);0 表示关闭
|
||||
MsgBurnDuration int32 `bson:"msg_burn_duration"`
|
||||
}
|
||||
|
||||
func (u *User) GetNickname() string {
|
||||
|
||||
2
protocol
2
protocol
@ -1 +1 @@
|
||||
Subproject commit de7a73dfcf97ac618dacdad970da0f3cbd7f0ac8
|
||||
Subproject commit 49fe436a9a00d4b5a2e86f728cdd34156bed1164
|
||||
Loading…
x
Reference in New Issue
Block a user