Fixed post tips for new posts path

This commit is contained in:
emad-salah 2020-10-30 13:22:01 +01:00
parent ddfbb2aeed
commit 14da521229
2 changed files with 5 additions and 14 deletions

View file

@ -51,7 +51,6 @@ const ordersProcessed = new Set()
* @prop {import('shock-common').Schema.InvoiceState} state * @prop {import('shock-common').Schema.InvoiceState} state
* @prop {string} targetType * @prop {string} targetType
* @prop {(string)=} postID * @prop {(string)=} postID
* @prop {(number)=} postPage
*/ */
let currentOrderAddr = '' let currentOrderAddr = ''
@ -241,8 +240,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
hash, hash,
state: 'OPEN', state: 'OPEN',
targetType: order.targetType, targetType: order.targetType,
postID: order.postID, postID: order.postID
postPage: order.postPage
} }
getUser() getUser()
.get(Key.TIPS_PAYMENT_STATUS) .get(Key.TIPS_PAYMENT_STATUS)

View file

@ -39,10 +39,7 @@ const _lookupInvoice = hash =>
const _getPostTipInfo = ({ postID, page }) => const _getPostTipInfo = ({ postID, page }) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
getUser() getUser()
.get(Key.WALL) .get(Key.POSTS_NEW)
.get(Key.PAGES)
.get(page)
.get(Key.POSTS)
.get(postID) .get(postID)
.once(post => { .once(post => {
if (post && post.date) { if (post && post.date) {
@ -58,7 +55,7 @@ const _getPostTipInfo = ({ postID, page }) =>
}) })
}) })
const _incrementPost = ({ postID, page, orderAmount }) => const _incrementPost = ({ postID, orderAmount }) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const parsedAmount = parseFloat(orderAmount) const parsedAmount = parseFloat(orderAmount)
@ -69,7 +66,7 @@ const _incrementPost = ({ postID, page, orderAmount }) =>
Logger.info('[POST TIP] Getting Post Tip Values...') Logger.info('[POST TIP] Getting Post Tip Values...')
return _getPostTipInfo({ postID, page }) return _getPostTipInfo({ postID })
.then(({ tipValue, tipCounter }) => { .then(({ tipValue, tipCounter }) => {
const updatedTip = { const updatedTip = {
tipCounter: tipCounter + 1, tipCounter: tipCounter + 1,
@ -77,10 +74,7 @@ const _incrementPost = ({ postID, page, orderAmount }) =>
} }
getUser() getUser()
.get(Key.WALL) .get(Key.POSTS_NEW)
.get(Key.PAGES)
.get(page)
.get(Key.POSTS)
.get(postID) .get(postID)
.put(updatedTip, () => { .put(updatedTip, () => {
Logger.info('[POST TIP] Successfully updated Post tip info') Logger.info('[POST TIP] Successfully updated Post tip info')
@ -158,7 +152,6 @@ const executeTipAction = (tip, invoice) => {
if (tip.targetType === 'post') { if (tip.targetType === 'post') {
_incrementPost({ _incrementPost({
postID: tip.postID, postID: tip.postID,
page: tip.postPage,
orderAmount: invoice.amt_paid_sat orderAmount: invoice.amt_paid_sat
}) })
} }