mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-04 22:24:25 +01:00
Merge branch 'main' into feat-create-reports
(((Updating local branch)))
This commit is contained in:
@@ -75,7 +75,7 @@ import { auth19, requirePubkey } from '@/middleware/auth19.ts';
|
||||
import { auth98, requireProof, requireRole } from '@/middleware/auth98.ts';
|
||||
import { cache } from '@/middleware/cache.ts';
|
||||
import { csp } from '@/middleware/csp.ts';
|
||||
import { adminRelaysController } from '@/controllers/api/ditto.ts';
|
||||
import { adminRelaysController, adminSetRelaysController } from '@/controllers/api/ditto.ts';
|
||||
import { storeMiddleware } from '@/middleware/store.ts';
|
||||
import { reportsController } from '@/controllers/api/reports.ts';
|
||||
|
||||
@@ -191,7 +191,7 @@ app.post('/api/v1/pleroma/admin/config', requireRole('admin'), updateConfigContr
|
||||
app.delete('/api/v1/pleroma/admin/statuses/:id', requireRole('admin'), pleromaAdminDeleteStatusController);
|
||||
|
||||
app.get('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController);
|
||||
app.put('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController);
|
||||
app.put('/api/v1/admin/ditto/relays', requireRole('admin'), adminSetRelaysController);
|
||||
|
||||
app.post('/api/v1/reports', requirePubkey, reportsController);
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ import { Conf } from '@/config.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
|
||||
const markerSchema = z.enum(['read', 'write']);
|
||||
|
||||
const relaySchema = z.object({
|
||||
url: z.string().url(),
|
||||
read: z.boolean(),
|
||||
write: z.boolean(),
|
||||
marker: markerSchema.optional(),
|
||||
});
|
||||
|
||||
type RelayEntity = z.infer<typeof relaySchema>;
|
||||
@@ -31,7 +32,7 @@ export const adminSetRelaysController: AppController = async (c) => {
|
||||
|
||||
const event = await new AdminSigner().signEvent({
|
||||
kind: 10002,
|
||||
tags: relays.map(({ url, read, write }) => ['r', url, read && write ? '' : read ? 'read' : 'write']),
|
||||
tags: relays.map(({ url, marker }) => marker ? ['r', url, marker] : ['r', url]),
|
||||
content: '',
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
@@ -47,8 +48,7 @@ function renderRelays(event: NostrEvent): RelayEntity[] {
|
||||
if (name === 'r') {
|
||||
const relay: RelayEntity = {
|
||||
url,
|
||||
read: !marker || marker === 'read',
|
||||
write: !marker || marker === 'write',
|
||||
marker: markerSchema.safeParse(marker).success ? marker as 'read' | 'write' : undefined,
|
||||
};
|
||||
acc.push(relay);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TTLCache from '@isaacs/ttlcache';
|
||||
import Debug from '@soapbox/stickynotes/debug';
|
||||
import { unfurl } from 'unfurl';
|
||||
import { unfurl } from 'unfurl.js';
|
||||
|
||||
import { sanitizeHtml } from '@/deps.ts';
|
||||
import { Time } from '@/utils/time.ts';
|
||||
|
||||
@@ -33,6 +33,10 @@ class SqliteWorker {
|
||||
return this.#client.executeQuery(query) as Promise<QueryResult<R>>;
|
||||
}
|
||||
|
||||
streamQuery<R>(): AsyncIterableIterator<R> {
|
||||
throw new Error('Streaming queries are not supported in the web worker');
|
||||
}
|
||||
|
||||
destroy(): Promise<void> {
|
||||
return this.#client.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user