1
0
mirror of git://jb55.com/damus synced 2024-09-16 02:03:45 +00:00
Commit Graph

19 Commits

Author SHA1 Message Date
William Casarin
579303f741 ndb: fix minor text search result bug 2023-12-04 14:51:58 -08:00
William Casarin
a07b78e47f ndb: add safemode so we don't instantly crash on bad dbs
Fixes: https://github.com/damus-io/damus/issues/1741
2023-12-04 13:26:24 -08:00
William Casarin
0a9ac9cb0d ndb: more dumb results building 2023-12-03 22:13:11 -08:00
William Casarin
9c3b052de2 ndb/note: always track note size, add to_owned 2023-12-03 22:12:31 -08:00
William Casarin
9502fc30ba ndb: add initial search interface
Still needs updating because of the tuple array
2023-12-02 15:05:15 -08:00
William Casarin
dd78272a5e Ndb: update to use new nostrdb config struct 2023-12-02 13:44:03 -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
William Casarin
a324523b85 ndb: new methods for profile fetched_at
This adds a few methods to Ndb for reading and writing fetched_at stats.
These are a way of tracking when we last tried to fetch profiles so that
we don't need to keep fetching them.
2023-10-23 10:44:54 +08:00
William Casarin
f591ad2dff ndb: add process_client_event helper
This is a quick helper for the new client event processing functionality
2023-09-24 17:06:35 -07:00
William Casarin
7a85ae29ca search: switch to nostrdb profile searching
Changelog-Changed: Switch to nostrdb for @'s and user search
2023-09-21 13:19:22 -04:00
William Casarin
fafe3b4b3e ndb: add nostrdb migrations 2023-09-21 09:10:06 -04:00
William Casarin
69c7acea76 tests: add ndb support to tests
stops it from crashing
2023-09-21 09:10:06 -04:00
William Casarin
22d635d850 ndb: don't verify flatbuffers in release builds 2023-09-21 09:10:06 -04:00
William Casarin
fc9b9f2940 ndb: switch profile queries to use transactions
this should ensure no crashing occurs when querying profiles
2023-09-21 09:10:06 -04:00
William Casarin
bb4fd75576 nostrdb: add profiles to nostrdb
This adds profiles to nostrdb

- Remove in-memory Profiles caches, nostrdb is as fast as an in-memory cache
- Remove ProfileDatabase and just use nostrdb directly

Changelog-Changed: Use nostrdb for profiles
2023-09-21 09:10:06 -04:00
William Casarin
984c7b6932 ndb: ensure profile flatbuffers are not copied
These are pointers into LMDB's virtual memory map of the database. No
copy required.
2023-08-28 08:00:45 -07:00
William Casarin
0bbc2c6348 ndb: save in documents instead of cache dir
This is more long term storage
2023-08-28 08:00:45 -07:00
William Casarin
caffa0398b nostrdb: profile flatbuffers in nostrdb working! 2023-08-26 20:46:42 -07:00
William Casarin
35b67dc08d nostrdb: initial Ndb class 2023-08-26 17:11:41 -07:00