use types from ozone

This commit is contained in:
Hailey
2025-09-01 10:13:46 -07:00
parent 4da6bd5b95
commit b543f5790c
2 changed files with 8 additions and 20 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
import { import {
AtpAgent, AtpAgent,
CredentialSession, CredentialSession,
type ToolsOzoneSafelinkDefs,
type ToolsOzoneSafelinkQueryEvents, type ToolsOzoneSafelinkQueryEvents,
} from '@atproto/api' } from '@atproto/api'
import {HOUR} from '@atproto/common' import {HOUR} from '@atproto/common'
@@ -8,7 +9,7 @@ import {LRUCache} from 'lru-cache'
import {type ServiceConfig} from '../config.js' import {type ServiceConfig} from '../config.js'
import type Database from '../db/index.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' import {redirectLogger} from '../logger.js'
const SAFELINK_MIN_FETCH_INTERVAL = 1_000 const SAFELINK_MIN_FETCH_INTERVAL = 1_000
@@ -93,7 +94,7 @@ export class SafelinkClient {
private async getRule( private async getRule(
db: Database, db: Database,
url: string, url: string,
pattern: RulePatternType, pattern: ToolsOzoneSafelinkDefs.PatternType,
): Promise<SafelinkRule> { ): Promise<SafelinkRule> {
return db.db return db.db
.selectFrom('safelink_rule') .selectFrom('safelink_rule')
+5 -18
View File
@@ -1,3 +1,4 @@
import {type ToolsOzoneSafelinkDefs} from '@atproto/api'
import {type Selectable} from 'kysely' import {type Selectable} from 'kysely'
export type DbSchema = { export type DbSchema = {
@@ -16,27 +17,13 @@ export enum LinkType {
StarterPack = 1, 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 { export interface SafelinkRule {
id: number id: number
eventType: RuleEventType eventType: ToolsOzoneSafelinkDefs.EventType
url: string url: string
pattern: RulePatternType pattern: ToolsOzoneSafelinkDefs.PatternType
action: RuleActionType action: ToolsOzoneSafelinkDefs.ActionType
reason: RuleReasonType reason: ToolsOzoneSafelinkDefs.ReasonType
createdBy: string createdBy: string
createdAt: string createdAt: string
comment?: string comment?: string