1
0
mirror of git://jb55.com/damus synced 2024-09-05 21:03:51 +00:00
Commit Graph

2884 Commits

Author SHA1 Message Date
William Casarin
ff60f8a2db nostrdb/index: write kind index when processing notes
We have a kind index database now, so write to it when processing notes

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
bfd78c01ca nostrdb/refactor: move write id index to its own function
We will be writing more indices so I'm trying to clean this up a bit
before this function gets too messy

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
a2af030367 nostrdb/refactor: move profile index writing to its own function
Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
3c2e8b728f nostrdb/index: create kind+timestamp index database
We don't build the index yet, but create the database like the others.

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
8269ca59cd nostrdb/index: add u64_timestamp lmdb comparator
custom kind+timestamp comparison function. This is used by lmdb to
perform b+ tree searches over the kind+timestamp index.

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
0f9d55d4f9 nostrdb/debug: use mdb_strerror in more places
instead of codes

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
4109649dc2 nostrdb/filter: make sure we only match single chars
Without this, we could accidently match `pr` for `#p` filters

Fixes: 30ed801285dd ("filters: add initial filter interface")
Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
466dfcb7d7 nostrdb/filters: add initial filter interface
This adds a way to construct filters and match them against notes. This
will be used by our query interface in the future.

Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-02 13:44:03 -08:00
William Casarin
27905d24b4 cursor: add cursor_memset 2023-12-02 13:44:03 -08:00
7a5aef94a8 relays: Publish kind 10_002
Closes: https://github.com/damus-io/damus/pull/1783
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-12-01 09:58:07 -08:00
Jing维
9e4f0122f5 update testdata URL path
Closes: https://github.com/damus-io/damus/pull/1767
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-26 13:06:10 -08:00
ericholguin
a80ddc08ec settings: add media previews setting
Closes: https://github.com/damus-io/damus/pull/1757
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-23 10:57:23 -08:00
Daniel D’Aquino
6daa4f7e13 Add regional relays for Thailand and Germany.
This commit adds region-specific relays for Thailand and Germany. The list was blindly copied and pasted from the tickets.

Testing
-------

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: A locally modded version combining these changes with changes made in #1730 (A bit hacky, but makes testing faster)
Steps:
1. Change region to Canada. Only international relays should be shown in recommended relay list. PASS
2. Change region to Japan. International + Japanese relays should be shown in the recommended list. PASS
3. Repeat step (2) for Thailand and Germany. International + corresponding regional relays should be shown. PASS

Changelog-Added: Add regional relays for Thailand
Closes: https://github.com/damus-io/damus/issues/1698
Changelog-Added: Add regional relays for Germany
Closes: https://github.com/damus-io/damus/issues/1750
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-23 10:42:18 -08:00
ericholguin
9686f82e8f ux: only handle one qr code in an image and add copy functionality
Closes: https://github.com/damus-io/damus/pull/1758
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-22 12:52:25 -08:00
Daniel D’Aquino
a1e6be214e Migrate NostrDB files to shared app group file container
This change was made so that NostrDB data can be accessed from different build targets such as the notification service extension.

Upon initialization of NostrDB, it will check both DB file locations (the old documents directory, and the new shared app group container). If it sees the DB is present on the old location, and not on the new location, it will move the files to the new location. In any other condition it will keep the files intact to prevent data loss.

In order to avoid any conflicts between the damusApp's Ndb instance and the extension's Ndb instance when writing or moving the file, a new parameter called "owns_db_file" was added, and set to "false" for the extension. This ensures that the extension will not attempt to move DB files or create a new DB file on its own. Only the main app can move or create the DB file.

Testing
-------

PASS

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: This commit
Steps:
1. Run with the debugger attached to the extension target.
2. Using Apple's push notification testing dashboard, send a test push notification with a real payload (that includes the nostr event under `nostr_event`. Payload generated by strfry-push-notify).
3. Watch logs. It should show a message like "Got push notification from <DISPLAY_NAME>", where `DISPLAY_NAME` is the correct profile name of the user who generated the event. PASS

Regression testing
------------------

