-
Notifications
You must be signed in to change notification settings - Fork 20
feat(SPV-1538): migrate contact endpoints to v2 API #931
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?
Conversation
Manual Testsℹ️ Remember to ask team members to perform manual tests and to assign |
…-1538-migrate-contacts # Conflicts: # api/components/requests.yaml # api/gen.api.yaml # api/gen.models.go
…-1538-migrate-contacts
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #931 +/- ##
==========================================
- Coverage 34.50% 32.68% -1.83%
==========================================
Files 437 457 +20
Lines 20826 22469 +1643
==========================================
+ Hits 7186 7343 +157
- Misses 13041 14511 +1470
- Partials 599 615 +16
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
|
||
| // when: | ||
| res, _ := client.R(). | ||
| Post("/api/v2/admin/invitations/" + strconv.Itoa(int(contact.ID))) |
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.
| Post("/api/v2/admin/invitations/" + strconv.Itoa(int(contact.ID))) | |
| Post(fmt.Sprintf("/api/v2/admin/invitations/%d",contact.ID)) |
Also, applicable to other, similar places.
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.
Done
| } | ||
|
|
||
| // ContactsFixture is a test fixture for the contacts service | ||
| type ContactsFixture interface { |
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.
I would rename it to UserFixture because, in the future, it might be extended by other, not-contact-related features.
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.
Done
| return contact | ||
| } | ||
|
|
||
| func (f *contactFixture) removeContactIfExists(userB fixtures.User) { |
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.
I would try to avoid situations when fixtures need to remove/clear some data (most probably after previous test case).
Maybe you should separate test cases and avoid givenForAllTests and create "fresh" given for each case (given, when := testabilities.New())
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.
Done, removed deleting contact and created fresh tests where it was required
| "status": contactsmodels.ContactNotConfirmed, | ||
| }) | ||
|
|
||
| // and: |
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.
Remove unnecessary and
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.
Done
actions/v2/admin/contacts/accept.go
Outdated
|
|
||
| // AdminAcceptInvitation accepts an invitation from a contact. | ||
| func (s *APIAdminContacts) AdminAcceptInvitation(c *gin.Context, id uint) { | ||
| contact, err := s.engine.ContactService().AcceptContactByID(c.Request.Context(), id) |
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.
| contact, err := s.engine.ContactService().AcceptContactByID(c.Request.Context(), id) | |
| contact, err := s.engine.ContactService().AcceptContactByID(c, id) |
And for other, similar places.
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.
Done
| then.Response(res).IsOK() | ||
|
|
||
| // and: | ||
| // when: |
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.
Remove unnecessary // and:
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.
Done
| }`, map[string]any{ | ||
| "code": spverrors.ErrNotAnAdminKey.Code, | ||
| "message": spverrors.ErrNotAnAdminKey.Message, | ||
| }) |
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.
See how it's done in other places: https://github.com/bitcoin-sv/spv-wallet/blob/f2f26fdcc181c4de4cdab3ef14e0712302e6430a/actions/v2/admin/users/paymail_add_test.go#L225-L227
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.
Done
actions/v2/admin/contacts/search.go
Outdated
| ) | ||
|
|
||
| // AdminGetContacts returns a list of contacts for the admin. | ||
| func (s *APIAdminContacts) AdminGetContacts(c *gin.Context, params api.AdminGetContactsParams) { |
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.
@mgosek-4chain is doing a task for filters and pagination.
I would postpone this after he finishes.
For now, I would suggest to remove all code/endpoints related to this and create a task for the future.
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.
Done, removed endpoints but created a copy of the branch (feat/add-contacts-search-v2) to use them when new changes will be merged
|
|
||
| import "gorm.io/gorm" | ||
|
|
||
| func mapConditionsToScopes(conditions map[string]interface{}) []func(tx *gorm.DB) *gorm.DB { |
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.
I think this should be handled differently. And, as I said above - it is already been researched by @mgosek-4chain.
I would remove this function for now.
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.
removed
…-1538-migrate-contacts
Description:
Pull Request Checklist