Skip to content

Commit

Permalink
Add ResponseMessage::from_request.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jul 9, 2020
1 parent a93b46d commit fd43ed4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libsignal-service/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,25 @@ impl WebSocketRequestMessage {
false
}
}

impl WebSocketResponseMessage {
/// Equivalent of
/// `SignalServiceMessagePipe::isSignalServiceEnvelope(WebSocketMessage)`.
pub fn from_request(msg: &WebSocketRequestMessage) -> Self {
if msg.is_signal_service_envelope() {
WebSocketResponseMessage {
id: msg.id,
status: Some(200),
message: Some("OK".to_string()),
..Default::default()
}
} else {
WebSocketResponseMessage {
id: msg.id,
status: Some(400),
message: Some("Unknown".to_string()),
..Default::default()
}
}
}
}

0 comments on commit fd43ed4

Please sign in to comment.