remove payer data encoding before going to db
This commit is contained in:
		
							parent
							
								
									b3e8280d76
								
							
						
					
					
						commit
						0767b23d80
					
				@ -292,6 +292,9 @@ export default {
 | 
			
		||||
          ...payer,
 | 
			
		||||
          identifier: payer.identifier ? me.name : undefined
 | 
			
		||||
        }
 | 
			
		||||
        payer = Object.fromEntries(
 | 
			
		||||
          Object.entries(payer).filter(([, value]) => !!value)
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const milliamount = 1000 * amount
 | 
			
		||||
@ -303,7 +306,7 @@ export default {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      let encodedPayerData = ''
 | 
			
		||||
      if (payer) {
 | 
			
		||||
      if (payer && Object.entries(payer).length) {
 | 
			
		||||
        encodedPayerData = encodeURIComponent(JSON.stringify(payer))
 | 
			
		||||
        callback.searchParams.append('payerdata', encodedPayerData)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -47,8 +47,8 @@ export default async ({ query: { username, amount, nostr, comment, payerdata: pa
 | 
			
		||||
      return res.status(400).json({ status: 'ERROR', reason: `comment cannot exceed ${LNURLP_COMMENT_MAX_LENGTH} characters in length` })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (payerData) {
 | 
			
		||||
    let parsedPayerData
 | 
			
		||||
    if (payerData) {
 | 
			
		||||
      try {
 | 
			
		||||
        parsedPayerData = JSON.parse(decodeURIComponent(payerData))
 | 
			
		||||
      } catch (err) {
 | 
			
		||||
@ -81,7 +81,7 @@ export default async ({ query: { username, amount, nostr, comment, payerdata: pa
 | 
			
		||||
    await serialize(models,
 | 
			
		||||
      models.$queryRaw`SELECT * FROM create_invoice(${invoice.id}, ${invoice.request},
 | 
			
		||||
        ${expiresAt}::timestamp, ${Number(amount)}, ${user.id}::INTEGER, ${noteStr || description},
 | 
			
		||||
        ${comment || null}, ${payerData || null}::JSONB, ${INV_PENDING_LIMIT}::INTEGER, ${BALANCE_LIMIT_MSATS})`)
 | 
			
		||||
        ${comment || null}, ${parsedPayerData || null}::JSONB, ${INV_PENDING_LIMIT}::INTEGER, ${BALANCE_LIMIT_MSATS})`)
 | 
			
		||||
 | 
			
		||||
    return res.status(200).json({
 | 
			
		||||
      pr: invoice.request,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user