Merge branch 'main' into cashu

This commit is contained in:
P. Reis 2025-02-06 13:19:35 -03:00
commit f5ebb5d82a
8 changed files with 55 additions and 26 deletions

View file

@ -47,8 +47,8 @@
"@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1", "@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1",
"@negrel/webpush": "jsr:@negrel/webpush@^0.3.0", "@negrel/webpush": "jsr:@negrel/webpush@^0.3.0",
"@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0",
"@nostrify/db": "jsr:@nostrify/db@^0.37.3", "@nostrify/db": "jsr:@nostrify/db@^0.38.0",
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.38.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.38.1",
"@nostrify/policies": "jsr:@nostrify/policies@^0.36.1", "@nostrify/policies": "jsr:@nostrify/policies@^0.36.1",
"@nostrify/types": "jsr:@nostrify/types@^0.36.0", "@nostrify/types": "jsr:@nostrify/types@^0.36.0",
"@scure/base": "npm:@scure/base@^1.1.6", "@scure/base": "npm:@scure/base@^1.1.6",
@ -73,7 +73,7 @@
"fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0", "fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0",
"formdata-helper": "npm:formdata-helper@^0.3.0", "formdata-helper": "npm:formdata-helper@^0.3.0",
"hono-rate-limiter": "npm:hono-rate-limiter@^0.3.0", "hono-rate-limiter": "npm:hono-rate-limiter@^0.3.0",
"iso-639-1": "npm:iso-639-1@2.1.15", "iso-639-1": "npm:iso-639-1@^3.1.5",
"isomorphic-dompurify": "npm:isomorphic-dompurify@^2.16.0", "isomorphic-dompurify": "npm:isomorphic-dompurify@^2.16.0",
"kysely": "npm:kysely@^0.27.4", "kysely": "npm:kysely@^0.27.4",
"kysely-postgres-js": "npm:kysely-postgres-js@2.0.0", "kysely-postgres-js": "npm:kysely-postgres-js@2.0.0",

38
deno.lock generated
View file

