-
Notifications
You must be signed in to change notification settings - Fork 74
Add contacts API #2817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rygine
wants to merge
7
commits into
main
Choose a base branch
from
rygine/contacts-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add contacts API #2817
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| use super::*; | ||
| use xmtp_proto::xmtp::device_sync::{backup_element::Element, contact_backup::ContactSave}; | ||
|
|
||
| #[xmtp_common::async_trait] | ||
| impl BackupRecordProvider for ContactSave { | ||
| const BATCH_SIZE: i64 = 100; | ||
| async fn backup_records<D>( | ||
| state: Arc<BackupProviderState<D>>, | ||
| ) -> Result<Vec<BackupElement>, StorageError> | ||
| where | ||
| Self: Sized, | ||
| D: DbQuery, | ||
| { | ||
| let cursor = state.cursor.load(Ordering::SeqCst); | ||
| let batch = state.db.contacts_paged(Self::BATCH_SIZE, cursor)?; | ||
|
|
||
| let records = batch | ||
| .into_iter() | ||
| .map(|record| BackupElement { | ||
| element: Some(Element::Contact(record.into())), | ||
| }) | ||
| .collect(); | ||
|
|
||
| Ok(records) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
xmtp_db/migrations/2025-12-28-000000_create_contacts/down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| -- Drop FTS triggers first | ||
| DROP TRIGGER IF EXISTS contact_addresses_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_addresses_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_addresses_fts_insert; | ||
| DROP TRIGGER IF EXISTS contact_aliases_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_aliases_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_aliases_fts_insert; | ||
| DROP TRIGGER IF EXISTS contact_wallet_addresses_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_wallet_addresses_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_wallet_addresses_fts_insert; | ||
| DROP TRIGGER IF EXISTS contact_urls_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_urls_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_urls_fts_insert; | ||
| DROP TRIGGER IF EXISTS contact_emails_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_emails_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_emails_fts_insert; | ||
| DROP TRIGGER IF EXISTS contact_phone_numbers_fts_delete; | ||
| DROP TRIGGER IF EXISTS contact_phone_numbers_fts_update; | ||
| DROP TRIGGER IF EXISTS contact_phone_numbers_fts_insert; | ||
| DROP TRIGGER IF EXISTS contacts_fts_delete; | ||
| DROP TRIGGER IF EXISTS contacts_fts_update; | ||
| DROP TRIGGER IF EXISTS contacts_fts_insert; | ||
|
|
||
| -- Drop FTS table | ||
| DROP TABLE IF EXISTS contacts_fts; | ||
|
|
||
| -- Drop view | ||
| DROP VIEW IF EXISTS contact_list; | ||
|
|
||
| -- Drop companion tables (due to foreign key constraints) | ||
| DROP TABLE IF EXISTS contact_addresses; | ||
| DROP TABLE IF EXISTS contact_aliases; | ||
| DROP TABLE IF EXISTS contact_wallet_addresses; | ||
| DROP TABLE IF EXISTS contact_urls; | ||
| DROP TABLE IF EXISTS contact_emails; | ||
| DROP TABLE IF EXISTS contact_phone_numbers; | ||
|
|
||
| -- Drop main contacts table | ||
| DROP TABLE IF EXISTS contacts; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.