core_crypto/transaction_context/conversation/
external_sender.rs

1//! This module is concerned with setting the external sender.
2
3use super::{Result, TransactionContext};
4use crate::{RecursiveError, prelude::MlsConversationConfiguration};
5
6impl TransactionContext {
7    /// Parses external senders' keys provided by the delivery service
8    /// and updates the conversation's configuration with them.
9    pub async fn set_raw_external_senders(
10        &self,
11        cfg: &mut MlsConversationConfiguration,
12        external_senders: Vec<Vec<u8>>,
13    ) -> Result<()> {
14        let mls_provider = self.mls_provider().await?;
15        cfg.external_senders = external_senders
16            .into_iter()
17            .map(|key| {
18                MlsConversationConfiguration::parse_external_sender(&key).or_else(|_| {
19                    MlsConversationConfiguration::legacy_external_sender(
20                        key,
21                        cfg.ciphersuite.signature_algorithm(),
22                        &mls_provider,
23                    )
24                })
25            })
26            .collect::<crate::mls::conversation::Result<_>>()
27            .map_err(RecursiveError::mls_conversation("setting external sender"))?;
28        Ok(())
29    }
30}