Skip to content
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

Clean up some unused variable and unused result warnings #136

Merged
merged 2 commits into from
Aug 18, 2023
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
59 changes: 31 additions & 28 deletions yew-ui/src/components/attendants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,32 @@ impl AttendantsComponent {
}
let email = ctx.props().email.clone();
let rsa = &*self.rsa;
rsa.pub_key
.to_public_key_der()
.map_err(|e| error!("Failed to export rsa public key to der: {}", e.to_string()))
.and_then(|public_key_der| {
let data = RsaPacket {
match rsa.pub_key.to_public_key_der() {
Ok(public_key_der) => {
let packet = RsaPacket {
username: email.clone(),
public_key_der: public_key_der.to_vec(),
..Default::default()
}
.write_to_bytes()
.map_err(|e| error!("Failed to serialize rsa packet: {}", e.to_string()))
.and_then(|data| {
ctx.link()
.send_message(Msg::OnOutboundPacket(PacketWrapper {
packet_type: PacketType::RSA_PUB_KEY.into(),
email,
data,
..Default::default()
}));
Ok(())
});
Ok(())
});
};
match packet.write_to_bytes() {
Ok(data) => {
ctx.link()
.send_message(Msg::OnOutboundPacket(PacketWrapper {
packet_type: PacketType::RSA_PUB_KEY.into(),
email,
data,
..Default::default()
}));
}
Err(e) => {
error!("Failed to serialize rsa packet: {}", e.to_string())
}
};
}
Err(e) => {
error!("Failed to export rsa public key to der: {}", e.to_string())
}
}
}

fn create_peer_decoder_manager(ctx: &Context<Self>) -> PeerDecodeManager {
Expand Down Expand Up @@ -298,11 +301,8 @@ impl Component for AttendantsComponent {
}
debug!("Received AES_KEY {}", &response.email);
if let Ok(bytes) = self.rsa.decrypt(&response.data) {
let aes_packet = AesPacket::parse_from_bytes(&bytes)
.map_err(|e| {
error!("Failed to parse aes packet: {}", e.to_string())
})
.and_then(|aes_packet| {
match AesPacket::parse_from_bytes(&bytes) {
Ok(aes_packet) => {
self.peer_keys.insert(
response.email,
Aes128State::from_vecs(
Expand All @@ -311,8 +311,11 @@ impl Component for AttendantsComponent {
self.e2ee_enabled,
),
);
Ok(())
});
}
Err(e) => {
error!("Failed to parse aes packet: {}", e.to_string())
}
}
}
return false;
}
Expand All @@ -325,7 +328,7 @@ impl Component for AttendantsComponent {
.and_then(parse_public_key)
.and_then(|pub_key| {
self.serialize_aes_packet()
.and_then(|aes_packet| Ok((aes_packet, pub_key)))
.map(|aes_packet| (aes_packet, pub_key))
})
.and_then(|(aes_packet, pub_key)| {
self.encrypt_aes_packet(&aes_packet, &pub_key)
Expand Down
Loading