Commit Graph

156 Commits

Author SHA1 Message Date
SatsAllDay 94fbabcdf9
Notifications for when you are forwarded sats from a post (#467)
* Notifications for when you are forwarded sats from a post

Support notifications when a post for which you are forwarded gets zapped

This is controlled by a new boolean flag in user settings

* Send push notifications to forwarded users when they get forwarded sats

* Add `Promise.allSettled` per PR feedback

* Remove `FEE` act type when building forwarded zaps notifications

Don't include `FEE` actions, only `TIP` actions to avoid "0 sats forwarded" notifications

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-09-12 10:31:46 -05:00
rleed 2ba969ebab
Add new visitor welcome banner (#418)
* add new visitor welcome banner

* show dismissible banner on first-time login

* add mutation to hide welcome banner

* Update components/banners.js

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

* fix error handling

* simplifications and other review suggestions

* cleanup

* restore selective display logic

* remove unnecessary query arguments

* cleanup a bit more

* don't show welcome banner to existing stackers

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: ekzyis <27162016+ekzyis@users.noreply.github.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-09-11 16:29:45 -05:00
ekzyis ac45fdc234
Use HODL invoices (#432)
* Use HODL invoices

* Fix expiry check comparing string with Date

* Fix unconfirmed user balance for HODL invoices

This is done by syncing the data from LND to the Invoice table.

If the columns is_held and msatsReceived are set, the frontend is told that we're ready to execute the action.

We then update the user balance in the same tx as the action.

We need to still keep checking the invoice for expiration though.

* Fix worker acting upon deleted invoices

* Prevent usage of invoice after expiration

* Use onComplete from <Countdown> to show expired status

* Remove unused lnd argument

* Fix item destructuring from query

* Fix balance added to every stacker

* Fix hmac required

* Fix invoices not used when logged in

* refactor: move invoiceable code into form

* renamed invoiceHash, invoiceHmac to hash, hmac since it's less verbose all over the place
* form now supports `invoiceable` in its props
* form then wraps `onSubmit` with `useInvoiceable` and passes optional invoice options

* Show expired if expired and canceled

* Also use useCallback for zapping

* Always expire modal invoices after 3m

* little styling thing

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-08-30 21:48:49 -05:00
SatsAllDay 0d4a225442
Subscribe to a user (#443)
* First pass of user subscriptions

* add new db model to track subscriptions
* update user typedef and api resolver for subscription state
* add subscribe action to user profile page
* add mutation to subscribe to a user

* Update notifications queries, hasNewNotes queries for FollowActivity note type

* Only show items that have been created since subscribing to the user

* Send push notifications to user subscribers for posts and comments

* Rename item dropdown to action dropdown and re-use for item info and user actions

* Don't allow self-follows

* Add index on followee for faster lookups

* Don't show subscribe action if not logged in

* small style enhance

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-28 20:27:56 -05:00
keyan a847b16b2c make item creation easier 2023-08-25 13:42:55 -05:00
SatsAllDay 3da395a792
multiple forwards on a post (#403)
* multiple forwards on a post

first phase of the multi-forward support

* update the graphql mutation for discussion posts to accept and validate multiple forwards

* update the discussion form to allow multiple forwards in the UI

* start working on db schema changes

* uncomment db schema, add migration to create the new model, and update create_item, update_item
stored procedures

* Propagate updates from discussion to poll, link, and bounty forms

Update the create, update poll sql functions for multi forward support

* Update gql, typedefs, and resolver to return forwarded users in items responses

* UI changes to show multiple forward recipients, and conditional upvote logic changes

* Update notification text to reflect multiple forwards upon vote action

* Disallow duplicate stacker entries

* reduce duplication in populating adv-post-form initial values

* Update item_act sql function to implement multi-way forwarding

* Update referral functions to scale referral bonuses for forwarded users

* Update notification text to reflect non-100% forwarded sats cases

* Update wallet history sql queries to accommodate multi-forward use cases

* Block zaps for posts you are forwarded zaps at the API layer, in addition
to in the UI

* Delete fwdUserId column from Item table as part of migration

* Fix how we calculate stacked sats after partial forwards in wallet history

* Exclude entries from wallet history that are 0 stacked sats from posts with 100% forwarded to other users

* Fix wallet history query for forwarded stacked sats to be scaled by the fwd pct

* Reduce duplication in adv post form, and do some style tweaks for better layout

* Use MAX_FORWARDS constants

* Address various PR feedback

* first enhancement pass

* enhancement pass too

---------

Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-08-23 17:44:17 -05:00
SatsAllDay ee3f892053
Add new user setting to hide bookmarks from other users (and anon) (#424)
* Add new setting to hide bookmarks from other users (and anon)

* Optional chaining in case user doesnt exist, and avoid duplicate sql query in some cases
2023-08-23 15:29:55 -05:00
ekzyis 670c567bff
Configure imgproxy timeouts + add click to load on imgproxy errors (#404)
* Configure imgproxy timeouts

* Use click to load on imgproxy errors

* Add setting for click to load

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-08-15 12:55:16 -05:00
keyan e913ab71ad more even rewards 2023-08-09 22:27:03 -05:00
ekzyis 7369bd819d
Add nostr login (#367)
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-07 19:50:01 -05:00
keyan ffb856ae88 fix oauth signup 2023-08-07 15:05:55 -05:00
keyan 5232b59625 upgrade to next-auth 4 (bonus: improve error pages) 2023-07-29 14:38:20 -05:00
keyan 7542dd6cc4 upgrade to prisma 4 2023-07-26 19:18:42 -05:00
keyan 672853a7ea upgrade to prisma 3 2023-07-26 11:01:31 -05:00
ekzyis 0d3328e509
Show longest cowboy streak in profile (#353)
* Show longest cowboy streak in profile

* Fix image offset

* Initialize maxStreak for every user

* Use resolver instead of denormalization for maxStreak

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-12 19:10:29 -05:00
ekzyis 388e00dd04
Service worker rework, Web Target Share API & Web Push API (#324)
* npm uninstall next-pwa

next-pwa was last updated in August 2022.
There is also an issue which mentions that next-pwa is abandoned (?): https://github.com/shadowwalker/next-pwa/issues/482

But the main reason for me uninstalling it is that it adds a lot of preconfigured stuff which is not necessary for us.
It even lead to a bug since pages were cached without our knowledge.

So I will go with a different PWA approach. This different approach should do the following:
- make it more transparent what the service worker is doing
- gives us more control to configure the service worker and thus making it easier

* Use workbox-webpack-plugin

Every other plugin (`next-offline`, `next-workbox-webpack-plugin`, `next-with-workbox`, ...) added unnecessary configuration which felt contrary to how PWAs should be built.
(PWAs should progressivly enhance the website in small steps, see https://web.dev/learn/pwa/getting-started/#focus-on-a-feature)

These default configurations even lead to worse UX since they made invalid assumptions about stacker.news:
We _do not_ want to cache our start url and we _do not_ want to cache anything unless explicitly told to.
Almost every page on SN should be fresh for the best UX.

To achieve this, by default, the service worker falls back to the network (as if the service worker wasn't there).

Therefore, this should be the simplest configuration with a valid precache and cache busting support.

In the future, we can try to use prefetching to improve performance of navigation requests.

* Add support for Web Share Target API

See https://developer.chrome.com/articles/web-share-target/

* Use Web Push API for push notifications

I followed this (very good!) guide: https://web.dev/notifications/

* Refactor code related to Web Push

* Send push notification to users on events

* Merge notifications

* Send notification to author of every parent recursively

* Remove unused userId param in savePushSubscription

As it should be, the user id is retrieved from the authenticated user in the backend.

* Resubscribe user if push subscription changed

* Update old subscription if oldEndpoint was given

* Allow users to unsubscribe

* Use LTREE operator instead of recursive query

* Always show checkbox for push notifications

* Justify checkbox to end

* Update title of first push notification

* Fix warning from uncontrolled to controlled

* Add comment about Notification.requestPermission

* Fix timestamp

* Catch error on push subscription toggle

* Wrap function bodies in try/catch

* Use Promise.allSettled

* Filter subscriptions by user notification settings

* Fix user notification filter

* Use skipWaiting

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-04 14:36:07 -05:00
keyan 747371a4e4 snl live banner 2023-06-20 09:57:06 -05:00
ekzyis 0c251ca376
Add thread subscriptions (#293)
* Add thread subscriptions

* remove dead code: reply only notifications

* break out thread subscription queries to reduce search space

* one db dip for item lists/threads re:meSubscription

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-05-31 19:44:06 -05:00
keyan f6ab939bcc use mat views (tm) for historicals (tm) 2023-05-19 17:38:39 -05:00
keyan 80968d7b35 let comments influence ranking 2023-05-09 13:52:35 -05:00
keyan 1c608d42f4 denormalize votes 2023-05-06 18:53:10 -05:00
keyan e2aceee234 higher tip defaults 2023-05-06 18:29:20 -05:00
keyan 4be5286122 hide cowboy hat setting 2023-05-01 16:52:02 -05:00
keyan a241d683d8 nostr sub 2023-05-01 15:58:30 -05:00
keyan 9afbe0abd8 enhance item related query perf 2023-02-24 10:35:05 -06:00
ekzyis 7b838cdeb2
Implement bookmarking of posts and comments (#235) 2023-02-16 16:23:59 -06:00
keyan 30cde2ea38 fix nip57? 2023-02-15 11:20:43 -06:00
keyan 3a9994a9a6 denormalize user streak to avoid extra dip 2023-02-03 14:40:30 -06:00
keyan 072e60c954 streaks 2023-02-01 17:40:49 -06:00
keyan 291fe24363 denormalize bountyPaidTo 2023-01-26 17:28:10 -06:00
keyan 5306b11157 improve bounty performance 2023-01-26 13:09:57 -06:00
Austin Kelsay e13e37744e
stackernews bounties (#227)
bounties
2023-01-26 10:11:55 -06:00
keyan 29c59d93ea open timestamps 2023-01-22 14:17:50 -06:00
keyan 9644a9f867 slashtags auth 2023-01-18 12:49:20 -06:00
keyan 10ff3fa1c3 delete 2023-01-13 11:52:18 -06:00
keyan 2d012ba7fe allow nip05 for users 2023-01-06 18:53:29 -06:00
keyan 41226245c5 referrals 2022-12-19 16:27:52 -06:00
keyan 7b7ed0047c turbo tipping 2022-12-09 13:25:38 -06:00
keyan e1bdb9c769 donations to rewards 2022-12-07 18:04:02 -06:00
keyan a2db3e18b4 better user analytics mostly 2022-12-01 15:31:04 -06:00
keyan 5746160893 let tips affect ranking 2022-11-23 12:12:09 -06:00
keyan 1bf747c7c0 sats to msats 2022-11-16 10:57:03 -06:00
keyan 9431469453 more indices 2022-11-16 10:57:03 -06:00
ekzyis 2dd4b1ce98
Merge branch 'master' into 103-add-other-currencies 2022-10-04 01:01:43 +02:00
keyan d9d426e5c3 add freebies 2022-09-27 16:19:15 -05:00
keyan 7faae425b3 wild west mode 2022-09-21 14:57:36 -05:00
keyan 08893d020c improved earning: more detail, longer top tail 2022-09-14 17:01:30 -05:00
ekzyis 5d4abecf3c Add input for fiat currency in settings 2022-09-13 02:02:55 +02:00
keyan 6aeeb40623 denormalize item sats, comment sats, last comment time, and num comments 2022-09-01 15:28:19 -05:00
keyan 172d6c3c2f optionally hide invoice descriptions 2022-08-30 16:50:47 -05:00
keyan ddb4a30c4b spam fees 2022-08-11 15:38:10 -05:00
keyan 7cf5396ef3 remove free comments 2022-08-06 17:03:57 -05:00
keyan 82280b0966 add polls 2022-07-30 08:51:04 -05:00
keyan cb313429d5 job board enhancements 2022-07-21 17:55:05 -05:00
keyan 9d3c52ed00 improve trust 2022-07-05 14:51:13 -05:00
keyan 35b533c572 denormalize ranking metrics 2022-05-17 14:54:12 -05:00
keyan 29fb37b763 profile photos 2022-05-16 15:51:22 -05:00
keyan 9abc41b7b2 image uploading backend 2022-05-12 13:44:21 -05:00
keyan e2409efbaf indicate to user when there are new jobs 2022-05-09 13:01:23 -05:00
keyan 188230c37c add notification settings 2022-04-21 17:50:02 -05:00
keyan 2b594109ea WIP forward 2022-04-18 15:19:07 -05:00
keyan bc9f602d13 up default tip to 10 2022-04-12 16:09:12 -05:00
keyan c284e18278 denormalize stacked count 2022-04-04 16:54:31 -05:00
keyan 5ff856d061 earning 2022-03-17 15:13:19 -05:00
keyan 8c513e93c8 record sats spent on auction items 2022-03-16 11:35:51 -05:00
keyan 46f552b803 store last time user visited so we can guage retention 2022-03-14 11:43:21 -05:00
keyan 3f59d02c91 more indices 2022-03-10 13:26:35 -06:00
keyan 7997085813 add more indices to item 2022-03-10 13:17:30 -06:00
keyan a627322220 add job company and location 2022-03-07 15:50:13 -06:00
keyan 1472de0f91 sats/mo -> sats/min on jobs 2022-03-07 13:30:21 -06:00
keyan 1b84f76a27 make jobs expensive, priced based ranking rather than auction 2022-03-03 12:56:02 -06:00
keyan 3fb7ab9cd7 fix integer overflow 2022-02-26 15:42:38 -06:00
keyan 1338c026a3 create worker for auction ranking 2022-02-25 11:34:09 -06:00
keyan b954186d31 jobs w/o payments yet 2022-02-24 13:05:57 -06:00
keyan 7903dbdaf3 WIP trust 2022-01-14 17:43:12 -06:00
keyan ccc1251f7e drop theme from users table 2022-01-14 11:42:45 -06:00
keyan c3e6627cea support pinned posts + recurring pins 2022-01-07 10:32:31 -06:00
keyan 435f32ac09 redo tipping, removing modal, adding walkthrough, setting tipping default to 1 2021-12-13 13:49:34 -06:00
keyan 4d3ab603da tip walkthrough 2021-12-09 14:41:09 -06:00
keyan 3bbf3f7470 add dark mode 2021-11-04 19:07:41 -04:00
keyan b8080137a8 lnurl-withdrawal support 2021-10-28 14:59:53 -05:00
keyan 09c4883366 invite model 2021-10-12 15:40:30 -05:00
keyan 4d1b8bb11e add index to created_at columns 2021-10-06 07:43:32 -07:00
keyan e7787e3e67 WIP bios 2021-09-23 12:42:00 -05:00
keyan e4c1c2f1e1 refine tipping 2021-09-12 11:55:38 -05:00
keyan 3f8b5894cb small clean up 2021-09-09 14:10:15 -05:00
keyan 93428e3183 tips WIP 2021-09-08 16:51:23 -05:00
keyan 28d684da73 workout tips functions etc 2021-09-08 16:15:06 -05:00
keyan 38ba31f2b4 case insensitive names 2021-09-02 17:22:00 -05:00
keyan 3370675d61 db portion of mentions 2021-08-18 17:20:33 -05:00
keyan 14e929b3f0 allow retries of failed withdraw invoice while enforcing uniqueness of pending/confirmed 2021-07-10 09:16:40 -05:00
keyan 2e26e421e7 lnurl-auth 2021-06-26 22:09:39 -05:00
keyan 01922e4b88 notifications done 2021-06-24 18:56:01 -05:00
keyan 17a79b2251 prepare for deployment 2021-06-02 10:23:30 -04:00
keyan 80ff13abd6 finish mvp 2021-05-24 19:08:56 -05:00
keyan a9ea341a7b create reserved usernames 2021-05-21 19:09:11 -05:00
keyan 8a462252af force unique user name 2021-05-21 14:34:40 -05:00
keyan 157488ea5d make withdrawls mostly work 2021-05-13 16:19:51 -05:00
keyan d92fc12187 half done with wallets 2021-05-12 18:04:19 -05:00
keyan bc0389e622 invoiced ... WIP transactions 2021-05-11 10:52:50 -05:00