Skip to content
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

fix(routing): add connection type on mediation grant #1147

Merged

Conversation

genaris
Copy link
Contributor

@genaris genaris commented Dec 8, 2022

Small update to the feature added in #994 to aggregate the connection type when a connection is related to a mediation grant.

Previously, it was setting only ConnectionType.Mediator, so if the connection was previously tagged with another type, it would be lost.

Also fixes typing for connectionType in ConnectionRecord in order to be able to properly query for connections matching one or multiple types.

@genaris genaris requested a review from a team as a code owner December 8, 2022 02:23
Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @genaris! Could you add some tests to make sure it correctly adds instead of overwrites?

@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2022

Codecov Report

Merging #1147 (e67fe1c) into main (9f10da8) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
+ Coverage   88.32%   88.35%   +0.02%     
==========================================
  Files         706      706              
  Lines       16430    16437       +7     
  Branches     2664     2664              
==========================================
+ Hits        14512    14523      +11     
+ Misses       1911     1907       -4     
  Partials        7        7              
Impacted Files Coverage Δ
...ges/core/src/modules/connections/ConnectionsApi.ts 67.69% <100.00%> (+0.28%) ⬆️
...modules/connections/repository/ConnectionRecord.ts 95.65% <100.00%> (ø)
.../modules/connections/services/ConnectionService.ts 88.64% <100.00%> (+1.33%) ⬆️
...ules/routing/services/MediationRecipientService.ts 84.53% <100.00%> (-0.09%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@genaris genaris requested a review from TimoGlastra December 9, 2022 13:17
@genaris
Copy link
Contributor Author

genaris commented Dec 9, 2022

Thanks @genaris! Could you add some tests to make sure it correctly adds instead of overwrites?

Done and also fixed the typing as discussed in #1145. Could you quickly review these new changes?

@@ -642,6 +642,28 @@ export class ConnectionService {
return connectionRecord
}

public async addConnectionType(agentContext: AgentContext, connectionRecord: ConnectionRecord, type: string) {
const tags = (connectionRecord.getTag('connectionType') as string[]) || ([] as string[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the typing is correctly set on getTags, I think the casting is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use getTag('connectionType') it's still needed. However I think it's more elegant to use getTags().connectionType, where the typing is already there as you say.

}

public async getConnectionTypes(connectionRecord: ConnectionRecord) {
const tags = connectionRecord.getTag('connectionType') as string[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is incorrect (as it could be null), but per my comment above, not sure if the cast is needed anymore

@genaris genaris enabled auto-merge (squash) December 12, 2022 12:42
@genaris genaris merged commit 979c695 into openwallet-foundation:main Dec 12, 2022
@genaris genaris deleted the fix/connection-type-on-mediation branch December 12, 2022 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants