diff --git a/bskylink/src/cache/safelinkClient.ts b/bskylink/src/cache/safelinkClient.ts index a5111ebeea..88c5b7b529 100644 --- a/bskylink/src/cache/safelinkClient.ts +++ b/bskylink/src/cache/safelinkClient.ts @@ -1,6 +1,7 @@ import { AtpAgent, CredentialSession, + type ToolsOzoneSafelinkDefs, type ToolsOzoneSafelinkQueryEvents, } from '@atproto/api' import {HOUR} from '@atproto/common' @@ -8,7 +9,7 @@ import {LRUCache} from 'lru-cache' import {type ServiceConfig} from '../config.js' import type Database from '../db/index.js' -import {type RulePatternType, type SafelinkRule} from '../db/schema.js' +import {type SafelinkRule} from '../db/schema.js' import {redirectLogger} from '../logger.js' const SAFELINK_MIN_FETCH_INTERVAL = 1_000 @@ -93,7 +94,7 @@ export class SafelinkClient { private async getRule( db: Database, url: string, - pattern: RulePatternType, + pattern: ToolsOzoneSafelinkDefs.PatternType, ): Promise { return db.db .selectFrom('safelink_rule') diff --git a/bskylink/src/db/schema.ts b/bskylink/src/db/schema.ts index edd070d200..9ea29b94fc 100644 --- a/bskylink/src/db/schema.ts +++ b/bskylink/src/db/schema.ts @@ -1,3 +1,4 @@ +import {type ToolsOzoneSafelinkDefs} from '@atproto/api' import {type Selectable} from 'kysely' export type DbSchema = { @@ -16,27 +17,13 @@ export enum LinkType { StarterPack = 1, } -export type RuleEventType = - | 'addRule' - | 'updateRule' - | 'removeRule' - | (string & {}) -export type RulePatternType = 'domain' | 'url' | (string & {}) -export type RuleActionType = 'block' | 'warn' | 'whitelist' | (string & {}) -export type RuleReasonType = - | 'csam' - | 'spam' - | 'phishing' - | 'none' - | (string & {}) - export interface SafelinkRule { id: number - eventType: RuleEventType + eventType: ToolsOzoneSafelinkDefs.EventType url: string - pattern: RulePatternType - action: RuleActionType - reason: RuleReasonType + pattern: ToolsOzoneSafelinkDefs.PatternType + action: ToolsOzoneSafelinkDefs.ActionType + reason: ToolsOzoneSafelinkDefs.ReasonType createdBy: string createdAt: string comment?: string