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

Add admins/owner on group create #76

Merged
merged 26 commits into from
Nov 25, 2019
Merged

Add admins/owner on group create #76

merged 26 commits into from
Nov 25, 2019

Conversation

giarc3
Copy link
Member

@giarc3 giarc3 commented Nov 20, 2019

  • Added add_as_admin, admins, and owner to GroupCreateOpts.
  • Made GroupCreateOpts::standardize() return a new GroupCreateOptsStd that is destructured by group_create.
  • Added additional validation with combinations of owner and admins.
  • Added owner to group response structs.
  • Added tests for adding admins/owner on group create.
  • Restructured lots of tests to return Result and use ? because better error messages were needed during testing.

TODO:

  • Changelog

src/group.rs Outdated Show resolved Hide resolved
src/group.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/group.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@clintfred clintfred left a comment

Choose a reason for hiding this comment

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

Made some suggestions. I would really like to see if we can add some more unit tests for this change.

src/group.rs Outdated Show resolved Hide resolved
src/group.rs Outdated Show resolved Hide resolved
src/group.rs Show resolved Hide resolved
src/group.rs Outdated Show resolved Hide resolved
src/group.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/requests.rs Show resolved Hide resolved
Copy link
Contributor

@clintfred clintfred left a comment

Choose a reason for hiding this comment

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

Moving in the right direction!

src/group.rs Outdated Show resolved Hide resolved
owner_id
}
// if the owner is the calling user (default), they should have been added to the
// admins list by `add_as_admin`. If they aren't, it will error later on.
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this mean "will error later on"?

Copy link
Member Author

Choose a reason for hiding this comment

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

The validation for it is a few lines below it. I was trying to show that the case is accounted for, even though it's not right here. Should I call this out differently?

src/group.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
user_ids_and_keys: HashMap<UserId, PublicKey>,
) -> Result<
(
Vec<(UserId, PublicKey, TransformKey)>,
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 generating the transform keys in this function is not good separation of concerns. You could argue that if the number of members is huge there could be a performance reason to mix this in here so that you don't have to go over the list again, but I don't see that as a legitimate concern.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see this function as getting everything ready to make request::GroupMembers and request::GroupAdmins, so generating the TransformKeys here seems to fulfill that purpose to me. Are you thinking of it more as just a way to re-partition the admins and members?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should rename the function to note that, or add a comment to it? Really it wouldn't be that bad to have this return the 2 vecs and feed the members vec back into another function which would generate the transform keys. At the same time, this does break it up more than it was, which is incremental improvement.

I'll let you and clint figure out what needs to be done. 🏃‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

I still do think it would be cleaner to do the transform key generation as a separate step, but this solution isn't bad. I think the function signature makes it clear that transform keys are also being computed in here, but maybe putting a small doc comment on this function is a good idea anyway.

src/internal/group_api/mod.rs Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
user_ids_and_keys: HashMap<UserId, PublicKey>,
) -> Result<
(
Vec<(UserId, PublicKey, TransformKey)>,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should rename the function to note that, or add a comment to it? Really it wouldn't be that bad to have this return the 2 vecs and feed the members vec back into another function which would generate the transform keys. At the same time, this does break it up more than it was, which is incremental improvement.

I'll let you and clint figure out what needs to be done. 🏃‍♂️

user_ids_and_keys: HashMap<UserId, PublicKey>,
) -> Result<
(
Vec<(UserId, PublicKey, TransformKey)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I still do think it would be cleaner to do the transform key generation as a separate step, but this solution isn't bad. I think the function signature makes it clear that transform keys are also being computed in here, but maybe putting a small doc comment on this function is a good idea anyway.

CHANGELOG.md Outdated Show resolved Hide resolved
@giarc3 giarc3 merged commit a6eaa54 into master Nov 25, 2019
@giarc3 giarc3 deleted the 66-group-create-admins branch November 25, 2019 20:13
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.

5 participants