Skip to content

Commit

Permalink
Feat: add fields to invites (#393)
Browse files Browse the repository at this point in the history
* add fields to invites

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

* make roleName an Enum of COORDINATOR, MEMBER, BLOCKED

* start fixing e2e tests

* keep fixing tests

* 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

* add project name to members and sync e2e tests

This avoid the tests hanging since now we need a project name in order
to send an invite

* * add roleIdFromName to simplify memberApi.invite
* regenerate rpc.js due
to formatting issues

* various changes

* 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

* add `invitorName` to invite

* union `Invite` with {invitorName:string}

* add `invitorName` to `Invite` protobuf and fix tests

* * Make roleName optional in `memberApi.invite`, derive from roleId if not
  passed
* check MEMBER and COORDINATOR ROLE_ID as only valid roleIds
* delete `roleIdFromName` from `src/capabilities.js`

* Add tests for custom `roleName` and empty `roleName`

Also:
* Fix typo with wrong ROLE_ID
* Change test-e2e/utils.Invite signature to return invite response
* revert assertion in `memberApi.invite` to using every available
  capability instead of only member and coordinator

* more descriptive tests text

Co-authored-by: Andrew Chou <andrewchou@fastmail.com>

* Revert changes on test-e2e/utils.invite

Co-authored-by: Andrew Chou <andrewchou@fastmail.com>

* Use event listener on invite in `test-e2d/members.js`

Co-authored-by: Andrew Chou <andrewchou@fastmail.com>

---------

Co-authored-by: Tomás Ciccola <tciccola@digital-democracy.com>
Co-authored-by: Andrew Chou <andrewchou@fastmail.com>
  • Loading branch information
3 people committed Dec 13, 2023
1 parent e629cd6 commit 6eac910
Show file tree
Hide file tree
Showing 14 changed files with 559 additions and 269 deletions.
3 changes: 3 additions & 0 deletions proto/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ message Invite {
bytes projectKey = 1;
EncryptionKeys encryptionKeys = 2;
optional ProjectInfo projectInfo = 3;
string roleName = 4;
optional string roleDescription = 5;
string invitorName = 6;
}
message InviteResponse {
enum Decision {
Expand Down
15 changes: 15 additions & 0 deletions src/generated/rpc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export interface Invite {
projectKey: Buffer;
encryptionKeys: EncryptionKeys | undefined;
projectInfo?: Invite_ProjectInfo | undefined;
roleName: string;
roleDescription?: string | undefined;
invitorName: string;
}
/** Project info that is displayed to the user receiving the invite */
export interface Invite_ProjectInfo {
Expand Down Expand Up @@ -41,6 +44,9 @@ export declare const Invite: {
projectInfo?: {
name?: string | undefined;
};
roleName?: string;
roleDescription?: string | undefined;
invitorName?: string;
} & {
projectKey?: Buffer;
encryptionKeys?: {
Expand All @@ -61,6 +67,9 @@ export declare const Invite: {
} & {
name?: string | undefined;
} & { [K_1 in Exclude<keyof I["projectInfo"], "name">]: never; };
roleName?: string;
roleDescription?: string | undefined;
invitorName?: string;
} & { [K_2 in Exclude<keyof I, keyof Invite>]: never; }>(base?: I): Invite;
fromPartial<I_1 extends {
projectKey?: Buffer;
Expand All @@ -74,6 +83,9 @@ export declare const Invite: {
projectInfo?: {
name?: string | undefined;
};
roleName?: string;
roleDescription?: string | undefined;
invitorName?: string;
} & {
projectKey?: Buffer;
encryptionKeys?: {
Expand All @@ -94,6 +106,9 @@ export declare const Invite: {
} & {
name?: string | undefined;
} & { [K_4 in Exclude<keyof I_1["projectInfo"], "name">]: never; };
roleName?: string;
roleDescription?: string | undefined;
invitorName?: string;
} & { [K_5 in Exclude<keyof I_1, keyof Invite>]: never; }>(object: I_1): Invite;
};
export declare const Invite_ProjectInfo: {
Expand Down
Loading

0 comments on commit 6eac910

Please sign in to comment.