diff --git a/src/algos/whats-alf.ts b/src/algos/whats-alf.ts index ece91fac1..1aeb04e7c 100644 --- a/src/algos/whats-alf.ts +++ b/src/algos/whats-alf.ts @@ -13,6 +13,10 @@ export const handler = async (ctx: AppContext, params: QueryParams) => { .limit(params.limit) if (params.cursor) { + const [indexedAt, cid] = params.cursor.split('::') + if (!indexedAt || !cid) { + throw new InvalidRequestError('malformed cursor') + } const timeStr = new Date(parseInt(params.cursor, 10)).toISOString() builder = builder.where('post.indexedAt', '<', timeStr) } diff --git a/src/db/migrations.ts b/src/db/migrations.ts index be720eede..73fe548bb 100644 --- a/src/db/migrations.ts +++ b/src/db/migrations.ts @@ -15,6 +15,7 @@ migrations['001'] = { .addColumn('uri', 'varchar', (col) => col.primaryKey()) .addColumn('cid', 'varchar', (col) => col.notNull()) .addColumn('indexedAt', 'varchar', (col) => col.notNull()) + .addColumn('postText', 'varchar') .execute() await db.schema .createTable('sub_state') diff --git a/src/subscription.ts b/src/subscription.ts index 0422a03cb..2ddb23961 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -19,16 +19,13 @@ export class FirehoseSubscription extends FirehoseSubscriptionBase { const postsToDelete = ops.posts.deletes.map((del) => del.uri) const postsToCreate = ops.posts.creates - .filter((create) => { - // only alf-related posts - return create.record.text.toLowerCase().includes('alf') - }) .map((create) => { // map alf-related posts to a db row return { uri: create.uri, cid: create.cid, indexedAt: new Date().toISOString(), + postText: create.record.text.toLowerCase() } })