Files
open-im-server/internal/rpc/msg/del_msg.go
T

57 lines
2.0 KiB
Go
Raw Normal View History

2022-03-16 18:02:26 +08:00
package msg
import (
2022-03-17 19:00:05 +08:00
"Open_IM/pkg/common/constant"
2022-07-29 12:24:54 +08:00
"Open_IM/pkg/common/db"
2022-03-16 18:02:26 +08:00
"Open_IM/pkg/common/log"
2022-07-29 12:24:54 +08:00
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/proto/msg"
2023-01-04 17:14:30 +08:00
commonPb "Open_IM/pkg/proto/sdk_ws"
2022-03-16 18:02:26 +08:00
"Open_IM/pkg/utils"
"context"
2022-05-23 10:14:10 +08:00
"time"
2022-03-16 18:02:26 +08:00
)
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &commonPb.DelMsgListResp{}
2022-05-23 10:14:10 +08:00
select {
case rpc.delMsgCh <- deleteMsg{
UserID: req.UserID,
OpUserID: req.OpUserID,
SeqList: req.SeqList,
OperationID: req.OperationID,
}:
case <-time.After(1 * time.Second):
resp.ErrCode = constant.ErrSendLimit.ErrCode
resp.ErrMsg = constant.ErrSendLimit.ErrMsg
2022-03-31 14:50:02 +08:00
return resp, nil
2022-03-17 19:00:05 +08:00
}
2022-03-17 12:48:54 +08:00
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
2022-03-16 18:02:26 +08:00
return resp, nil
}
2022-07-29 12:24:54 +08:00
func (rpc *rpcChat) DelSuperGroupMsg(_ context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
if !token_verify.CheckAccess(req.OpUserID, req.UserID) {
log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.UserID)
return &msg.DelSuperGroupMsgResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
}
resp := &msg.DelSuperGroupMsgResp{}
groupMaxSeq, err := db.DB.GetGroupMaxSeq(req.GroupID)
if err != nil {
2023-01-04 17:14:30 +08:00
log.NewError(req.OperationID, "GetGroupMaxSeq false ", req.OpUserID, req.UserID, req.GroupID)
2022-07-29 12:24:54 +08:00
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = err.Error()
return resp, nil
}
2023-02-01 17:44:34 +08:00
err = db.DB.SetGroupUserMinSeq(req.GroupID, req.UserID, groupMaxSeq)
2022-07-29 12:24:54 +08:00
if err != nil {
2023-01-04 17:14:30 +08:00
log.NewError(req.OperationID, "SetGroupUserMinSeq false ", req.OpUserID, req.UserID, req.GroupID)
2022-07-29 12:24:54 +08:00
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = err.Error()
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
2023-01-04 17:14:30 +08:00
}