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 {string} targetType
* @prop {(string)=} postID
* @prop {(number)=} postPage
*/
let currentOrderAddr = ''
@ -241,8 +240,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
hash,
state: 'OPEN',
targetType: order.targetType,
postID: order.postID,
postPage: order.postPage
postID: order.postID
}
getUser()
.get(Key.TIPS_PAYMENT_STATUS)

View file

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