kopia lustrzana https://github.com/cloudflare/wildebeest
remove admins endpoint
rodzic
65c4924cdb
commit
75c8b7ff0e
|
@ -0,0 +1,15 @@
|
||||||
|
import { type Database } from 'wildebeest/backend/src/database'
|
||||||
|
import { Person, personFromRow } from 'wildebeest/backend/src/activitypub/actors'
|
||||||
|
|
||||||
|
export async function getAdmins(db: Database): Promise<Person[]> {
|
||||||
|
let rows: unknown[] = []
|
||||||
|
try {
|
||||||
|
const stmt = db.prepare('SELECT * FROM actors WHERE is_admin=1')
|
||||||
|
const result = await stmt.all<unknown>()
|
||||||
|
rows = result.success ? (result.results as unknown[]) : []
|
||||||
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows.map(personFromRow)
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
|
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
|
||||||
import { Database } from 'wildebeest/backend/src/database'
|
import { Database } from 'wildebeest/backend/src/database'
|
||||||
import { getJwtEmail } from 'wildebeest/backend/src/utils/auth/getJwtEmail'
|
import { getJwtEmail } from 'wildebeest/backend/src/utils/auth/getJwtEmail'
|
||||||
import { getAdmins } from 'wildebeest/functions/api/wb/settings/server/admins'
|
import { getAdmins } from './getAdmins'
|
||||||
import { isUserAuthenticated } from './isUserAuthenticated'
|
import { isUserAuthenticated } from './isUserAuthenticated'
|
||||||
|
|
||||||
export async function isUserAdmin(
|
export async function isUserAdmin(
|
||||||
|
|
|
@ -10,10 +10,10 @@ import { ServerSettingsData } from '~/routes/(admin)/settings/(admin)/server-set
|
||||||
import { Account } from '~/types'
|
import { Account } from '~/types'
|
||||||
import { getDocumentHead } from '~/utils/getDocumentHead'
|
import { getDocumentHead } from '~/utils/getDocumentHead'
|
||||||
import { instanceLoader } from '../layout'
|
import { instanceLoader } from '../layout'
|
||||||
import { getAdmins } from 'wildebeest/functions/api/wb/settings/server/admins'
|
|
||||||
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
|
import { emailSymbol } from 'wildebeest/backend/src/activitypub/actors'
|
||||||
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
||||||
import { AccountCard } from '~/components/AccountCard/AccountCard'
|
import { AccountCard } from '~/components/AccountCard/AccountCard'
|
||||||
|
import { getAdmins } from 'wildebeest/backend/src/utils/auth/getAdmins'
|
||||||
|
|
||||||
type AboutInfo = {
|
type AboutInfo = {
|
||||||
image: string
|
image: string
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
|
||||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
|
||||||
import { type Database, getDatabase } from 'wildebeest/backend/src/database'
|
|
||||||
import { Person, personFromRow } from 'wildebeest/backend/src/activitypub/actors'
|
|
||||||
|
|
||||||
export const onRequestGet: PagesFunction<Env, any, ContextData> = async ({ env }) => {
|
|
||||||
return handleRequestGet(await getDatabase(env))
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function handleRequestGet(db: Database) {
|
|
||||||
const admins = await getAdmins(db)
|
|
||||||
return new Response(JSON.stringify(admins), { status: 200 })
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAdmins(db: Database): Promise<Person[]> {
|
|
||||||
let rows: unknown[] = []
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('SELECT * FROM actors WHERE is_admin=1')
|
|
||||||
const result = await stmt.all<unknown>()
|
|
||||||
rows = result.success ? (result.results as unknown[]) : []
|
|
||||||
} catch {
|
|
||||||
/* empty */
|
|
||||||
}
|
|
||||||
|
|
||||||
return rows.map(personFromRow)
|
|
||||||
}
|
|
Ładowanie…
Reference in New Issue