diff --git a/api/paidAction/lib/item.js b/api/paidAction/lib/item.js index 1516d5a0..b7a17a63 100644 --- a/api/paidAction/lib/item.js +++ b/api/paidAction/lib/item.js @@ -2,11 +2,11 @@ import { USER_ID } from '@/lib/constants' import { deleteReminders, getDeleteAt, getRemindAt } from '@/lib/item' import { parseInternalLinks } from '@/lib/url' -export async function getMentions ({ text }, { me, models }) { +export async function getMentions ({ text }, { me, tx }) { const mentionPattern = /\B@[\w_]+/gi const names = text.match(mentionPattern)?.map(m => m.slice(1)) if (names?.length > 0) { - const users = await models.user.findMany({ + const users = await tx.user.findMany({ where: { name: { in: names @@ -21,7 +21,7 @@ export async function getMentions ({ text }, { me, models }) { return [] } -export const getItemMentions = async ({ text }, { me, models }) => { +export const getItemMentions = async ({ text }, { me, tx }) => { const linkPattern = new RegExp(`${process.env.NEXT_PUBLIC_URL}/items/\\d+[a-zA-Z0-9/?=]*`, 'gi') const refs = text.match(linkPattern)?.map(m => { try { @@ -33,7 +33,7 @@ export const getItemMentions = async ({ text }, { me, models }) => { }).filter(r => !!r) if (refs?.length > 0) { - const referee = await models.item.findMany({ + const referee = await tx.item.findMany({ where: { id: { in: refs }, userId: { not: me?.id || USER_ID.anon } diff --git a/worker/paidAction.js b/worker/paidAction.js index 23adb024..63ec26fb 100644 --- a/worker/paidAction.js +++ b/worker/paidAction.js @@ -119,11 +119,12 @@ async function performPessimisticAction ({ lndInvoice, dbInvoice, tx, models, ln const context = { tx, cost: BigInt(lndInvoice.received_mtokens), - me: dbInvoice.user, - sybilFeePercent: await paidActions[dbInvoice.actionType].getSybilFeePercent?.() + me: dbInvoice.user } - const result = await paidActions[dbInvoice.actionType].perform(args, context) + const sybilFeePercent = await paidActions[dbInvoice.actionType].getSybilFeePercent?.(args, context) + + const result = await paidActions[dbInvoice.actionType].perform(args, { ...context, sybilFeePercent }) await tx.invoice.update({ where: { id: dbInvoice.id }, data: {