Commit Graph

16 Commits

Author SHA1 Message Date
ekzyis b379e7467f
Territory transfers (#878)
* 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
2024-03-05 13:56:02 -06:00
ekzyis f450a00073 Fix logged title 2024-01-14 21:14:14 +01: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 df1edd5b79
Fix push notification counting on iOS devices (#739)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-10 09:25:30 -06:00
ekzyis 045ba28c41
Remove logging to browser (#733)
* Don't log to browser console

* Don't log options (too verbose)

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-04 13:53:52 -06:00
ekzyis 562b243111
Fix usage of hardcoded strings for sw message types (#730)
Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 14:02:01 -06:00
ekzyis 31cef5a7b7
Only close notifications manually on iOS (#729)
* Only close notifications manually on iOS

* Use function instead of hardcoded string

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-01-03 11:56:29 -06:00
ekzyis ade35b9ea0
Add verbose logging in onPush listener (#724)
* refactor: Use log function in service worker

* Add verbose logging on push listener

* Fix TypeError: Cannot read properties of null (reading 'postMessage')

navigator.serviceWorker.controller is null on forced refreshes:

"""
This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
"""

-- https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller

This means when we unregister a service worker manually (like I do for debugging purposes) and then reload the page, there is no service worker available when this code is run.

Adding a check with a more helpful error message should improve UX.

This error might also happen in other cases where a page refresh should also help.

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-01-03 11:51:04 -06:00
ekzyis 7f512d6adb
Fix silent push due to missing tag support in Safari on iOS (#719)
* Merge notifications manually without relying on tag

* Use tag as argument

* Fix title and undefined sats in DEPOSIT push notification

* Remove wrong comment

* Fix wrong var used for tag check

* Also immediately display STREAK notifications

* Close all notifications with same tag manually before

* Fix merge of DEPOSIT notifications

* Remove unused tag from reduce argument

* Remove FIXME(iOS) comment

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-29 18:04:07 -06:00
keyan 9698679d38 attempt another fix for #411 2023-12-28 14:44:56 -06:00
ekzyis 0b872cbbe7
Only resubscribe on compatible old subscriptions (#616)
This change makes resubscriptions backwards compatible by only running the new resubscribe code if the old push subscription was saved under service worker version 2.

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-08 18:18:41 -06:00
SatsAllDay 522c821c89
Notification badges (#595)
* First pass of implementing Badging API for notifications

* Only show app badge when driven from push notifications

* Display number of unread push notifications instead of just an empty badge

Clear badge via postMessage when notifications page is loaded

* de-dupe some code, update badge counter on each notification click

* remove ids, track open note count instead

* restore optional chaining

* ensure note count doesn't go below 0, and fix event.waitUntil error when clearing badge

* incorporate PR feedback
2023-11-08 18:17:01 -06:00
ekzyis 5dfeb700bc
Resubscribe if service worker lost push subscription (#597)
* Also delete push subscription in IndexedDB

* Fix pushsubscriptionchange function signature

* Send SYNC_SUBSCRIPTION after successful registration

* Resubscribe if service worker lost subscription

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-05 15:08:44 -06:00
ekzyis 7040dbfce6
Fix missing merge of FOLLOW push notifications (#596)
* Use consistent lowercase titles

* Fix missing merge of FOLLOW push notifications

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-11-05 15:06:38 -06:00
ekzyis eeaf2d5cf6
Fix FORWARDEDTIP change lost in serviceworker (#582)
Co-authored-by: ekzyis <ek@stacker.news>
2023-10-24 11:27:59 -05:00
ekzyis dd36155b04
Fix duplicate push notifications on item edit if mentioned (#563)
* Refactor service worker event listeners into own file

* Refactor service worker onPush listener

* Only show one MENTION push notification per item

* Update index.js to have newline

---------

Co-authored-by: ekzyis <ek@ekzyis.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2023-10-20 19:21:44 -05:00