| 1 |
use super::*; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#[async_trait] |
| 8 |
pub trait ContactRepository: Send + Sync { |
| 9 |
|
| 10 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<Contact>>; |
| 11 |
|
| 12 |
|
| 13 |
async fn get_by_id(&self, id: ContactId, user_id: UserId) -> Result<Option<Contact>>; |
| 14 |
|
| 15 |
|
| 16 |
async fn create(&self, user_id: UserId, contact: NewContact) -> Result<Contact>; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
async fn restore(&self, user_id: UserId, contact: &Contact) -> Result<()>; |
| 23 |
|
| 24 |
|
| 25 |
async fn update(&self, id: ContactId, user_id: UserId, contact: UpdateContact) -> Result<Option<Contact>>; |
| 26 |
|
| 27 |
|
| 28 |
async fn delete(&self, id: ContactId, user_id: UserId) -> Result<bool>; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
async fn set_external_ref( |
| 33 |
&self, |
| 34 |
id: ContactId, |
| 35 |
user_id: UserId, |
| 36 |
source: &str, |
| 37 |
external_id: &str, |
| 38 |
) -> Result<()>; |
| 39 |
|
| 40 |
|
| 41 |
async fn delete_many(&self, ids: &[ContactId], user_id: UserId) -> Result<u64>; |
| 42 |
|
| 43 |
|
| 44 |
async fn tag_many(&self, ids: &[ContactId], user_id: UserId, tag: &str) -> Result<u64>; |
| 45 |
|
| 46 |
|
| 47 |
async fn list_by_tag(&self, user_id: UserId, tag: &str) -> Result<Vec<Contact>>; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
async fn list_filtered(&self, user_id: UserId, search: Option<&str>, tag: Option<&str>, include_implicit: bool) -> Result<Vec<Contact>>; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
async fn list_email_directory(&self, user_id: UserId, include_implicit: bool) -> Result<Vec<ContactEmailEntry>>; |
| 56 |
|
| 57 |
|
| 58 |
async fn find_by_email(&self, user_id: UserId, email: &str) -> Result<Option<Contact>>; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
async fn find_emails_in_contacts(&self, user_id: UserId, addresses: &[&str]) -> Result<HashSet<String>>; |
| 63 |
|
| 64 |
|
| 65 |
async fn promote_contact(&self, id: ContactId, user_id: UserId) -> Result<Option<Contact>>; |
| 66 |
|
| 67 |
|
| 68 |
async fn find_by_external_id(&self, source: &str, ext_id: &str, user_id: UserId) -> Result<Option<Contact>>; |
| 69 |
|
| 70 |
|
| 71 |
async fn add_email(&self, contact_id: ContactId, user_id: UserId, email: NewContactEmail) -> Result<ContactEmail>; |
| 72 |
|
| 73 |
|
| 74 |
async fn remove_email(&self, email_id: ContactEmailId, user_id: UserId) -> Result<bool>; |
| 75 |
|
| 76 |
|
| 77 |
async fn add_phone(&self, contact_id: ContactId, user_id: UserId, phone: NewContactPhone) -> Result<ContactPhone>; |
| 78 |
|
| 79 |
|
| 80 |
async fn remove_phone(&self, phone_id: ContactPhoneId, user_id: UserId) -> Result<bool>; |
| 81 |
|
| 82 |
|
| 83 |
async fn add_social_handle(&self, contact_id: ContactId, user_id: UserId, handle: NewSocialHandle) -> Result<SocialHandle>; |
| 84 |
|
| 85 |
|
| 86 |
async fn remove_social_handle(&self, handle_id: SocialHandleId, user_id: UserId) -> Result<bool>; |
| 87 |
|
| 88 |
|
| 89 |
async fn add_custom_field(&self, contact_id: ContactId, user_id: UserId, field: NewContactCustomField) -> Result<ContactCustomField>; |
| 90 |
|
| 91 |
|
| 92 |
async fn remove_custom_field(&self, field_id: CustomFieldId, user_id: UserId) -> Result<bool>; |
| 93 |
|
| 94 |
|
| 95 |
async fn update_email(&self, email_id: ContactEmailId, user_id: UserId, email: NewContactEmail) -> Result<Option<ContactEmail>>; |
| 96 |
|
| 97 |
|
| 98 |
async fn update_phone(&self, phone_id: ContactPhoneId, user_id: UserId, phone: NewContactPhone) -> Result<Option<ContactPhone>>; |
| 99 |
|
| 100 |
|
| 101 |
async fn update_social_handle(&self, handle_id: SocialHandleId, user_id: UserId, handle: NewSocialHandle) -> Result<Option<SocialHandle>>; |
| 102 |
|
| 103 |
|
| 104 |
async fn update_custom_field(&self, field_id: CustomFieldId, user_id: UserId, field: NewContactCustomField) -> Result<Option<ContactCustomField>>; |
| 105 |
} |
| 106 |
|