Skip to content

refactor: Rename add_or_lookup_key_contacts_by_address_list() to add_or_lookup_key_contacts() #7052

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,16 @@ async fn get_to_and_past_contact_ids(
past_member_fingerprints = &[];
}

let pgp_to_ids = add_or_lookup_key_contacts_by_address_list(
context,
&mime_parser.recipients,
&mime_parser.gossiped_keys,
to_member_fingerprints,
Origin::Hidden,
)
.await?;

match chat_assignment {
ChatAssignment::GroupChat { .. } => {
to_ids = pgp_to_ids;
to_ids = add_or_lookup_key_contacts(
context,
&mime_parser.recipients,
&mime_parser.gossiped_keys,
to_member_fingerprints,
Origin::Hidden,
)
.await?;

if let Some(chat_id) = chat_id {
past_ids = lookup_key_contacts_by_address_list(
Expand All @@ -319,7 +317,7 @@ async fn get_to_and_past_contact_ids(
)
.await?;
} else {
past_ids = add_or_lookup_key_contacts_by_address_list(
past_ids = add_or_lookup_key_contacts(
context,
&mime_parser.past_members,
&mime_parser.gossiped_keys,
Expand All @@ -336,7 +334,14 @@ async fn get_to_and_past_contact_ids(
ChatAssignment::ExistingChat { chat_id, .. } => {
let chat = Chat::load_from_db(context, *chat_id).await?;
if chat.is_encrypted(context).await? {
to_ids = pgp_to_ids;
to_ids = add_or_lookup_key_contacts(
context,
&mime_parser.recipients,
&mime_parser.gossiped_keys,
to_member_fingerprints,
Origin::Hidden,
)
.await?;
past_ids = lookup_key_contacts_by_address_list(
context,
&mime_parser.past_members,
Expand Down Expand Up @@ -388,6 +393,14 @@ async fn get_to_and_past_contact_ids(
.await?;
}
ChatAssignment::OneOneChat => {
let pgp_to_ids = add_or_lookup_key_contacts(
context,
&mime_parser.recipients,
&mime_parser.gossiped_keys,
to_member_fingerprints,
Origin::Hidden,
)
.await?;
if pgp_to_ids
.first()
.is_some_and(|contact_id| contact_id.is_some())
Expand Down Expand Up @@ -429,7 +442,7 @@ async fn get_to_and_past_contact_ids(
context,
&mime_parser.recipients,
to_member_fingerprints,
chat_id,
None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be more explicit, otherwise one need to scroll up to see that chat_id == None

)
.await?
}
Expand Down Expand Up @@ -3727,7 +3740,7 @@ async fn add_or_lookup_contacts_by_address_list(
}

/// Looks up contact IDs from the database given the list of recipients.
async fn add_or_lookup_key_contacts_by_address_list(
async fn add_or_lookup_key_contacts(
context: &Context,
address_list: &[SingleInfo],
gossiped_keys: &HashMap<String, SignedPublicKey>,
Expand Down
Loading