Commit Graph

541 Commits

Author SHA1 Message Date
keyan b530b611f5 disable self sends in autowithdraw 2024-01-12 09:37:50 -06:00
keyan 1dae33312f allow territories to be renamed 2024-01-11 17:48:08 -06:00
keyan 86e8350994 autowithdraw to lightning address 2024-01-11 13:10:07 -06:00
ekzyis bdf9b1f0fd
Territory post notifications (#745)
* Notify founders of new posts

* Only merge notifications of same territory

* Show territory posts in /notifications

* Don't notify on own posts
2024-01-11 11:27:54 -06:00
ekzyis 39c9775c4c
Fix TypeError on item creation if JIT invoicing is used (#744)
* Fix TypeError on item creation if JIT invoicing is used

* Fix bad if body

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-10 19:24:49 -06:00
ekzyis 2151323c8d
Use LND subscriptions (#726)
* 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>
2024-01-08 16:37:58 -06:00
keyan 6495ce9454 keep citext cast from 8996fd0 2024-01-03 21:02:04 -06:00
keyan 26e0dd6f7e Revert "fix #703"
This reverts commit 8996fd085a.
2024-01-03 20:39:26 -06:00
keyan 8996fd085a fix #703 2024-01-03 16:12:33 -06:00
keyan 717f8d1ef6 territory billing notifications 2024-01-03 15:20:10 -06:00
keyan 76b63240db fix territory mutes for logged out 2023-12-30 19:45:41 -06:00
keyan 0999004646 mute territories in overflow 2023-12-30 19:41:16 -06:00
keyan f267137662 add muted section to territory select 2023-12-30 18:19:42 -06:00
keyan 214e863458 mute territories 2023-12-30 17:16:09 -06:00
keyan baee771d67 add gofacurself grace period 2023-12-30 17:15:21 -06:00
keyan dc15be914c opt-in moderation for territory founders 2023-12-29 18:05:16 -06:00
keyan 9698679d38 attempt another fix for #411 2023-12-28 14:44:56 -06:00
keyan 45e7503784 improve outlawed comment ux 2023-12-27 18:14:22 -06:00
keyan 6170853d72 unify idempotent act and act 2023-12-27 10:15:18 -06:00
keyan 73ad93f2bb idempotent zaps 2023-12-26 20:27:52 -06:00
keyan 374a7985da unify zap/downzap/bounty mutation 2023-12-26 16:51:47 -06:00
keyan 67a9fe23cf stablize act mutation reference 2023-12-26 15:55:48 -06:00
keyan 6633b9f894 don't bail if node is unannounced 2023-12-23 14:27:01 -06:00
keyan 01bc3dd752 catch query errors 2023-12-20 20:05:09 -06:00
st4rgut24 e9a5d22a6e
Add chain fees to price carousel (#658)
* add chain fees to price carousel

* restore check for valid carousel values

* add nym to contributors

---------

Co-authored-by: stargut <stargut@starguts-MacBook-Pro.local>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-12-20 16:06:22 -06:00
keyan 65744364f1 undo zap/downzap and improve downzap ux 2023-12-19 19:55:19 -06:00
keyan efd48afd61 auth updating note id 2023-12-19 12:31:24 -06:00
Austin Kelsay 5737027c0f
Nostr crossposting improvements (#629)
* Add nostr event id field to items

* crosspost-item

* crosspost old items, update with nEventId

* Updating noteId encoding, cleaning up a little

* Fixing item-info condition, cleaning up

* Linting

* Spacing nit

* Add createdAt variable back

* Change instances of eventId to noteId

* Adding upsertNoteId mutation

* Cleaning up updateItem, using toasts to communivate success/failure in crosspost-item

* Linting

* Fix type

* Move crosspost to share button, make sure only OP can crosspost

* Lint

* Simplify conditions

* user might have no nostr extension installed

Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>

* change upsertNoteId to updateNoteID for resolver and mutations, change isOp to mine, remove unused noteId params

* Use nostr.com for linking out with noteId

* lint

* add noopener to window.open call

* Simplify condition, throw GraphQLError

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>
2023-12-19 11:48:48 -06:00
keyan ee68bd2946 hide lnurlpay errors while still reporting errors accurately 2023-12-18 18:02:39 -06:00
keyan 13f3a89540 gofac node ip 2023-12-17 15:14:59 -06:00
ekzyis db36076541
Mix error messages to hide user balance (#693)
Co-authored-by: ekzyis <ek@stacker.news>
2023-12-17 13:25:20 -06:00
keyan d3fac7f968 fix qr withdrawal 2023-12-15 18:13:24 -06:00
keyan 71bbf34f36 remove unused param 2023-12-14 12:01:09 -06:00
keyan a5e50821b7 gofac yourself 2023-12-14 11:30:51 -06:00
keyan 6763ef7bf0 fix comment edit bug 2023-12-10 19:26:25 -06:00
keyan fbacf1ac63 fix changing subs with different fees 2023-12-10 17:42:30 -06:00
keyan ca02d627c1 make anon fees consistent 2023-12-10 16:56:22 -06:00
keyan 11e6a98bc7 prevent modification of billing type 2023-12-09 10:43:18 -06:00
keyan 0d5ef11b1e fix accidentally reporting deleted withdrawals 2023-12-08 19:21:46 -06:00
keyan aaa47e9b67 fix balance limit control logic 2023-12-05 10:17:45 -06:00
keyan 10203f565c territories 2023-12-04 21:34:06 -06:00
keyan f438b14df7 update balance limit error msg 2023-12-04 17:02:40 -06:00
keyan f31598d08d balance limit changes 2023-12-04 09:35:54 -06:00
keyan 80d49a7e57 limit limits 2023-11-22 10:30:43 -06:00
keyan 8e01568622 remove dead gql 2023-11-21 17:26:24 -06:00
keyan 47a5b311c3 refine mentions 2023-11-21 14:49:39 -06:00
SatsAllDay 4596681fbc
Toast on delete bot directive usage (#620)
* Toast on successful delete bot directive

* refactor duplicate code into a reusable function

* restore empty spacing lines to clean up the diff

* perf optimization, only query for deleteScheduledAt for your own items

* Issue a warning toast if the delete bot was mentioned but the item was not scheduled for deletion

* use bs-secondary color for warning

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-11-19 15:09:47 -06:00
keyan a318727f9c fix freebie dialog (#460) 2023-11-19 14:16:35 -06:00
keyan 589b15b597 fix custom dates to use ms since epoch 2023-11-14 10:23:44 -06:00
keyan 7b58edb77b reintroduce searching by most recent 2023-11-13 18:17:45 -06:00
keyan 84b5475270 fix custom range queries 2023-11-13 17:15:43 -06:00
keyan 7db70d0dfc more search refinements 2023-11-11 18:18:14 -06:00
keyan ca87bf56b3 improve related search querying 2023-11-11 17:56:20 -06:00
keyan 3499f92436 dramatically improve search 2023-11-10 09:22:30 -06:00
keyan 494b8b3dcd better organize user graphql types 2023-11-09 19:05:35 -06:00
rleed d86d8b3bac
Provide option to clear withdrawal invoices (#591)
* add settings option

* add auto-drop worker

* add manual delete option

* add warning and note

* cleanup

* incorporate most review feedback

* add warning to settings option

* remove debugging tweaks and simplify

* refine auto delete bolt11s

* refine UI

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-11-09 11:50:43 -06:00
rleed fb724ed9ec
escape postgres regex meta characters (#604)
Co-authored-by: rleed <rleed1@pm.me>
2023-11-08 18:25:36 -06:00
rleed 3a56782572
Custom date selector for more pages (#567)
* add custom range option to top items page

* add custom range option to profile page

* add date filter option to chart pages

* cleanup

* fix x-axis date labels

* date picker improvements

* enhancements to custom date selection

* remove unneeded condition

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-11-08 18:15:36 -06:00
ekzyis 8f590425dc
Image uploads (#576)
* Add icon to add images

* Open file explorer to select image

* Upload images to S3 on selection

* Show uploaded images below text input

* Link and remove image

* Fetch unsubmitted images from database

* Mark S3 images as submitted in imgproxy job

* Add margin-top

* Mark images as submitted on client after successful mutation

* Also delete objects in S3

* Allow items to have multiple uploads linked

* Overwrite old avatar

* Add fees for presigned URLs

* Use Github style upload

* removed upfront fees
* removed images provider since we no longer need to keep track of unsubmitted images on the client
* removed User.images resolver
* removed deleteImage mutation
* use Github style upload where it shows ![Uploading <filename>...]() first and then replaces that with ![<filename>](<url>) after successful upload

* Add Upload.paid boolean column

One item can have multiple images linked to it, but an image can also be used in multiple items (many-to-many relation).

Since we don't really care to which item an image is linked and vice versa, we just use a boolean column to mark if an image was already paid for.

This makes fee calculation easier since no JOINs are required.

* Add image fees during item creation/update

* we calculate image fees during item creation and update now
* function imageFees returns queries which deduct fees from user and mark images as paid + fees
* queries need to be run inside same transaction as item creation/update

* Allow anons to get presigned URLs

* Add comments regarding avatar upload

* Use megabytes in error message

* Remove unnecessary avatar check during image fees calculation

* Show image fees in frontend

* Also update image fees on blur

This makes sure that the images fees reflect the current state. For example, if an image was removed.

We could also add debounced requests.

* Show amount of unpaid images in receipt

* Fix fees in sats deducted from msats

* Fix algebraic order of fees

Spam fees must come immediately after the base fee since it multiplies the base fee.

* Fix image fees in edit receipt

* Fix stale fees shown

If we pay for an image and then want to edit the comment, the cache might return stale date; suggesting we didn't pay for the existing image yet.

* Add 0 base fee in edit receipt

* Remove 's' from 'image fees' in receipts

* Remove unnecessary async

* Remove 'Uploading <name>...' from text input on error

* Support upload of multiple files at once

* Add schedule to delete unused images

* Fix image fee display in receipts

* Use Drag and Drop API for image upload

* Remove dragOver style on drop

* Increase max upload size to 10MB to allow HQ camera pictures

* Fix free upload quota

* Fix stale image fees served

* Fix bad image fee return statements

* Fix multiplication with feesPerImage

* Fix NULL returned for size24h, sizeNow

* Remove unnecessary text field in query

* refactor: Unify <ImageUpload> and <Upload> component

* Add avatar cache busting using random query param

* Calculate image fee info in postgres function

* we now calculate image fee info in a postgres function which is much cleaner
* we use this function inside `create_item` and `update_item`: image fees are now deducted in the same transaction as creating/updating the item!
* reversed changes in `serializeInvoiceable`

* Fix line break in receipt

* Update upload limits

* Add comment about `e.target.value = null`

* Use debounce instead of onBlur to update image fees info

* Fix invoice amount

* Refactor avatar upload control flow

* Update image fees in onChange

* Fix rescheduling of other jobs

* also update schedule from every minute to every hour

* Add image fees in calling context

* keep item ids on uploads

* Fix incompatible onSubmit signature

* Revert "keep item ids on uploads"

This reverts commit 4688962abc.

* many2many item uploads

* pretty subdomain for images

* handle upload conditions for profile images and job logos

---------

Co-authored-by: ekzyis <ek@ekzyis.com>
Co-authored-by: ekzyis <ek@stacker.news>
2023-11-06 14:53:33 -06:00
ekzyis 64cf40a04c
Additionally compare user ids during bookmark privacy check (#587)
Co-authored-by: ekzyis <ek@stacker.news>
2023-10-25 13:04:13 -05:00
keyan a0216788b4 remove debug log message 2023-10-24 14:10:54 -05:00
keyan a85af82460 make rewards query less aggressive 2023-10-23 19:46:51 -05:00
keyan d2697477a0 saner lastSeenAt checking 2023-10-23 18:19:36 -05:00
keyan 53a8af8d20 improve delete bot ux 2023-10-23 17:55:48 -05:00
keyan 67ec82b6d9 disambiguate preimage after payment from hold preimage 2023-10-23 16:44:09 -05:00
keyan 3160a3f66f prevent redoing queries for notifications 2023-10-22 17:51:07 -05:00
keyan f9f13cc752 update checkedNotesAt when there are none 2023-10-22 17:38:24 -05:00
keyan 1a33c8778b hasnewnotes query cleanup 2023-10-22 12:47:46 -05:00
keyan 4d7d4c28f9 user new create_item and remove double check for replies 2023-10-22 12:19:11 -05:00
SatsAllDay 1d394bebe1
Ephemeral item support (#570)
backend impl and some of the UI for ephemeral item support

more to come, this is just a WIP so far

Consolidate client-side ephemeral fee logic in FeeButton components for easier reuse

* update the update_item function to handle the case where an item was not
ephemeral, but now is, so we charge the user accordingly

* introduce `hasDeleteCommand` for a better logical abstraction for some use cases in the code

* introduce `EPHEMERAL_FEE_SATS` which is derived from `EPHEMERAL_FEE_MSATS`, so we don't
have to the same calculation over and over

Remove fees for ephemeral items

* remove unused markdownField prop in FeeButton

* remove empty migration

minor code cleanup

Centralize delete item by author code to reduce duplication
2023-10-22 11:02:58 -05:00
rleed e713387920
migrate to ThreadSubscription model and enable self-unsubscribe (#569)
Co-authored-by: rleed <rleed1@pm.me>
2023-10-22 11:00:23 -05:00
SatsAllDay 56111efd6a
SN wallet transaction details (#550)
* display bolt11 info and preimage for invoices

* Remove preimage attempt for wdrwl, since it doesn't make sense

Other various code cleanup

* Only include preimage for confirmed paid and settled invoices
2023-10-20 19:25:22 -05:00
rleed 72b8b5b634
Attempt to get publication year when auto-titling links (#520)
* port date scraper from python

* bug fixes and cleanup

* bug fixes and cleanup

* refactor

* address comments

* make it intuitive

* Update timedate-scraper.js - lint

* address review comments

* cleanup

* simplfy and don't use side effects

---------

Co-authored-by: rleed <rleed1@pm.me>
2023-10-20 19:23:50 -05:00
Keyan ca9b60b0fb
Merge pull request #564 from SatsAllDay/ignore-own-comments-new-notes-thread-subscribe
hasNewNotes for your own comments in subscribed threads
2023-10-20 19:06:55 -05:00
Keyan 8bbd480ca3
Merge branch 'master' into fix-magic-numbers-in-update-item 2023-10-20 19:04:27 -05:00
keyan d73d3fda74 personal wot 2023-10-19 18:45:07 -05:00
Satoshi Nakamoto a6d3ca09e9 Don't include your own comments when determining if there are new thread
subscription replies for user hasNewNotes
2023-10-13 20:23:57 -04:00
ekzyis dcfcbfb0ad Refactor typeof check with isJob function 2023-10-13 22:37:41 +02:00
ekzyis 78745379aa Fix magic numbers in item update logic 2023-10-13 22:27:27 +02:00
Satoshi Nakamoto 0b8316d08c Don't create mentions when mentioning yourself
By extension, also don't send yourself a push notification when
mentioning yourself
2023-10-11 16:07:48 -04:00
Satoshi Nakamoto e9c0c06779 Various LUD-18 fixes
* Debounce the `onAddrChange` event handler when sending to a LN Address,
so we more accurately display the input form for LUD-12 and LUD-18 options

* Remove explicit URI encoding of Payer Data when sending to a LN Addr, since we're getting encoding for free via URLSearchParams

* Append `@stacker.news` to identifier values sent in payer data

* Don't do extra decoding when receiving LUD-18 data
2023-10-05 10:27:01 -04:00
keyan 0767b23d80 remove payer data encoding before going to db 2023-10-04 19:34:32 -05:00
SatsAllDay 502bfee072
Mention auto-complete (#532)
* uber rough first pass at mention autocompletes

* support custom limit on topUsers query

* hot keys for selecting user suggestion in markdown input

* query top stackers for mentions with no search query

* refactor UserSuggestion to help with reusability

textarea-caret for placing the user suggest dropdown appropriately

other various code cleanup items to make it easier to use

off by one errors are fun!

various code cleanup and reuse the UserSuggest component in InputUserSuggest to reduce duplication

* change default users to week query

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-10-04 15:10:56 -05:00
rleed 247744a83c
Add a date selector to the search function (#494)
* add date picker

* lint

* add date picker

* lint

* refine

* fix/finish the date picker UI part

* finish query parameter passing & incremental cleanup

* fix/finish the date picker UI part

* finish query parameter passing & incremental cleanup

* fix bad merge

* fix linting errors

* wrap for mobile

* add date picker

* lint

* add date picker

* lint

* refine

* fix/finish the date picker UI part

* finish query parameter passing & incremental cleanup

* fix/finish the date picker UI part

* finish query parameter passing & incremental cleanup

* fix bad merge

* fix linting errors

* wrap for mobile

* merge glitch?

* enhance a little

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-10-04 14:44:06 -05:00
SatsAllDay 362f95add9
LUD-18 Wallet implementation (#531)
* LUD-18 Wallet implementation

Query the lightning address provider client-side to learn of capabilities

Conditionally render LUD-12 and LUD-18 fields based on what the remote
server says is supported

Allow identifier, name, and email to be sent from the SN side during the withdrawal flow. Auth seems too complicated for our use case, and idk about pubkey?

* Clear inputs if the new ln addr provier doesn't support those fields

* various ux improvements

* dynamic client-side validation for required payer data

* don't re-init form state on error

* correct min and max amount values

* only send applicable data to graphql api based on payerdata schema

* input type for numeric values (amount, max fee)

* update step for amount and max fee

* Fix identifier optional and field blur

* reuse more code

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-10-03 18:22:56 -05:00
SatsAllDay 3acaee377b
LUD-18 Service Support (#518)
* first pass of LUD-18 support

* Various LUD-18 updates

* don't cache the well-known response, since it includes randomly generated single use values

* validate k1 from well-known response to pay URL

* only keep k1's for 10 minutes if they go unused

* fix validation logic to make auth object optional

* Various LUD18 updates

* move k1 cache to database

* store payer data in invoice db table

* show payer data in invoices on satistics page

* show comments and payer data on invoice page

* Show lud18 data in invoice notification

* PayerData component for easier display of info in invoice, notification, wallet history

* `payerData` -> `invoicePayerData` in fact schema

* Merge prisma migrations

* lint fixes

* worker job to clear out unused lnurlp requests after 30 minutes

* More linting

* Move migration to older

* WIP review

* enhance lud-18

* refine notification ui

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-10-03 14:35:53 -05:00
keyan 33c1adde3d use match_phrase_prefix instead 2023-10-02 19:56:54 -05:00
rleed 073fc6b848
allow seaching longer urls (#521)
Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-10-02 19:55:51 -05:00
keyan 62b53e1b3e make zoomable image fallback to link, fix styling, refine text component, search highlighting without remark-directive 2023-10-02 19:07:05 -05:00
ekzyis b2b38d8924
Images v2 (#513) 2023-10-01 18:03:52 -05:00
keyan 1f0a4e0729 50% speed up in notifications query with many items 2023-09-29 19:12:23 -05:00
keyan f2b1c321c2 make saloon muteable 2023-09-29 14:43:25 -05:00
keyan dfe859eb92 fix top user stack amount to only include tips 2023-09-28 16:26:06 -05:00
keyan c63ae3c515 fix whenClause in item queries 2023-09-28 16:25:02 -05:00
keyan 4bd489a36a mutes 2023-09-28 15:02:25 -05:00
keyan 683e06bab4 move push notification calls to their own file 2023-09-26 15:27:55 -05:00
keyan 32847670e2 reduce duplication of invoicable code 2023-09-26 15:15:09 -05:00
keyan 370e3c1c48 raise boost minimum to 25k, enhance editing boost, JIT fund editing costs 2023-09-25 19:54:35 -05:00
SatsAllDay 9c774d596b
Support JIT invoicing on donations to rewards pool (#515)
* Support JIT invoicing on donations to rewards pool

Now you can just-in-time fund your account to donate to SN's reward pool.

You can also donate without an account via the @anon account, also using
JIT invoices.

* Ensure donate amount is numeric

* Explicit error checking for hash being required for invoice validation

* let donation exceptions bubble for jit funding

---------

Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-09-24 14:38:37 -05:00
benthecarman a14341c742
Verify invoice amount in lightning address withdrawal (#501)
* Verify invoice amount in lightning address withdrawal

* Add benthecarman to contributors.txt
2023-09-23 20:21:40 -05:00