mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix signerMiddleware, don't throw in streamingController
This commit is contained in:
parent
6a63724864
commit
efae292099
2 changed files with 3 additions and 7 deletions
|
|
@ -78,11 +78,6 @@ const streamingController: AppController = async (c) => {
|
||||||
return c.text('Please use websocket protocol', 400);
|
return c.text('Please use websocket protocol', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pubkey = await signer?.getPublicKey();
|
|
||||||
if (!pubkey) {
|
|
||||||
return c.json({ error: 'Invalid access token' }, 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ip = c.req.header('x-real-ip');
|
const ip = c.req.header('x-real-ip');
|
||||||
if (ip) {
|
if (ip) {
|
||||||
const count = limiter.get(ip) ?? 0;
|
const count = limiter.get(ip) ?? 0;
|
||||||
|
|
@ -96,6 +91,7 @@ const streamingController: AppController = async (c) => {
|
||||||
const store = await Storages.db();
|
const store = await Storages.db();
|
||||||
const pubsub = await Storages.pubsub();
|
const pubsub = await Storages.pubsub();
|
||||||
|
|
||||||
|
const pubkey = await signer?.getPublicKey();
|
||||||
const policy = pubkey ? new MuteListPolicy(pubkey, await Storages.admin()) : undefined;
|
const policy = pubkey ? new MuteListPolicy(pubkey, await Storages.admin()) : undefined;
|
||||||
|
|
||||||
function send(e: StreamingEvent) {
|
function send(e: StreamingEvent) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ export const signerMiddleware: AppMiddleware = async (c, next) => {
|
||||||
} catch {
|
} catch {
|
||||||
throw new HTTPException(401);
|
throw new HTTPException(401);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (accessToken) {
|
||||||
try {
|
try {
|
||||||
const decoded = nip19.decode(accessToken!);
|
const decoded = nip19.decode(accessToken!);
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ export const signerMiddleware: AppMiddleware = async (c, next) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
throw new HTTPException(401);
|
throw new HTTPException(401, { message: 'Invalid access token' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue