Skip to content

Commit 0f9b404

Browse files
committed
fix(cipher-collections): fix method changing collections of a cipher
1 parent de96fcf commit 0f9b404

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

src/vaultwarden/models/bitwarden.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,34 @@ def add_collections(self, collections: list[UUID]):
5757
if collection in _current_collections:
5858
continue
5959
self.CollectionIds.append(collection)
60+
dump = [str(coll_id) for coll_id in self.CollectionIds]
6061
return self.api_client.api_request(
6162
"POST",
62-
f"api/ciphers/{self.Id}",
63-
json=self.model_dump(
64-
include={
65-
"CollectionIds": True,
66-
}
67-
),
63+
f"api/ciphers/{self.Id}/collections",
64+
json={"collectionIds": dump},
6865
)
6966

7067
def remove_collections(self, collections: list[UUID]):
7168
self.CollectionIds = [
7269
coll for coll in self.CollectionIds if coll not in collections
7370
]
71+
dump = [str(coll_id) for coll_id in self.CollectionIds]
7472
return self.api_client.api_request(
7573
"POST",
76-
f"api/ciphers/{self.Id}",
77-
json=self.model_dump(
78-
include={
79-
"CollectionIds": True,
80-
}
81-
),
74+
f"api/ciphers/{self.Id}/collections",
75+
json={"collectionIds": dump},
8276
)
8377

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

8781
def update_collection(self, collections: list[UUID]):
82+
dump = [str(coll_id) for coll_id in collections]
8883
self.CollectionIds = collections
8984
return self.api_client.api_request(
9085
"POST",
91-
f"api/ciphers/{self.Id}",
92-
json=self.model_dump(
93-
include={
94-
"CollectionIds": True,
95-
}
96-
),
86+
f"api/ciphers/{self.Id}/collections",
87+
json={"collectionIds": dump},
9788
)
9889

9990

0 commit comments

Comments
 (0)