mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
delete super group message
This commit is contained in:
parent
1eda0ebea7
commit
51679b47a6
@ -78,15 +78,18 @@ func DelSuperGroupMsg(c *gin.Context) {
|
|||||||
req api.DelSuperGroupMsgReq
|
req api.DelSuperGroupMsgReq
|
||||||
resp api.DelSuperGroupMsgResp
|
resp api.DelSuperGroupMsgResp
|
||||||
)
|
)
|
||||||
|
rpcReq := &rpc.DelSuperGroupMsgReq{}
|
||||||
|
utils.CopyStructFields(req, &req)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
|
var ok bool
|
||||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
var errInfo string
|
||||||
|
ok, rpcReq.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + opUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := req.OperationID + " " + rpcReq.OpUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
@ -137,18 +140,32 @@ func DelSuperGroupMsg(c *gin.Context) {
|
|||||||
client := rpc.NewMsgClient(etcdConn)
|
client := rpc.NewMsgClient(etcdConn)
|
||||||
|
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
||||||
|
if req.IsAllDelete {
|
||||||
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
RpcResp, err := client.DelSuperGroupMsg(context.Background(),rpcReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
log.NewError(req.OperationID, "call delete DelSuperGroupMsg rpc server failed", err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call DelSuperGroupMsg rpc server failed"})
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||||
|
resp.ErrCode = RpcResp.ErrCode
|
||||||
|
resp.ErrMsg = RpcResp.ErrMsg
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}else{
|
||||||
|
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||||
|
resp.ErrCode = RpcResp.ErrCode
|
||||||
|
resp.ErrMsg = RpcResp.ErrMsg
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
|
||||||
resp.ErrCode = RpcResp.ErrCode
|
|
||||||
resp.ErrMsg = RpcResp.ErrMsg
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary 清空用户消息
|
// @Summary 清空用户消息
|
||||||
|
@ -2,8 +2,11 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/proto/msg"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
@ -27,3 +30,27 @@ func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
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 {
|
||||||
|
log.NewError(req.OperationID, "GetGroupMaxSeq false ", req.OpUserID, req.UserID,req.GroupID)
|
||||||
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
err = db.DB.SetGroupUserMinSeq(req.GroupID,req.UserID, groupMaxSeq)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "SetGroupUserMinSeq false ", req.OpUserID, req.UserID,req.GroupID)
|
||||||
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -120,12 +120,22 @@ message GetSendMsgStatusResp{
|
|||||||
string errMsg = 2;
|
string errMsg = 2;
|
||||||
int32 status = 3;
|
int32 status = 3;
|
||||||
}
|
}
|
||||||
|
message DelSuperGroupMsgReq{
|
||||||
|
string opUserID = 1;
|
||||||
|
string userID = 2;
|
||||||
|
string groupID = 3;
|
||||||
|
string operationID = 4;
|
||||||
|
}
|
||||||
|
message DelSuperGroupMsgResp{
|
||||||
|
int32 errCode = 1;
|
||||||
|
string errMsg = 2;
|
||||||
|
}
|
||||||
service msg {
|
service msg {
|
||||||
rpc GetMaxAndMinSeq(server_api_params.GetMaxAndMinSeqReq) returns(server_api_params.GetMaxAndMinSeqResp);
|
rpc GetMaxAndMinSeq(server_api_params.GetMaxAndMinSeqReq) returns(server_api_params.GetMaxAndMinSeqResp);
|
||||||
rpc PullMessageBySeqList(server_api_params.PullMessageBySeqListReq) returns(server_api_params.PullMessageBySeqListResp);
|
rpc PullMessageBySeqList(server_api_params.PullMessageBySeqListReq) returns(server_api_params.PullMessageBySeqListResp);
|
||||||
rpc SendMsg(SendMsgReq) returns(SendMsgResp);
|
rpc SendMsg(SendMsgReq) returns(SendMsgResp);
|
||||||
rpc DelMsgList(server_api_params.DelMsgListReq) returns(server_api_params.DelMsgListResp);
|
rpc DelMsgList(server_api_params.DelMsgListReq) returns(server_api_params.DelMsgListResp);
|
||||||
|
rpc DelSuperGroupMsg(DelSuperGroupMsgReq) returns(DelSuperGroupMsgResp);
|
||||||
rpc ClearMsg(ClearMsgReq) returns(ClearMsgResp);
|
rpc ClearMsg(ClearMsgReq) returns(ClearMsgResp);
|
||||||
rpc SetMsgMinSeq(SetMsgMinSeqReq) returns(SetMsgMinSeqResp);
|
rpc SetMsgMinSeq(SetMsgMinSeqReq) returns(SetMsgMinSeqResp);
|
||||||
rpc SetSendMsgFailedFlag(SetSendMsgFailedFlagReq) returns(SetSendMsgFailedFlagResp);
|
rpc SetSendMsgFailedFlag(SetSendMsgFailedFlagReq) returns(SetSendMsgFailedFlagResp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user