187 Commits

Author SHA1 Message Date
ekzyis
b9461b7eb3
Allow zapping, posting and commenting without funds or an account (#336)
* Add anon zaps

* Add anon comments and posts (link, discussion, poll)

* Use payment hash instead of invoice id as proof of payment

Our invoice IDs can be enumerated.
So there is a - even though very rare - chance that an attacker could find a paid invoice which is not used yet and use it for himself.
Random payment hashes prevent this.

Also, since we delete invoices after use, using database IDs as proof of payments are not suitable.
If a user tells us an invoice ID after we deleted it, we can no longer tell if the invoice was paid or not since the LN node only knows about payment hashes but nothing about the database IDs.

* Allow pay per invoice for stackers

The modal which pops up if the stacker does not have enough sats now has two options: "fund wallet" and "pay invoice"

* Fix onSuccess called twice

For some reason, when calling `showModal`, `useMemo` in modal.js and the code for the modal component (here: <Invoice>) is called twice.

This leads to the `onSuccess` callback being called twice and one failing since the first one deletes the invoice.

* Keep invoice modal open if focus is lost

* Skip anon user during trust calculation

* Add error handling

* Skip 'invoice not found' errors

* Remove duplicate insufficient funds handling

* Fix insufficient funds error detection

* Fix invoice amount for comments

* Allow pay per invoice for bounty and job posts

* Also strike on payment after short press

* Fix unexpected token 'export'

* Fix eslint

* Remove unused id param

* Fix comment copy-paste error

* Rename to useInvoiceable

* Fix unexpected token 'export'

* Fix onConfirmation called at every render

* Add invoice HMAC

This prevents entities which know the invoice hash (like all LN nodes on the payment path) from using the invoice hash on SN.

Only the user which created the invoice knows the HMAC and thus can use the invoice hash.

* make anon posting less hidden, add anon info button explainer

* Fix anon users can't zap other anon users

* Always show repeat and contacts on action error

* Keep track of modal stack

* give anon an icon

* add generic date pivot helper

* make anon user's invoices expire in 5 minutes

* fix forgotten find and replace

* use datePivot more places

* add sat amounts to invoices

* reduce anon invoice expiration to 3 minutes

* don't abbreviate

* Fix [object Object] as error message

Any errors thrown here are already objects of shape { message: string }

* Fix empty invoice creation attempts

I stumbled across this while checking if anons can edit their items.

I monkey patched the code to make it possible (so they can see the 'edit' button) and tried to edit an item but I got this error:

  Variable "$amount" of required type "Int!" was not provided.

I fixed this even though this function should never be called without an amount anyway. It will return a sane error in that case now.

* anon func mods, e.g. inv limits

* anon tips should be denormalized

* remove redundant meTotalSats

* correct overlay zap text for anon

* exclude anon from trust graph before algo runs

* remove balance limit on anon

* give anon a bio and remove cowboy hat/top stackers;

* make anon hat appear on profile

* concat hash and hmac and call it a token

* Fix localStorage cleared because error were swallowed

* fix qr layout shift

* restyle fund error modal

* Catch invoice errors in fund error modal

* invoice check backoff

* anon info typo

* make invoice expiration times have saner defaults

* add comma to anon info

* use builtin copy input label

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-11 18:50:57 -05:00
SatsAllDay
6e05cd38f9
Singular/Plural "Sats" labels (#380)
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-08 16:04:06 -05:00
keyan
9745b82d63 fix viewing stacker's bookmarks 2023-07-29 18:27:32 -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
keyan
8ab018af88 fix nested comment sorting 2023-07-25 19:45:35 -05:00
keyan
ab2046ab0b fix issues with new linting 2023-07-25 09:14:45 -05:00
keyan
59f7b6ff26 Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades""
This reverts commit 18910fa2ed470fe12ffbfb83df18e206101f0a05.
2023-07-23 10:08:43 -05:00
keyan
18910fa2ed Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"
This reverts commit d0314ab73c42ebf85fe2f418dddd681af45dbc55.
2023-07-23 09:16:12 -05:00
keyan
d0314ab73c shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades 2023-07-21 17:33:11 -05:00
keyan
3c711b6083 enhance image detection and proxy 2023-07-13 15:18:04 -05:00
Jo Wo
bf4b8714fe
Render images without markdown and use image proxy (#245)
* Parse image links during markdown rendering

* Use imgproxy to replace links

* Add healthcheck

See https://docs.imgproxy.net/healthcheck

* Enable WebP and animation support

* Only replace image URLs

* Replace all occurrences

* Fix creating posts with no text

* Embed image on link posts where link is image

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-12 19:10:01 -05:00
ekzyis
5e4dedad28
Add nym in reply notification (#349)
Co-authored-by: ekzyis <ek@stacker.news>
2023-07-07 08:45:44 -05:00
ekzyis
37e70f9791
Scroll to items on push notification click (#345)
* Scroll from root item in reach on notification click

Instead of going directly to the item of the notification, we now scroll from the root item which is still in reach to the comment.

This should provide more context to the user in most cases.

* Also scroll from root item in reach in /notifications

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-06 10:00:38 -05:00
keyan
a17b4d1f1a refine push notification ui and catch promises 2023-07-04 17:19:59 -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
3e4161ae8c tip -> zap 2023-06-19 13:21:55 -05:00
keyan
f0f51438c4 add top posts/comments to subs 2023-06-12 19:40:18 -05:00
keyan
369bd82a84 make freebie comments visible case by case 2023-06-03 20:01:50 -05:00
ekzyis
ace2a4df3b
Match any port in dupe check (#297)
Co-authored-by: ekzyis <ek@stacker.news>
2023-05-31 19:49:28 -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
0de134309c improve perf of rank view perf 2023-05-24 02:35:39 -05:00
keyan
28263bc6c7 rank views 2023-05-23 09:21:04 -05:00
keyan
2579a6b51c fix ranking function order operation in wild west mode 2023-05-09 15:07:23 -05:00
keyan
80968d7b35 let comments influence ranking 2023-05-09 13:52:35 -05:00
keyan
fbd746b023 fix auction ranking with query layers 2023-05-08 17:32:37 -05:00
keyan
67b815d9d6 preserve ordering in new layered item query 2023-05-08 15:06:42 -05:00
keyan
61d57056ed I dip you dip one db dip 2023-05-06 20:27:51 -05:00
keyan
1c608d42f4 denormalize votes 2023-05-06 18:53:10 -05:00
keyan
a97f8229b0 avoid extra dip when getting users 2023-05-06 18:18:18 -05:00
keyan
347a6a54d2 improve comment performance 2023-05-06 16:51:17 -05:00
keyan
3d4d86a40a simplify item queries with subs 2023-05-05 13:06:53 -05:00
keyan
abd9555792 fix recent comments 2023-05-04 19:20:48 -05:00
keyan
a241d683d8 nostr sub 2023-05-01 15:58:30 -05:00
keyan
e4a3095cb4 give pinned item recent sort by default 2023-03-19 10:43:33 -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
4cae1ae230 reuse validation on server 2023-02-08 13:39:53 -06:00
keyan
36ddb25b46 remove extra queries 2023-02-03 18:08:08 -06:00
keyan
291fe24363 denormalize bountyPaidTo 2023-01-26 17:28:10 -06:00
keyan
80f04b5a28 remove expensive query 2023-01-26 15:00:45 -06:00
keyan
d8e3e73def check for rootId 2023-01-26 13:37:51 -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
ceac96e149 dup /live variation of youtube link 2023-01-24 08:37:33 -06:00
keyan
29c59d93ea open timestamps 2023-01-22 14:17:50 -06:00
keyan
71e61e51e8 fix youtube dupe regex 2023-01-13 17:42:40 -06:00
keyan
9c0ead308b remove debug logging 2023-01-13 13:19:42 -06:00
keyan
10ff3fa1c3 delete 2023-01-13 11:52:18 -06:00