Delete labels for highlights when label is deleted

This commit is contained in:
Hongbo Wu 2022-06-08 15:35:52 +08:00
parent 22c604c15b
commit 0d67d0fb90

View file

@ -31,6 +31,7 @@ import { createPubSubClient } from '../../datalayer/pubsub'
import { AppDataSource } from '../../server'
import { getPageById } from '../../elastic/pages'
import {
deleteLabelForHighlights,
deleteLabelInPages,
setLabelsForHighlight,
updateLabelInPage,
@ -38,6 +39,7 @@ import {
} from '../../elastic/labels'
import { getHighlightById } from '../../elastic/highlights'
import { getLabelsByIds } from '../../services/labels'
import { PageContext } from '../../elastic/types'
export const labelsResolver = authorized<LabelsSuccess, LabelsError>(
async (_obj, _params, { claims: { uid }, log }) => {
@ -178,11 +180,13 @@ export const deleteLabelResolver = authorized<
}
}
// delete label in elastic pages
await deleteLabelInPages(uid, label.name, {
const ctx: PageContext = {
pubsub: createPubSubClient(),
uid,
})
}
// delete label in elastic pages and highlights
await deleteLabelInPages(uid, label.name, ctx)
await deleteLabelForHighlights(uid, label.name, ctx)
analytics.track({
userId: uid,