Filter server-side labels ()

filter server side labels
This commit is contained in:
Daniel Holmgren 2023-05-02 16:00:41 -05:00 committed by GitHub
parent b1493650f4
commit 4555596212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,9 +3,14 @@ import Database from '../../../db'
import { Label } from '../../../lexicon/types/com/atproto/label/defs'
import { ids } from '../../../lexicon/lexicons'
import { sql } from 'kysely'
import { NotEmptyArray } from '@atproto/common'
export type Labels = Record<string, Label[]>
// @TODO forward these labels to client
// these are labels are currently only used server side & not sent to client since it does not handle them correctly
const SERVER_SIDE_LABELS: NotEmptyArray<string> = ['!no-promote']
export class LabelService {
constructor(public db: Database) {}
@ -68,6 +73,7 @@ export class LabelService {
const res = await this.db.db
.selectFrom('label')
.where('label.uri', 'in', subjects)
.where('label.val', 'not in', SERVER_SIDE_LABELS)
.if(!includeNeg, (qb) => qb.where('neg', '=', 0))
.selectAll()
.execute()