dani-garcia / vaultwarden

Unofficial Bitwarden compatible server written in Rust, formerly known as bitwarden_rs
GNU Affero General Public License v3.0
34.78k stars 1.69k forks source link

Pass in collection ids to notifier when sharing cipher. #4517

Closed kristof-mattei closed 2 months ago

kristof-mattei commented 2 months ago

(sorry about hitting publish too soon).

This PR fixes a bug where moving a cipher from a personal vault to an organization does not attach the collection ids of which the cipher is now a member.

The front-end relies on these if the notification type is NotificationType.SyncCipherUpdate (https://github.com/bitwarden/clients/blob/91f1d9fb86142805d0774182c3ee6234e13946e3/libs/common/src/services/notifications.service.ts#L150) which in turn controls isEdit in syncUpsertCipher (https://github.com/bitwarden/clients/blob/91f1d9fb86142805d0774182c3ee6234e13946e3/libs/common/src/vault/services/sync/sync.service.ts#L177). If isEdit is true (we moved a cipher, we didn't create one) we need the collectionIds otherwise shouldUpdate remains false (https://github.com/bitwarden/clients/blob/91f1d9fb86142805d0774182c3ee6234e13946e3/libs/common/src/vault/services/sync/sync.service.ts#L213).

This causes a client on the receiving side to fail to properly update its view, requiring a manual refresh.

Before:

https://github.com/dani-garcia/vaultwarden/assets/864376/d2e0d455-2bd6-476f-823c-b357f0bd2f15

After:

https://github.com/dani-garcia/vaultwarden/assets/864376/8e08a0bd-9ea6-4bda-b1e8-67ab7e68514a

I chose Option<Vec<String>> because that's what the notifier service takes, even though technically we could do Vec<String> but that makes it much uglier for other consumers. Passing in None is much nicer than vec![].

BlackDex commented 2 months ago

@kristof-mattei could you share what is resolved with this specific pr please?

That would make testing it a bit quicker and nice for reference.

kristof-mattei commented 2 months ago

@BlackDex absolutely, I must've hit the wrong button. It's supposed to be a draft.

kristof-mattei commented 2 months ago

@BlackDex there we go.