db/events: add a baseline 200 character limit to tag values
This commit is contained in:
parent
fe08aaa2a3
commit
6e139985ac
|
@ -14,10 +14,10 @@ type TagCondition = ({ event, count, value }: {
|
||||||
|
|
||||||
/** Conditions for when to index certain tags. */
|
/** Conditions for when to index certain tags. */
|
||||||
const tagConditions: Record<string, TagCondition> = {
|
const tagConditions: Record<string, TagCondition> = {
|
||||||
'd': ({ event, count, value }) => isParameterizedReplaceableKind(event.kind) && count === 0 && value.length < 200,
|
'd': ({ event, count }) => isParameterizedReplaceableKind(event.kind) && count === 0,
|
||||||
'e': ({ count, value }) => isNostrId(value) && count < 15,
|
'e': ({ count, value }) => isNostrId(value) && count < 15,
|
||||||
'p': ({ event, count, value }) => isNostrId(value) && (event.kind === 3 || count < 15),
|
'p': ({ event, count, value }) => isNostrId(value) && (event.kind === 3 || count < 15),
|
||||||
'proxy': ({ count, value }) => isURL(value) && count === 0 && value.length < 200,
|
'proxy': ({ count, value }) => isURL(value) && count === 0,
|
||||||
'q': ({ event, count, value }) => isNostrId(value) && event.kind === 1 && count === 0,
|
'q': ({ event, count, value }) => isNostrId(value) && event.kind === 1 && count === 0,
|
||||||
't': ({ count, value }) => count < 5 && value.length < 50,
|
't': ({ count, value }) => count < 5 && value.length < 50,
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,7 @@ function insertEvent(event: Event): Promise<void> {
|
||||||
const tags = event.tags.reduce<Insertable<TagRow>[]>((results, [name, value]) => {
|
const tags = event.tags.reduce<Insertable<TagRow>[]>((results, [name, value]) => {
|
||||||
tagCounts[name] = (tagCounts[name] || 0) + 1;
|
tagCounts[name] = (tagCounts[name] || 0) + 1;
|
||||||
|
|
||||||
if (value && tagConditions[name]?.({ event, count: tagCounts[name] - 1, value })) {
|
if (value && value.length < 200 && tagConditions[name]?.({ event, count: tagCounts[name] - 1, value })) {
|
||||||
results.push({
|
results.push({
|
||||||
event_id: event.id,
|
event_id: event.id,
|
||||||
tag: name,
|
tag: name,
|
||||||
|
|
Loading…
Reference in New Issue