mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix bug
This commit is contained in:
parent
ae684d6d39
commit
6525d63459
@ -230,6 +230,11 @@ chatpersistencemysql: true
|
|||||||
reliablestorage: false
|
reliablestorage: false
|
||||||
#消息缓存时间
|
#消息缓存时间
|
||||||
msgCacheTimeout: 1800
|
msgCacheTimeout: 1800
|
||||||
|
#群聊已读开启
|
||||||
|
groupMessageHasReadReceiptEnable: false
|
||||||
|
#单聊已读开启
|
||||||
|
singleMessageHasReadReceiptEnable: false
|
||||||
|
|
||||||
|
|
||||||
#token config
|
#token config
|
||||||
tokenpolicy:
|
tokenpolicy:
|
||||||
|
@ -181,7 +181,7 @@ func onboardingProcessNotification(operationID, userID, groupID string) {
|
|||||||
Content: content,
|
Content: content,
|
||||||
MsgFrom: constant.UserMsgType,
|
MsgFrom: constant.UserMsgType,
|
||||||
ContentType: constant.Text,
|
ContentType: constant.Text,
|
||||||
SessionType: constant.SingleChatType,
|
SessionType: constant.GroupChatType,
|
||||||
OperationID: operationID,
|
OperationID: operationID,
|
||||||
}
|
}
|
||||||
// notification user join group
|
// notification user join group
|
||||||
|
@ -210,7 +210,7 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||||
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data)
|
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, string(m.Data))
|
||||||
nReply := new(pbChat.SendMsgResp)
|
nReply := new(pbChat.SendMsgResp)
|
||||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
|
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendSignalMsg)
|
||||||
if isPass {
|
if isPass {
|
||||||
|
@ -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.SingleChatType {
|
if data.MsgData.SessionType == constant.SingleChatType {
|
||||||
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) {
|
||||||
@ -150,7 +168,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)
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
|
|||||||
log.Error(req.OperationID, errMsg)
|
log.Error(req.OperationID, errMsg)
|
||||||
return &rpc.CreateDepartmentResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
return &rpc.CreateDepartmentResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||||
}
|
}
|
||||||
err, createdDepartment := imdb.GetDepartment(department.DepartmentID)
|
createdDepartment, err := imdb.GetDepartment(department.DepartmentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + "GetDepartment failed " + err.Error() + department.DepartmentID
|
errMsg := req.OperationID + " " + "GetDepartment failed " + err.Error() + department.DepartmentID
|
||||||
log.Error(req.OperationID, errMsg)
|
log.Error(req.OperationID, errMsg)
|
||||||
@ -141,6 +141,9 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
|
|||||||
resp.ErrMsg = constant.ErrDB.ErrMsg + " createGroup failed " + createGroupResp.ErrMsg
|
resp.ErrMsg = constant.ErrDB.ErrMsg + " createGroup failed " + createGroupResp.ErrMsg
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
if err := imdb.SetDepartmentRelatedGroupID(createGroupResp.GroupInfo.GroupID, department.DepartmentID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetDepartmentRelatedGroupID failed", err.Error())
|
||||||
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +219,8 @@ type config struct {
|
|||||||
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"`
|
||||||
|
SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"`
|
||||||
|
|
||||||
TokenPolicy struct {
|
TokenPolicy struct {
|
||||||
AccessSecret string `yaml:"accessSecret"`
|
AccessSecret string `yaml:"accessSecret"`
|
||||||
|
@ -42,6 +42,7 @@ const (
|
|||||||
HasReadReceipt = 112
|
HasReadReceipt = 112
|
||||||
Typing = 113
|
Typing = 113
|
||||||
Quote = 114
|
Quote = 114
|
||||||
|
GroupHasReadReceipt = 116
|
||||||
Common = 200
|
Common = 200
|
||||||
GroupMsg = 201
|
GroupMsg = 201
|
||||||
SignalMsg = 202
|
SignalMsg = 202
|
||||||
|
@ -55,6 +55,7 @@ var (
|
|||||||
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 (
|
||||||
|
@ -16,14 +16,14 @@ func CreateDepartment(department *db.Department) error {
|
|||||||
return dbConn.Table("departments").Create(department).Error
|
return dbConn.Table("departments").Create(department).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDepartment(departmentID string) (error, *db.Department) {
|
func GetDepartment(departmentID string) (*db.Department, error) {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, nil
|
return nil, err
|
||||||
}
|
}
|
||||||
var department db.Department
|
var department db.Department
|
||||||
err = dbConn.Table("departments").Where("department_id=?", departmentID).Find(&department).Error
|
err = dbConn.Table("departments").Where("department_id=?", departmentID).Find(&department).Error
|
||||||
return err, &department
|
return &department, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateDepartment(department *db.Department, args map[string]interface{}) error {
|
func UpdateDepartment(department *db.Department, args map[string]interface{}) error {
|
||||||
@ -237,6 +237,15 @@ func GetSubDepartmentNum(departmentID string) (error, uint32) {
|
|||||||
return nil, number
|
return nil, number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetDepartmentRelatedGroupID(groupID, departmentID string) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "DefaultGormDB failed")
|
||||||
|
}
|
||||||
|
department := &db.Department{RelatedGroupID: groupID}
|
||||||
|
return dbConn.Model(&department).Where("department_id=?", departmentID).Update(department).Error
|
||||||
|
}
|
||||||
|
|
||||||
func GetDepartmentRelatedGroupIDList(departmentIDList []string) ([]string, error) {
|
func GetDepartmentRelatedGroupIDList(departmentIDList []string) ([]string, error) {
|
||||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -257,7 +266,7 @@ func getDepartmentParent(departmentID string, dbConn *gorm.DB) (*db.Department,
|
|||||||
return nil, utils.Wrap(err, "")
|
return nil, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
err = dbConn.Model(&parentDepartment).Where("department_id = ?", department.ParentID).Find(&parentDepartment).Error
|
err = dbConn.Model(&parentDepartment).Where("department_id = ?", department.ParentID).Find(&parentDepartment).Error
|
||||||
return &department, err
|
return &parentDepartment, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDepartmentParent(departmentID string, dbConn *gorm.DB, parentIDList *[]string) error {
|
func GetDepartmentParent(departmentID string, dbConn *gorm.DB, parentIDList *[]string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user