Merge branch 'blocks-to-mutes' into 'main'
Rename blocks to mutes in the API See merge request soapbox-pub/ditto!212
This commit is contained in:
commit
e61dd73761
10
src/app.ts
10
src/app.ts
|
@ -13,15 +13,15 @@ import {
|
||||||
accountLookupController,
|
accountLookupController,
|
||||||
accountSearchController,
|
accountSearchController,
|
||||||
accountStatusesController,
|
accountStatusesController,
|
||||||
blockController,
|
|
||||||
createAccountController,
|
createAccountController,
|
||||||
favouritesController,
|
favouritesController,
|
||||||
followController,
|
followController,
|
||||||
followersController,
|
followersController,
|
||||||
followingController,
|
followingController,
|
||||||
|
muteController,
|
||||||
relationshipsController,
|
relationshipsController,
|
||||||
unblockController,
|
|
||||||
unfollowController,
|
unfollowController,
|
||||||
|
unmuteController,
|
||||||
updateCredentialsController,
|
updateCredentialsController,
|
||||||
verifyCredentialsController,
|
verifyCredentialsController,
|
||||||
} from '@/controllers/api/accounts.ts';
|
} from '@/controllers/api/accounts.ts';
|
||||||
|
@ -32,6 +32,7 @@ import { bookmarksController } from '@/controllers/api/bookmarks.ts';
|
||||||
import { emptyArrayController, emptyObjectController, notImplementedController } from '@/controllers/api/fallback.ts';
|
import { emptyArrayController, emptyObjectController, notImplementedController } from '@/controllers/api/fallback.ts';
|
||||||
import { instanceController } from '@/controllers/api/instance.ts';
|
import { instanceController } from '@/controllers/api/instance.ts';
|
||||||
import { mediaController } from '@/controllers/api/media.ts';
|
import { mediaController } from '@/controllers/api/media.ts';
|
||||||
|
import { mutesController } from '@/controllers/api/mutes.ts';
|
||||||
import { notificationsController } from '@/controllers/api/notifications.ts';
|
import { notificationsController } from '@/controllers/api/notifications.ts';
|
||||||
import { createTokenController, oauthAuthorizeController, oauthController } from '@/controllers/api/oauth.ts';
|
import { createTokenController, oauthAuthorizeController, oauthController } from '@/controllers/api/oauth.ts';
|
||||||
import {
|
import {
|
||||||
|
@ -77,6 +78,8 @@ import { cache } from '@/middleware/cache.ts';
|
||||||
import { csp } from '@/middleware/csp.ts';
|
import { csp } from '@/middleware/csp.ts';
|
||||||
import { adminRelaysController, adminSetRelaysController } from '@/controllers/api/ditto.ts';
|
import { adminRelaysController, adminSetRelaysController } from '@/controllers/api/ditto.ts';
|
||||||
import { storeMiddleware } from '@/middleware/store.ts';
|
import { storeMiddleware } from '@/middleware/store.ts';
|
||||||
|
import { blockController } from '@/controllers/api/accounts.ts';
|
||||||
|
import { unblockController } from '@/controllers/api/accounts.ts';
|
||||||
|
|
||||||
interface AppEnv extends HonoEnv {
|
interface AppEnv extends HonoEnv {
|
||||||
Variables: {
|
Variables: {
|
||||||
|
@ -141,6 +144,8 @@ app.get('/api/v1/accounts/lookup', accountLookupController);
|
||||||
app.get('/api/v1/accounts/relationships', requirePubkey, relationshipsController);
|
app.get('/api/v1/accounts/relationships', requirePubkey, relationshipsController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/block', requirePubkey, blockController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/block', requirePubkey, blockController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unblock', requirePubkey, unblockController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unblock', requirePubkey, unblockController);
|
||||||
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/mute', requirePubkey, muteController);
|
||||||
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unmute', requirePubkey, unmuteController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/follow', requirePubkey, followController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/follow', requirePubkey, followController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unfollow', requirePubkey, unfollowController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unfollow', requirePubkey, unfollowController);
|
||||||
app.get('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/followers', followersController);
|
app.get('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/followers', followersController);
|
||||||
|
@ -183,6 +188,7 @@ app.get('/api/v1/notifications', requirePubkey, notificationsController);
|
||||||
app.get('/api/v1/favourites', requirePubkey, favouritesController);
|
app.get('/api/v1/favourites', requirePubkey, favouritesController);
|
||||||
app.get('/api/v1/bookmarks', requirePubkey, bookmarksController);
|
app.get('/api/v1/bookmarks', requirePubkey, bookmarksController);
|
||||||
app.get('/api/v1/blocks', requirePubkey, blocksController);
|
app.get('/api/v1/blocks', requirePubkey, blocksController);
|
||||||
|
app.get('/api/v1/mutes', requirePubkey, mutesController);
|
||||||
|
|
||||||
app.get('/api/v1/admin/accounts', requireRole('admin'), adminAccountsController);
|
app.get('/api/v1/admin/accounts', requireRole('admin'), adminAccountsController);
|
||||||
app.get('/api/v1/pleroma/admin/config', requireRole('admin'), configController);
|
app.get('/api/v1/pleroma/admin/config', requireRole('admin'), configController);
|
||||||
|
|
|
@ -273,7 +273,17 @@ const followingController: AppController = async (c) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** https://docs.joinmastodon.org/methods/accounts/#block */
|
/** https://docs.joinmastodon.org/methods/accounts/#block */
|
||||||
const blockController: AppController = async (c) => {
|
const blockController: AppController = (c) => {
|
||||||
|
return c.json({ error: 'Blocking is not supported by Nostr' }, 422);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** https://docs.joinmastodon.org/methods/accounts/#unblock */
|
||||||
|
const unblockController: AppController = (c) => {
|
||||||
|
return c.json({ error: 'Blocking is not supported by Nostr' }, 422);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** https://docs.joinmastodon.org/methods/accounts/#mute */
|
||||||
|
const muteController: AppController = async (c) => {
|
||||||
const sourcePubkey = c.get('pubkey')!;
|
const sourcePubkey = c.get('pubkey')!;
|
||||||
const targetPubkey = c.req.param('pubkey');
|
const targetPubkey = c.req.param('pubkey');
|
||||||
|
|
||||||
|
@ -287,8 +297,8 @@ const blockController: AppController = async (c) => {
|
||||||
return c.json(relationship);
|
return c.json(relationship);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** https://docs.joinmastodon.org/methods/accounts/#unblock */
|
/** https://docs.joinmastodon.org/methods/accounts/#unmute */
|
||||||
const unblockController: AppController = async (c) => {
|
const unmuteController: AppController = async (c) => {
|
||||||
const sourcePubkey = c.get('pubkey')!;
|
const sourcePubkey = c.get('pubkey')!;
|
||||||
const targetPubkey = c.req.param('pubkey');
|
const targetPubkey = c.req.param('pubkey');
|
||||||
|
|
||||||
|
@ -334,9 +344,11 @@ export {
|
||||||
followController,
|
followController,
|
||||||
followersController,
|
followersController,
|
||||||
followingController,
|
followingController,
|
||||||
|
muteController,
|
||||||
relationshipsController,
|
relationshipsController,
|
||||||
unblockController,
|
unblockController,
|
||||||
unfollowController,
|
unfollowController,
|
||||||
|
unmuteController,
|
||||||
updateCredentialsController,
|
updateCredentialsController,
|
||||||
verifyCredentialsController,
|
verifyCredentialsController,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,24 +1,6 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
|
||||||
import { getTagSet } from '@/tags.ts';
|
|
||||||
import { renderAccounts } from '@/views.ts';
|
|
||||||
|
|
||||||
/** https://docs.joinmastodon.org/methods/blocks/#get */
|
/** https://docs.joinmastodon.org/methods/blocks/#get */
|
||||||
const blocksController: AppController = async (c) => {
|
export const blocksController: AppController = (c) => {
|
||||||
const pubkey = c.get('pubkey')!;
|
return c.json({ error: 'Blocking is not supported by Nostr' }, 422);
|
||||||
const { signal } = c.req.raw;
|
|
||||||
|
|
||||||
const [event10000] = await Storages.db.query(
|
|
||||||
[{ kinds: [10000], authors: [pubkey], limit: 1 }],
|
|
||||||
{ signal },
|
|
||||||
);
|
|
||||||
|
|
||||||
if (event10000) {
|
|
||||||
const pubkeys = getTagSet(event10000.tags, 'p');
|
|
||||||
return renderAccounts(c, [...pubkeys].reverse());
|
|
||||||
} else {
|
|
||||||
return c.json([]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { blocksController };
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { type AppController } from '@/app.ts';
|
||||||
|
import { Storages } from '@/storages.ts';
|
||||||
|
import { getTagSet } from '@/tags.ts';
|
||||||
|
import { renderAccounts } from '@/views.ts';
|
||||||
|
|
||||||
|
/** https://docs.joinmastodon.org/methods/mutes/#get */
|
||||||
|
const mutesController: AppController = async (c) => {
|
||||||
|
const pubkey = c.get('pubkey')!;
|
||||||
|
const { signal } = c.req.raw;
|
||||||
|
|
||||||
|
const [event10000] = await Storages.db.query(
|
||||||
|
[{ kinds: [10000], authors: [pubkey], limit: 1 }],
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (event10000) {
|
||||||
|
const pubkeys = getTagSet(event10000.tags, 'p');
|
||||||
|
return renderAccounts(c, [...pubkeys].reverse());
|
||||||
|
} else {
|
||||||
|
return c.json([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export { mutesController };
|
Loading…
Reference in New Issue