diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-05-25 10:59:00 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-05-25 12:44:50 +0200 |
| commit | d2e45b013a116523774bb7c456687a477c18c2b3 (patch) | |
| tree | ddf395c68b34faa13f585388e90c0911f77bdf31 | |
| parent | 801393dabb599645f534c2497d677df137c121f7 (diff) | |
| download | mullvadvpn-d2e45b013a116523774bb7c456687a477c18c2b3.tar.xz mullvadvpn-d2e45b013a116523774bb7c456687a477c18c2b3.zip | |
Simplify device removal event
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/RemoveDeviceEvent.kt | 1 | ||||
| -rw-r--r-- | mullvad-daemon/src/device/service.rs | 25 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 5 | ||||
| -rw-r--r-- | mullvad-management-interface/proto/management_interface.proto | 3 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types.rs | 1 | ||||
| -rw-r--r-- | mullvad-types/src/device.rs | 1 |
6 files changed, 7 insertions, 29 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/RemoveDeviceEvent.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/RemoveDeviceEvent.kt index 3080d7f10a..94499c032a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/RemoveDeviceEvent.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/RemoveDeviceEvent.kt @@ -6,6 +6,5 @@ import kotlinx.parcelize.Parcelize @Parcelize data class RemoveDeviceEvent( val accountToken: String, - val removedDevice: Device, val newDevices: ArrayList<Device> ) : Parcelable diff --git a/mullvad-daemon/src/device/service.rs b/mullvad-daemon/src/device/service.rs index ca84e14cda..90a44d5fe1 100644 --- a/mullvad-daemon/src/device/service.rs +++ b/mullvad-daemon/src/device/service.rs @@ -109,29 +109,10 @@ impl DeviceService { &self, account_token: AccountToken, device_id: DeviceId, - ) -> Result<(Device, Vec<Device>), Error> { - let mut devices = self.list_devices(account_token.clone()).await?; - self.remove_device_inner(account_token, device_id.clone()) + ) -> Result<Vec<Device>, Error> { + self.remove_device_inner(account_token.clone(), device_id) .await?; - if let Some(index) = devices.iter().position(|device| device.id == device_id) { - Ok((devices.swap_remove(index), devices)) - } else { - // You would only end up here if the API service successfully removed a device that - // was previously not included in the list returned by it, which should be impossible. - // Just return a bogus device in its place. - log::error!("List did not contain the revoked device"); - Ok(( - Device { - id: device_id, - name: "unknown device".to_string(), - pubkey: talpid_types::net::wireguard::PublicKey::from([0u8; 32]), - ports: vec![], - hijack_dns: false, - created: Utc::now(), - }, - devices, - )) - } + self.list_devices(account_token).await } async fn remove_device_inner( diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index fbc27bcc92..b75ad9121c 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -1393,10 +1393,11 @@ where let result = device_service .remove_device(account_token.clone(), device_id) .await - .map(move |(removed_device, new_devices)| { + .map(move |new_devices| { + // FIXME: We should be able to get away with only returning the removed ID, + // and not have to request the list from the API. event_listener.notify_remove_device_event(RemoveDeviceEvent { account_token, - removed_device, new_devices, }); }); diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index b4a6731ff1..20d5318a58 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -621,6 +621,5 @@ message DeviceEvent { message RemoveDeviceEvent { string account_token = 1; - Device removed_device = 2; - repeated Device new_device_list = 3; + repeated Device new_device_list = 2; } diff --git a/mullvad-management-interface/src/types.rs b/mullvad-management-interface/src/types.rs index 4c52b36cc2..54aac8964f 100644 --- a/mullvad-management-interface/src/types.rs +++ b/mullvad-management-interface/src/types.rs @@ -281,7 +281,6 @@ impl From<mullvad_types::device::RemoveDeviceEvent> for RemoveDeviceEvent { fn from(event: mullvad_types::device::RemoveDeviceEvent) -> Self { RemoveDeviceEvent { account_token: event.account_token, - removed_device: Some(Device::from(event.removed_device)), new_device_list: event.new_devices.into_iter().map(Device::from).collect(), } } diff --git a/mullvad-types/src/device.rs b/mullvad-types/src/device.rs index 09fc747045..38dd528fd5 100644 --- a/mullvad-types/src/device.rs +++ b/mullvad-types/src/device.rs @@ -137,6 +137,5 @@ pub struct DeviceEvent { #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] pub struct RemoveDeviceEvent { pub account_token: AccountToken, - pub removed_device: Device, pub new_devices: Vec<Device>, } |
