Add dummy relationships endpoint

This commit is contained in:
Alex Gleason 2023-04-29 17:59:42 -05:00
parent 64102699ac
commit acabc7c4ad
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 34 additions and 1 deletions

View File

@ -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<Event<0> | undefined> {
console.log(`Looking up ${value}`);
@ -70,4 +95,10 @@ async function lookupAccount(value: string): Promise<Event<0> | undefined> {
}
}
export { accountController, accountLookupController, accountSearchController, credentialsController };
export {
accountController,
accountLookupController,
accountSearchController,
credentialsController,
relationshipsController,
};

View File

@ -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);