mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-08 08:04:21 +01:00
Refactor some code that uses getFilters to import the whole module under a namespace
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { type AppController } from '@/app.ts';
|
||||
import { type Filter, findReplyTag, z } from '@/deps.ts';
|
||||
import { publish } from '@/client.ts';
|
||||
import { getFilters } from '@/mixer.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import { getAuthor, getFollows } from '@/queries.ts';
|
||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { signEvent } from '@/sign.ts';
|
||||
@@ -117,7 +117,7 @@ const accountStatusesController: AppController = async (c) => {
|
||||
filter['#t'] = [tagged];
|
||||
}
|
||||
|
||||
let events = await getFilters([filter]);
|
||||
let events = await mixer.getFilters([filter]);
|
||||
events.sort(eventDateComparator);
|
||||
|
||||
if (exclude_replies) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getFilters, insertEvent } from '@/db/events.ts';
|
||||
import * as eventsDB from '@/db/events.ts';
|
||||
import { findUser } from '@/db/users.ts';
|
||||
import { jsonSchema } from '@/schema.ts';
|
||||
import {
|
||||
@@ -46,7 +46,7 @@ function connectStream(socket: WebSocket) {
|
||||
}
|
||||
|
||||
async function handleReq([_, sub, ...filters]: ClientREQ) {
|
||||
for (const event of await getFilters(prepareFilters(filters))) {
|
||||
for (const event of await eventsDB.getFilters(prepareFilters(filters))) {
|
||||
send(['EVENT', sub, event]);
|
||||
}
|
||||
send(['EOSE', sub]);
|
||||
@@ -54,7 +54,7 @@ function connectStream(socket: WebSocket) {
|
||||
|
||||
async function handleEvent([_, event]: ClientEVENT) {
|
||||
if (await findUser({ pubkey: event.pubkey })) {
|
||||
insertEvent(event);
|
||||
eventsDB.insertEvent(event);
|
||||
send(['OK', event.id, true, '']);
|
||||
} else {
|
||||
send(['OK', event.id, false, 'blocked: only registered users can post']);
|
||||
|
||||
Reference in New Issue
Block a user