diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9fda627c..ef26331e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -74,7 +74,7 @@ jobs: key: ${{ runner.OS }}-deno-cache-dir-${{ hashFiles('deno.lock') }} - name: Run deno cache command if: steps.cache-deno-cache-dir.outputs.cache-hit != 'true' - run: deno cache src/index.ts + run: deno task cache - name: Start MongoDB uses: supercharge/mongodb-github-action@1.8.0 with: @@ -120,7 +120,7 @@ jobs: key: ${{ runner.OS }}-deno-cache-dir-${{ hashFiles('deno.lock') }} - name: Run deno cache command if: steps.cache-deno-cache-dir.outputs.cache-hit != 'true' - run: deno cache src/index.ts + run: deno task cache - name: Start MongoDB uses: supercharge/mongodb-github-action@1.8.0 with: diff --git a/Dockerfile b/Dockerfile index b54dd9af..439b05eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ FROM base as cache COPY --chown=deno:deno . . # Cache dependencies -RUN deno cache src/index.ts +RUN deno task cache FROM base as runner diff --git a/deno.jsonc b/deno.jsonc index d4ff6d1c..2d13a44f 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -11,7 +11,9 @@ "test:integration:nip28": "deno test test/integration/features/nip-28/nip-28.feature.test.ts --no-check -A", "test:integration:nip33": "deno test test/integration/features/nip-33/nip-33.feature.test.ts --no-check -A", "git-hooks": "deno run --no-check=remote --allow-run=deno,git --allow-read --allow-write=.git-hooks https://deno.land/x/githooked/mod.ts install", - "bump": "deno run --allow-all .bump/bump.ts" + "bump": "deno run --allow-all .bump/bump.ts", + "cache": "deno cache src/index.ts --reload", + "force-cache": "deno cache src/index.ts --reload --lock-write" }, "imports": { "dotenv": "https://deno.land/x/dotenv@v3.2.0/mod.ts", @@ -32,7 +34,7 @@ "joi": "https://cdn.skypack.dev/joi@17.7.0?dts", "rxjs": "https://cdn.skypack.dev/rxjs@7.8.0?dts", "chai-as-promised": "https://cdn.skypack.dev/chai-as-promised@7.1.1?dts", - "events": "node:events", + "events": "https://deno.land/std@0.177.0/node/events.ts", "stream": "node:stream", "stream/promises": "node:stream/promises", "dns": "node:dns", diff --git a/deno.lock b/deno.lock index c76955d2..07dd9945 100644 --- a/deno.lock +++ b/deno.lock @@ -1,59 +1,9 @@ { "version": "2", "remote": { - "https://cdn.skypack.dev/-/@sinonjs/fake-timers@v10.0.2-7Q9DvtEGUhxo9tseVUWV/dist=es2019,mode=types/index.d.ts": "f83b320cceccfc48457a818d18fc9a006ab18d0bdd727aa2c2e73dc1b4a45e98", - "https://cdn.skypack.dev/-/@sinonjs/fake-timers@v7.1.2-ixsdnXajQrmeGBLmevQ2/dist=es2019,mode=types/types/fake-timers-src.d.ts": "6b40029289530423f407a22755c85b81740f9acfd88d2b53564f8c1657c26660", - "https://cdn.skypack.dev/-/assertion-error@v1.1.0-kNvqltoxcdROsufUrL09/dist=es2019,mode=imports/optimized/assertion-error.js": "fb392c145699a7beacbabe94b21ee5d0219707929450fffbb18eb83b8318c818", - "https://cdn.skypack.dev/-/chai-as-promised@v7.1.1-V8qEOEdB9XCPaGNrdaUw/dist=es2019,mode=imports/optimized/chai-as-promised.js": "d7cd7f53c84e3959c4d1d428385e7f5a0eee45baa66e4a041732ac31cf4869da", - "https://cdn.skypack.dev/-/chai-as-promised@v7.1.1-V8qEOEdB9XCPaGNrdaUw/dist=es2019,mode=types/index.d.ts": "1fec4bad3aa3ed84c4839b7ed6725872a94dde3db86505445d812e955bcbfa7b", - "https://cdn.skypack.dev/-/chai@v4.3.4-4LD1LjgHWVQjvyMFe7sm/dist=es2019,mode=imports/optimized/chai.js": "2d517f26a740a2c43a158c510ba0c97b1743f1825022583234f7f3b8ec6b7599", - "https://cdn.skypack.dev/-/chai@v4.3.4-4LD1LjgHWVQjvyMFe7sm/dist=es2019,mode=types/index.d.ts": "b6c73080490a06c472c0f05afba3b564b170f39bbaeca57d0b60a6bcd98a840c", - "https://cdn.skypack.dev/-/check-error@v1.0.2-pv7N1FcwI8awT920b4E0/dist=es2019,mode=imports/optimized/check-error.js": "c00358ede04680f37b081564d88b9457e9812bb3c5c7effc90acb090f3bd73f4", - "https://cdn.skypack.dev/-/deep-eql@v3.0.1-EVT6yn6LFH7vvQx4YnOu/dist=es2019,mode=imports/optimized/deep-eql.js": "e8a3877f0ee43db99f1b903a8b527c57827fe2753a0f0fd560563aa2e435a0d3", - "https://cdn.skypack.dev/-/get-func-name@v2.0.0-scW92yE6OFNJbvjxk2uF/dist=es2019,mode=imports/optimized/get-func-name.js": "8926a16a678d5ca12cae705fa8a5be600aaf5355e601d34575f1bd9af64a170c", "https://cdn.skypack.dev/-/joi@v17.7.0-RK0tA5T7StpATAhyOHd0/dist=es2019,mode=imports/optimized/joi.js": "302fe80da79cf00792631c966c91f2067e1fc6c335f70079579323ff28b0f041", "https://cdn.skypack.dev/-/joi@v17.7.0-RK0tA5T7StpATAhyOHd0/dist=es2019,mode=types/lib/index.d.ts": "356aa4e888eedc8b29ae1532aea69c6d819b4795552d34cc9a04f8ac97b7e60c", - "https://cdn.skypack.dev/-/pathval@v1.1.1-4hf44tKt2vdiXpyywiwN/dist=es2019,mode=imports/optimized/pathval.js": "778f821f97d08e946a894e3b94635a63121d8bd5000aeb3d00785318d5ed32de", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/AsyncScheduler-1be47af6.js": "eb94849b5a274c8cd075dec4312cba3998ccaf820149462c490ceebb75fbc987", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/EmptyError-41db9d3f.js": "b9406314bc6936aaf61de500a900f4fd8bf1012bdd8dc301c1ecd324e65057b9", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/Notification-5a9034fd.js": "053ac309d71f0e752343b659fd8440305612bc7ba5665acf3180798fa8ff3d13", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/Observable-7e44db0b.js": "4850765ea35eba1d219484bced5d58c088bb212f2c4de037ded304c66a5a2435", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/OperatorSubscriber-6d72c4ab.js": "81f1ae08d9c0c5ec618f6cfb8dd4abec3b85c411f198694e54f4d624a20e95fc", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/Subject-289b09f9.js": "f226d38bbd77961774a1df0219e0bac5a22b256276167d326b2c480fffab39dd", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/Subscriber-368decef.js": "15405901be614ace9de7787172c8510a903eaa8831d91c407696099d70f1b562", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/Subscription-b18e6761.js": "a0862b17da978e5f9b61ab3d92494368c4c9866eb0b9f487dfdedb2e77c5b37f", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/VirtualTimeScheduler-9142a7bb.js": "1a742b7d31a597e7024a38b26b5a6353956a9fbcf32ca491acf93a010819edc6", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/createErrorClass-d37b97e3.js": "4398cce2f98e5b5a965e278fe97749fe2849bdfc2f7c836af40cd0718ae07b3f", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/dateTimestampProvider-43e4031c.js": "91b5af8cb2394e9168701e79872557ed1da75522642bf0179ae5c1ad26617eb1", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/innerFrom-911ff024.js": "4249e9884ee94c33208868321f903fc7f7e8dc2d49fb9bc79290140af3fc4874", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/lift-8243c0ff.js": "af4bfefee1b2bf408b6530591b8c8cabff34d0160bc56c66ebe6baf6deea6b51", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/map-3df1de07.js": "234ebbf399f55766008765d9e2fb68b998ac54f58330b89d6b8db0489568c65f", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/common/zipWith-ee4749e2.js": "5f2a9a01d80f89e2d74f361e966d16315c57fad4d0999393c395ba448d65fb55", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs.js": "53f80634624765127e4af3087e5c9e998ff04ac68f994b518328d29eb7978fe0", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/AsyncSubject.js": "ddc8e59238dd34ebcfca85a240de7c46a7258288cddb369e4da19cefe7df1360", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/BehaviorSubject.js": "038dbfe6b372347c522eaaae60b0c993aebf2ebc083f99d221474caad14dc427", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/NotificationFactories.js": "bc822ec4b2d05f3726c8bd3735dcb44775ec85aed8435ab473e8d992bd4dfead", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/ReplaySubject.js": "7791dcdb33a9fe41e2692e42485519fd62fe2dd4aacd391449db3b4c209e6eb4", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/Scheduler.js": "ce5d2f71ad5e76ffa039827b091a10da299695f93c46376e46cdc1e082e0a87c", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/config.js": "78900e946906e3f588b78a53d433b9ce8deb63db0fa84c150ffaf2f54ab3f420", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/firstValueFrom.js": "7ddb48503167cfa36f0c184bd8d50b59af83b58afae3b44cde1385667a13a736", - "https://cdn.skypack.dev/-/rxjs@v7.8.0-oE0GhbhAdiS0mpw9Iw6u/dist=es2019,mode=imports/optimized/rxjs/internal/lastValueFrom.js": "7bab19ffb1619b9f4d2f6f1e43e3c4a0e71659dd1c2094a869cdaf3089c57253", - "https://cdn.skypack.dev/-/sinon-chai@v3.7.0-sPO3yztXU6JvAbBcqOA6/dist=es2019,mode=imports/optimized/sinon-chai.js": "da69ffb373302464defc70b76f18a103fedad00eca82751840388a4881d452bb", - "https://cdn.skypack.dev/-/sinon-chai@v3.7.0-sPO3yztXU6JvAbBcqOA6/dist=es2019,mode=types/index.d.ts": "1b96f339dbcb43da644b021168045ac6236520a3f8017c622dcc0503b23e54f5", - "https://cdn.skypack.dev/-/sinon@v11.1.1-a4QDxvQ2C1lyBOKwzLcr/dist=es2019,mode=types/index.d.ts": "194a06aac2c91f395d387a41a7b74a1cf3b153049c68f698f3da5c106bc71968", - "https://cdn.skypack.dev/-/sinon@v15.0.1-qlKtgxOm72taiA3pbkK2/dist=es2019,mode=imports/optimized/sinon.js": "4fa78f658343ba3153a936f7ff0488ad9845324c1854d6d73a0a6d7a5d4bc7d5", - "https://cdn.skypack.dev/-/sinon@v15.0.1-qlKtgxOm72taiA3pbkK2/dist=es2019,mode=types/index.d.ts": "e49a3c9e2a9a7386a21a6c1ebf9d3883b2712c99fc14ecf8ea1433f6e7a5845c", - "https://cdn.skypack.dev/-/tslib@v2.4.1-EnXszYOb70PNwhRTrKtW/dist=es2019,mode=imports/optimized/common/tslib-5f663465.js": "5962d7e4d3723d7189d43ed6143cf8a00fe688624c4e541e0bea70fff1ae0745", - "https://cdn.skypack.dev/-/tslib@v2.4.1-EnXszYOb70PNwhRTrKtW/dist=es2019,mode=imports/optimized/tslib.js": "ce8027a3f38ac0e0d3c85d525de72b2c6934ff125b6a0449038df975dbcc2967", - "https://cdn.skypack.dev/-/type-detect@v4.0.8-3tmjjwwFw2jHiLYy7SbM/dist=es2019,mode=imports/optimized/type-detect.js": "eb7ac639d3de6a0b64aaf9032a5b01ab79afb7c768cc02c07956613ecbd0bd32", - "https://cdn.skypack.dev/chai-as-promised@7.1.1?dts": "830017e3a2f15f0f888639655c861d666ffa3c290b30fb095609c6781cd7b9d3", - "https://cdn.skypack.dev/chai@4.3.4?dts": "19489c45018b0bcfb63455624ade9adf84e2a3c99a08379160d90763ba7e3f41", - "https://cdn.skypack.dev/error/unknown:chai?from=chai-as-promised": "d81c24bdeb6353bd4c69635a787f47511d41c71940b159e88e0e7a15d7573b95", - "https://cdn.skypack.dev/error/unknown:chai?from=sinon-chai": "c5eea0fab0f428ffb949645e4adcb0da74722dc5b483bb13bf48d0723436a185", "https://cdn.skypack.dev/joi@17.7.0?dts": "70e396b701dea0c5a59bf8a5578457cb04a98e5ba37d77b10900c7c7aed8e0e3", - "https://cdn.skypack.dev/rxjs@7.8.0?dts": "e5c758eebc71433a4c75900690399c74ca86bc31085a40c69509f377aeacccc1", - "https://cdn.skypack.dev/sinon-chai@3.7.0?dts": "e1773fa39d5bebee9e9f4a32b62ebc67c7330043a725ecf0e4c9bf5730738db1", - "https://cdn.skypack.dev/sinon@15.0.1?dts": "220487f84273811340f37025cfa8c092492aaa700d9318fe2938f4adb04fea5e", "https://deno.land/std@0.139.0/bytes/equals.ts": "fc16dff2090cced02497f16483de123dfa91e591029f985029193dfaa9d894c9", "https://deno.land/std@0.139.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf", "https://deno.land/std@0.139.0/encoding/base64.ts": "c8c16b4adaa60d7a8eee047c73ece26844435e8f7f1328d74593dbb2dd58ea4f", @@ -301,8 +251,6 @@ "https://deno.land/std@0.178.0/streams/writer_from_stream_writer.ts": "31126a6bf2e678c5a718011d4831dbe75dbdbd885965d3dbd5dd105e6f20f976", "https://deno.land/std@0.178.0/streams/zip_readable_streams.ts": "9eb82070d83055fe6f077192fb204dc7612695a4b330148e9aa376df1a65e708", "https://deno.land/std@0.178.0/types.d.ts": "220ed56662a0bd393ba5d124aa6ae2ad36a00d2fcbc0e8666a65f4606aaa9784", - "https://deno.land/std@0.180.0/testing/_test_suite.ts": "30f018feeb3835f12ab198d8a518f9089b1bcb2e8c838a8b615ab10d5005465c", - "https://deno.land/std@0.180.0/testing/bdd.ts": "c5ca6d85940dbcc19b4d2bc3608d49ab65d81470aa91306d5efa4b0d5c945731", "https://deno.land/x/debuglog@v1.0.0/debug.ts": "032cfda27de5d294218ff7d6611f0b9de7e7c4c3a8a801eeaa49573e15809998", "https://deno.land/x/debuglog@v1.0.0/format.ts": "efc757450d212872880177f3d4284a8bcf11551ec5e33ee2de24977b68242c2b", "https://deno.land/x/debuglog@v1.0.0/utils.ts": "bce2e8ce7956a04e79eb184f475fc8a2dc6a0eace0c8dbc69707498e6f33bd6b", @@ -712,16 +660,12 @@ }, "npm": { "specifiers": { - "@isaacs/ttlcache": "@isaacs/ttlcache@1.4.0", "@isaacs/ttlcache@1.4.0": "@isaacs/ttlcache@1.4.0", "axios@1.2.6": "axios@1.2.6", "bech32@2.0.0": "bech32@2.0.0", "js-yaml@4.1.0": "js-yaml@4.1.0", "knex@2.4.2": "knex@2.4.2", - "mongodb": "mongodb@5.5.0", "mongodb@5.3.0": "mongodb@5.3.0", - "mongodb@5.5.0": "mongodb@5.5.0", - "mongoose": "mongoose@7.1.1", "mongoose@7.1.1": "mongoose@7.1.1" }, "packages": { @@ -729,8 +673,8 @@ "integrity": "sha512-2i5IL+VRvSOAhyqOI6lVrPzHiLhmC+gZEfG/4z8YA7/zRvQGs75SdF9qsZiNWPgKd1SK06NirpIU+Hd+XWDPfQ==", "dependencies": {} }, - "@types/node@20.2.0": { - "integrity": "sha512-3iD2jaCCziTx04uudpJKwe39QxXgSUnpxXSvRQjRvHPxFQfmfP4NXIm/NURVeNlTCc+ru4WqjYGTmpXrW9uMlw==", + "@types/node@20.2.1": { + "integrity": "sha512-DqJociPbZP1lbZ5SQPk4oag6W7AyaGMO6gSfRwq3PWl4PXTwJpRQJhDq4W0kzrg3w6tJ1SwlvGZ5uKFHY13LIg==", "dependencies": {} }, "@types/webidl-conversions@7.0.0": { @@ -740,7 +684,7 @@ "@types/whatwg-url@8.2.2": { "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", "dependencies": { - "@types/node": "@types/node@20.2.0", + "@types/node": "@types/node@20.2.1", "@types/webidl-conversions": "@types/webidl-conversions@7.0.0" } }, @@ -907,15 +851,6 @@ "socks": "socks@2.7.1" } }, - "mongodb@5.5.0": { - "integrity": "sha512-XgrkUgAAdfnZKQfk5AsYL8j7O99WHd4YXPxYxnh8dZxD+ekYWFRA3JktUsBnfg+455Smf75/+asoU/YLwNGoQQ==", - "dependencies": { - "bson": "bson@5.3.0", - "mongodb-connection-string-url": "mongodb-connection-string-url@2.6.0", - "saslprep": "saslprep@1.0.3", - "socks": "socks@2.7.1" - } - }, "mongoose@7.1.1": { "integrity": "sha512-AIxaWwGY+td7QOMk4NgK6fbRuGovFyDzv65nU1uj1DsUh3lpjfP3iFYHSR+sUKrs7nbp19ksLlRXkmInBteSCA==", "dependencies": { diff --git a/src/@types/event.ts b/src/@types/event.ts index 938d9687..dfbc8fe8 100644 --- a/src/@types/event.ts +++ b/src/@types/event.ts @@ -46,10 +46,10 @@ export interface DBEvent { event_tags: Tag[] event_signature: Buffer event_delegator?: Buffer | null - event_deduplication?: string | null - first_seen: Date - deleted_at?: Date - expires_at?: number + event_deduplication?: { 0: string; 1: number }[] | null + first_seen?: Date + deleted_at: string + expires_at: number } export interface CanonicalEvent { diff --git a/src/core-services/WebSocketServerService.ts b/src/core-services/WebSocketServerService.ts index f95d7550..85786709 100644 --- a/src/core-services/WebSocketServerService.ts +++ b/src/core-services/WebSocketServerService.ts @@ -20,7 +20,7 @@ export class WebSocketServerService extends ServiceClass { debug('events.broadcast %s data: %o', clientAction, data) if (data && typeof data !== 'undefined') { // ignore draft - if (data.event_kind === 5 && data.event_signature) { + if (data?.event_signature?.toString() === '' || data?.deleted_at) { return } adapter.emit(WebSocketServerAdapterEvent.Broadcast, toNostrEvent(data as DBEvent)) diff --git a/src/database/models/Events.ts b/src/database/models/Events.ts index 6f4bc4fd..2e92e22d 100644 --- a/src/database/models/Events.ts +++ b/src/database/models/Events.ts @@ -42,7 +42,7 @@ const EventSchema = new mongoose.Schema({ }, event_deduplication: [mongoose.Schema.Types.Mixed], first_seen: { type: Date }, - deleted_at: { type: Date }, + deleted_at: { type: String }, expires_at: { type: Number }, }) @@ -70,6 +70,14 @@ EventSchema.index({ 'event_tags.0.1': 1 }, { background: true, sparse: true, }) +EventSchema.index({ 'event_tags.0.2': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.0.3': 1 }, { + background: true, + sparse: true, +}) EventSchema.index({ 'event_tags.1.0': 1 }, { background: true, sparse: true, @@ -78,6 +86,30 @@ EventSchema.index({ 'event_tags.1.1': 1 }, { background: true, sparse: true, }) +EventSchema.index({ 'event_tags.1.2': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.1.3': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.2.0': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.2.1': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.2.2': 1 }, { + background: true, + sparse: true, +}) +EventSchema.index({ 'event_tags.2.3': 1 }, { + background: true, + sparse: true, +}) EventSchema.index({ 'remote_address': 1 }, { background: true, }) diff --git a/src/repositories/event-repository.ts b/src/repositories/event-repository.ts index 1263e0b7..8b80b071 100644 --- a/src/repositories/event-repository.ts +++ b/src/repositories/event-repository.ts @@ -43,7 +43,7 @@ export class EventRepository implements IEventRepository { private async insert(event: Event) { debug('inserting event: %o', event) - const row = applySpec({ + const row: DBEvent = applySpec({ event_id: pipe(prop('id'), toBuffer), event_pubkey: pipe(prop('pubkey'), toBuffer), event_created_at: pipe(prop('created_at'), toNumber), @@ -66,6 +66,7 @@ export class EventRepository implements IEventRepository { prop(EventExpirationTimeMetadataKey as any), always(null), ), + deleted_at: always(null), })(event) try { @@ -191,7 +192,7 @@ export class EventRepository implements IEventRepository { event_id: { $in: eventIdsToDelete.map(toBuffer) }, deleted_at: null, }, - { deleted_at: new Date() }, + { deleted_at: new Date().toISOString() }, ) return ignoreUpdateConflicts(query) }