Delete db/events.ts, db/memorelay.ts, move to @/storages.ts
This commit is contained in:
parent
a4bc951eee
commit
b3e4b79439
|
@ -1,8 +1,8 @@
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { db } from '@/db.ts';
|
import { db } from '@/db.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { type Kysely } from '@/deps.ts';
|
import { type Kysely } from '@/deps.ts';
|
||||||
import { signAdminEvent } from '@/sign.ts';
|
import { signAdminEvent } from '@/sign.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
||||||
interface DB {
|
interface DB {
|
||||||
users: {
|
users: {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { insertUser } from '@/db/users.ts';
|
import { insertUser } from '@/db/users.ts';
|
||||||
import { findReplyTag, nip19, z } from '@/deps.ts';
|
import { findReplyTag, nip19, z } from '@/deps.ts';
|
||||||
import { type DittoFilter } from '@/filter.ts';
|
import { type DittoFilter } from '@/filter.ts';
|
||||||
import { getAuthor, getFollowedPubkeys } from '@/queries.ts';
|
import { getAuthor, getFollowedPubkeys } from '@/queries.ts';
|
||||||
import { booleanParamSchema, fileSchema } from '@/schema.ts';
|
import { booleanParamSchema, fileSchema } from '@/schema.ts';
|
||||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { addTag, deleteTag, getTagSet } from '@/tags.ts';
|
import { addTag, deleteTag, getTagSet } from '@/tags.ts';
|
||||||
import { uploadFile } from '@/upload.ts';
|
import { uploadFile } from '@/upload.ts';
|
||||||
import { lookupAccount, nostrNow } from '@/utils.ts';
|
import { lookupAccount, nostrNow } from '@/utils.ts';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { getTagSet } from '@/tags.ts';
|
import { getTagSet } from '@/tags.ts';
|
||||||
import { renderAccounts } from '@/views.ts';
|
import { renderAccounts } from '@/views.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { getTagSet } from '@/tags.ts';
|
import { getTagSet } from '@/tags.ts';
|
||||||
import { renderStatuses } from '@/views.ts';
|
import { renderStatuses } from '@/views.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { paginated, paginationSchema } from '@/utils/api.ts';
|
import { paginated, paginationSchema } from '@/utils/api.ts';
|
||||||
import { renderNotification } from '@/views/mastodon/notifications.ts';
|
import { renderNotification } from '@/views/mastodon/notifications.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { z } from '@/deps.ts';
|
import { z } from '@/deps.ts';
|
||||||
import { configSchema, elixirTupleSchema } from '@/schemas/pleroma-api.ts';
|
import { configSchema, elixirTupleSchema } from '@/schemas/pleroma-api.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { createAdminEvent } from '@/utils/api.ts';
|
import { createAdminEvent } from '@/utils/api.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { type Event, nip19, z } from '@/deps.ts';
|
import { type Event, nip19, z } from '@/deps.ts';
|
||||||
import { type DittoFilter } from '@/filter.ts';
|
import { type DittoFilter } from '@/filter.ts';
|
||||||
import { booleanParamSchema } from '@/schema.ts';
|
import { booleanParamSchema } from '@/schema.ts';
|
||||||
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { dedupeEvents } from '@/utils.ts';
|
import { dedupeEvents } from '@/utils.ts';
|
||||||
import { lookupNip05Cached } from '@/utils/nip05.ts';
|
import { lookupNip05Cached } from '@/utils/nip05.ts';
|
||||||
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { z } from '@/deps.ts';
|
import { z } from '@/deps.ts';
|
||||||
import { type DittoFilter } from '@/filter.ts';
|
import { type DittoFilter } from '@/filter.ts';
|
||||||
import { getFeedPubkeys } from '@/queries.ts';
|
import { getFeedPubkeys } from '@/queries.ts';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { jsonSchema } from '@/schema.ts';
|
import { jsonSchema } from '@/schema.ts';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
import { db } from '@/db.ts';
|
|
||||||
import { EventsDB } from '@/storages/events-db.ts';
|
|
||||||
|
|
||||||
const eventsDB = new EventsDB(db);
|
|
||||||
|
|
||||||
export { eventsDB };
|
|
|
@ -1,10 +0,0 @@
|
||||||
import { Memorelay } from '@/storages/memorelay.ts';
|
|
||||||
|
|
||||||
/** In-memory data store for events using microfilters. */
|
|
||||||
const memorelay = new Memorelay({
|
|
||||||
max: 3000,
|
|
||||||
maxEntrySize: 5000,
|
|
||||||
sizeCalculation: (event) => JSON.stringify(event).length,
|
|
||||||
});
|
|
||||||
|
|
||||||
export { memorelay };
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { Debug, type Filter } from '@/deps.ts';
|
import { Debug, type Filter } from '@/deps.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { signAdminEvent } from '@/sign.ts';
|
import { signAdminEvent } from '@/sign.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
||||||
const debug = Debug('ditto:users');
|
const debug = Debug('ditto:users');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { client } from '@/client.ts';
|
import { client } from '@/client.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { memorelay } from '@/db/memorelay.ts';
|
|
||||||
import { addRelays } from '@/db/relays.ts';
|
import { addRelays } from '@/db/relays.ts';
|
||||||
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
||||||
import { findUser } from '@/db/users.ts';
|
import { findUser } from '@/db/users.ts';
|
||||||
|
@ -10,6 +8,7 @@ import { isEphemeralKind } from '@/kinds.ts';
|
||||||
import { isLocallyFollowed } from '@/queries.ts';
|
import { isLocallyFollowed } from '@/queries.ts';
|
||||||
import { reqmeister } from '@/reqmeister.ts';
|
import { reqmeister } from '@/reqmeister.ts';
|
||||||
import { updateStats } from '@/stats.ts';
|
import { updateStats } from '@/stats.ts';
|
||||||
|
import { eventsDB, memorelay } from '@/storages.ts';
|
||||||
import { Sub } from '@/subs.ts';
|
import { Sub } from '@/subs.ts';
|
||||||
import { getTagSet } from '@/tags.ts';
|
import { getTagSet } from '@/tags.ts';
|
||||||
import { type EventData } from '@/types.ts';
|
import { type EventData } from '@/types.ts';
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB, memorelay } from '@/storages.ts';
|
||||||
import { memorelay } from '@/db/memorelay.ts';
|
|
||||||
import { Debug, type Event, findReplyTag } from '@/deps.ts';
|
import { Debug, type Event, findReplyTag } from '@/deps.ts';
|
||||||
import { type AuthorMicrofilter, type DittoFilter, type IdMicrofilter, type Relation } from '@/filter.ts';
|
import { type AuthorMicrofilter, type DittoFilter, type IdMicrofilter, type Relation } from '@/filter.ts';
|
||||||
import { reqmeister } from '@/reqmeister.ts';
|
import { reqmeister } from '@/reqmeister.ts';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { type AuthorStatsRow, db, type DittoDB, type EventStatsRow } from '@/db.ts';
|
import { type AuthorStatsRow, db, type DittoDB, type EventStatsRow } from '@/db.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { Debug, type Event, findReplyTag, type InsertQueryBuilder } from '@/deps.ts';
|
import { Debug, type Event, findReplyTag, type InsertQueryBuilder } from '@/deps.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
||||||
type AuthorStat = keyof Omit<AuthorStatsRow, 'pubkey'>;
|
type AuthorStat = keyof Omit<AuthorStatsRow, 'pubkey'>;
|
||||||
type EventStat = keyof Omit<EventStatsRow, 'event_id'>;
|
type EventStat = keyof Omit<EventStatsRow, 'event_id'>;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { db } from '@/db.ts';
|
||||||
|
import { EventsDB } from '@/storages/events-db.ts';
|
||||||
|
import { Memorelay } from '@/storages/memorelay.ts';
|
||||||
|
|
||||||
|
/** SQLite database to store events this Ditto server cares about. */
|
||||||
|
const eventsDB = new EventsDB(db);
|
||||||
|
|
||||||
|
/** In-memory data store for cached events. */
|
||||||
|
const memorelay = new Memorelay({ max: 3000 });
|
||||||
|
|
||||||
|
export { eventsDB, memorelay };
|
|
@ -13,8 +13,8 @@ import {
|
||||||
} from '@/deps.ts';
|
} from '@/deps.ts';
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { signAdminEvent, signEvent } from '@/sign.ts';
|
import { signAdminEvent, signEvent } from '@/sign.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
|
|
||||||
const debug = Debug('ditto:api');
|
const debug = Debug('ditto:api');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { AppContext } from '@/app.ts';
|
import { AppContext } from '@/app.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { type Filter } from '@/deps.ts';
|
import { type Filter } from '@/deps.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
||||||
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
||||||
import { paginated, paginationSchema } from '@/utils/api.ts';
|
import { paginated, paginationSchema } from '@/utils/api.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { eventsDB } from '@/db/events.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { hasTag } from '@/tags.ts';
|
import { hasTag } from '@/tags.ts';
|
||||||
|
|
||||||
async function renderRelationship(sourcePubkey: string, targetPubkey: string) {
|
async function renderRelationship(sourcePubkey: string, targetPubkey: string) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { isCWTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';
|
import { isCWTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { eventsDB } from '@/db/events.ts';
|
|
||||||
import { findReplyTag, nip19 } from '@/deps.ts';
|
import { findReplyTag, nip19 } from '@/deps.ts';
|
||||||
import { getMediaLinks, parseNoteContent } from '@/note.ts';
|
import { getMediaLinks, parseNoteContent } from '@/note.ts';
|
||||||
import { getAuthor } from '@/queries.ts';
|
import { getAuthor } from '@/queries.ts';
|
||||||
import { jsonMediaDataSchema } from '@/schemas/nostr.ts';
|
import { jsonMediaDataSchema } from '@/schemas/nostr.ts';
|
||||||
import { DittoEvent } from '@/store.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
import { type DittoEvent } from '@/store.ts';
|
||||||
import { nostrDate } from '@/utils.ts';
|
import { nostrDate } from '@/utils.ts';
|
||||||
import { unfurlCardCached } from '@/utils/unfurl.ts';
|
import { unfurlCardCached } from '@/utils/unfurl.ts';
|
||||||
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
||||||
|
|
Loading…
Reference in New Issue