Skip to content

Commit 4ffc0ca

Browse files
committed
refactor: don't ignore get_for_contact errors
1 parent 3d19996 commit 4ffc0ca

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

src/receive_imf.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -946,14 +946,11 @@ async fn add_parts(
946946
chat_id = Some(chat.id);
947947
chat_id_blocked = chat.blocked;
948948
} else if allow_creation {
949-
if let Ok(chat) = ChatIdBlocked::get_for_contact(context, from_id, create_blocked)
949+
let chat = ChatIdBlocked::get_for_contact(context, from_id, create_blocked)
950950
.await
951-
.context("Failed to get (new) chat for contact")
952-
.log_err(context)
953-
{
954-
chat_id = Some(chat.id);
955-
chat_id_blocked = chat.blocked;
956-
}
951+
.context("Failed to get (new) chat for contact")?;
952+
chat_id = Some(chat.id);
953+
chat_id_blocked = chat.blocked;
957954
}
958955

959956
if let Some(chat_id) = chat_id {
@@ -1149,9 +1146,8 @@ async fn add_parts(
11491146
chat_id = Some(id);
11501147
chat_id_blocked = blocked;
11511148
}
1152-
} else if let Ok(chat) =
1153-
ChatIdBlocked::get_for_contact(context, to_id, Blocked::Not).await
1154-
{
1149+
} else {
1150+
let chat = ChatIdBlocked::get_for_contact(context, to_id, Blocked::Not).await?;
11551151
chat_id = Some(chat.id);
11561152
chat_id_blocked = chat.blocked;
11571153
}
@@ -1167,7 +1163,7 @@ async fn add_parts(
11671163
if chat_id_blocked != Blocked::Not {
11681164
if let Some(chat_id) = chat_id {
11691165
chat_id.unblock_ex(context, Nosync).await?;
1170-
chat_id_blocked = Blocked::Not;
1166+
// Not assigning `chat_id_blocked = Blocked::Not` to avoid unused_assignments warning.
11711167
}
11721168
}
11731169
}
@@ -1204,20 +1200,15 @@ async fn add_parts(
12041200
if chat_id.is_none() && self_sent {
12051201
// from_id==to_id==ContactId::SELF - this is a self-sent messages,
12061202
// maybe an Autocrypt Setup Message
1207-
if let Ok(chat) = ChatIdBlocked::get_for_contact(context, ContactId::SELF, Blocked::Not)
1203+
let chat = ChatIdBlocked::get_for_contact(context, ContactId::SELF, Blocked::Not)
12081204
.await
1209-
.context("Failed to get (new) chat for contact")
1210-
.log_err(context)
1211-
{
1212-
chat_id = Some(chat.id);
1213-
chat_id_blocked = chat.blocked;
1214-
}
1205+
.context("Failed to get (new) chat for contact")?;
12151206

1216-
if let Some(chat_id) = chat_id {
1217-
if Blocked::Not != chat_id_blocked {
1218-
chat_id.unblock_ex(context, Nosync).await?;
1219-
// Not assigning `chat_id_blocked = Blocked::Not` to avoid unused_assignments warning.
1220-
}
1207+
chat_id = Some(chat.id);
1208+
// Not assigning `chat_id_blocked = chat.blocked` to avoid unused_assignments warning.
1209+
1210+
if Blocked::Not != chat.blocked {
1211+
chat.id.unblock_ex(context, Nosync).await?;
12211212
}
12221213
}
12231214
}

0 commit comments

Comments
 (0)