Skip to content

Commit

Permalink
fix(cipher-collections): fix method changing collections of a cipher
Browse files Browse the repository at this point in the history
  • Loading branch information
Lowaiz committed Aug 14, 2024
1 parent de96fcf commit 0f9b404
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/vaultwarden/models/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,43 +57,34 @@ def add_collections(self, collections: list[UUID]):
if collection in _current_collections:
continue
self.CollectionIds.append(collection)
dump = [str(coll_id) for coll_id in self.CollectionIds]
return self.api_client.api_request(
"POST",
f"api/ciphers/{self.Id}",
json=self.model_dump(
include={
"CollectionIds": True,
}
),
f"api/ciphers/{self.Id}/collections",
json={"collectionIds": dump},
)

def remove_collections(self, collections: list[UUID]):
self.CollectionIds = [
coll for coll in self.CollectionIds if coll not in collections
]
dump = [str(coll_id) for coll_id in self.CollectionIds]
return self.api_client.api_request(
"POST",
f"api/ciphers/{self.Id}",
json=self.model_dump(
include={
"CollectionIds": True,
}
),
f"api/ciphers/{self.Id}/collections",
json={"collectionIds": dump},
)

def delete(self):
return self.api_client.api_request("DELETE", f"api/ciphers/{self.Id}")

def update_collection(self, collections: list[UUID]):
dump = [str(coll_id) for coll_id in collections]
self.CollectionIds = collections
return self.api_client.api_request(
"POST",
f"api/ciphers/{self.Id}",
json=self.model_dump(
include={
"CollectionIds": True,
}
),
f"api/ciphers/{self.Id}/collections",
json={"collectionIds": dump},
)


Expand Down

0 comments on commit 0f9b404

Please sign in to comment.