Merge pull request #237 from shocknet/bug/new-posts-path-tips
Bug/new posts path tips
This commit is contained in:
commit
6d29062061
2 changed files with 5 additions and 12 deletions
|
|
@ -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 = ''
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
@ -52,13 +49,14 @@ const _getPostTipInfo = ({ postID, page }) =>
|
||||||
tipCounter: typeof tipCounter === 'number' ? tipCounter : 0,
|
tipCounter: typeof tipCounter === 'number' ? tipCounter : 0,
|
||||||
tipValue: typeof tipValue === 'number' ? tipValue : 0
|
tipValue: typeof tipValue === 'number' ? tipValue : 0
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(post)
|
resolve(post)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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 +67,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 +75,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 +153,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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue