feature: start to lay groundwork for reactions

This commit is contained in:
Andy Burke 2025-10-12 16:25:42 -07:00
parent 10b3e9ff72
commit 6500d9a9be
4 changed files with 56 additions and 5 deletions

View file

@ -1,6 +1,9 @@
import { by_character, by_lurid } from '@andyburke/fsdb/organizers';
import { FSDB_COLLECTION } from '@andyburke/fsdb';
import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers';
import { EMOJI_MAP as JS_EMOJI_MAP } from '../public/js/emojis/en.js';
const EMOJI_MAP: Record<string, string[]> = JS_EMOJI_MAP;
/**
* @typedef {object} TIMESTAMPS
@ -110,7 +113,37 @@ export function VALIDATE_EVENT(event: EVENT) {
});
}
break;
case 'reaction':
if (typeof event.parent_id !== 'string') {
errors.push({
cause: 'reaction_missing_parent_id',
message: 'A reaction must have a parent_id that refers to another event.'
});
} else if (typeof event.data?.reaction !== 'string') {
errors.push({
cause: 'reaction_must_be_an_emoji',
message: 'A reaction event must have a `data.reaction` that is an emoji.'
});
} else if (typeof EMOJI_MAP[event.data.reaction] === 'undefined') {
errors.push({
cause: 'reaction_must_be_an_emoji',
message: 'A reaction event must have a `data.reaction` that is an emoji.'
});
}
break;
case 'test':
if (Deno.env.get('DENO_ENV') !== 'test') {
errors.push({
cause: 'unknown_event_type',
message: 'Event types allowed: ' + ['chat', 'post', 'blurb', 'essay', 'reaction'].join(', ')
});
}
break;
default:
errors.push({
cause: 'unknown_event_type',
message: 'Event types allowed: ' + ['chat', 'post', 'blurb', 'essay', 'reaction'].join(', ')
});
break;
}