diff --git a/src/api/accounts.ts b/src/api/accounts.ts index 2377aa3..cc889b9 100644 --- a/src/api/accounts.ts +++ b/src/api/accounts.ts @@ -59,6 +59,31 @@ const accountSearchController: AppController = async (c) => { return c.json([]); }; +const relationshipsController: AppController = (c) => { + const ids = c.req.queries('id[]'); + + if (!ids) { + return c.json({ error: 'Missing `id[]` query parameters.' }, 422); + } + + const result = ids.map((id) => ({ + id, + following: false, + showing_reblogs: false, + notifying: false, + followed_by: false, + blocking: false, + blocked_by: false, + muting: false, + muting_notifications: false, + requested: false, + domain_blocking: false, + endorsed: false, + })); + + return c.json(result); +}; + /** Resolve a bech32 or NIP-05 identifier to an account. */ async function lookupAccount(value: string): Promise | undefined> { console.log(`Looking up ${value}`); @@ -70,4 +95,10 @@ async function lookupAccount(value: string): Promise | undefined> { } } -export { accountController, accountLookupController, accountSearchController, credentialsController }; +export { + accountController, + accountLookupController, + accountSearchController, + credentialsController, + relationshipsController, +}; diff --git a/src/app.ts b/src/app.ts index 39faf4f..2e28594 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,6 +5,7 @@ import { accountLookupController, accountSearchController, credentialsController, + relationshipsController, } from './api/accounts.ts'; import { appCredentialsController, createAppController } from './api/apps.ts'; import { emptyArrayController, emptyObjectController } from './api/fallback.ts'; @@ -40,6 +41,7 @@ app.post('/oauth/revoke', emptyObjectController); app.get('/api/v1/accounts/verify_credentials', requireAuth, credentialsController); app.get('/api/v1/accounts/search', accountSearchController); app.get('/api/v1/accounts/lookup', accountLookupController); +app.get('/api/v1/accounts/relationships', relationshipsController); app.get('/api/v1/accounts/:pubkey{[0-9a-f]{64}}', accountController); app.get('/api/v1/statuses/:id{[0-9a-f]{64}}', statusController);