Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bytes-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon committed Jan 24, 2021
2 parents 9a17c45 + 51d9b5d commit d1f52d2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libsignal-service-actix/src/provisioning.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use futures::{channel::mpsc::Sender, pin_mut, SinkExt, StreamExt};
use futures::{pin_mut, prelude::Sink, SinkExt, StreamExt};
use std::fmt::Debug;
use url::Url;

use crate::push_service::AwcPushService;
Expand Down Expand Up @@ -30,14 +31,18 @@ pub enum SecondaryDeviceProvisioning {
},
}

pub async fn provision_secondary_device(
pub async fn provision_secondary_device<S>(
ctx: &Context,
service_configuration: &ServiceConfiguration,
signaling_key: &[u8; 52],
password: &str,
device_name: &str,
mut tx: Sender<SecondaryDeviceProvisioning>,
) -> Result<(), ProvisioningError> {
mut tx: S,
) -> Result<(), ProvisioningError>
where
S: Sink<SecondaryDeviceProvisioning> + Unpin,
<S as Sink<SecondaryDeviceProvisioning>>::Error: Debug,
{
assert_eq!(
password.len(),
24,
Expand Down
1 change: 1 addition & 0 deletions libsignal-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ thiserror = "1.0"
serde = {version = "1.0", features=["derive"]}
prost = "0.7"
http = "0.2.2"
chrono = { version = "0.4", features = ["serde"] }
log = "0.4.8"

sha2 = "0.9.0"
Expand Down
27 changes: 27 additions & 0 deletions libsignal-service/src/push_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use aes_gcm::{
Aes256Gcm, NewAead,
};

use chrono::prelude::*;

use libsignal_protocol::{keys::PublicKey, Context, PreKeyBundle};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -76,6 +78,17 @@ pub struct DeviceId {
pub device_id: i32,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeviceInfo {
pub id: i64,
pub name: Option<String>,
#[serde(with = "chrono::serde::ts_milliseconds")]
pub created: DateTime<Utc>,
#[serde(with = "chrono::serde::ts_milliseconds")]
pub last_seen: DateTime<Utc>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfirmDeviceMessage {
Expand Down Expand Up @@ -357,6 +370,20 @@ pub trait PushService {
Ok(VoiceVerificationCodeResponse::CallIssued)
}

/// Fetches a list of all devices tied to the authenticated account.
///
/// This list include the device that sends the request.
async fn devices(&mut self) -> Result<Vec<DeviceInfo>, ServiceError> {
#[derive(serde::Deserialize)]
struct DeviceInfoList {
devices: Vec<DeviceInfo>,
}

let devices: DeviceInfoList = self.get("/v1/devices/").await?;

Ok(devices.devices)
}

async fn confirm_verification_code(
&mut self,
confirm_code: u32,
Expand Down

0 comments on commit d1f52d2

Please sign in to comment.