diff --git a/source/knexfile.ts b/source/knexfile.ts index 78011c42158..2505ca8ff9e 100644 --- a/source/knexfile.ts +++ b/source/knexfile.ts @@ -1,4 +1,10 @@ /* eslint @typescript-eslint/explicit-module-boundary-types: 0 */ +try { + const pg = require('pg'); + pg.types.setTypeParser(20, 'text', parseInt); +} catch (err) { + logger.info('There is no pg'); +} import { config } from './config'; import { parse } from 'url'; import { Knex } from 'knex'; diff --git a/source/proxies/rss-feed.ts b/source/proxies/rss-feed.ts index 024ef977600..74f0929440d 100644 --- a/source/proxies/rss-feed.ts +++ b/source/proxies/rss-feed.ts @@ -32,7 +32,7 @@ export async function sub( } } else { await db.transaction(async (trx) => { - const [feed_id] = await db('rss_feed') + let [feed_id] = await db('rss_feed') .insert( { url: feedUrl, @@ -41,7 +41,11 @@ export async function sub( }, 'feed_id' ) + .returning('feed_id') .transacting(trx); + if (typeof feed_id === 'object') { + feed_id = feed_id.feed_id; // pg return object + } await db('subscribes') .insert({ feed_id, user_id: userId }, 'subscribe_id') .transacting(trx);