@ -31,14 +31,15 @@
"jsr:@lambdalisue/async@^2.1.1": "2.1.1", "jsr:@lambdalisue/async@^2.1.1": "2.1.1",
"jsr:@negrel/http-ece@0.6.0": "0.6.0", "jsr:@negrel/http-ece@0.6.0": "0.6.0",
"jsr:@negrel/webpush@0.3": "0.3.0", "jsr:@negrel/webpush@0.3": "0.3.0",
"jsr:@nostrify/db@~0.37.3": "0.37.3", "jsr:@nostrify/db@0.38": "0.38.0",
"jsr:@nostrify/nostrify@0.31": "0.31.0", "jsr:@nostrify/nostrify@0.31": "0.31.0",
"jsr:@nostrify/nostrify@0.32": "0.32.0", "jsr:@nostrify/nostrify@0.32": "0.32.0",
"jsr:@nostrify/nostrify@0.36": "0.36.2", "jsr:@nostrify/nostrify@0.36": "0.36.2",
"jsr:@nostrify/nostrify@0.38": "0.38.0", "jsr:@nostrify/nostrify@0.38": "0.38.1",
"jsr:@nostrify/nostrify@~0.22.1": "0.22.5", "jsr:@nostrify/nostrify@~0.22.1": "0.22.5",
"jsr:@nostrify/nostrify@~0.22.4": "0.22.4", "jsr:@nostrify/nostrify@~0.22.4": "0.22.4",
"jsr:@nostrify/nostrify@~0.22.5": "0.22.5", "jsr:@nostrify/nostrify@~0.22.5": "0.22.5",
"jsr:@nostrify/nostrify@~0.38.1": "0.38.1",
"jsr:@nostrify/policies@0.33": "0.33.0", "jsr:@nostrify/policies@0.33": "0.33.0",
"jsr:@nostrify/policies@0.33.1": "0.33.1", "jsr:@nostrify/policies@0.33.1": "0.33.1",
"jsr:@nostrify/policies@0.34": "0.34.0", "jsr:@nostrify/policies@0.34": "0.34.0",
@ -102,7 +103,7 @@
"npm:fast-stable-stringify@1": "1.0.0", "npm:fast-stable-stringify@1": "1.0.0",
"npm:formdata-helper@0.3": "0.3.0", "npm:formdata-helper@0.3": "0.3.0",
"npm:hono-rate-limiter@0.3": "0.3.0_hono@4.2.5", "npm:hono-rate-limiter@0.3": "0.3.0_hono@4.2.5",
"npm:iso-639-1@2.1.15": "2.1.15", "npm:iso-639-1@^3.1.5": "3.1.5",
"npm:isomorphic-dompurify@^2.16.0": "2.16.0", "npm:isomorphic-dompurify@^2.16.0": "2.16.0",
"npm:kysely-postgres-js@2.0.0": "2.0.0_kysely@0.27.3_postgres@3.4.4", "npm:kysely-postgres-js@2.0.0": "2.0.0_kysely@0.27.3_postgres@3.4.4",
"npm:kysely@~0.27.2": "0.27.4", "npm:kysely@~0.27.2": "0.27.4",
@ -357,10 +358,10 @@
"jsr:@std/path@0.224.0" "jsr:@std/path@0.224.0"
] ]
}, },
"@nostrify/db@0.37.3": { "@nostrify/db@0.38.0": {
"integrity": "fe7cacd67bb817f10fb44587e832cfb042a3a0d32db29b24a487b7d006438623", "integrity": "44118756b95f747779839f0e578a5e1dbca164ec44edb8885bd1c99840775e8a",
"dependencies": [ "dependencies": [
"jsr:@nostrify/nostrify@0.38", "jsr:@nostrify/nostrify@~0.38.1",
"jsr:@nostrify/types@0.36", "jsr:@nostrify/types@0.36",
"npm:kysely@~0.27.3", "npm:kysely@~0.27.3",
"npm:nostr-tools@^2.10.4" "npm:nostr-tools@^2.10.4"
@ -479,6 +480,21 @@
"npm:zod" "npm:zod"
] ]
}, },
"@nostrify/nostrify@0.38.1": {
"integrity": "087d1be0d5c46420e6040b07c8cfb1a3ecb9808f23de54d22dd64d3eed001bce",
"dependencies": [
"jsr:@nostrify/types@0.36",
"jsr:@std/crypto",
"jsr:@std/encoding@~0.224.1",
"npm:@scure/base",
"npm:@scure/bip32",
"npm:@scure/bip39",
"npm:lru-cache@^10.2.0",
"npm:nostr-tools@^2.10.4",
"npm:websocket-ts",
"npm:zod"
]
},
"@nostrify/policies@0.33.0": { "@nostrify/policies@0.33.0": {
"integrity": "c946b06d0527298b4d7c9819d142a10f522ba09eee76c37525aa4acfc5d87aee", "integrity": "c946b06d0527298b4d7c9819d142a10f522ba09eee76c37525aa4acfc5d87aee",
"dependencies": [ "dependencies": [
@ -1271,8 +1287,8 @@
"isexe@2.0.0": { "isexe@2.0.0": {
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
}, },
"iso-639-1@2.1.15": { "iso-639-1@3.1.5": {
"integrity": "sha512-7c7mBznZu2ktfvyT582E2msM+Udc1EjOyhVRE/0ZsjD9LBtWSm23h3PtiRh2a35XoUsTQQjJXaJzuLjXsOdFDg==" "integrity": "sha512-gXkz5+KN7HrG0Q5UGqSMO2qB9AsbEeyLP54kF1YrMsIxmu+g4BdB7rflReZTSTZGpfj8wywu6pfPBCylPIzGQA=="
}, },
"isomorphic-dompurify@2.16.0": { "isomorphic-dompurify@2.16.0": {
"integrity": "sha512-cXhX2owp8rPxafCr0ywqy2CGI/4ceLNgWkWBEvUz64KTbtg3oRL2ZRqq/zW0pzt4YtDjkHLbwcp/lozpKzAQjg==", "integrity": "sha512-cXhX2owp8rPxafCr0ywqy2CGI/4ceLNgWkWBEvUz64KTbtg3oRL2ZRqq/zW0pzt4YtDjkHLbwcp/lozpKzAQjg==",
@ -2416,8 +2432,8 @@
"jsr:@hono/hono@^4.4.6", "jsr:@hono/hono@^4.4.6",
"jsr:@lambdalisue/async@^2.1.1", "jsr:@lambdalisue/async@^2.1.1",
"jsr:@negrel/webpush@0.3", "jsr:@negrel/webpush@0.3",
"jsr:@nostrify/db@~0.37.3", "jsr:@nostrify/db@0.38",
"jsr:@nostrify/nostrify@0.38", "jsr:@nostrify/nostrify@~0.38.1",
"jsr:@nostrify/policies@~0.36.1", "jsr:@nostrify/policies@~0.36.1",
"jsr:@nostrify/types@0.36", "jsr:@nostrify/types@0.36",
"jsr:@soapbox/kysely-pglite@1", "jsr:@soapbox/kysely-pglite@1",
@ -2444,7 +2460,7 @@
"npm:fast-stable-stringify@1", "npm:fast-stable-stringify@1",
"npm:formdata-helper@0.3", "npm:formdata-helper@0.3",
"npm:hono-rate-limiter@0.3", "npm:hono-rate-limiter@0.3",
"npm:iso-639-1@2.1.15", "npm:iso-639-1@^3.1.5",
"npm:isomorphic-dompurify@^2.16.0", "npm:isomorphic-dompurify@^2.16.0",
"npm:kysely-postgres-js@2.0.0", "npm:kysely-postgres-js@2.0.0",
"npm:kysely@~0.27.4", "npm:kysely@~0.27.4",

View file

@ -293,7 +293,7 @@ class Conf {
} }
/** Languages this server wishes to highlight. Used when querying trends.*/ /** Languages this server wishes to highlight. Used when querying trends.*/
static get preferredLanguages(): LanguageCode[] | undefined { static get preferredLanguages(): LanguageCode[] | undefined {
return Deno.env.get('DITTO_LANGUAGES')?.split(',')?.filter(ISO6391.validate) as LanguageCode[]; return Deno.env.get('DITTO_LANGUAGES')?.split(',')?.filter(ISO6391.validate);
} }
/** Translation provider used to translate posts. */ /** Translation provider used to translate posts. */
static get translationProvider(): string | undefined { static get translationProvider(): string | undefined {

View file

@ -60,7 +60,7 @@ const languageSchema = z.string().transform<LanguageCode>((val, ctx) => {
}); });
return z.NEVER; return z.NEVER;
} }
return val as LanguageCode; return val;
}); });
const localeSchema = z.string().transform<Intl.Locale>((val, ctx) => { const localeSchema = z.string().transform<Intl.Locale>((val, ctx) => {

View file

@ -75,7 +75,7 @@ export function getLanguage(text: string): LanguageCode | undefined {
const [iso6393] = topResult; const [iso6393] = topResult;
const locale = new Intl.Locale(iso6393); const locale = new Intl.Locale(iso6393);
if (ISO6391.validate(locale.language)) { if (ISO6391.validate(locale.language)) {
return locale.language as LanguageCode; return locale.language;
} }
} }
return; return;

View file

@ -36,7 +36,7 @@ export class DeepLTranslator implements DittoTranslator {
return { return {
results: translations.map((value) => value.text), results: translations.map((value) => value.text),
source_lang: translations[0]?.detected_source_language as LanguageCode, source_lang: translations[0]?.detected_source_language,
}; };
} }

View file

@ -46,7 +46,7 @@ export function detectLanguage(text: string, minConfidence: number): LanguageCod
const locale = new Intl.Locale(iso6393); const locale = new Intl.Locale(iso6393);
if (confidence >= minConfidence && ISO6391.validate(locale.language)) { if (confidence >= minConfidence && ISO6391.validate(locale.language)) {
return locale.language as LanguageCode; return locale.language;
} }
} }
} }

View file

@ -79,14 +79,27 @@ export async function getIdsBySearch(
} }
} }
for (const [key, values] of Object.entries(ext)) { for (let [key, values] of Object.entries(ext)) {
if (key === 'domain') continue; if (key === 'domain' || key === '-domain') continue;
query = query.where((eb) => let negated = false;
eb.or(
values.map((value) => eb('nostr_events.search_ext', '@>', { [key]: value })), if (key.startsWith('-')) {
) key = key.slice(1);
); negated = true;
}
query = query.where((eb) => {
if (negated) {
return eb.and(
values.map((value) => eb.not(eb('nostr_events.search_ext', '@>', { [key]: value }))),
);
} else {
return eb.or(
values.map((value) => eb('nostr_events.search_ext', '@>', { [key]: value })),
);
}
});
} }
if (domains.size) { if (domains.size) {