Device: iPhone 13 Mini (Real device)
iOS: 17.1.1
Damus: This commit
Other preconditions:
- Damus is at 1.6 (29) at the start of the test
- NostrDB filled with real data on the old location
Steps:
1. Flash (upgrade) the new Damus version (this commit) (This will be the first time upgrading, shared file container is empty)
2. Try to use the app normally. Scroll and navigate to several locations. Interact with some notes. App should be stable, work, and appear to have profile names already (i.e. It shouldn't start with a bunch of npubs in the place of profile names on known contacts). PASS
3. Downgrade back to the App store version (v1.6 (29))
4. Try to use the app normally. Scroll and navigate, interact, etc. App should work and be stable, but profile name cache is expected to be lost (i.e. shows npubs for a bit until profile is reloaded into NostrDB). PASS
5. Upgrade app again to the version in this commit.
6. Repeat step 2. Everything should work as normal and all profiles should be preloaded from the start. PASS

Closes: https://github.com/damus-io/damus/issues/1744
2023-11-21 10:39:27 -08:00
Daniel D’Aquino
87860a7151 Make NostrDB (and related) code build under the new extension target as well.
This change includes several source files related to NostrDB into the extension target as well, so that we can use it from that context (and thus enable more advanced push notification formatting and suppression)

To make this change possible, I had to split some source files as well as to move some functions to different files, to ensure we don't have to pull too much unnecessary code into the extension.

Testing
-------

PASS

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: This commit
Test steps:
1. Build DamusNotificationService. Should succeed. PASS
2. Build Damus (the app). PASS
3. Run app, scroll around some notes, go to a few different views, post a note. Should work as normal. PASS
2023-11-21 10:39:27 -08:00
Daniel D’Aquino
ad75d8546c Add experimental push notification support
I added support for the experimental push notifications feature. There are many improvements to be made, so this feature is currently opt-in only. If the user does not opt-in, their device tokens will not be sent out and thus they will receive no push notifications.

We should perform more testing on real-life staging environments before fully releasing this feature.

Testing
-------

Testing was done gradually during development.

Device: iOS simulators
iOS: 17
Damus version: A few different but recent prototypes
Rough coverage:
1. Checked that no device tokens are sent out when setting is off
2. Checked that I can successfully receive device tokens when feature is ON and set to localhost.
3. Checked sending test push notifications of types "note" (kind: 1), reaction (kind: 7) and DMs (kind 4) works and shows a generic but reasonable push notification message
4. Checked that clicking on the notifications above take the user to the correct screen

Closes: https://github.com/damus-io/damus/issues/67
Changelog-Added: Add experimental push notification support
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-20 10:32:33 -08:00
Daniel D’Aquino
878b1caa95 Fix onboarding post view not being dismissed
This commit fixes the issue where clicking "post" on the onboarding sheet does not dismisses itself under certain device/iOS combos.

The root cause is that the behavior of `dismiss` calls under a deeply nested view (i.e. not a direct subview of the sheet) is inconsistent depending on the device or iOS.

This fix does two things:
1. It upgrades the usage of `presentationMode` (which is deprecated) to the new `dismiss` API
2. It makes the onboarding sheet view (A direct subview of the sheet) to listen to signals from the post view and use that to also call `dismiss()`, which is explicitly supported by Apple in their docs (https://developer.apple.com/documentation/swiftui/environmentvalues/dismiss)

Testing
-------

PASS

Device: iPhone 13 mini (physical device)
iOS: 17.1
Damus: This commit (Local build, no local mods)
Setting: "Always show onboarding" is set to ON
Coverage:
1. Clicking "post" on onboarding post view publishes the post and dismisses the view. PASS
2. Clicking "cancel" on onboarding post view dismisses the view without publishing. PASS
3. Dragging the onboarding post view down dismisses the view without publishing. PASS
4. Making a normal post (I replied to a thread) still publishes the post and dismisses the normal post view sheet. PASS

Testing on other Device/iOS combos
---------------------------------

PASS

Preconditions:
- iPhone 15 Pro (simulator) on iOS 17.0.1
- iPhone SE 3rd gen (simulator) on iOS 16.4
Damus: This commit (Local build, no local mods)
Setting: "Always show onboarding" is set to ON
Coverage:
1. Clicking "post" on onboarding post view publishes the post and dismisses the view. PASS

Closes: https://github.com/damus-io/damus/issues/1726
Changelog-Fixed: Fix onboarding post view not being dismissed under certain conditions
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-20 08:35:37 -08:00
William Casarin
1fcbba5041 parser: fix url parse regression 2023-11-17 08:57:36 -08:00
William Casarin
20299615ba parser: always convert damus.io links to bech32 mentions
Update our note parse to always interpret damus.io links as bech32
mentions (nostr:npub...)

This means links will get converted to nostr: on post composition, and
if we ever see a link it will also get converted to nostr: visually

Changelog-Added: Always convert damus.io links to inline mentions
Fixes: https://github.com/damus-io/damus/issues/690
2023-11-17 08:09:28 -08:00
William Casarin
972a183ed8 damus-c: add cursor_skip helper
This is a cursor util for skipping over bytes
2023-11-17 08:07:53 -08:00
William Casarin
f976f23854 v1.6 (29)
Almost there!!!
2023-11-15 12:50:44 -08:00
William Casarin
cf13e1ca61 Actually fix camera descriptions 2023-11-15 12:48:56 -08:00
William Casarin
309cbaccce Manually update camera description translation
Just so we can get on the appstore.
2023-11-15 12:23:41 -08:00
William Casarin
d8640e2a1e Update Translations 2023-11-15 12:02:45 -08:00
William Casarin
bc330ab5de update nostrdb
to include potential ingester thread crash fix
2023-11-14 10:26:09 -08:00
William Casarin
41c76d9de0 tests: disable snapshot tests for now
Until they are working on macos and xcode cloud
2023-11-14 07:13:51 -08:00
William Casarin
eaaf802157 test: attempt to fix broken tests 2023-11-13 15:03:17 -08:00
William Casarin
bf59b5850c ci: remove xcode github action
We're using xcode cloud now which seems much more reliable
2023-11-13 15:02:00 -08:00
William Casarin
2585a375ab v1.6 (28) 2023-11-13 10:31:28 -08:00
William Casarin
29fa4ecf2e build: fix invalid function name 2023-11-13 10:31:28 -08:00
William Casarin
518fdffce9 ndb: potential fix for a crash in some nostrdb queries 2023-11-13 10:31:28 -08:00
William Casarin
289e051202 v1.6 (26) 2023-11-13 10:31:28 -08:00
Daniel D’Aquino
2a6c4d0b61 storage: Set more aggressive cache expiration values
I am setting the expiration values lower because it seems that the previous values were not keeping storage usage low enough.

Testing: Testing will be performed as a long-term test on Github issue #1689 (https://github.com/damus-io/damus/issues/1689)
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-11 20:23:37 -08:00
Daniel D’Aquino
386a28455a permissions: Update camera usage string to be more accurate
This changes the text that appears on the camera permission dialog, and makes it clear that camera access is also needed for the scanning of QR codes. This change was made to address a concern raised during the Apple app review process.

Testing
-------

PASS

Device: iPhone 13 Mini (physical)
iOS: 17.1
Damus: This commit
Special remarks: I locally modified the bundle identifier to be able to install a fresh copy of Damus from scratch and go through the prompt, without having to uninstall my own copy of Damus

Steps:
1. Install a fresh copy of Damus
2. On account creation, try to scan an nsec.
3. Make sure the camera usage prompt message is modified to the new string.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-11 20:23:34 -08:00
Daniel D’Aquino
b2e555284b Add "Always show onboarding suggestions" developer setting
This commit adds a new setting that can be used by developers to test onboarding suggestions without having to make local changes to code or reinstall the app.

Testing
-------

Device: iPhone 15 Pro (Simulator)
iOS: 17.0.1
Damus: This commit
Coverage:
1. Starting the existing app under the default setting does not show onboarding suggestions
2. Turning the setting ON causes the app to show onboarding suggestions on every app restart
3. Turning the setting back OFF causes the app to no longer show onboarding suggestions

Changelog-Added: Add "Always show onboarding suggestions" developer setting
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-11 20:23:29 -08:00
William Casarin
cc385d3c3f nostrdb: add migration to fix local japanese profile names 2023-11-02 14:17:17 +09:00
ericholguin
2895c374c0 fix: relay filter button fix
Closes: https://github.com/damus-io/damus/pull/1678
Tested-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-11-02 13:21:19 +09:00
William Casarin
6863e74c0f nostrdb: fix japanese profile names not loading
update flatcc, including the patch that fixes japanese usenames

Changelog-Fixed: Fix japanese profiles names not loading
2023-11-02 10:20:40 +09:00
William Casarin
280d889f25 v1.6 (25) changelog 2023-10-31 10:27:55 +09:00
William Casarin
d1d830fca1 v1.6 (25) 2023-10-31 10:26:12 +09:00
Daniel D’Aquino
d2bb013db7 relays: automatically load extra regional bootstrap relays
Depending on user's locale. currently only supported for Japanese users.

This change allows Japanese users to automatically connect with popular
Japanese regional relays during account creation, thus allowing Japanese
users to better connect with the Japanese Nostr community.

More specifically, 3 Japanese regional relays will be automatically
added to the user's relay list (on top of the usual relays) under the
following conditions:

1. User's region (As configured in iOS settings) is Japan, AND
2. The user is creating a new Nostr account through Damus.

In the case the Nostr account is not new, Damus will not add any
regional relays (It will respect the user's relay list).

Testing
-------

PASS

Device: iPhone 15 Pro (Simulator)
iOS: 17.0.1
Damus: This commit
Test steps:

1. With the US region set, install Damus
2. Go through onboarding and create a new account.
3. Once the onboarding is complete, look at the connected relays. Should only be connected with popular international relays. PASS
4. Uninstall Damus
5. On iOS settings, go to Location & Region settings and change the region to Japan.
6. Install Damus
7. Go through onboarding and create a new account.
8. Once the onboarding is complete, look at the connected relays. User should be connected with intl relays as well as Japanese relays. PASS
9. Quit Damus and restart
10. Ensure the Japanese relays are still on the list. PASS
11. Quit Damus
12. Change region back to US
13. Restart Damus and check the relay list. Relay list should not be affected. PASS
14. Reinstall Damus
15. Check relay list. Only intl relays should be shown. PASS
16. Change region to Japan (JP)
17. Restart Damus and check the relay list. Relay list should not be affected. PASS
18. Reinstall Damus
19. This time, login with a pre-existing account (One that is not connected to Japanese relays).
20. After onboarding, check relay list. The relay list should be unaffected (i.e. Japanese relays should not have been added since this account is pre-existing). PASS

Note: The actual network connection with some of the Japanese relays
failed, but that is likely due to the Geo-based IP restrictions imposed
by some of those Japanese relays. The relay list has been copied
verbatim from @mattn's suggestions.

Reference ticket: https://github.com/damus-io/damus/issues/1447

Changelog-Changed: Automatically load extra regional Japanese relays during account creation if user's region is set to Japan.
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-31 10:03:13 +09:00
ericholguin
c437a05ec0 ux: add long press to profile to navigate to profile page
Closes: https://github.com/damus-io/damus/pull/1665
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-30 11:59:13 +09:00
ericholguin
a2fdb61013 ui: change post view background to be all black
Closes: https://github.com/damus-io/damus/pull/1666
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-30 11:59:10 +09:00
ericholguin
4dd800e6b9 ui: make qrcode view font color white
Currently when in light mode the font is black which blends into the background
Changelog-Fixed: use white font color in qrcode view

Closes: https://github.com/damus-io/damus/pull/1653
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-30 11:59:07 +09:00
ericholguin
34c0728f21 ui: update the customize zap view
This PR updates the customize zap view by:

- replacing the old gradient button to the pink style
- show cursor on text field
- show textfield by default
- change custom zap grid to 4x2 instead of 3x3

Changelog-Changed: Updated customize zap view
Closes: https://github.com/damus-io/damus/pull/1656
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-30 11:58:36 +09:00
ericholguin
ec604664d8 ui: status view fixes for smaller screen devices
Changelog-Added: Tap to dismiss keyboard on user status view
Closes: https://github.com/damus-io/damus/pull/1652
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-27 09:21:43 +08:00
William Casarin
7710839261 noting: users are now notified when you quote repost them
Changelog-Changed: Users are now notified when you quote repost them
2023-10-27 09:02:05 +08:00
William Casarin
4389cc2128 load_profiles: add context for debugging
This is useful to see where the load_profiles request is coming from

We may need to switch to a central dispatch for profile loading, I
suspect there is a lot of redundancy between requests.
2023-10-24 13:02:41 +08:00
William Casarin
76508dbbfd perf: don't continuously attempt to fetch old profiles
Changelog-Changed: Save bandwidth by only fetching new profiles after a certain amount of time
2023-10-24 13:02:41 +08:00