release: v1.4.3
GitHub Release / release (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
Add a Telegram channel or group storage backend, with proxied image URLs and an optional API proxy.
This commit is contained in:
1 parent
4ed4692f5e
commit
cc19dc6435
32 files changed
+1527
-143
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { getDb } from '../db'
|
||||
import type { TelegramObjectRef } from './types'
|
||||
|
||||
export function getStorageObjectRef(
|
||||
backendId: string,
|
||||
key: string
|
||||
): TelegramObjectRef | null {
|
||||
const row = getDb().prepare(`
|
||||
SELECT ref_json FROM storage_object_refs
|
||||
WHERE backend_id = ? AND key = ?
|
||||
`).get(backendId, key) as { ref_json: string } | undefined
|
||||
|
||||
if (!row) return null
|
||||
|
||||
try {
|
||||
return JSON.parse(row.ref_json) as TelegramObjectRef
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function setStorageObjectRef(
|
||||
backendId: string,
|
||||
key: string,
|
||||
ref: TelegramObjectRef
|
||||
): void {
|
||||
getDb().prepare(`
|
||||
INSERT INTO storage_object_refs (backend_id, key, ref_json)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(backend_id, key) DO UPDATE SET ref_json = excluded.ref_json
|
||||
`).run(backendId, key, JSON.stringify(ref))
|
||||
}
|
||||
|
||||
export function deleteStorageObjectRef(backendId: string, key: string): void {
|
||||
getDb().prepare(`
|
||||
DELETE FROM storage_object_refs WHERE backend_id = ? AND key = ?
|
||||
`).run(backendId, key)
|
||||
}
|
||||
|
||||
export function deleteStorageObjectRefsForBackend(backendId: string): void {
|
||||
getDb().prepare(`
|
||||
DELETE FROM storage_object_refs WHERE backend_id = ?
|
||||
`).run(backendId)
|
||||
}
|
||||
Reference in new issue
Block a user