mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-20 22:04:23 +01:00
Add preliminary nameRequestsController
This commit is contained in:
25
src/views/ditto.ts
Normal file
25
src/views/ditto.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
||||
import { getTagSet } from '@/utils/tags.ts';
|
||||
|
||||
export async function renderNameRequest(event: DittoEvent) {
|
||||
const n = getTagSet(event.info?.tags ?? [], 'n');
|
||||
|
||||
let approvalStatus = 'pending';
|
||||
|
||||
if (n.has('approved')) {
|
||||
approvalStatus = 'approved';
|
||||
}
|
||||
if (n.has('rejected')) {
|
||||
approvalStatus = 'rejected';
|
||||
}
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
account: event.author ? await renderAccount(event.author) : accountFromPubkey(event.pubkey),
|
||||
name: event.tags.find(([name]) => name === 'r')?.[1] || '',
|
||||
reason: event.content,
|
||||
approval_status: approvalStatus,
|
||||
created_at: new Date(event.created_at * 1000).toISOString(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user