* wip: Use uniform interface for wallets
* Fix import error
* Update wallet logging + other stuff
* add canPay and canSend to wallet definition
* rename 'default payment method' to 'enabled' and add enable + disable method
* Set canPay, canReceive in useWallet
* Enable wallet if just configured
* Don't pass logger to sendPayment
* Add logging to attach & detach
* Add schema to wallet def
* Add NWC wallet
* Fix unused isDefault saved in config
* Fix enableWallet
* wrong storage key was used
* broke if wallets with no configs existed
* Run validation during save
* Use INFO level for 'wallet disabled' message
* Pass config with spread operator
* Support help, optional, hint in wallet fields
* wip: Add LNC
* Fix 20s page load for /settings/wallets.json?nodata=true
For some reason, if nodata is passed (which is the case if going back), the page takes 20s to load.
* Fix extremely slow page load for LNC import
I noticed that the combination of
```
import { Form, PasswordInput, SubmitButton } from '@/components/form'
```
in components/wallet/lnc.js and the dynamic import via `await import` in components/wallet/index.js caused extremely slow page loads.
* Use normal imports
* Revert "Fix 20s page load for /settings/wallets.json?nodata=true"
This reverts commit deb476b3a966569fefcfdf4082d6b64f90fbd0a2.
Not using the dynamic import for LNC fixed the slow page load with ?nodata=true.
* Remove follow and show recent logs first
* Fix position of log start marker
* Add FIXMEs for LNC
I can't get LNC to connect. It just hangs forever on lnc.connect(). See FIXMEs.
* Remove logger.error since already handled in useWallet
* Don't require destructuring to pass props to input
* wip: Add LND autowithdrawals
* receiving wallets need to export 'server' object field
* don't print macaroon error stack
* fix missing wallet logs order update
* mark autowithdrawl settings as required
* fix server wallet logs deletion
* remove canPay and canReceive since it was confusing where it is available
TODO
* also use numeric priority for sending wallets to be consistent with how status for receiving wallets is determined
* define createInvoice function in wallet definition
* consistent wallet logs: sending wallets use 'wallet attached'+'wallet enabled/disabled' whereas receiving wallets use 'wallet created/updated'
* see FIXMEs
* Fix TypeError
* Fix sendPayment called with empty config
* removed useEffect such that config is available on first render
* fix hydration error using dynamic import without SSR
* Fix confusing UX around enabled
* Remove FIXMEs
Rebase on master seemed to have fixed these, weird
* Use same error format in toast and wallet log
* Fix usage of conditional hooks in useConfig
* Fix isConfigured
* Fix delete wallet logs on server
* Fix wallet logs refetch
onError does not exist on client.mutate
* Fix TypeError in isConfigured if no enabled wallet found
* Only include local/server config if required
* Fix another hydration error
* Fix server config not updated after save or detach
* Also use 'enabled' for server wallets
* Fix wallet logs not updated after server delete
* Consistent logs between local and server wallets
* 'wallet attached' on create
* 'wallet updated' on config updates
* 'wallet enabled' and 'wallet disabled' if checkbox changed
* 'wallet detached' on delete
* Also enable server wallets on create
* Disable checkbox if not configured yet
* Move all validation schema into lib/validate
* Implement drag & drop w/o persistence
* Use dynamic import for WalletCard
This fixes a lot of issues with hydration
* Save order as priority
* Fix autowithdrawSettings not applied
Form requires config in flat format but mutation requires autowithdraw settings in a separate 'settings' field.
I have decided that config will be in flat form format. It will be transformed into mutation format during save.
* Save dedicated enabled flag for server wallets
* wallet table now contains boolean column 'enabled'
* 'priority' is now a number everywhere
* use consistent order between how autowithdrawals are attempted and server wallets cards
* Fix onCanceled missing
* Fix typo
* Fix noisy changes in lib/validate
I moved the schema for lnbits, nwc and lnc out of lib/validate only to put them back in there later.
This commit should make the changeset cleaner by removing noise.
* Split arguments into [value,] config, context
* Run lnbits url.replace in validate and sendPayment
* Remove unnecessary WALLETS_QUERY
* Generate wallet mutation from fields
* Generate wallet resolver from fields
* Fix import inconsistency between app and worker
* Use wallet.createInvoice for autowithdrawals
* Fix success autowithdrawal log
* Fix wallet security banner shown for server wallets
* Add autowithdrawal to lightning address
* Add optional wallet short name for logging
* Fix draggable
* Fix autowithdraw loop
* Add missing hints
* Add CLN autowithdrawal
* Detach wallets and delete logs on logout
* Remove Wallet in lib/constants
* Use inject function for resolvers and typeDefs
* Fix priority ignored when fetching enabled wallet
* Fix draggable false on first page load due to SSR
* Use touches instead of dnd on mobile
Browsers don't support drag events for touch devices.
To have a consistent implementation for desktop and mobile, we would need to use mousedown/touchstart, mouseup/touchend and mousemove/touchmove.
For now, this commit makes changing the order possible on touch devices with simple touches.
* Fix duplicate CLN error
* Fix autowithdraw priority order
* Fix error per invalid bip39 word
* Update LNC code
* remove LNC FIXMEs
Mhh, I guess the TURN server was down or something? It now magically works. Or maybe it only works once per mnemonic?
* also removed the lnc.lnd.lightning.getInfo() call since we don't ask and need permission for this RPC for payments.
* setting a password does not work though. It fails with 'The password provided is not valid' which is triggered at https://github.com/lightninglabs/lnc-web/blob/main/lib/util/credentialStore.ts#L81.
* Fix order if wallet with no priority exists
* Use common sort
* Add link to lnbits.com
* Add example wallet def
* Remove TODOs
TODO in components/wallet-logger.js was handled.
I don't see a need for the TODO in lib/wallet.js anymore. This function will only be called with the wallet of type LIGHTNING_ADDRESS anyway.
* Remove console.log
* Toast priority save errors
* Fix leaking relay connections
* Remove 'tor or clearnet' hint for LN addresses
* Remove React dependency from wallet definitions
* Generate resolver name from walletField
* Move wallets into top level directory wallet/
* Put wallets into own folder
* Fix generateMutation
* remove resolverName property from wallet defs
* move function into lib/wallet
* use function in generateMutation on client to fix wrongly generated mutation
* Separate client and server imports by files
* wallets now consist of an index.js, a client.js and a server.js file
* client.js is imported on the client and contains the client portion
* server.js is imported on the server and contains the server porition
* both reexport index.js so everything in index.js can be shared by client and server
* every wallet contains a client.js file since they are all imported on the client to show the cards
* client.js of every wallet is reexported as an array in wallets/client.js
* server.js of every wallet is reexported as an array in wallets/server.js
FIXME: for some reason, worker does not properly import the default export of wallets/server.js
* Fix worker import of wallets/server
* Fix wallet.server usage
* I removed wallet.server in a previous commit
* the client couldn't determine which wallet was stored on the server since all server specific fields were set in server.js
* walletType and walletField are now set in index.js
* walletType is now used to determine if a wallet is stored on the server
* also included some formatting changes
* Fix w.default usage
Since package.json with { "type": "module" } was added, this is no longer needed.
* Fix id access in walletPrioritySort
* Fix autowithdrawal error log
* Generate validation schema for LNbits
* Generate validation schema for NWC
* Rename to torAllowed
* Generate validation schema for LNC
* Generate validation schema for LND
* Generate validation schema for LnAddr
* Remove stringTypes
* Generate validation schema for CLN
* Make clear that message belongs to test
* validate.message was used in tandem with validate.test
* it might be confused as the message if the validation for validate.type failed
* now validate.test can be a function or an object of { test, message } shape which matches Yup.test
* Remove validate.schema as a trap door
* make lnc work
* Return null if no wallet was found
* Revert code around schema generation
* Transform autowithdrawSchemaMembers into an object
* Rename schema to yupSchema
* Fix missing required for LNbits adminKey
* Support formik form-level validation
* Fix missing addWalletLog import
* Fix missing space after =
* fix merge conflict resolution mistake
* remove non-custodial* badges
* create guides for attaching wallets in sndev
* Use built-in formik validation or Yup schema but not both
* Rename: validate -> testConnectClient, testConnect -> testConnectServer
* make lnaddr autowithdraw work in dev
* move ATTACH docs to ./wallets and add lnaddr doc
* Fix missing rename: yupSchema -> fieldValidation
* Remove unused context
* Add documentation how to add wallets
---------
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* capture/store data for new referral scheme
* simplify signup/forever referral rules
* no self-referrals and other fixes
* better post/comment distinction and support /items/1/related
* wip backend optimism
* another inch
* make action state transitions only happen once
* another inch
* almost ready for testing
* use interactive txs
* another inch
* ready for basic testing
* lint fix
* inches
* wip item update
* get item update to work
* donate and downzap
* inchy inch
* fix territory paid actions
* wip usePaidMutation
* usePaidMutation error handling
* PENDING_HELD and HELD transitions, gql paidAction return types
* mostly working pessimism
* make sure invoice field is present in optimisticResponse
* inches
* show optimistic values to current me
* first pass at notifications and payment status reporting
* fix migration to have withdrawal hash
* reverse optimism on payment failure
* Revert "Optimistic updates via pending sats in item context (#1229)"
This reverts commit 93713b33df.
* add onCompleted to usePaidMutation
* onPaid and onPayError for new comments
* use 'IS DISTINCT FROM' for NULL invoiceActionState columns
* make usePaidMutation easier to read
* enhance invoice qr
* prevent actions on unpaid items
* allow navigation to action's invoice
* retry create item
* start edit window after item is paid for
* fix ux of retries from notifications
* refine retries
* fix optimistic downzaps
* remember item updates can't be retried
* store reference to action item in invoice
* remove invoice modal layout shift
* fix destructuring
* fix zap undos
* make sure ItemAct is paid in aggregate queries
* dont toast on long press zap undo
* fix delete and remindme bots
* optimistic poll votes with retries
* fix retry notifications and invoice item context
* fix pessimisitic typo
* item mentions and mention notifications
* dont show payment retry on item popover
* make bios work
* refactor paidAction transitions
* remove stray console.log
* restore docker compose nwc settings
* add new todos
* persist qr modal on post submission + unify item form submission
* fix post edit threshold
* make bounty payments work
* make job posting work
* remove more store procedure usage ... document serialization concerns
* dont use dynamic imports for paid action modules
* inline comment denormalization
* create item starts with median votes
* fix potential of serialization anomalies in zaps
* dont trigger notification indicator on successful paid action invoices
* ignore invoiceId on territory actions and add optimistic concurrency control
* begin docs for paid actions
* better error toasts and fix apollo cache warnings
* small documentation enhancements
* improve paid action docs
* optimistic concurrency control for territory updates
* use satsToMsats and msatsToSats helpers
* explictly type raw query template parameters
* improve consistency of nested relation names
* complete paid action docs
* useEffect for canEdit on payment
* make sure invoiceId is provided when required
* don't return null when expecting array
* remove buy credits
* move verifyPayment to paidAction
* fix comments invoicePaidAt time zone
* close nwc connections once
* grouped logs for paid actions
* stop invoiceWaitUntilPaid if not attempting to pay
* allow actionState to transition directly from HELD to PAID
* make paid mutation wait until pessimistic are fully paid
* change button text when form submits/pays
* pulsing form submit button
* ignore me in notification indicator for territory subscription
* filter unpaid items from more queries
* fix donation stike timing
* fix pending poll vote
* fix recent item notifcation padding
* no default form submitting button text
* don't show paying on submit button on free edits
* fix territory autorenew with fee credits
* reorg readme
* allow jobs to be editted forever
* fix image uploads
* more filter fixes for aggregate views
* finalize paid action invoice expirations
* remove unnecessary async
* keep clientside cache normal/consistent
* add more detail to paid action doc
* improve paid action table
* remove actionType guard
* fix top territories
* typo api/paidAction/README.md
Co-authored-by: ekzyis <ek@stacker.news>
* typo components/use-paid-mutation.js
Co-authored-by: ekzyis <ek@stacker.news>
* Apply suggestions from code review
Co-authored-by: ekzyis <ek@stacker.news>
* encorporate ek feeback
* more ek suggestions
* fix 'cost to post' hover on items
* Apply suggestions from code review
Co-authored-by: ekzyis <ek@stacker.news>
---------
Co-authored-by: ekzyis <ek@stacker.news>
* make polls anonymous
Introduce a `PollBlindVote` DB table that tracks when a user votes in a poll,
but does not track which choice they made.
Alter the `PollVote` DB table to remove the `userId` column, meaning `PollVote`
now tracks poll votes anonymously - it captures votes per poll option,
but does not track which user submitted the vote.
Update the `poll_vote` DB function to work with both tables now.
Update the `item.poll` resolver to calculate `meVoted` based on the `PollBlindVote`
table instead of `PollVote`.
* remove `meVoted` on `PollOption`s
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* Parse internal refs to links
* Item mention notifications
* Also parse item mentions as URLs
* Fix subType determined by referrer item instead of referee item
* Ignore subType
Considering if the item that was referred to was a post or comment made the code more complex than initially necessary.
For example, notifications for /notifications are deduplicated based on item id and the same item could refer to posts and comments, so to include "one of your posts" or "one of your comments" in the title would require splitting notifications based on the type of referred item.
I didn't want to do this but also wanted to have consistent notification titles between push and /notifications, so I use "items" in both places now, even though I think using "items" isn't ideal from a user perspective. I think it might be confusing.
* Fix rootText
* Replace full links to #<id> syntax in push notifications
* Refactor mention code into separate functions
* Replace useInvoiceable with usePayment hook
* Show WebLnError in QR code fallback
* Fix missing removal of old zap undo code
* Fix payment timeout message
* Fix unused arg in super()
* Also bail if invoice expired
* Fix revert on reply error
* Use JIT_INVOICE_TIMEOUT_MS constant
* Remove unnecessary PaymentContext
* Fix me as a dependency in FeeButtonContext
* Fix anon sats added before act success
* Optimistic updates for zaps
* Fix modal not closed after custom zap
* Optimistic update for custom zaps
* Optimistic update for bounty payments
* Consistent error handling for zaps and bounty payments
* Optimistic update for poll votes
* Use var balance in payment.request
* Rename invoiceable to prepaid
* Log cancelled invoices
* Client notifications
We now show notifications that are stored on the client to inform the user about following errors in the prepaid payment flow:
- if a payment fails
- if an invoice expires before it is paid
- if a payment was interrupted (for example via page refresh)
- if the action fails after payment
* Remove unnecessary passing of act
* Use AbortController for zap undos
* Fix anon zap update not updating bolt color
* Fix zap counted towards anon sats even if logged in
* Fix duplicate onComplete call
* Fix downzap type error
* Fix "missing field 'path' while writing result" error
* Pass full item in downzap props
The previous commit fixed cache updates for downzaps but then the cache update for custom zaps failed because 'path' wasn't included in the server response.
This commit is the proper fix.
* Parse lnc rpc error messages
* Add hash to InvoiceExpiredError
* @remindme bot support
support reminders via @remindme bot, just like @delete bot
* minor cleanup
* minor query cleanup
* add db migration
* various fixes and updates:
* hasNewNotes implementation
* actually return notification component in ui
* delete reminder and job on item delete
* other goodies
* refactor to use prisma for deleting existing reminder
* * switch to deleteMany to delete existing Reminders upon edit/delete of post to satisfy prisma
* update wording in form toast for remindme bot usage
* update wording in the push notification sent
* transactional reminder inserts and expirein
* set expirein on @delete too
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* honor mutes when sending push notifications for:
* territory subscriptions
* mentions
* user subscriptions
Also, don't allow you to mute a subscribed user, or vice versa
* refactor mute detection for more code reuse
update mute/subscribe error messages for consistency
* variable rename
* move `isMuted` to shared user lib, reuse in user resolver and webpush
* update awards.csv
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* first pass of hashing user emails
* use salt
* add a salt to .env.development (prod salt needs to be kept a secret)
* move `hashEmail` util to a new util module
* trigger a one-time job to migrate existing emails via the worker
so we can use the salt from an env var
* move newsletter signup
move newsletter signup to prisma adapter create user with email code path
so we can still auto-enroll email accounts without having to persist the email address
in plaintext
* remove `email` from api key session lookup query
* drop user email index before dropping column
* restore email column, just null values instead
* fix function name
* fix salt and hash raw sql statement
* update auth methods email type in typedefs from str to bool
* remove todo comment
* lowercase email before hashing during migration
* check for emailHash and email to accommodate migration window
update our lookups to check for a matching emailHash, and then a matching
email, in that order, to accommodate the case that a user tries to login
via email while the migration is running, and their account has not yet been migrated
also update sndev to have a command `./sndev email` to launch the mailhog inbox in your browser
also update `./sndev login` to hash the generated email address and insert it into the db record
* update sndev help
* update awards.csv
* update the hack in next-auth to re-use the email supplied on input to `getUserByEmail`
* consolidate console.error logs
* create generic open command
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* Allow deletion of wallet logs
* Refactor wallet logs client<>server glue code
* Use variant='link' and className='text-muted fw-bold nav-link' for clear & cancel
There is a bug though: 'clear' stays highlighted after modal is closed
* Include wallet in toast
* Delete logs on logout
* Fix ugly wallet name in confirm dialog
* Fix clear still highlighted after modal closed
* Only delete client wallet logs
* Fix ugly wallet name in toast
* Fix bad search and replace
* Use Wallet object as constant
* Also delete LNC logs on logout
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* Support `is:bookmarked` search option to search my bookmarked items
* Update the worker search module to include `bookmarkedBy: Array<Number>` which
contains the list of user ids which have bookmarked a given item
* Add a trigger on the `Bookmark` DB table to re-index the corresponding item when
a bookmark is added/removed
* Update the Search resolver to check for a `is:bookmarked` query option. If provided,
include it as an option in the search request. This updates search to look for items
which are bookmarked by the current user. By default, this preserves stacker privacy
so you can only search your own bookmarks
* Update the search page UI to show how to invoke searching your own bookmarks
* undo `is:bookmarked` support, add `bookmarks` item in search select
* short circuit return empty payload for anon requesting bookmarks
* remove console.log for debugging
* fix indexing a new item that has yet to be bookmarked
* update db migration to re-index all existing bookmarked items one time
* fix the case where deleting a bookmark doesn't trigger a new index of items
explictly specify a `updatedAt` value when deleting a bookmark, to ensure that
deleting a bookmark results in a new indexed version of the bookmarked item
* update search indexer to use the latest of all three choices for the latest version
* give bookmark index jobs longer expiration
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* Also log autowithdrawal routing errors
* Only log autowithdrawal success in worker
* Use WalletType for WalletLog.wallet
* Fix autowithdrawal success message
* Infer walletName from walletType in upsertWallet
* Merge serializeInvoiceable with serialize
* Rename to verifyPayment
We already have a function named checkInvoice in the worker which can be confusing.
Also, we don't need to export this function.
* Use crypto.timingSafeEqual
* Fix missing unwrap for item creation and update
* Merge serializeInvoiceable with serialize
* Rename to verifyPayment
We already have a function named checkInvoice in the worker which can be confusing.
Also, we don't need to export this function.
* Use crypto.timingSafeEqual
* first pass of a mute mgmt page, ported from subscription mgmt page pr
* adjust error message for mutes
* muted users -> muted stackers
* fix typo in component name
* first pass of a subscription management page under settings
* add tabs to settings ui
* NymActionDropdown
* update Apollo InMemoryCache to merge paginated list of my subscribed users
* various updates
* switch from UsersNullable to Users
* bake the nym action dropdwon into the user component
* add back fields to the user query
* `meSubscriptionPosts`, `meSubscriptionComments`, `meMute`
* Refetch my subscribed users when a user subscription is changed
* update user list to hide stats in the subscribed list users
* update my sub'd users fragment to remove unnecessary user fields
* memoize subscribe user context provider value to avoid re-renders
* use inner join instead of left join
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* throw error when unauthenticated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* nwc wallet logs
* persist logs in IndexedDB
* Potential fix for empty error message
* load logs limited to 5m ago from IDB
* load logs from past via query param
* Add 5m, 1h, 6h links for earlier logs
* Show end of log
* Clamp to logStart
* Add log.module.css
* Remove TODO about persistence
* Use table for logs
* <table> fixes bad format with fixed width and message overflow into start of next row
* also using ---start of log--- instead of ---end of log--- now
* removed time string in header nav
* Rename .header to .logNav
* Simply load all logs and remove navigation
I realized the code for navigation was most likely premature optimization which even resulted in worse UX:
Using the buttons to load logs from 5m, 1h, 6h ago sometimes meant that nothing happened at all since there were no logs from 5m, 1h, 6h ago.
That's why I added a time string as "start of logs" so it's at least visible that it changed but that looked bad so I removed it.
But all of this was not necessary: I can simply load all logs at once and then the user can scroll around however they like.
I was worried that it would be bad for performance to load all logs at once since we might store a lot of logs but as mentioned, that's probably premature optimization.
WHEN a lot of logs are stored AND this becomes a problem (What problem even? Slow page load?), THEN we can think about this.
If page load ever becomes slow because of loading logs, we could probably simply not load the logs at page load but only when /wallet/logs is visited.
But for now, this works fine.
* Add follow checkbox
* Create WalletLogs component
* Embed wallet logs
* Remove test error
* Fix level padding
* Add LNbits logs
* Add logs for attaching LND and lnAddr
* Use err.message || err.toString?.() consistently
* Autowithdrawal logs
* Use details from LND error
* Don't log test invoice individually
* Also refetch logs on error
* Remove obsolete and annoying toasts
* Replace scrollIntoView with scroll
* Use constant embedded max-height
* Fix missing width: 100% for embedded logs
* Show full payment hash and preimage in logs
* Also parse details from LND errors on autowithdrawal failures
* Remove TODO
* Fix accidental removal of wss:// check
* Fix alignment of start marker and show empty if empty
* Fix sendPayment loop
* Split context in two
* first pass of disallowing certain APIs with API keys
Disallow the following APIs:
* item.act (zap)
* create withdrawal
* unlink auth method
* link unverified email
* disallow creating lnauths via API key to stop the flow of linking via lnauth
* undo the limitation on donating to rewards
* revert the assertion on createAuth
* assert no api key on createWithdrawal and sendToLNAddr
* incorporate PR feedback by adding API Key negative assertion to more mutations:
* `createInvite`
* `createAuth`
* `upsertWalletLND` by way of `upsertWallet`
* `upsertWalletLNAddr` by way of `upsertWallet`
* Add top cowboys, stackers, and spenders to newsletter
* Rearrange to match the issue title
* fix top spenders `by` variable
* Update user resolver for top users `spending` `by` value
* wrap in try catch to not have errors break the script execution
return the array as defined whenever an error occurs
* Handle archived territories in territory form
* Use dedicated mutation
* Add sanity check for eternal territories
* Fix fields and cost ignored
* Remove no longer needed manual validation in upsertSub
* Remove founder check
* Always check if sub is archived
Using { abortEarly: false } now since previously, if no description was not given, we wouldn't detect if the sub was archived since validation would abort on empty descriptions.
Only on submission all fields would get validated but since we ignore archived errors during submission, the user would never see that the sub is archived before submission
+ the wrong mutation would run if archived is not already true before submission.
Hence, we need to validate all fields always.
There is currently still a bug where the validation does not immediately run but maybe this can be fixed by simply using validateImmediately on the Formik component.
* Fix archived warning not shown after first render
* Only create transfers if owner actually changes
* Reuse helper functions in lib/territory.js
* Rename var to editing
* Use onChange instead of validation override
* Run same validation on server for unarchiving
* Fix 'territory archived' shown during edits
* Use && instead of ternary operator for conditional query
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* Generate API key in settings
* Check x-api-key for GraphQL API requests
* Don't fallback to cookie if x-api-key header was provided
* Select all session fields
* Fix error if API key not found
* Fix style in settings via form-label className
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* Ignore if sub belongs to user during existence check
* Remove code no longer needed
* Fix territory edit
Territory edits were broken because validation failed for existing territories and if you edit an territory, it obviously already exists.
This commit fixes this by ignoring the territory that we're currently editing.
* Fix existence check using stale cache
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* Don't hide self in top even if hidden
* Also don't hide self in top cowboys
* only use anon icon for anon stuff
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* Allow founders to transfer territories
* Log territory transfers in new AuditLog table
* Add territory transfer notifications
* Use polymorphic AuditEvent table
* Add setting for territory transfer notifications
* Add push notification
* Rename label from user to stacker
* More space between cancel and confirm button
* Remove AuditEvent table
The audit table is not necessary for territory transfers and only adds complexity and unrelated discussion to this PR.
Thinking about a future-proof schema for territory transfers and how/what to audit at the same time made my head spin.
Some thoughts I had:
1. Maybe using polymorphism for an audit log / audit events is not a good idea
Using polymorphism as is currently used in the code base (user wallets) means that every generic event must map to exactly one specialized event.
Is this a good requirement/assumption? It already didn't work well for naive auditing of territory transfers since we want events to be indexable by user (no array column) so every event needs to point to a single user but a territory transfer involves multiple users.
This made me wonder: Do we even need a table? Maybe the audit log for a user can be implemented using a view? This would also mean no data denormalization.
2. What to audit and how and why?
Most actions are already tracked in some way by necessity: zaps, items, mutes, payments, ...
In that case: what is the benefit of tracking these things individually in a separate table?
Denormalize simply for convenience or performance? Why no view (see previous point)? Use case needs to be more clearly defined before speccing out a schema.
* Fix territory transfer notification id conflict
* Use include instead of two separate queries
* Drop territory transfer setting
* Remove trigger usage
* Prevent transfers to yourself
* show placeholder for hidden stackers in top
* top rewardability views
* make territory revenue idependent job
* monthly rewards and leaderboard on rewards pages
* fix earn reschedule
* add query for rewards leaderboard
* reduce likelihood of rewards racing with views
* fix earn and refine values views
* Territory notifications
* Migrate old setting to new table
* Auto subscribe founders to their territories on creation
* Fix (un)subscribe not shown to founder
* Rename to toggleSubSubscription
* Fix inconsistency between toggleSubSubscription and toggleMuteSub
* Add dedicated button in header for following territories
* Don't drop noteTerritoryPosts column
* Fix db dip in Sub.meSubscription resolver
* Move territory subscribe to new territory context menu
* Decrease space between share icon and mute button
* Fix eslint
* add nterritories field to User
* add userSubs query
* show territories tab on user profiles
hide the tab if user has 0 territories, except when the
viewer navigated directly to the user's territories page
* add USER_WITH_SUBS query for user territories page
* add user territories page
* add poll expires at column to Item table
* update upsertPoll mutation for pollExpiresAt param
* use pollExpiresAt to show time left for poll
* correctly pluralize days for timeLeft
* correctly update pollExpiresAt when item is updated to remove poll expiration
* add DateTimePicker and DateTimeInput components to select datetimes
* update pollExpiresAt to be nullable and more than 1 day in the future
* hide time left text if poll has no expiration
* initialize pollExpiresAt with current value or default of 25 hours in the future
we add a one hour time buffer so that the user doesn't get a validation error
for pollExpiresAt if they post their poll within an hour from creation. there's
still a chance they'll hit the validation error but they should see the error
message toast
* add DateTimeInput into the options part of the poll form
add right padding to make room for the "clear" button.
allow field to be cleared (i.e. null pollExpiresAt) to allow
non-ending polls.
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* auto canceling bolt11s from lnd when auto dropped from DB
* auto canceling bolt11s from lnd when auto dropped from DB
* removed semicolon for lint
* changed cancleHodlInvoic to deletePayment function
* updated code to account for failed LND deletes
* linter fixes
* updated to only remove hashes and bolt11's from model when successfully deleted from LND
* updated to revert unsuccessful deletes from LND and add those values back into the db
* linter fix and renaming for clarity
* updated WITH query
* added if statement to account for invoices not returning from db
* fixed linter
* reverted docker-compose.yml
* made it dry
* made it dry
* added a comment because the query might be confusing
* made query moar dry
* Query formatting
* Fix query returns number of rows instead of rows
* updated to
* fixed linter
* removed lnbits dir
* removed gitignore and docker-compose.yml from pr
* added deleting from LND in wallet resolver
* linter + added missing import
* fixed merge conflict
* refine invoice deletion
---------
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* add subViewGroup function to create view to read sub stats from
* add topSubs resolver to graphql query
* add TOP_SUBS query fragment
* add SUB_SORTS for top territory sorting
* add custom cache policy for topSubs
* add territories to top header select
* add top territories page
* add db views for sub stats
* configure sub_stats views to refresh by worker
* filter rows with empty subName
* update msats_spent calculation to include all ItemAct in sub
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* add nsfw column to sub
* add nsfw boolean to territorySchema
* save nsfw value in upsertSub mutation
* return nsfw value from Sub query for correct value in edit territory form
* add nsfw checkbox to territory form
* add nsfw badge to territory header
* add nsfwMode to user
* show nsfw badge next to item territory
* exclude nsfw sub from items query
* show nsfw mode checkbox on settings page
* fix nsfw badge formatting
* separate user from current, signed in user
* update relationClause to join with sub table
* refactor to simplify hide nsfw sql
* filter nsfw items when viewing user items
* hide nsfw posts for logged out users
* filter nsfw subs based on user preference
* show nsfw sub name if logged out user is viewing the page
* show current sub at the top of the list instead of bottom
* always join item with sub to check nsfw
* check for sub presence before showing nsfw badge on item
* skip manually adding sub to select if sub is null
* fix relationClause to join with root item
* move moderation and nsfw into accordion
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
* improves ux for url only searches
* updates with sn nym
* add back original implementation when query has more than url: filter
* eliminates use of wildcards
* adds docs for testing search in a way that more closely resembles prod
* fixes lint issues
---------
Co-authored-by: utanapishtim <utnapishtim.utanapishtim@gmail.com>
It looks like a regression was introduced at some point, because
the `uri` that's compared against the `whitelist` is a regular
expression and not the url hostname + pathname as it was originally
written.
This brings back the original behavior of comparing the whitelist
against the hostname + pathname
* Use parallel invoice subscriptions
* Fix missing idempotency
* Log error
* Use cursor for invoice subscription
* Subscribe to outgoing payments for withdrawals
* Add TODO comments regarding migration to LND subscriptions
* Also use isPoll variable in checkInvoice
* Queue status check of pending withdrawals
* Use for loop to check pending withdrawals
* Reconnect to LND gRPC API on error
* Fix hash modified of applied migrations
* Separate wallet code from worker index
* refactor subscription code some more
* remove unnecessary subWrapper abstraction
* move all wallet related code into worker/wallet.js such that only a single import is needed in worker/index.js
* Migrate from polling to LND subscriptions
* Remove unnecessary reconnect code
* Add FIXME
* Add listener for HODL invoice updates
* Remove obsolete comment
* Update README
* Add job to cancel hodl invoice if expired
* Fix missing else
* small bug fixes and readability enhancements
* refine and add periodic redundant deposit/withdrawal checks
---------
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>