optionally hide invoice descriptions

This commit is contained in:
keyan 2022-08-30 16:50:47 -05:00
parent 0ad886ffc0
commit 172d6c3c2f
7 changed files with 36 additions and 6 deletions

View File

@ -186,7 +186,7 @@ export default {
const description = `${amount} sats for @${user.name} on stacker.news` const description = `${amount} sats for @${user.name} on stacker.news`
try { try {
const invoice = await createInvoice({ const invoice = await createInvoice({
description, description: user.hideInvoiceDesc ? undefined : description,
lnd, lnd,
tokens: amount, tokens: amount,
expires_at: expiresAt expires_at: expiresAt

View File

@ -30,7 +30,7 @@ export default gql`
setName(name: String!): Boolean setName(name: String!): Boolean
setSettings(tipDefault: Int!, noteItemSats: Boolean!, noteEarning: Boolean!, setSettings(tipDefault: Int!, noteItemSats: Boolean!, noteEarning: Boolean!,
noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!,
noteInvites: Boolean!, noteJobIndicator: Boolean!): Boolean noteInvites: Boolean!, noteJobIndicator: Boolean!, hideInvoiceDesc: Boolean!): Boolean
setPhoto(photoId: ID!): Int! setPhoto(photoId: ID!): Int!
upsertBio(bio: String!): User! upsertBio(bio: String!): User!
setWalkthrough(tipPopover: Boolean, upvotePopover: Boolean): Boolean setWalkthrough(tipPopover: Boolean, upvotePopover: Boolean): Boolean
@ -70,6 +70,7 @@ export default gql`
noteDeposits: Boolean! noteDeposits: Boolean!
noteInvites: Boolean! noteInvites: Boolean!
noteJobIndicator: Boolean! noteJobIndicator: Boolean!
hideInvoiceDesc: Boolean!
lastCheckedJobs: String lastCheckedJobs: String
authMethods: AuthMethods! authMethods: AuthMethods!
} }

View File

@ -24,6 +24,7 @@ export const ME = gql`
noteDeposits noteDeposits
noteInvites noteInvites
noteJobIndicator noteJobIndicator
hideInvoiceDesc
lastCheckedJobs lastCheckedJobs
} }
}` }`
@ -48,6 +49,7 @@ export const ME_SSR = gql`
noteDeposits noteDeposits
noteInvites noteInvites
noteJobIndicator noteJobIndicator
hideInvoiceDesc
lastCheckedJobs lastCheckedJobs
} }
}` }`
@ -63,6 +65,7 @@ export const SETTINGS = gql`
noteDeposits noteDeposits
noteInvites noteInvites
noteJobIndicator noteJobIndicator
hideInvoiceDesc
authMethods { authMethods {
lightning lightning
email email

View File

@ -20,7 +20,7 @@ export default async ({ query: { username, amount } }, res) => {
const descriptionHash = lnurlPayDescriptionHashForUser(username) const descriptionHash = lnurlPayDescriptionHashForUser(username)
try { try {
const invoice = await createInvoice({ const invoice = await createInvoice({
description, description: user.hideInvoiceDesc ? undefined : description,
description_hash: descriptionHash, description_hash: descriptionHash,
lnd, lnd,
mtokens: amount, mtokens: amount,

View File

@ -11,6 +11,7 @@ import ModalButton from '../components/modal-button'
import { LightningAuth } from '../components/lightning-auth' import { LightningAuth } from '../components/lightning-auth'
import { SETTINGS } from '../fragments/users' import { SETTINGS } from '../fragments/users'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Info from '../components/info'
export const getServerSideProps = getGetServerSideProps(SETTINGS) export const getServerSideProps = getGetServerSideProps(SETTINGS)
@ -31,11 +32,11 @@ export default function Settings ({ data: { settings } }) {
gql` gql`
mutation setSettings($tipDefault: Int!, $noteItemSats: Boolean!, $noteEarning: Boolean!, mutation setSettings($tipDefault: Int!, $noteItemSats: Boolean!, $noteEarning: Boolean!,
$noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!,
$noteInvites: Boolean!, $noteJobIndicator: Boolean!) { $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $hideInvoiceDesc: Boolean!) {
setSettings(tipDefault: $tipDefault, noteItemSats: $noteItemSats, setSettings(tipDefault: $tipDefault, noteItemSats: $noteItemSats,
noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants,
noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites, noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites,
noteJobIndicator: $noteJobIndicator) noteJobIndicator: $noteJobIndicator, hideInvoiceDesc: $hideInvoiceDesc)
}` }`
) )
@ -57,7 +58,8 @@ export default function Settings ({ data: { settings } }) {
noteMentions: settings?.noteMentions, noteMentions: settings?.noteMentions,
noteDeposits: settings?.noteDeposits, noteDeposits: settings?.noteDeposits,
noteInvites: settings?.noteInvites, noteInvites: settings?.noteInvites,
noteJobIndicator: settings?.noteJobIndicator noteJobIndicator: settings?.noteJobIndicator,
hideInvoiceDesc: settings?.hideInvoiceDesc
}} }}
schema={SettingsSchema} schema={SettingsSchema}
onSubmit={async ({ tipDefault, ...values }) => { onSubmit={async ({ tipDefault, ...values }) => {
@ -108,6 +110,25 @@ export default function Settings ({ data: { settings } }) {
label='there is a new job' label='there is a new job'
name='noteJobIndicator' name='noteJobIndicator'
/> />
<div className='form-label'>privacy</div>
<Checkbox
label={
<>hide invoice descriptions
<Info>
<ul className='font-weight-bold'>
<li>Use this if you don't want funding sources to be linkable to your SN identity.</li>
<li>It makes your invoice descriptions blank.</li>
<li>This only applies invoices you create
<ul>
<li>lnurl-pay or lightning addresses still reference your nym</li>
</ul>
</li>
</ul>
</Info>
</>
}
name='hideInvoiceDesc'
/>
<div className='d-flex'> <div className='d-flex'>
<SubmitButton variant='info' className='ml-auto mt-1 px-4'>save</SubmitButton> <SubmitButton variant='info' className='ml-auto mt-1 px-4'>save</SubmitButton>
</div> </div>

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "hideInvoiceDesc" BOOLEAN NOT NULL DEFAULT false;

View File

@ -56,6 +56,9 @@ model User {
noteInvites Boolean @default(true) noteInvites Boolean @default(true)
noteJobIndicator Boolean @default(true) noteJobIndicator Boolean @default(true)
// privacy settings
hideInvoiceDesc Boolean @default(false)
Earn Earn[] Earn Earn[]
Upload Upload[] @relation(name: "Uploads") Upload Upload[] @relation(name: "Uploads")
PollVote PollVote[] PollVote PollVote[]