diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 5eede0cb..18f1725b 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -186,7 +186,7 @@ export default { const description = `${amount} sats for @${user.name} on stacker.news` try { const invoice = await createInvoice({ - description, + description: user.hideInvoiceDesc ? undefined : description, lnd, tokens: amount, expires_at: expiresAt diff --git a/api/typeDefs/user.js b/api/typeDefs/user.js index 1214eb57..b5101bb0 100644 --- a/api/typeDefs/user.js +++ b/api/typeDefs/user.js @@ -30,7 +30,7 @@ export default gql` setName(name: String!): Boolean setSettings(tipDefault: Int!, noteItemSats: Boolean!, noteEarning: Boolean!, noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, - noteInvites: Boolean!, noteJobIndicator: Boolean!): Boolean + noteInvites: Boolean!, noteJobIndicator: Boolean!, hideInvoiceDesc: Boolean!): Boolean setPhoto(photoId: ID!): Int! upsertBio(bio: String!): User! setWalkthrough(tipPopover: Boolean, upvotePopover: Boolean): Boolean @@ -70,6 +70,7 @@ export default gql` noteDeposits: Boolean! noteInvites: Boolean! noteJobIndicator: Boolean! + hideInvoiceDesc: Boolean! lastCheckedJobs: String authMethods: AuthMethods! } diff --git a/fragments/users.js b/fragments/users.js index e0301264..5052af03 100644 --- a/fragments/users.js +++ b/fragments/users.js @@ -24,6 +24,7 @@ export const ME = gql` noteDeposits noteInvites noteJobIndicator + hideInvoiceDesc lastCheckedJobs } }` @@ -48,6 +49,7 @@ export const ME_SSR = gql` noteDeposits noteInvites noteJobIndicator + hideInvoiceDesc lastCheckedJobs } }` @@ -63,6 +65,7 @@ export const SETTINGS = gql` noteDeposits noteInvites noteJobIndicator + hideInvoiceDesc authMethods { lightning email diff --git a/pages/api/lnurlp/[username]/pay.js b/pages/api/lnurlp/[username]/pay.js index 416a4ea3..a4b40f76 100644 --- a/pages/api/lnurlp/[username]/pay.js +++ b/pages/api/lnurlp/[username]/pay.js @@ -20,7 +20,7 @@ export default async ({ query: { username, amount } }, res) => { const descriptionHash = lnurlPayDescriptionHashForUser(username) try { const invoice = await createInvoice({ - description, + description: user.hideInvoiceDesc ? undefined : description, description_hash: descriptionHash, lnd, mtokens: amount, diff --git a/pages/settings.js b/pages/settings.js index 9ecc16ed..3ce803e4 100644 --- a/pages/settings.js +++ b/pages/settings.js @@ -11,6 +11,7 @@ import ModalButton from '../components/modal-button' import { LightningAuth } from '../components/lightning-auth' import { SETTINGS } from '../fragments/users' import { useRouter } from 'next/router' +import Info from '../components/info' export const getServerSideProps = getGetServerSideProps(SETTINGS) @@ -31,11 +32,11 @@ export default function Settings ({ data: { settings } }) { gql` mutation setSettings($tipDefault: Int!, $noteItemSats: Boolean!, $noteEarning: Boolean!, $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, - $noteInvites: Boolean!, $noteJobIndicator: Boolean!) { + $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $hideInvoiceDesc: Boolean!) { setSettings(tipDefault: $tipDefault, noteItemSats: $noteItemSats, noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, 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, noteDeposits: settings?.noteDeposits, noteInvites: settings?.noteInvites, - noteJobIndicator: settings?.noteJobIndicator + noteJobIndicator: settings?.noteJobIndicator, + hideInvoiceDesc: settings?.hideInvoiceDesc }} schema={SettingsSchema} onSubmit={async ({ tipDefault, ...values }) => { @@ -108,6 +110,25 @@ export default function Settings ({ data: { settings } }) { label='there is a new job' name='noteJobIndicator' /> +
privacy
+ hide invoice descriptions + + + + + } + name='hideInvoiceDesc' + />
save
diff --git a/prisma/migrations/20220830213020_hide_invoice_desc/migration.sql b/prisma/migrations/20220830213020_hide_invoice_desc/migration.sql new file mode 100644 index 00000000..db1eaca0 --- /dev/null +++ b/prisma/migrations/20220830213020_hide_invoice_desc/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "users" ADD COLUMN "hideInvoiceDesc" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 75e8c3a4..0442bf6f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -56,6 +56,9 @@ model User { noteInvites Boolean @default(true) noteJobIndicator Boolean @default(true) + // privacy settings + hideInvoiceDesc Boolean @default(false) + Earn Earn[] Upload Upload[] @relation(name: "Uploads") PollVote PollVote[]