mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
add super delete
This commit is contained in:
parent
ec5177342e
commit
504e4cc6a3
@ -139,6 +139,7 @@ func main() {
|
||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||
chatGroup.POST("/del_super_group_msg", apiChat.DelSuperGroupMsg)
|
||||
chatGroup.POST("/clear_msg", apiChat.ClearMsg)
|
||||
chatGroup.POST("/manage_send_msg", manage.ManagementSendMsg)
|
||||
chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -72,6 +73,83 @@ func DelMsg(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func DelSuperGroupMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelSuperGroupMsgReq
|
||||
resp api.DelSuperGroupMsgResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
|
||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + opUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
pbData := rpc.SendMsgReq{
|
||||
OperationID: req.OperationID,
|
||||
MsgData: &pbCommon.MsgData{
|
||||
SendID: req.UserID,
|
||||
RecvID: req.UserID,
|
||||
ClientMsgID: utils.GetMsgID(req.UserID),
|
||||
SessionType: constant.SingleChatType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.MsgDeleteNotification,
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
},
|
||||
}
|
||||
var tips pbCommon.TipsComm
|
||||
deleteMsg := api.MsgDeleteNotificationElem{
|
||||
GroupID: req.GroupID,
|
||||
IsAllDelete: req.IsAllDelete,
|
||||
SeqList: req.SeqList,
|
||||
}
|
||||
tips.JsonDetail = utils.StructToJsonString(deleteMsg)
|
||||
var err error
|
||||
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(req.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||
resp.ErrCode = 400
|
||||
resp.ErrMsg = err.Error()
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewChatClient(etcdConn)
|
||||
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// @Summary 清空用户消息
|
||||
// @Description 清空用户消息
|
||||
|
@ -18,3 +18,19 @@ type CleanUpMsgReq struct {
|
||||
type CleanUpMsgResp struct {
|
||||
CommResp
|
||||
}
|
||||
type DelSuperGroupMsgReq struct {
|
||||
UserID string `json:"userID,omitempty" binding:"required"`
|
||||
GroupID string `json:"groupID,omitempty" binding:"required"`
|
||||
SeqList []uint32 `json:"seqList,omitempty"`
|
||||
IsAllDelete bool `json:"isAllDelete"`
|
||||
OperationID string `json:"operationID,omitempty" binding:"required"`
|
||||
}
|
||||
|
||||
type DelSuperGroupMsgResp struct {
|
||||
CommResp
|
||||
}
|
||||
type MsgDeleteNotificationElem struct {
|
||||
GroupID string `json:"groupID"`
|
||||
IsAllDelete bool `json:"isAllDelete"`
|
||||
SeqList []uint32 `json:"seqList"`
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ const (
|
||||
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
||||
BlackAddedNotification = 1207 //add_black
|
||||
BlackDeletedNotification = 1208 //remove_black
|
||||
MsgDeleteNotification = 1209
|
||||
|
||||
ConversationOptChangeNotification = 1300 // change conversation opt
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user