mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
config for msg read receipt
This commit is contained in:
parent
96f09c45f5
commit
32565dd188
@ -49,6 +49,24 @@ type MsgCallBackResp struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isMessageHasReadEnabled(pb *pbChat.SendMsgReq) (bool, int32, string) {
|
||||||
|
switch pb.MsgData.ContentType {
|
||||||
|
case constant.HasReadReceipt:
|
||||||
|
if config.Config.SingleMessageHasReadReceiptEnable {
|
||||||
|
return true, 0, ""
|
||||||
|
} else {
|
||||||
|
return false, constant.ErrMessageHasReadDisable.ErrCode, constant.ErrMessageHasReadDisable.ErrMsg
|
||||||
|
}
|
||||||
|
case constant.GroupHasReadReceipt:
|
||||||
|
if config.Config.GroupMessageHasReadReceiptEnable {
|
||||||
|
return true, 0, ""
|
||||||
|
} else {
|
||||||
|
return false, constant.ErrMessageHasReadDisable.ErrCode, constant.ErrMessageHasReadDisable.ErrMsg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true, 0, ""
|
||||||
|
}
|
||||||
|
|
||||||
func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string) {
|
func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string) {
|
||||||
if data.MsgData.SessionType == constant.GroupChatType {
|
if data.MsgData.SessionType == constant.GroupChatType {
|
||||||
return true, 0, ""
|
return true, 0, ""
|
||||||
@ -144,7 +162,11 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
replay := pbChat.SendMsgResp{}
|
replay := pbChat.SendMsgResp{}
|
||||||
newTime := db.GetCurrentTimestampByMill()
|
newTime := db.GetCurrentTimestampByMill()
|
||||||
log.NewWarn(pb.OperationID, "rpc sendMsg come here", pb.String(), pb.MsgData.ClientMsgID)
|
log.NewWarn(pb.OperationID, "rpc sendMsg come here", pb.String(), pb.MsgData.ClientMsgID)
|
||||||
flag, errCode, errMsg := userRelationshipVerification(pb)
|
flag, errCode, errMsg := isMessageHasReadEnabled(pb)
|
||||||
|
if !flag {
|
||||||
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
||||||
|
}
|
||||||
|
flag, errCode, errMsg = userRelationshipVerification(pb)
|
||||||
if !flag {
|
if !flag {
|
||||||
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
||||||
}
|
}
|
||||||
|
@ -214,13 +214,14 @@ type config struct {
|
|||||||
MsgToPush string `yaml:"msgToPush"`
|
MsgToPush string `yaml:"msgToPush"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Secret string `yaml:"secret"`
|
Secret string `yaml:"secret"`
|
||||||
MultiLoginPolicy int `yaml:"multiloginpolicy"`
|
MultiLoginPolicy int `yaml:"multiloginpolicy"`
|
||||||
ChatPersistenceMysql bool `yaml:"chatpersistencemysql"`
|
ChatPersistenceMysql bool `yaml:"chatpersistencemysql"`
|
||||||
ReliableStorage bool `yaml:"reliablestorage"`
|
ReliableStorage bool `yaml:"reliablestorage"`
|
||||||
MsgCacheTimeout int `yaml:"msgCacheTimeout"`
|
MsgCacheTimeout int `yaml:"msgCacheTimeout"`
|
||||||
|
GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"`
|
||||||
TokenPolicy struct {
|
SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"`
|
||||||
|
TokenPolicy struct {
|
||||||
AccessSecret string `yaml:"accessSecret"`
|
AccessSecret string `yaml:"accessSecret"`
|
||||||
AccessExpire int64 `yaml:"accessExpire"`
|
AccessExpire int64 `yaml:"accessExpire"`
|
||||||
}
|
}
|
||||||
|
@ -28,23 +28,24 @@ const (
|
|||||||
|
|
||||||
///ContentType
|
///ContentType
|
||||||
//UserRelated
|
//UserRelated
|
||||||
Text = 101
|
Text = 101
|
||||||
Picture = 102
|
Picture = 102
|
||||||
Voice = 103
|
Voice = 103
|
||||||
Video = 104
|
Video = 104
|
||||||
File = 105
|
File = 105
|
||||||
AtText = 106
|
AtText = 106
|
||||||
Merger = 107
|
Merger = 107
|
||||||
Card = 108
|
Card = 108
|
||||||
Location = 109
|
Location = 109
|
||||||
Custom = 110
|
Custom = 110
|
||||||
Revoke = 111
|
Revoke = 111
|
||||||
HasReadReceipt = 112
|
HasReadReceipt = 112
|
||||||
Typing = 113
|
Typing = 113
|
||||||
Quote = 114
|
Quote = 114
|
||||||
Common = 200
|
GroupHasReadReceipt = 116
|
||||||
GroupMsg = 201
|
Common = 200
|
||||||
SignalMsg = 202
|
GroupMsg = 201
|
||||||
|
SignalMsg = 202
|
||||||
|
|
||||||
//SysRelated
|
//SysRelated
|
||||||
NotificationBegin = 1000
|
NotificationBegin = 1000
|
||||||
|
@ -49,12 +49,13 @@ var (
|
|||||||
ErrTokenUnknown = ErrInfo{705, TokenUnknownMsg.Error()}
|
ErrTokenUnknown = ErrInfo{705, TokenUnknownMsg.Error()}
|
||||||
ErrTokenKicked = ErrInfo{706, TokenUserKickedMsg.Error()}
|
ErrTokenKicked = ErrInfo{706, TokenUserKickedMsg.Error()}
|
||||||
|
|
||||||
ErrAccess = ErrInfo{ErrCode: 801, ErrMsg: AccessMsg.Error()}
|
ErrAccess = ErrInfo{ErrCode: 801, ErrMsg: AccessMsg.Error()}
|
||||||
ErrDB = ErrInfo{ErrCode: 802, ErrMsg: DBMsg.Error()}
|
ErrDB = ErrInfo{ErrCode: 802, ErrMsg: DBMsg.Error()}
|
||||||
ErrArgs = ErrInfo{ErrCode: 803, ErrMsg: ArgsMsg.Error()}
|
ErrArgs = ErrInfo{ErrCode: 803, ErrMsg: ArgsMsg.Error()}
|
||||||
ErrStatus = ErrInfo{ErrCode: 804, ErrMsg: StatusMsg.Error()}
|
ErrStatus = ErrInfo{ErrCode: 804, ErrMsg: StatusMsg.Error()}
|
||||||
ErrCallback = ErrInfo{ErrCode: 809, ErrMsg: CallBackMsg.Error()}
|
ErrCallback = ErrInfo{ErrCode: 809, ErrMsg: CallBackMsg.Error()}
|
||||||
ErrSendLimit = ErrInfo{ErrCode: 810, ErrMsg: "send msg limit, to many request, try again later"}
|
ErrSendLimit = ErrInfo{ErrCode: 810, ErrMsg: "send msg limit, to many request, try again later"}
|
||||||
|
ErrMessageHasReadDisable = ErrInfo{ErrCode: 811, ErrMsg: "message has read disable"}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user