fix fragment when comment visited directly + one db dip

This commit is contained in:
k00b 2025-03-10 20:02:55 -05:00
parent 65b1db23a7
commit ed9fa5f823
2 changed files with 7 additions and 15 deletions

View File

@ -20,21 +20,12 @@ export async function getBaseCost ({ models, bio, parentId, subName }) {
if (parentId) { if (parentId) {
// the subname is stored in the root item of the thread // the subname is stored in the root item of the thread
const parent = await models.item.findFirst({ const [sub] = await models.$queryRaw`
where: { id: Number(parentId) }, SELECT s."replyCost"
include: { FROM "Item" i
root: { include: { sub: true } }, LEFT JOIN "Item" r ON r.id = i."rootId"
sub: true LEFT JOIN "Sub" s ON s.name = COALESCE(r."subName", i."subName")
} WHERE i.id = ${Number(parentId)}`
})
const root = parent.root ?? parent
// XXX Prisma does not support case-insensitive joins on CITEXT column
// so we fetch the territory in a separate query
const sub = await models.sub.findUnique({
where: { name: root.subName }
})
if (!sub) return DEFAULT_ITEM_COST if (!sub) return DEFAULT_ITEM_COST
return satsToMsats(sub.replyCost) return satsToMsats(sub.replyCost)

View File

@ -108,6 +108,7 @@ export const ITEM_FULL_FIELDS = gql`
moderated moderated
meMuteSub meMuteSub
meSubscription meSubscription
replyCost
} }
} }
forwards { forwards {