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

44 lines
1.2 KiB
Go
Raw Normal View History

2022-03-16 18:02:26 +08:00
package msg
import (
2023-02-09 14:40:49 +08:00
"Open_IM/pkg/common/tokenverify"
2022-07-29 12:24:54 +08:00
"Open_IM/pkg/proto/msg"
2023-02-09 20:36:34 +08:00
common "Open_IM/pkg/proto/sdkws"
2022-03-16 18:02:26 +08:00
"context"
)
2023-02-13 18:14:26 +08:00
func (m *msgServer) DelMsgList(ctx context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) {
2023-02-09 14:40:49 +08:00
resp := &common.DelMsgListResp{}
2023-02-13 18:14:26 +08:00
if err := m.MsgInterface.DelMsgFromCache(ctx, req.UserID, req.SeqList); err != nil {
2023-02-13 11:24:13 +08:00
return nil, err
2022-03-17 19:00:05 +08:00
}
2023-02-13 11:24:13 +08:00
DeleteMessageNotification(ctx, req.UserID, req.SeqList)
2022-03-16 18:02:26 +08:00
return resp, nil
}
2023-02-13 11:24:13 +08:00
2023-02-13 18:14:26 +08:00
func (m *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) {
2022-07-29 12:24:54 +08:00
resp := &msg.DelSuperGroupMsgResp{}
2023-02-13 11:24:13 +08:00
if err := tokenverify.CheckAdmin(ctx); err != nil {
return nil, err
2022-07-29 12:24:54 +08:00
}
2023-02-13 18:14:26 +08:00
maxSeq, err := m.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID)
2022-07-29 12:24:54 +08:00
if err != nil {
2023-02-13 11:24:13 +08:00
return nil, err
}
2023-02-13 18:14:26 +08:00
if err := m.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil {
2023-02-13 11:24:13 +08:00
return nil, err
2022-07-29 12:24:54 +08:00
}
return resp, nil
2023-01-11 16:23:16 +08:00
}
2023-02-10 22:10:37 +08:00
2023-02-13 18:14:26 +08:00
func (m *msgServer) ClearMsg(ctx context.Context, req *msg.ClearMsgReq) (*msg.ClearMsgResp, error) {
2023-02-13 11:24:13 +08:00
resp := &msg.ClearMsgResp{}
if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
return nil, err
2023-02-10 22:10:37 +08:00
}
2023-02-13 18:14:26 +08:00
if err := m.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil {
2023-02-13 11:24:13 +08:00
return nil, err
2023-02-10 22:10:37 +08:00
}
2023-02-13 11:24:13 +08:00
return resp, nil
2023-02-10 22:10:37 +08:00
}