diff --git a/api/paidAction/itemCreate.js b/api/paidAction/itemCreate.js
index d6fb603f7..f36ea60b6 100644
--- a/api/paidAction/itemCreate.js
+++ b/api/paidAction/itemCreate.js
@@ -42,7 +42,7 @@ export async function getCost ({ subName, parentId, uploadIds, boost = 0, bio },
const [{ cost }] = await models.$queryRaw`
SELECT ${baseCost}::INTEGER
* POWER(10, item_spam(${parseInt(parentId)}::INTEGER, ${me?.id ?? USER_ID.anon}::INTEGER,
- ${me?.id && !bio ? ITEM_SPAM_INTERVAL : ANON_ITEM_SPAM_INTERVAL}::INTERVAL))
+ ${me?.id && !bio ? ITEM_SPAM_INTERVAL : ANON_ITEM_SPAM_INTERVAL}::INTERVAL, ${subName}::TEXT))
* ${me ? 1 : 100}::INTEGER
+ (SELECT "nUnpaid" * "uploadFeesMsats"
FROM upload_fees(${me?.id || USER_ID.anon}::INTEGER, ${uploadIds}::INTEGER[]))
diff --git a/api/resolvers/item.js b/api/resolvers/item.js
index b1a53e544..f4527104f 100644
--- a/api/resolvers/item.js
+++ b/api/resolvers/item.js
@@ -350,11 +350,11 @@ function typeClause (type) {
export default {
Query: {
- itemRepetition: async (parent, { parentId }, { me, models }) => {
+ itemRepetition: async (parent, { parentId, sub }, { me, models }) => {
if (!me) return 0
// how many of the parents starting at parentId belong to me
- const [{ item_spam: count }] = await models.$queryRawUnsafe(`SELECT item_spam($1::INTEGER, $2::INTEGER, '${ITEM_SPAM_INTERVAL}')`,
- Number(parentId), Number(me.id))
+ const [{ item_spam: count }] = await models.$queryRawUnsafe(`SELECT item_spam($1::INTEGER, $2::INTEGER, '${ITEM_SPAM_INTERVAL}', $3::TEXT)`,
+ Number(parentId), Number(me.id), sub)
return count
},
diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js
index 730f61830..34a6dbb0e 100644
--- a/api/typeDefs/item.js
+++ b/api/typeDefs/item.js
@@ -10,7 +10,7 @@ export default gql`
search(q: String, sub: String, cursor: String, what: String, sort: String, when: String, from: String, to: String): Items
auctionPosition(sub: String, id: ID, boost: Int): Int!
boostPosition(sub: String, id: ID, boost: Int): BoostPositions!
- itemRepetition(parentId: ID): Int!
+ itemRepetition(parentId: ID, sub: String): Int!
}
type BoostPositions {
diff --git a/components/fee-button.js b/components/fee-button.js
index d490c4499..98b56c7b9 100644
--- a/components/fee-button.js
+++ b/components/fee-button.js
@@ -37,10 +37,15 @@ export function postCommentBaseLineItems ({ baseCost = 1, comment = false, me })
}
}
-export function postCommentUseRemoteLineItems ({ parentId } = {}) {
- const query = parentId
- ? gql`{ itemRepetition(parentId: "${parentId}") }`
- : gql`{ itemRepetition }`
+export function postCommentUseRemoteLineItems ({ sub, parentId } = {}) {
+ const query = parentId && sub
+ ? gql`{ itemRepetition(parentId: "${parentId}", sub: "${sub}") }`
+ : (parentId
+ ? gql`{ itemRepetition(parentId: "${parentId}") }`
+ : (sub
+ ? gql`{ itemRepetition(sub: "${sub}") }`
+ : gql`{ itemRepetition }`
+ ))
return function useRemoteLineItems () {
const [line, setLine] = useState({})
diff --git a/components/post.js b/components/post.js
index 6245d1a16..7be73d8fb 100644
--- a/components/post.js
+++ b/components/post.js
@@ -150,7 +150,7 @@ export function PostForm ({ type, sub, children }) {
return (