Commit Graph

14 Commits

Author SHA1 Message Date
71258e3736 Add Nostr event cache
This commit adds a simple in-memory Nostr Event cache, to reduce the
amount of bandwidth used as well as to improve performance.

Testing
-------

Setup:
  - Two iPhone simulators running Damus and on different accounts
  - Damus version: 774da239b92ed630fbf91fce42d9e233661c0d7f
  - Notepush: This commit
  - Push notifications turned on, setup to connect to localhost, and configured to receive DM notifications
  - Run Notepush with `RUST_LOG=DEBUG` env variable for debug logging
Steps:
1. Send a DM from one account to another.
  - Push notification should arrive with a few seconds delay
  - Push notification logs should mention that the event was cached
2. Send a DM again.
  - Push notification should arrive immediately
3. Wait for more than a minute
4. Send a DM again.
  - Push notification should take a few seconds again
  - Push notification logs should mention that the cache item expired and was deleted

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Closes: https://github.com/damus-io/notepush/issues/3
2024-08-05 18:01:52 -07:00
3ca3a83257 Add support to "only notifications from following" setting
Testing
-------

PASS

Devices: Mix of iPhone simulators and real devices
notepush: This commit
Damus: 4ea6c360e6e33747cb09ecf085049948ec1dadd1 (WIP change from GH issue #2360)
Setup:
  - Account A with push notifications enabled, DM notifications enabled,
    and "only notifications from following enabled"
  - Account A follows B but not C
Steps:
1. Send DM to A from B. Push notification appears
2. Send DM to A from C. Push notification does not appear

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Closes: https://github.com/damus-io/damus/issues/2360
2024-08-04 11:57:43 -07:00
c51f37e6ea Push notification preferences
This commit implements basic push notification preferences as well as
the interface to change them.

Furthermore, the API interface was reworked to follow better REST API
conventions.

Testing
--------

PASS

Device: iPhone 15 simulators
iOS: 17.5
Damus: 4ea6c360e6e33747cb09ecf085049948ec1dadd1 (A commit from GH issue #2360)
notepush: This commit
Steps:
1. Disable all types of notifications, except for DMs.
2. Send a like to this user's post. Push notification should not appear. PASS
3. Send a DM to this user's post. Push notification should appear. PASS

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-04 11:55:02 -07:00
d9f8f93e83 Do not send notifications about unsupported nostr event kinds
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 18:54:59 -07:00
ee79f04d24 Improve message formatting fallbacks
to something more user-friendly

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 18:49:01 -07:00
94778cdf70 Fix nostr event payload on custom data
Previously, the nostr event data was being transformed into
serde::Value, which is incompatible with the current notification
extension implementation. This commit fixes that by serializing it all
into a single JSON string

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 18:34:26 -07:00
73a7dc1e4a Reduce shared resource contention
This commit should drastically improve performance of the relay.

It reduces contention by removing the mutex on NotificationManager and
replacing it with several smaller mutexes for each shared resource, so
that more operations can happen concurrently.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 17:32:44 -07:00
697bd4eb83 Add more debug logging for better troubleshooting
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 16:49:30 -07:00
daa2408cfd Remove unused code to fix cargo warnings
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-08-02 10:24:25 -07:00
36cc9f8742 run cargo fmt --all
we should try to stick to rustfmt style, many editors save it like this
by default.

Signed-off-by: William Casarin <jb55@jb55.com>
2024-07-31 17:44:48 -07:00
e704f6e24c Make APNS client persistent across sends + better logging
Previously, the APNS client would be reinitialized in every send.
This commit makes it so that the client is initialized with the rest of
Notification manager, to avoid performance and token management issues.
2024-07-31 14:12:23 -07:00
1e591217c5 Web API interface
First implementation of the Web API interface, which can be used to
manage pubkey to APNS token relationships.
2024-07-31 14:11:42 -07:00
c0cded7255 Improve relay draft
This commit brings a compilable, runnable relay draft, with logging
setup, basic README instructions, Mutex protection around shared
resources, implemented with code safety in mind

Notes:
- This is not fully tested
- The mutex design is not the most efficient, and could cause some contention on high traffic
- The REST API is not yet integrated
2024-07-19 20:52:30 -07:00
e11c636ce3 Initial draft commit 2024-07-11 09:53:43 -07:00