diff --git a/packages/api/src/resolvers/subscriptions/index.ts b/packages/api/src/resolvers/subscriptions/index.ts index 4b4ede2ec..0680339ff 100644 --- a/packages/api/src/resolvers/subscriptions/index.ts +++ b/packages/api/src/resolvers/subscriptions/index.ts @@ -1,6 +1,5 @@ import Parser from 'rss-parser' import { Brackets } from 'typeorm' -import { Feed } from '../../entity/feed' import { Subscription } from '../../entity/subscription' import { env } from '../../env' import { @@ -227,44 +226,25 @@ export const subscribeResolver = authorized< // validate rss feed const feed = await parser.parseURL(input.url) - const results = await authTrx(async (t) => { - if (!input.isPrivate) { - await t.getRepository(Feed).upsert( - { - url: feed.feedUrl, - title: feed.title, - description: feed.description, - image: feed.image?.url, - }, - { - conflictPaths: ['url'], - skipUpdateIfNoValuesChanged: true, - } - ) - } - - // limit number of rss subscriptions to 150 - const results = (await t.getRepository(Subscription).query( - `insert into omnivore.subscriptions (name, url, description, type, user_id, icon, auto_add_to_library, is_private) + // limit number of rss subscriptions to 150 + const results = (await getRepository(Subscription).query( + `insert into omnivore.subscriptions (name, url, description, type, user_id, icon, auto_add_to_library, is_private) select $1, $2, $3, $4, $5, $6, $7, $8 from omnivore.subscriptions where user_id = $5 and type = 'RSS' and status = 'ACTIVE' having count(*) < $9 returning *;`, - [ - feed.title, - feed.feedUrl, - feed.description || null, - SubscriptionType.Rss, - uid, - feed.image?.url || null, - input.autoAddToLibrary ?? null, - input.isPrivate ?? null, - MAX_RSS_SUBSCRIPTIONS, - ] - )) as Subscription[] - - return results - }) + [ + feed.title, + feed.feedUrl, + feed.description || null, + SubscriptionType.Rss, + uid, + feed.image?.url || null, + input.autoAddToLibrary ?? null, + input.isPrivate ?? null, + MAX_RSS_SUBSCRIPTIONS, + ] + )) as Subscription[] if (results.length === 0) { return { diff --git a/packages/api/test/resolvers/subscriptions.test.ts b/packages/api/test/resolvers/subscriptions.test.ts index 28d96b564..cfdf6b10e 100644 --- a/packages/api/test/resolvers/subscriptions.test.ts +++ b/packages/api/test/resolvers/subscriptions.test.ts @@ -3,7 +3,6 @@ import 'mocha' import Parser from 'rss-parser' import sinon from 'sinon' import sinonChai from 'sinon-chai' -import { Feed } from '../../src/entity/feed' import { NewsletterEmail } from '../../src/entity/newsletter_email' import { Subscription } from '../../src/entity/subscription' import { User } from '../../src/entity/user' @@ -406,7 +405,6 @@ describe('Subscriptions API', () => { after(async () => { await deleteSubscription(existingSubscription.id) - await getRepository(Feed).delete({ url: existingSubscription.url }) }) it('returns an error', async () => { diff --git a/packages/db/migrations/0146.do.following.sql b/packages/db/migrations/0146.do.following.sql index 30d92256c..61e59ccc7 100755 --- a/packages/db/migrations/0146.do.following.sql +++ b/packages/db/migrations/0146.do.following.sql @@ -22,23 +22,4 @@ CREATE POLICY library_item_admin_policy on omnivore.library_item TO omnivore_admin USING (true); -CREATE TABLE omnivore.feed ( - id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), - title text NOT NULL, - url text NOT NULL, - author text, - description text, - image text, - created_at timestamptz NOT NULL DEFAULT current_timestamp, - updated_at timestamptz NOT NULL DEFAULT current_timestamp, - published_at timestamptz, - UNIQUE(url) -); - -CREATE INDEX feed_title_idx ON omnivore.feed(title); - -CREATE TRIGGER update_feed_modtime BEFORE UPDATE ON omnivore.feed FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column(); - -GRANT SELECT, INSERT, UPDATE, DELETE ON omnivore.feed TO omnivore_user; - COMMIT; diff --git a/packages/db/migrations/0146.undo.following.sql b/packages/db/migrations/0146.undo.following.sql index 10054874c..8d41f08e4 100755 --- a/packages/db/migrations/0146.undo.following.sql +++ b/packages/db/migrations/0146.undo.following.sql @@ -4,8 +4,6 @@ BEGIN; -DROP TABLE omnivore.feed; - DROP policy library_item_admin_policy ON omnivore.library_item; ALTER TABLE omnivore.library_item