-
Notifications
You must be signed in to change notification settings - Fork 1
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 fields to invites #393
Conversation
1. Add roleName and roleDescription to Invite protobuf (rpc.proto) 2. add fields to memberApi.invite 3. send those fields as part of 'invite-received' on invite-api callback
the e2e tests that are failing are all related to calling |
* Omit roleName from mapeoManager.addProject (solves a bunch of tests, but may need to regress this) * capitalize roleName in member-api * fix local-peers tests
|
The fix for the test would be to update this line in the test so that the project that's created has a name e.g. Probably also makes sense to have a test that makes sure that invites don't work if the project doesn't have a name, if that doesn't exist already.
i think it should be kept that way. i believe we explicitly decided to let the consumer decide the fallback name for projects that don't have a name |
heh, I missed that method signature 😄 |
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.
raised a couple of concerns but seems like the foundational pieces are there! there's a related issue around translations that isn't entirely clear to me just yet, which would be good to get a resolution on
src/member-api.js
Outdated
* @param {import('./generated/rpc.js').Invite_RoleName} opts.roleName | ||
* @param {string} [opts.roleDescription] |
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.
Not sure the params should change here. To me, the roleId should still be used here, and the name and description sent with the invite are derived based on the capabilities associated with the roleId.
The other (tangential) uncertainty i have is how this all works with translations. if the name and description are built into the capability definition, how does internationalization work when you want to surface those things are part of the UI? (easier for name than description in that case)
thoughts @gmaclennan ?
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 what you say makes sense, but syncing this morning with gregor we arrived at that change maybe there's some reason I'm forgetting??
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.
hm i see. if this was discussed already then feel free to disregard my initial comment! i admit the advantage of providing the description is that there's more freedom from the consumer to describe the role/capability, as opposed to us hardcoding it in the capability definition. still unsure about the role name as a param but hard to tell without diving deeper myself
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.
Yes good points @achou11, it was late last night when discussing and I hadn't fully wrapped my head around this - I was wondering where the frontend would get the roleId from, but having a fixed role name doesn't allow the frontend to internationalize what is sent in the invite.
- We need to export the DEFAULT_CAPABILITIES from @mapeo/core so the front end can read those - ideally they are accessible from the mapeo client without needing to do an async call to the backend - maybe an opportunity to use package.exports @achou11 :)
- We keep
roleId
as the required param here, and both role name and role description optional. Role name can default to thename
on the capability record. The frontend can pass a translated role name (the invitor would decide on the translation, rather than the invitee - because in the future capabilities and capability names might not be available on a device before it joins a project) - Need to add a check for a valid role ID and throw if invalid.
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.
If we keep roleId
, shouldn't we remove roleName
from params since it can be grabbed from the roleId
. I dunno about roleDescription
since DEFAULT_CAPABILITIES
doesn't have a roleDescription
(maybe the idea is to add it to that record?)
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.
If we keep roleId, shouldn't we remove roleName from params since it can be grabbed from the roleId.
it's still useful for roleName to be an optional param (not a required param) because otherwise we wouldn't be able to easily provide a translated role name for the invited device to see when they receive the invite. Gregor's suggestion is to have the optional name param and if that isn't provided use the name associated with the roleId. For example, an application should be able to do members.invite({ roleName: "Miembro", ... })
if they want the invited device to see the translated name of the role. Otherwise the default is the english name we're using in the role id definition
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.
We keep roleId as the required param here, and both role name and role description optional.
The only risk with this is inviting someone with misleading information, which isn't a huge issue for us I guess. For example, one could do this:
members.invite({
roleId: MEMBER_ROLE_ID,
roleName: "Coordinator",
roleDescription: "Definitely a coordinator ;)"
})
This avoid the tests hanging since now we need a project name in order to send an invite
is adding the invitor name and id also going to be part of this PR? doesn't seem like it's doing so at the moment, but I think those were a later addition to that issue's checklist. if not, let's make sure to update the PR title and description to be precise about which fields are being added by these changes |
* regenerate rpc.js due to formatting issues
I must double check with @gmaclennan but I think what we talked about was that sending the invitorId ( |
yeah i think that makes sense 👍 |
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.
a couple of cleanup suggestions, but some requested changes around role names and passing the role ID
src/member-api.js
Outdated
* @param {import('./generated/rpc.js').Invite_RoleName} opts.roleName | ||
* @param {string} [opts.roleDescription] |
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.
Yes good points @achou11, it was late last night when discussing and I hadn't fully wrapped my head around this - I was wondering where the frontend would get the roleId from, but having a fixed role name doesn't allow the frontend to internationalize what is sent in the invite.
- We need to export the DEFAULT_CAPABILITIES from @mapeo/core so the front end can read those - ideally they are accessible from the mapeo client without needing to do an async call to the backend - maybe an opportunity to use package.exports @achou11 :)
- We keep
roleId
as the required param here, and both role name and role description optional. Role name can default to thename
on the capability record. The frontend can pass a translated role name (the invitor would decide on the translation, rather than the invitee - because in the future capabilities and capability names might not be available on a device before it joins a project) - Need to add a check for a valid role ID and throw if invalid.
Invitor ID can be removed from the checklist, but invitor name is still needed, as you say, from |
* revert Invite.roleName to be a string instead of an enum * add `roleId` again as a param to memberApi.invite. derive roleName as `DEFAULT_CAPABILITIES[roleId]` * on MapeoManager, instead of `Omit` `roleName`, `Pick` desired fields from `Invite` * fix tests do to api changes in memberApi.invite
|
seems to happen on windows too, based on another run on the main branch: https://github.com/digidem/mapeo-core-next/actions/runs/7019047664/job/19095674265#step:6:2657 |
@tomasciccola mind trying this from #396 to fix the tests? EDIT: Doesn't look like it fully fixes the issue but basically seems like a known issue |
The failing test here is because the tear down function is deleting the temporary storage files, but SQLite is still trying to write to the database. I’m ok with ignoring for now until we merge the close() PR. |
…ddFieldsToInvites
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.
Overall changes are looking good! still noted a couple of items that should be addressed in this PR and ideally have tests added for them.
… not passed * check MEMBER and COORDINATOR ROLE_ID as only valid roleIds * delete `roleIdFromName` from `src/capabilities.js`
should close #275