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

feat: add user organization domain/route logic #2327

Merged
merged 31 commits into from
Feb 13, 2025
Merged

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Feb 5, 2025

Summary

This implements the domain/route layer for adding Users to Organizations, by means of the UserOrganizations.

A new UserOrganizations repository, with relevant methods for sending, accepting and declining invites and updating/removing users has been added to the domain layer. Respective routes for each have been included in a new UserOrganizationsController.

Changes

  • Add IUserOrganizationsRepository with implementation
  • Add UserOrganizationController with routes for inviting, accepting and declining user invites, modifying roles and removing users
  • Add UserOrganizationService to route repository to controller
  • Associated entity updates
  • Add appropriate test coverage

@iamacook iamacook self-assigned this Feb 5, 2025
@iamacook iamacook force-pushed the feat/user-org-domain branch 2 times, most recently from 3b49834 to 8d07a86 Compare February 7, 2025 10:54
@iamacook iamacook changed the base branch from main to feature/organizationRoute February 7, 2025 10:54
…organization creation and updates, Add Swagger decorators
@PooyaRaki PooyaRaki force-pushed the feature/organizationRoute branch from 3c13f71 to 00408ed Compare February 7, 2025 12:51
@iamacook iamacook force-pushed the feat/user-org-domain branch from 5565dbe to 6eb88c7 Compare February 7, 2025 13:00
…ations parameters, update controller methods to use ParseIntPipe, Add organiation controller tests
@PooyaRaki PooyaRaki force-pushed the feature/organizationRoute branch from 426806e to 69dd3ea Compare February 10, 2025 06:18
Comment on lines 121 to 126
await entityManager.insert(DbUserOrganization, {
user: { id: invitedUserId },
organization: signer.org,
role: userToInvite.role,
status: UserOrganizationStatus.INVITED,
});
Copy link
Member

Choose a reason for hiding this comment

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

What happens when an admin invites two wallets that belong to the same user. Would this request throw for the second wallet since we are trying to insert the same user id for the same org into the user-org table?

Copy link
Member

Choose a reason for hiding this comment

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

We discussed this and initially we thought as long as we do an upsert it should be fine since for the second wallet we would just update the existing membership entry of the user but now that I think about it again what do we do if those wallets were invited with different roles? It might be highly unlikely but still leaves room for interpretation (do we keep the initial role or always also update the role again -> behaviour is not clear to the admin who invites wallets).

Overall I think if we limited this flow to single wallet invites it would make error handling a lot easier since we could detect if that user already got invited and show an error message or update the role if its different. I will bring this up in the next sync.

@PooyaRaki PooyaRaki force-pushed the feature/organizationRoute branch from 69cde71 to c79d0ad Compare February 11, 2025 06:00
@iamacook iamacook marked this pull request as ready for review February 11, 2025 18:27
@iamacook iamacook requested a review from a team as a code owner February 11, 2025 18:27
@iamacook iamacook changed the title feat: add user organization domain logic feat: add user organization domain/route logic Feb 11, 2025
@PooyaRaki PooyaRaki force-pushed the feature/organizationRoute branch from b296b07 to 01f50e2 Compare February 12, 2025 10:23
Base automatically changed from feature/organizationRoute to main February 12, 2025 10:29
src/datasources/users/entities/users.entity.db.ts Outdated Show resolved Hide resolved
src/datasources/users/entities/users.entity.db.ts Outdated Show resolved Hide resolved
src/domain/common/utils/enum.ts Show resolved Hide resolved
src/routes/organizations/user-organizations.controller.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@PooyaRaki PooyaRaki left a comment

Choose a reason for hiding this comment

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

Great Job, LGTM 🚀

@iamacook iamacook merged commit 349113c into main Feb 13, 2025
18 checks passed
@iamacook iamacook deleted the feat/user-org-domain branch February 13, 2025 12:10
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