Skip to content

Conversation

@felixgateru
Copy link
Contributor

@felixgateru felixgateru commented Jun 25, 2025

What type of PR is this?

This is a refactor as it enables dedicated invitee invitation listing by adding ListInviteeInvitations

What does this do?

This pr:

  • Adds ability for users to list domain invitations specifically addressed to them using ListDomainInvitations
  • Updates the authorization check for this

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Yes, tests have been included

Did you document any new/modified feature?

Yes, in code documentation is included

Notes

@felixgateru felixgateru changed the title Smq2719 invitations SMQ-2719 - Update list invitee invitations endpoint Jun 25, 2025
@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 8.46154% with 119 lines in your changes missing coverage. Please review.

Project coverage is 29.05%. Comparing base (f6e8db4) to head (dda902c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
domains/mocks/service.go 0.00% 34 Missing ⚠️
domains/events/events.go 0.00% 28 Missing ⚠️
domains/middleware/logging.go 0.00% 17 Missing ⚠️
domains/events/streams.go 0.00% 14 Missing ⚠️
domains/middleware/authorization.go 0.00% 11 Missing ⚠️
domains/tracing/tracing.go 0.00% 9 Missing ⚠️
domains/middleware/metrics.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2965      +/-   ##
==========================================
+ Coverage   28.15%   29.05%   +0.89%     
==========================================
  Files         360       30     -330     
  Lines       56962     6019   -50943     
==========================================
- Hits        16040     1749   -14291     
+ Misses      40139     4172   -35967     
+ Partials      783       98     -685     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@felixgateru felixgateru marked this pull request as ready for review June 25, 2025 09:51
@felixgateru felixgateru requested a review from a team as a code owner June 25, 2025 09:51
return am.svc.ListInvitations(ctx, session, page)
}

func (am *authorizationMiddleware) ListInviteeInvitations(ctx context.Context, session authn.Session, page domains.InvitationPageMeta) (invs domains.InvitationPage, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can have two function ,
ListInvitations and ListDomainInvitations

  • ListInvitations list invitee invitations
  • ListDomainInvitations list all the invitations sent on domain

No need for CheckAdmin because SuperAdmin inherently get the permission

@felixgateru felixgateru force-pushed the smq2719-invitations branch from de8ad17 to b34f063 Compare June 30, 2025 14:20
@felixgateru felixgateru changed the title SMQ-2719 - Update list invitee invitations endpoint SMQ-2719 - Update list domain invitations endpoint Jun 30, 2025
@felixgateru felixgateru force-pushed the smq2719-invitations branch from b34f063 to f3c11ef Compare June 30, 2025 14:53
Copy link
Contributor

@arvindh123 arvindh123 left a comment

Choose a reason for hiding this comment

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

I could not see like this in domainID: chi.URLParam(r, "domainID"), in decoder requests of SendDomainInvitations, ListDomainInvitation

@felixgateru
Copy link
Contributor Author

I could not see like this in domainID: chi.URLParam(r, "domainID"), in decoder requests of SendDomainInvitations, ListDomainInvitation

They are obtained from the session since it already fetches them from the url

if !ok {
return nil, svcerr.ErrAuthorization
}
req.InvitationPageMeta.DomainID = session.DomainID
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this logic to service layer

Copy link
Contributor

@arvindh123 arvindh123 left a comment

Choose a reason for hiding this comment

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

session.DomainID = req.DomainID

This might not be needed , Please verify this one

Comment on lines 401 to 402
if lie.DomainID != "" {
val["domain_id"] = lie.DomainID
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Domain ID is mandatory, It could not be optional

in listInvitationsEvent super admin is not required , instead we can have requested user id

arvindh123
arvindh123 previously approved these changes Jul 1, 2025
@arvindh123 arvindh123 force-pushed the smq2719-invitations branch from c774efd to a1dbf68 Compare July 1, 2025 04:00
@felixgateru felixgateru force-pushed the smq2719-invitations branch from a1dbf68 to 894b583 Compare July 1, 2025 13:31
Comment on lines 375 to 377
if lie.State.String() != "" {
val["state"] = lie.State.String()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will never be true. Please check State.

@dborovcanin dborovcanin force-pushed the smq2719-invitations branch from 9abd9ff to dda902c Compare July 1, 2025 17:02
@dborovcanin dborovcanin merged commit 5d04de4 into absmach:main Jul 1, 2025
5 of 6 checks passed
nyagamunene pushed a commit to nyagamunene/supermq that referenced this pull request Jul 9, 2025
arvindh123 pushed a commit that referenced this pull request Jul 30, 2025
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.

Bug: Invitations could not be filter by domain_id by invitee

3 participants