Small adjustments

This commit is contained in:
Alex Gleason 2025-02-18 12:37:58 -06:00
parent 73e4708ba2
commit 004db322e7
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
9 changed files with 26 additions and 20 deletions

View file

@ -13,7 +13,7 @@ export class DittoApp extends Hono<DittoEnv> {
this.use((c, next) => {
c.set('db', vars.db);
c.set('conf', vars.conf);
c.set('store', vars.store);
c.set('relay', vars.relay);
c.set('signal', c.req.raw.signal);
return next();
});

View file

@ -18,7 +18,7 @@ const homeQuerySchema = z.object({
route.get('/home', userMiddleware({ privileged: false, required: true }), async (c) => {
const { user, pagination } = c.var;
const pubkey = await user?.signer.getPublicKey()!;
const pubkey = await user.signer.getPublicKey();
const result = homeQuerySchema.safeParse(c.req.query());
if (!result.success) {

View file

@ -155,7 +155,7 @@ import { logiMiddleware } from '@/middleware/logiMiddleware.ts';
const conf = new DittoConf(Deno.env);
const storages = new DittoStorages(conf);
const [kysely, store, pool, pubsub, db] = await Promise.all([
const [kysely, relay, pool, pubsub, db] = await Promise.all([
storages.kysely(),
storages.db(),
storages.pool(),
@ -223,7 +223,7 @@ type AppMiddleware = MiddlewareHandler<AppEnv>;
// deno-lint-ignore no-explicit-any
type AppController<P extends string = any> = Handler<AppEnv, P, HonoInput, Response | Promise<Response>>;
const app = new DittoApp({ conf, db, store }, { strict: false });
const app = new DittoApp({ conf, db, relay }, { strict: false });
/** User-provided files in the gitignored `public/` directory. */
const publicFiles = serveStatic({ root: conf.publicDir });

View file

@ -108,21 +108,6 @@ export class DittoPgStore extends NPostgres {
});
}
protected matchesFilter(event: NostrEvent, filter: NostrFilter): boolean {
// TODO: support streaming by search.
return matchFilter(filter, event) && filter.search === undefined;
}
streamOut(event: NostrEvent): void {
for (const { filters, machina } of this.subs.values()) {
for (const filter of filters) {
if (this.matchesFilter(event, filter)) {
machina.push(event);
}
}
}
}
/** Insert an event (and its tags) into the database. */
override async event(event: NostrEvent, opts: { signal?: AbortSignal; timeout?: number } = {}): Promise<void> {
event = purifyEvent(event);
@ -152,6 +137,21 @@ export class DittoPgStore extends NPostgres {
}
}
protected matchesFilter(event: NostrEvent, filter: NostrFilter): boolean {
// TODO: support streaming by search.
return matchFilter(filter, event) && filter.search === undefined;
}
protected streamOut(event: NostrEvent): void {
for (const { filters, machina } of this.subs.values()) {
for (const filter of filters) {
if (this.matchesFilter(event, filter)) {
machina.push(event);
}
}
}
}
/** Check if an event has been deleted by the admin. */
private async isDeletedAdmin(event: NostrEvent): Promise<boolean> {
const filters: NostrFilter[] = [
@ -257,7 +257,7 @@ export class DittoPgStore extends NPostgres {
/** Get events for filters from the database. */
override async query(
filters: NostrFilter[],
opts: { signal?: AbortSignal; timeout?: number; limit?: number } = {},
opts: { signal?: AbortSignal; pure?: boolean; timeout?: number; limit?: number } = {},
): Promise<DittoEvent[]> {
filters = await this.expandFilters(filters);

3
services/aio.ts Normal file
View file

@ -0,0 +1,3 @@
// All-In-One
//

1
services/core.ts Normal file
View file

@ -0,0 +1 @@
// Ditto Core

1
services/crawler.ts Normal file
View file

@ -0,0 +1 @@
// Ditto Crawler

1
services/server.ts Normal file
View file

@ -0,0 +1 @@
// Ditto Server