Merge branch 'main' into feat-create-reports

(((Updating local branch)))
This commit is contained in:
P. Reis 2024-05-01 20:56:18 -03:00
commit 9553fce25d
6 changed files with 16 additions and 1635 deletions

View File

@ -1,5 +1,6 @@
{ {
"$schema": "https://deno.land/x/deno@v1.41.0/cli/schemas/config-file.v1.json", "$schema": "https://deno.land/x/deno@v1.41.0/cli/schemas/config-file.v1.json",
"lock": false,
"tasks": { "tasks": {
"start": "deno run -A src/server.ts", "start": "deno run -A src/server.ts",
"dev": "deno run -A --watch src/server.ts", "dev": "deno run -A --watch src/server.ts",
@ -21,7 +22,7 @@
"@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0",
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0",
"@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs",
"@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", "@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.1.0",
"@soapbox/stickynotes": "jsr:@soapbox/stickynotes@^0.4.0", "@soapbox/stickynotes": "jsr:@soapbox/stickynotes@^0.4.0",
"@std/cli": "jsr:@std/cli@^0.223.0", "@std/cli": "jsr:@std/cli@^0.223.0",
"@std/crypto": "jsr:@std/crypto@^0.224.0", "@std/crypto": "jsr:@std/crypto@^0.224.0",
@ -49,9 +50,9 @@
"tldts": "npm:tldts@^6.0.14", "tldts": "npm:tldts@^6.0.14",
"tseep": "npm:tseep@^1.2.1", "tseep": "npm:tseep@^1.2.1",
"type-fest": "npm:type-fest@^4.3.0", "type-fest": "npm:type-fest@^4.3.0",
"unfurl": "npm:unfurl.js@^6.4.0", "unfurl.js": "npm:unfurl.js@^6.4.0",
"uuid62": "npm:uuid62@^1.0.2", "uuid62": "npm:uuid62@^1.0.2",
"zod": "npm:zod@^3.23.4", "zod": "npm:zod@^3.23.5",
"~/fixtures/": "./fixtures/" "~/fixtures/": "./fixtures/"
}, },
"lint": { "lint": {

1624
deno.lock

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,7 @@ import { auth19, requirePubkey } from '@/middleware/auth19.ts';
import { auth98, requireProof, requireRole } from '@/middleware/auth98.ts'; import { auth98, requireProof, requireRole } from '@/middleware/auth98.ts';
import { cache } from '@/middleware/cache.ts'; import { cache } from '@/middleware/cache.ts';
import { csp } from '@/middleware/csp.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 { storeMiddleware } from '@/middleware/store.ts';
import { reportsController } from '@/controllers/api/reports.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.delete('/api/v1/pleroma/admin/statuses/:id', requireRole('admin'), pleromaAdminDeleteStatusController);
app.get('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController); 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); app.post('/api/v1/reports', requirePubkey, reportsController);

View File

@ -6,10 +6,11 @@ import { Conf } from '@/config.ts';
import { Storages } from '@/storages.ts'; import { Storages } from '@/storages.ts';
import { AdminSigner } from '@/signers/AdminSigner.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts';
const markerSchema = z.enum(['read', 'write']);
const relaySchema = z.object({ const relaySchema = z.object({
url: z.string().url(), url: z.string().url(),
read: z.boolean(), marker: markerSchema.optional(),
write: z.boolean(),
}); });
type RelayEntity = z.infer<typeof relaySchema>; type RelayEntity = z.infer<typeof relaySchema>;
@ -31,7 +32,7 @@ export const adminSetRelaysController: AppController = async (c) => {
const event = await new AdminSigner().signEvent({ const event = await new AdminSigner().signEvent({
kind: 10002, 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: '', content: '',
created_at: Math.floor(Date.now() / 1000), created_at: Math.floor(Date.now() / 1000),
}); });
@ -47,8 +48,7 @@ function renderRelays(event: NostrEvent): RelayEntity[] {
if (name === 'r') { if (name === 'r') {
const relay: RelayEntity = { const relay: RelayEntity = {
url, url,
read: !marker || marker === 'read', marker: markerSchema.safeParse(marker).success ? marker as 'read' | 'write' : undefined,
write: !marker || marker === 'write',
}; };
acc.push(relay); acc.push(relay);
} }

View File

@ -1,6 +1,6 @@
import TTLCache from '@isaacs/ttlcache'; import TTLCache from '@isaacs/ttlcache';
import Debug from '@soapbox/stickynotes/debug'; import Debug from '@soapbox/stickynotes/debug';
import { unfurl } from 'unfurl'; import { unfurl } from 'unfurl.js';
import { sanitizeHtml } from '@/deps.ts'; import { sanitizeHtml } from '@/deps.ts';
import { Time } from '@/utils/time.ts'; import { Time } from '@/utils/time.ts';

View File

@ -33,6 +33,10 @@ class SqliteWorker {
return this.#client.executeQuery(query) as Promise<QueryResult<R>>; 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> { destroy(): Promise<void> {
return this.#client.destroy(); return this.#client.destroy();
} }