-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-33041] Organization Ability: Refactor CipherResponseModel #7202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e67bb18
e7043f1
4bbbcd7
c319a9e
cb43e89
ee2d859
ba6111d
ceb3dd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| using Bit.Core.KeyManagement.Models.Data; | ||
| using Bit.Core.KeyManagement.Queries.Interfaces; | ||
| using Bit.Core.Models.Data; | ||
| using Bit.Core.Models.Data.Organizations; | ||
| using Bit.Core.Repositories; | ||
| using Bit.Core.Services; | ||
| using Bit.Core.Settings; | ||
|
|
@@ -123,7 +124,7 @@ await _providerUserRepository.GetManyOrganizationDetailsByUserAsync(user.Id, | |
| var organizationClaimingActiveUser = await _userService.GetOrganizationsClaimingUserAsync(user.Id); | ||
| var organizationIdsClaimingActiveUser = organizationClaimingActiveUser.Select(o => o.Id); | ||
|
|
||
| var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync(); | ||
| var organizationAbilities = await GetOrganizationAbilitiesAsync(ciphers); | ||
| var webAuthnCredentials = _featureService.IsEnabled(FeatureFlagKeys.PM2035PasskeyUnlock) | ||
| ? await _webAuthnCredentialRepository.GetManyByUserIdAsync(user.Id) | ||
| : []; | ||
|
|
@@ -141,6 +142,24 @@ await _providerUserRepository.GetManyOrganizationDetailsByUserAsync(user.Id, | |
| return response; | ||
| } | ||
|
|
||
| private async Task<IDictionary<Guid, OrganizationAbility>> GetOrganizationAbilitiesAsync(ICollection<CipherDetails> ciphers) | ||
| { | ||
| var orgIds = ciphers | ||
| .Where(c => c.OrganizationId.HasValue) | ||
| .Select(c => c.OrganizationId!.Value) | ||
| .Distinct() | ||
| .ToList(); | ||
|
|
||
| if (orgIds.Count == 0) | ||
| { | ||
| return new Dictionary<Guid, OrganizationAbility>(); | ||
| } | ||
|
|
||
| var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync(orgIds); | ||
|
|
||
| return organizationAbilities; | ||
| } | ||
|
Comment on lines
+145
to
+161
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π¨ Suggested β DRY: Duplicated helper method This method is nearly identical to |
||
|
|
||
| private ICollection<CipherDetails> FilterSSHKeys(ICollection<CipherDetails> ciphers) | ||
| { | ||
| if (_currentContext.ClientVersion >= _sshKeyCipherMinimumVersion || _featureService.IsEnabled(FeatureFlagKeys.SSHVersionCheckQAOverride)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
β Was there an scenario that caused you to remove this call to get the updated cipher? Claude is also pointing out that this would lead to stale data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed this in the Claude's comment.