You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
package echomeet
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// @Summary 批量删除会议记录
|
|
// @Description 根据 Ids 批量删除会议记录
|
|
// @Tags Echomeet
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param user body pb.EchomeetDelRecordsReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.EchomeetDelRecordsResp} "响应数据"
|
|
// @Router /api/home/echomeet_delrecords [post]
|
|
func (this *apiComp) DelRecords(session comm.IUserSession, req *pb.EchomeetDelRecordsReq) (resp *pb.EchomeetDelRecordsResp, errdata *pb.ErrorData) {
|
|
var (
|
|
deleted []uint64
|
|
err error
|
|
)
|
|
uid, errdata := requireUID(session)
|
|
if errdata != nil {
|
|
return
|
|
}
|
|
// 只删本人的。ids 里混进别人的(或已被别的设备删掉的)id 时按交集删、不报错,
|
|
// 响应里回**实际删掉的**那批,客户端据它清本地缓存。
|
|
if deleted, err = this.module.model.delrecordsforuid(uid, req.Ids); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
// 连带清掉这些纪要自动抽出来的待办:来源都没了,待办还挂在日历上,
|
|
// 用户点进去找不到出处。用户改过的(user_edited=1)由 memory 那边保留。
|
|
//
|
|
// ⚠️ 另起 goroutine 且失败只记日志:纪要已经删掉了,不能因为附带清理失败
|
|
// 就对客户端报删除失败——那会让用户以为没删掉,再点一次。
|
|
this.deleteMeetingTodos(uid, deleted)
|
|
|
|
resp = &pb.EchomeetDelRecordsResp{
|
|
Ids: deleted,
|
|
}
|
|
return
|
|
}
|
|
|
|
// deleteMeetingTodos 异步清理这些记录在拾忆里留下的自动待办。
|
|
func (this *apiComp) deleteMeetingTodos(uid string, ids []uint64) {
|
|
if len(ids) == 0 {
|
|
return
|
|
}
|
|
mem := this.module.memoryModule()
|
|
if mem == nil {
|
|
return
|
|
}
|
|
recordIDs := make([]string, 0, len(ids))
|
|
for _, id := range ids {
|
|
recordIDs = append(recordIDs, strconv.FormatUint(id, 10))
|
|
}
|
|
go func() {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
this.module.Errorf("纪要删除连带清理待办 panic uid:%s err:%v", uid, r)
|
|
}
|
|
}()
|
|
if _, err := mem.DeleteMeetingItems(uid, recordIDs); err != nil {
|
|
this.module.Warnf("纪要删除连带清理待办失败已忽略 uid:%s records:%v err:%v", uid, recordIDs, err)
|
|
}
|
|
}()
|
|
}
|
|
|