Remove unnecessary withdrawl field
This commit is contained in:
		
							parent
							
								
									a1317b97e9
								
							
						
					
					
						commit
						922d2394fd
					
				| @ -1,7 +1,7 @@ | |||||||
| import { GraphQLError } from 'graphql' | import { GraphQLError } from 'graphql' | ||||||
| import { decodeCursor, LIMIT, nextNoteCursorEncoded } from '@/lib/cursor' | import { decodeCursor, LIMIT, nextNoteCursorEncoded } from '@/lib/cursor' | ||||||
| import { getItem, filterClause, whereClause, muteClause } from './item' | import { getItem, filterClause, whereClause, muteClause } from './item' | ||||||
| import { getInvoice, getWithdrawal } from './wallet' | import { getInvoice } from './wallet' | ||||||
| import { pushSubscriptionSchema, ssValidate } from '@/lib/validate' | import { pushSubscriptionSchema, ssValidate } from '@/lib/validate' | ||||||
| import { replyToSubscription } from '@/lib/webPush' | import { replyToSubscription } from '@/lib/webPush' | ||||||
| import { getSub } from './sub' | import { getSub } from './sub' | ||||||
| @ -443,9 +443,6 @@ export default { | |||||||
|   InvoicePaid: { |   InvoicePaid: { | ||||||
|     invoice: async (n, args, { me, models }) => getInvoice(n, { id: n.id }, { me, models }) |     invoice: async (n, args, { me, models }) => getInvoice(n, { id: n.id }, { me, models }) | ||||||
|   }, |   }, | ||||||
|   WithdrawlPaid: { |  | ||||||
|     withdrawl: async (n, args, { me, models }) => getWithdrawal(n, { id: n.id }, { me, models }) |  | ||||||
|   }, |  | ||||||
|   Invitification: { |   Invitification: { | ||||||
|     invite: async (n, args, { models }) => { |     invite: async (n, args, { models }) => { | ||||||
|       return await models.invite.findUnique({ |       return await models.invite.findUnique({ | ||||||
|  | |||||||
| @ -53,31 +53,6 @@ export async function getInvoice (parent, { id }, { me, models, lnd }) { | |||||||
|   return inv |   return inv | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function getWithdrawal (parent, { id }, { me, models }) { |  | ||||||
|   if (!me) { |  | ||||||
|     throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } }) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   const wdrwl = await models.withdrawl.findUnique({ |  | ||||||
|     where: { |  | ||||||
|       id: Number(id) |  | ||||||
|     }, |  | ||||||
|     include: { |  | ||||||
|       user: true |  | ||||||
|     } |  | ||||||
|   }) |  | ||||||
| 
 |  | ||||||
|   if (!wdrwl) { |  | ||||||
|     throw new GraphQLError('withdrawal not found', { extensions: { code: 'BAD_INPUT' } }) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   if (wdrwl.user.id !== me.id) { |  | ||||||
|     throw new GraphQLError('not ur withdrawal', { extensions: { code: 'FORBIDDEN' } }) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   return wdrwl |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export function createHmac (hash) { | export function createHmac (hash) { | ||||||
|   const key = Buffer.from(process.env.INVOICE_HMAC_KEY, 'hex') |   const key = Buffer.from(process.env.INVOICE_HMAC_KEY, 'hex') | ||||||
|   return crypto.createHmac('sha256', key).update(Buffer.from(hash, 'hex')).digest('hex') |   return crypto.createHmac('sha256', key).update(Buffer.from(hash, 'hex')).digest('hex') | ||||||
| @ -122,7 +97,30 @@ export default { | |||||||
|         } |         } | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|     withdrawl: getWithdrawal, |     withdrawl: async (parent, { id }, { me, models }) => { | ||||||
|  |       if (!me) { | ||||||
|  |         throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } }) | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       const wdrwl = await models.withdrawl.findUnique({ | ||||||
|  |         where: { | ||||||
|  |           id: Number(id) | ||||||
|  |         }, | ||||||
|  |         include: { | ||||||
|  |           user: true | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  | 
 | ||||||
|  |       if (!wdrwl) { | ||||||
|  |         throw new GraphQLError('withdrawal not found', { extensions: { code: 'BAD_INPUT' } }) | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       if (wdrwl.user.id !== me.id) { | ||||||
|  |         throw new GraphQLError('not ur withdrawal', { extensions: { code: 'FORBIDDEN' } }) | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       return wdrwl | ||||||
|  |     }, | ||||||
|     numBolt11s: async (parent, args, { me, models, lnd }) => { |     numBolt11s: async (parent, args, { me, models, lnd }) => { | ||||||
|       if (!me) { |       if (!me) { | ||||||
|         throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } }) |         throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } }) | ||||||
|  | |||||||
| @ -94,7 +94,6 @@ export default gql` | |||||||
|   type WithdrawlPaid { |   type WithdrawlPaid { | ||||||
|     id: ID! |     id: ID! | ||||||
|     earnedSats: Int! |     earnedSats: Int! | ||||||
|     withdrawl: Withdrawl! |  | ||||||
|     sortTime: Date! |     sortTime: Date! | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -96,7 +96,7 @@ const defaultOnClick = n => { | |||||||
|   if (type === 'SubStatus') return { href: `/~${n.sub.name}` } |   if (type === 'SubStatus') return { href: `/~${n.sub.name}` } | ||||||
|   if (type === 'Invitification') return { href: '/invites' } |   if (type === 'Invitification') return { href: '/invites' } | ||||||
|   if (type === 'InvoicePaid') return { href: `/invoices/${n.invoice.id}` } |   if (type === 'InvoicePaid') return { href: `/invoices/${n.invoice.id}` } | ||||||
|   if (type === 'WithdrawlPaid') return { href: `/withdrawals/${n.withdrawl.id}` } |   if (type === 'WithdrawlPaid') return { href: `/withdrawals/${n.id}` } | ||||||
|   if (type === 'Referral') return { href: '/referrals/month' } |   if (type === 'Referral') return { href: '/referrals/month' } | ||||||
|   if (type === 'Streak') return {} |   if (type === 'Streak') return {} | ||||||
|   if (type === 'TerritoryTransfer') return { href: `/~${n.sub.name}` } |   if (type === 'TerritoryTransfer') return { href: `/~${n.sub.name}` } | ||||||
|  | |||||||
| @ -137,10 +137,6 @@ export const NOTIFICATIONS = gql` | |||||||
|           id |           id | ||||||
|           sortTime |           sortTime | ||||||
|           earnedSats |           earnedSats | ||||||
|           withdrawl { |  | ||||||
|             id |  | ||||||
|             satsPaid |  | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user