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

API: Display membership status while fetching workspace members #406

Open
rajdip-b opened this issue Jul 30, 2024 · 19 comments
Open

API: Display membership status while fetching workspace members #406

rajdip-b opened this issue Jul 30, 2024 · 19 comments
Assignees
Labels
difficulty: 3 good first issue Good for newcomers priority: high scope: api Everything related to the API type: enhancement New feature or request

Comments

@rajdip-b
Copy link
Member

Description

When we hit the /api/workspace/{workspaceId}/members endpoint to fetch all the members of a workspace, we also want to get the membership status of the member, i.e, if they have accepted the invitation or not.

Currently, we just get the id, user and the roles they have.
image

Solution

We would want the return type to also include a active field that will be true if the user has accepted the invitation, false otherwise.

  • Update this function to fetch the necessary data:
    async getAllMembersOfWorkspace(
    user: User,
    workspaceId: Workspace['id'],
    page: number,
    limit: number,
    sort: string,
    order: string,
    search: string
    ) {
    await this.authorityCheckerService.checkAuthorityOverWorkspace({
    userId: user.id,
    entity: { id: workspaceId },
    authority: Authority.READ_USERS,
    prisma: this.prisma
    })
    //get all members of workspace for page with limit
    const items = await this.prisma.workspaceMember.findMany({
    skip: page * limit,
    take: limit,
    orderBy: {
    workspace: {
    [sort]: order
    }
    },
    where: {
    workspaceId,
    user: {
    OR: [
    {
    name: {
    contains: search
    }
    },
    {
    email: {
    contains: search
    }
    }
    ]
    }
    },
    select: {
    id: true,
    user: true,
    roles: {
    select: {
    id: true,
    role: {
    select: {
    id: true,
    name: true,
    description: true,
    colorCode: true,
    authorities: true,
    projects: {
    select: {
    id: true
    }
    }
    }
    }
    }
    }
    }
    })
  • The model responsible for storing the invitation status:
    model WorkspaceMember {
    id String @id @default(cuid())
    user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
    userId String
    workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
    workspaceId String
    invitationAccepted Boolean @default(false)
    roles WorkspaceMemberRoleAssociation[]
    @@unique([workspaceId, userId])
    }
  • Include tests.
@rajdip-b rajdip-b added type: enhancement New feature or request good first issue Good for newcomers scope: api Everything related to the API priority: high difficulty: 3 labels Jul 30, 2024
@rajdip-b rajdip-b moved this to Todo in keyshade-api Jul 30, 2024
@lakshay-saini-au8
Copy link
Contributor

/attempt

Copy link

github-actions bot commented Aug 7, 2024

Assigned the issue to @lakshay-saini-au8!

@lakshay-saini-au8
Copy link
Contributor

lakshay-saini-au8 commented Aug 10, 2024

@rajdip-b if possible can you share what will be the expected response

@lakshay-saini-au8
Copy link
Contributor

is it like

`{
id : "",
type:{active:},
user:{}

`

@rajdip-b
Copy link
Member Author

rajdip-b commented Sep 4, 2024

Hey @lakshay-saini-au8! Sorry about the late reply, must have overlooked your comments.

We just want something like this:

{
  // ...other fields,
  membershipAccepted: true/false
}

@rajdip-b
Copy link
Member Author

@lakshay-saini-au8 any updates on this yet?

@rothardo
Copy link

Hi @rajdip-b I would like to work on this issue as I think this is pending since more then 12 weeks,
please let me know if this is up for grabs

@rajdip-b
Copy link
Member Author

Sure, do go ahead!

@rajdip-b rajdip-b moved this from Todo to In progress in keyshade-api Oct 15, 2024
@rothardo
Copy link

Hi @rajdip-b ,

I hope you're doing well. I've been working on setting up the project according to the guidelines, but I've encountered a problem that's been quite bothersome.

I've followed the recommendations regarding PostgreSQL issues, and while I'm using WSL, which has been consuming a lot of memory, I’m managing that.

However, I would really appreciate your help in resolving the issue shown below so I can move forward:

Screenshot 2024-10-22 191849

Thank you!

@rajdip-b
Copy link
Member Author

Hey, can you please open up a github discussion for this issue? I feel that a lot of people will benefit from that. We are facing this issue quite often.

@rothardo
Copy link

@rajdip-b I have opened a discussion on the same,
thank you

@rothardo
Copy link

rothardo commented Nov 1, 2024

Hi there! I’m having trouble with the login process, and the documentation isn’t very clear about which modules to run. Could you guide me on how to run the project in full-stack mode? The backend is up and running, but I’m not sure where to find the UI or which directory to check. Thanks! @rajdip-b

@rajdip-b
Copy link
Member Author

rajdip-b commented Nov 1, 2024

The UI is still under works. The designs are incomplete. All of the api dev is currently being done using postman. So it's pointless in running the UI since it can only do so much. I recommend you to go through the postman api docs. You can find the link in readme.

@rajdip-b
Copy link
Member Author

rajdip-b commented Nov 5, 2024

@rothardo any luck?

@rothardo
Copy link

rothardo commented Nov 6, 2024

@rajdip-b yes, will raise pr soon

@rajdip-b
Copy link
Member Author

rajdip-b commented Nov 6, 2024

Looking forward to it!

@rothardo
Copy link

Hey @rajdip-b I was caught up in some important work, I will raise a PR on Monday mostly for this one

@rothardo
Copy link

rothardo commented Dec 5, 2024

Hey, @rajdip-b I was trying to import the collections and this is what the error was
import collection failed anything exitcode

image

and also is this causing the problem?

@rajdip-b
Copy link
Member Author

rajdip-b commented Dec 6, 2024

I really don't think that this has got anything to do with our codebase. Also, never faced this error before. If you have followed the steps from our docs and you are facing this, I would suggest you to raise a ticket with Bruno. Those folks are really helpful :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 good first issue Good for newcomers priority: high scope: api Everything related to the API type: enhancement New feature or request
Projects
Status: In progress
Development

No branches or pull requests

3 participants