Returns multi-line text summary of encryption preferences of all chat contacts. This can be used to find out if encryption is not available because keys for some users are missing or simply because the majority of the users in a group prefer plaintext emails. To get more verbose summary for a contact, including its key fingerprint, use [`Contact::get_encrinfo`].
(self, context: &Context)
| 1190 | /// |
| 1191 | /// To get more verbose summary for a contact, including its key fingerprint, use [`Contact::get_encrinfo`]. |
| 1192 | pub async fn get_encryption_info(self, context: &Context) -> Result<String> { |
| 1193 | let chat = Chat::load_from_db(context, self).await?; |
| 1194 | if !chat.is_encrypted(context).await? { |
| 1195 | return Ok(stock_str::encr_none(context)); |
| 1196 | } |
| 1197 | |
| 1198 | let mut ret = stock_str::messages_are_e2ee(context) + "\n"; |
| 1199 | |
| 1200 | for &contact_id in get_chat_contacts(context, self) |
| 1201 | .await? |
| 1202 | .iter() |
| 1203 | .filter(|&contact_id| !contact_id.is_special()) |
| 1204 | { |
| 1205 | let contact = Contact::get_by_id(context, contact_id).await?; |
| 1206 | let addr = contact.get_addr(); |
| 1207 | logged_debug_assert!( |
| 1208 | context, |
| 1209 | contact.is_key_contact(), |
| 1210 | "get_encryption_info: contact {contact_id} is not a key-contact." |
| 1211 | ); |
| 1212 | let fingerprint = contact |
| 1213 | .fingerprint() |
| 1214 | .context("Contact does not have a fingerprint in encrypted chat")? |
| 1215 | .human_readable(); |
| 1216 | if let Some(public_key) = contact.public_key(context).await? { |
| 1217 | if let Some(relay_addrs) = addresses_from_public_key(&public_key) { |
| 1218 | let relays = relay_addrs.join(","); |
| 1219 | ret += &format!("\n{addr}({relays})\n{fingerprint}\n"); |
| 1220 | } else { |
| 1221 | ret += &format!("\n{addr}\n{fingerprint}\n"); |
| 1222 | } |
| 1223 | } else { |
| 1224 | ret += &format!("\n{addr}\n(key missing)\n{fingerprint}\n"); |
| 1225 | } |
| 1226 | } |
| 1227 | |
| 1228 | Ok(ret.trim().to_string()) |
| 1229 | } |
| 1230 | |
| 1231 | /// Bad evil escape hatch. |
| 1232 | /// |
nothing calls this directly
no test coverage detected