Add per-user activity logs with storage backend tracking, gallery storage filter, and IP/token upload rate limiting. Fix storage delete modal flash, pin local backend in filter order, and link settings version to GitHub releases.
31 lines
793 B
TypeScript
31 lines
793 B
TypeScript
import { requireUserAuth } from '../utils/access'
|
|
import {
|
|
ensureStorageSchema,
|
|
listStorageBackendNameMap,
|
|
LOCAL_BACKEND_ID
|
|
} from '../utils/storage-backends'
|
|
|
|
function sortBackendsForFilter<T extends { id: string, name: string }>(backends: T[]): T[] {
|
|
return [...backends].sort((a, b) => {
|
|
if (a.id === LOCAL_BACKEND_ID) return -1
|
|
if (b.id === LOCAL_BACKEND_ID) return 1
|
|
return a.name.localeCompare(b.name, 'zh-CN')
|
|
})
|
|
}
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
await requireUserAuth(event)
|
|
ensureStorageSchema()
|
|
|
|
const map = listStorageBackendNameMap()
|
|
const backends = sortBackendsForFilter(
|
|
Array.from(map.entries()).map(([id, backend]) => ({
|
|
id,
|
|
name: backend.name,
|
|
type: backend.type
|
|
}))
|
|
)
|
|
|
|
return { backends }
|
|
})
|