mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Merge branch 'client-tag-improvements' into 'main'
Client tag improvements See merge request soapbox-pub/ditto!733
This commit is contained in:
commit
63ebad0412
3 changed files with 17 additions and 1 deletions
|
|
@ -83,6 +83,7 @@ export class DittoPgStore extends NPostgres {
|
||||||
/** Conditions for when to index certain tags. */
|
/** Conditions for when to index certain tags. */
|
||||||
static tagConditions: Record<string, TagCondition> = {
|
static tagConditions: Record<string, TagCondition> = {
|
||||||
'a': ({ count }) => count < 15,
|
'a': ({ count }) => count < 15,
|
||||||
|
'client': ({ count, value }) => count === 0 && value.length < 50,
|
||||||
'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind),
|
'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind),
|
||||||
'e': DittoPgStore.eTagCondition,
|
'e': DittoPgStore.eTagCondition,
|
||||||
'k': ({ count }) => count < 3,
|
'k': ({ count }) => count < 3,
|
||||||
|
|
@ -521,6 +522,12 @@ export class DittoPgStore extends NPostgres {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client = event.tags.find(([name]) => name === 'client')?.[2];
|
||||||
|
|
||||||
|
if (client && /^31990:([0-9a-f]{64}):(.+)$/.test(client)) {
|
||||||
|
ext.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
ext.protocol = event.tags.find(([name]) => name === 'proxy')?.[2] ?? 'nostr';
|
ext.protocol = event.tags.find(([name]) => name === 'proxy')?.[2] ?? 'nostr';
|
||||||
|
|
||||||
return ext;
|
return ext;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ export async function createNip89(opts: CreateNip89Opts): Promise<void> {
|
||||||
tags: [
|
tags: [
|
||||||
['d', 'ditto'],
|
['d', 'ditto'],
|
||||||
['k', '1'],
|
['k', '1'],
|
||||||
|
['t', 'ditto'],
|
||||||
['web', conf.local('/<bech32>'), 'web'],
|
['web', conf.local('/<bech32>'), 'web'],
|
||||||
],
|
],
|
||||||
content: JSON.stringify(metadata),
|
content: JSON.stringify(metadata),
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ async function renderStatus(
|
||||||
if (event.client) {
|
if (event.client) {
|
||||||
const result = n.json().pipe(n.metadata()).safeParse(event.client.content);
|
const result = n.json().pipe(n.metadata()).safeParse(event.client.content);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const name = result.data.name ?? result.data.display_name ?? event.tags.find(([name]) => name === 'client')?.[1];
|
const name = result.data.name ?? event.tags.find(([name]) => name === 'client')?.[1];
|
||||||
if (name) {
|
if (name) {
|
||||||
application = {
|
application = {
|
||||||
name,
|
name,
|
||||||
|
|
@ -131,6 +131,14 @@ async function renderStatus(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const name = event.tags.find(([name]) => name === 'client')?.[1];
|
||||||
|
if (name) {
|
||||||
|
application = {
|
||||||
|
name,
|
||||||
|
website: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const expiresAt = new Date(Number(event.tags.find(([name]) => name === 'expiration')?.[1]) * 1000);
|
const expiresAt = new Date(Number(event.tags.find(([name]) => name === 'expiration')?.[1]) * 1000);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue