mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-06 07:04:24 +01:00
Support admin accounts endpoint (first pass)
This commit is contained in:
@@ -12,7 +12,7 @@ interface ToAccountOpts {
|
||||
}
|
||||
|
||||
async function renderAccount(
|
||||
event: Omit<NonNullable<DittoEvent['author']>, 'id' | 'sig'>,
|
||||
event: Omit<DittoEvent<0>, 'id' | 'sig'>,
|
||||
opts: ToAccountOpts = {},
|
||||
) {
|
||||
const { withSource = false } = opts;
|
||||
@@ -39,7 +39,7 @@ async function renderAccount(
|
||||
avatar: picture,
|
||||
avatar_static: picture,
|
||||
bot: false,
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
created_at: user ? user.inserted_at.toISOString() : nostrDate(event.created_at).toISOString(),
|
||||
discoverable: true,
|
||||
display_name: name,
|
||||
emojis: renderEmojis(event),
|
||||
|
||||
30
src/views/mastodon/admin-accounts.ts
Normal file
30
src/views/mastodon/admin-accounts.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { DittoEvent } from '@/storages/types.ts';
|
||||
import { nostrDate } from '@/utils.ts';
|
||||
|
||||
import { accountFromPubkey, renderAccount } from './accounts.ts';
|
||||
|
||||
async function renderAdminAccount(event: DittoEvent<30361>) {
|
||||
const d = event.tags.find(([name]) => name === 'd')?.[1]!;
|
||||
const account = event.d_author ? await renderAccount({ ...event.d_author, user: event }) : await accountFromPubkey(d);
|
||||
|
||||
return {
|
||||
id: account.id,
|
||||
username: event.tags.find(([name]) => name === 'name')?.[1]!,
|
||||
domain: account.acct.split('@')[1] || null,
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
email: '',
|
||||
ip: null,
|
||||
ips: [],
|
||||
locale: '',
|
||||
invite_request: null,
|
||||
role: event.tags.find(([name]) => name === 'role')?.[1] || 'user',
|
||||
confirmed: true,
|
||||
approved: true,
|
||||
disabled: false,
|
||||
silenced: false,
|
||||
suspended: false,
|
||||
account,
|
||||
};
|
||||
}
|
||||
|
||||
export { renderAdminAccount };
|
||||
Reference in New Issue
Block a user