diff --git a/package-lock.json b/package-lock.json index 37cac47..5a89dbf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@leafac/sqlite": "^1.1.2", "@leafac/sqlite-migration": "^1.0.3", "crypto-random-string": "^3.3.1", - "escape-string-regexp": "^4.0.0", "express": "^4.17.1", "fs-extra": "^9.1.0", "mailparser": "^3.1.0", @@ -2973,17 +2972,6 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/escodegen": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", @@ -11407,11 +11395,6 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" - }, "escodegen": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", diff --git a/package.json b/package.json index 2e8adce..7d72534 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "@leafac/sqlite": "^1.1.2", "@leafac/sqlite-migration": "^1.0.3", "crypto-random-string": "^3.3.1", - "escape-string-regexp": "^4.0.0", "express": "^4.17.1", "fs-extra": "^9.1.0", "mailparser": "^3.1.0", diff --git a/src/index.ts b/src/index.ts index 793d0a7..9062472 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,6 @@ import path from "path"; import express from "express"; import { SMTPServer } from "smtp-server"; import mailparser from "mailparser"; -import escapeStringRegexp from "escape-string-regexp"; import fs from "fs-extra"; import cryptoRandomString from "crypto-random-string"; import { html, HTML } from "@leafac/html"; @@ -48,6 +47,12 @@ export default function killTheNewsletter( "author" TEXT NOT NULL, "content" TEXT NOT NULL ); + + CREATE TRIGGER "feedsUpdatedAt" + AFTER INSERT ON "entries" + BEGIN + UPDATE "feeds" SET "updatedAt" = datetime('now') WHERE "id" = "NEW"."feed"; + END; `, ]); @@ -458,12 +463,7 @@ export default function killTheNewsletter( ) ` ); - // TODO: Do this with a trigger. - database.run( - sql`UPDATE "feeds" SET "updatedAt" = datetime('now') WHERE "id" = ${feed.id}` - ); - - while (renderFeed(feedReference)!.length > 500_00) + while (renderFeed(feedReference)!.length > 500_000) database.run( sql`DELETE FROM "entries" WHERE "feed" = ${feed.id} ORDER BY "createdAt" ASC LIMIT 1` );