summaryrefslogtreecommitdiffhomepage
path: root/mullvad-management-interface/src
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-management-interface/src')
-rw-r--r--mullvad-management-interface/src/client.rs10
-rw-r--r--mullvad-management-interface/src/types/conversions/custom_list.rs18
2 files changed, 18 insertions, 10 deletions
diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs
index 73129d6b99..93a31a5042 100644
--- a/mullvad-management-interface/src/client.rs
+++ b/mullvad-management-interface/src/client.rs
@@ -571,18 +571,22 @@ impl MullvadProxyClient {
}
pub async fn create_custom_list(&mut self, name: String) -> Result<Id> {
+ let request = types::NewCustomList {
+ name,
+ locations: Vec::new(),
+ };
let id = self
.0
- .create_custom_list(name)
+ .create_custom_list(request)
.await
.map_err(map_custom_list_error)?
.into_inner();
Id::from_str(&id).map_err(|_| Error::CustomListListNotFound)
}
- pub async fn delete_custom_list(&mut self, id: String) -> Result<()> {
+ pub async fn delete_custom_list(&mut self, id: Id) -> Result<()> {
self.0
- .delete_custom_list(id)
+ .delete_custom_list(id.to_string())
.await
.map_err(map_custom_list_error)?;
Ok(())
diff --git a/mullvad-management-interface/src/types/conversions/custom_list.rs b/mullvad-management-interface/src/types/conversions/custom_list.rs
index 9d4e9cee78..11f2c4bd76 100644
--- a/mullvad-management-interface/src/types/conversions/custom_list.rs
+++ b/mullvad-management-interface/src/types/conversions/custom_list.rs
@@ -30,13 +30,14 @@ impl TryFrom<proto::CustomListSettings> for mullvad_types::custom_list::CustomLi
impl From<mullvad_types::custom_list::CustomList> for proto::CustomList {
fn from(custom_list: mullvad_types::custom_list::CustomList) -> Self {
+ let id = custom_list.id().to_string();
let locations = custom_list
.locations
.into_iter()
.map(proto::GeographicLocationConstraint::from)
.collect();
Self {
- id: custom_list.id.to_string(),
+ id,
name: custom_list.name,
locations,
}
@@ -52,11 +53,14 @@ impl TryFrom<proto::CustomList> for mullvad_types::custom_list::CustomList {
.into_iter()
.map(GeographicLocationConstraint::try_from)
.collect::<Result<BTreeSet<_>, Self::Error>>()?;
- Ok(Self {
- id: Id::from_str(&custom_list.id)
- .map_err(|_| FromProtobufTypeError::InvalidArgument("Invalid list ID"))?,
- name: custom_list.name,
- locations,
- })
+
+ let id = Id::from_str(&custom_list.id)
+ .map_err(|_| FromProtobufTypeError::InvalidArgument("Invalid list ID"))?;
+
+ let mut inner = Self::with_id(id);
+ inner.name = custom_list.name;
+ inner.append(locations);
+
+ Ok(inner)
}
}