mute member cant send msg

This commit is contained in:
wangchuxiao 2022-11-11 18:06:15 +08:00
parent 3c8a0bb011
commit 08a4b92f3a
2 changed files with 28 additions and 1 deletions

View File

@ -96,6 +96,17 @@ func isMessageHasReadEnabled(pb *pbChat.SendMsgReq) (bool, int32, string) {
return true, 0, ""
}
func userIsMuteInGroup(groupID, userID string) (bool, error) {
groupMemberInfo, err := rocksCache.GetGroupMemberInfoFromCache(groupID, userID)
if err != nil {
return false, utils.Wrap(err, "")
}
if groupMemberInfo.MuteEndTime.Unix() >= time.Now().Unix() {
return true, nil
}
return false, nil
}
func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string) {
switch data.MsgData.SessionType {
case constant.SingleChatType:
@ -169,6 +180,14 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s
return false, 202, "you are not in group", nil
}
}
isMute, err := userIsMuteInGroup(data.MsgData.GroupID, data.MsgData.SendID)
if err != nil {
errMsg := data.OperationID + err.Error()
return false, 223, errMsg, nil
}
if isMute {
return false, 224, "you are muted", nil
}
return true, 0, "", userIDList
case constant.SuperGroupChatType:
groupInfo, err := rocksCache.GetGroupInfoFromCache(data.MsgData.GroupID)
@ -222,6 +241,14 @@ func (rpc *rpcChat) messageVerification(data *pbChat.SendMsgReq) (bool, int32, s
return false, 202, "you are not in group", nil
}
}
isMute, err := userIsMuteInGroup(data.MsgData.GroupID, data.MsgData.SendID)
if err != nil {
errMsg := data.OperationID + err.Error()
return false, 223, errMsg, nil
}
if isMute {
return false, 224, "you are muted", nil
}
return true, 0, "", userIDList
}
default:

View File

@ -585,7 +585,7 @@ type usualConfig struct {
Minio struct {
AccessKeyID string `yaml:"accessKeyID"`
SecretAccessKey string `yaml:"secretAccessKey"`
Endpoint string `yaml:"endPoint"`
Endpoint string `yaml:"endpoint"`
} `yaml:"minio"`
} `yaml:"credential"`