Jinnrry/PMail

Some bugs about group deletion

Opened this issue · 3 comments

Looking at your logic about group deletion, you first find out all the child ids in a recursive way and delete them together. If there is a loop, it will SOF. you also didn't check when you added the group.A good approach is to remove the parent group before querying the child id

If it turns out to be a bug, I'll fix it

func getAllChildId(ctx *context.Context, rootId int) []int {
var ids []id
var ret []int
db.Instance.Select(&ids, db.WithContext(ctx, "select id from group where parent_id=? and user_id=?"), rootId, ctx.UserID)
for _, item := range ids {
ret = array.Merge(ret, getAllChildId(ctx, item.Id))
ret = append(ret, item.Id)
}
return ret
}

yes,this is a bug,welcome pr.