-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
rename membership and adopt newtype pattern #5320
base: main
Are you sure you want to change the base?
Conversation
f1af160
to
eff2ea0
Compare
6d34f06
to
af63c84
Compare
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.
Love this, I've been meaning for a while to do something about all the untyped string ids and never put much time into it as it seemed like a huge task. Thanks for the great work @stefan0xC!
Gave it a quick look and it looks pretty good, just have a couple of questions
af63c84
to
06026e3
Compare
Encountered this when trying to build:
I needed to add: diff --git a/.dockerignore b/.dockerignore
index 05c2a8e3..e11cb4ba 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -11,5 +11,6 @@
!build.rs
!Cargo.lock
!Cargo.toml
+!macros
!rustfmt.toml
!rust-toolchain.toml
diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine
index bc69fd7e..5341f1fd 100644
--- a/docker/Dockerfile.alpine
+++ b/docker/Dockerfile.alpine
@@ -81,6 +81,7 @@ RUN source /env-cargo && \
# Copies over *only* your manifests and build files
COPY ./Cargo.* ./rust-toolchain.toml ./build.rs ./
+COPY ./macros ./macros
ARG CARGO_PROFILE=release
diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian
index 896adf85..075d3759 100644
--- a/docker/Dockerfile.debian
+++ b/docker/Dockerfile.debian
@@ -120,6 +120,7 @@ RUN source /env-cargo && \
# Copies over *only* your manifests and build files
COPY ./Cargo.* ./rust-toolchain.toml ./build.rs ./
+COPY ./macros ./macros
ARG CARGO_PROFILE=release
diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2
index 797501ed..66db34eb 100644
--- a/docker/Dockerfile.j2
+++ b/docker/Dockerfile.j2
@@ -147,6 +147,7 @@ RUN source /env-cargo && \
# Copies over *only* your manifests and build files
COPY ./Cargo.* ./rust-toolchain.toml ./build.rs ./
+COPY ./macros ./macros
ARG CARGO_PROFILE=release |
@dfunkt Thanks for catching that. |
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.
LGTM, there's a few conflicts that need to be resolved before merging. Thanks for your work on this!
531589a
to
5c7a2fd
Compare
rename UserOrganization to Membership to clarify the relation and prevent confusion whether something refers to a member(ship) or user
Co-authored-by: dfunkt <[email protected]>
5c7a2fd
to
c44dfa3
Compare
@dani-garcia I am afraid you will have to approve this again. P.S.: sorry for the ping, but github doesn't send notification if a previous approval got invalidated |
I've been working on improving Vaultwarden's legibility by renaming the
UsersOrganizations
to simplyMembership
and making it clearer when something is referring to theUser
and when to aMembership
relation.After doing that I was motivated to try my hands on using the newtype pattern so that the Rust type system can be used to check on compile time if we always call the right
uuid
because there are a lot of Strings that can be used interchangeably otherwise.For example I noticed that we are passing the wrong id here:
vaultwarden/src/api/core/organizations.rs
Line 910 in ed4ad67
Because in contrast to
CollectionUser
theGroupUser::new
actually expects a different id:vaultwarden/src/db/models/group.rs
Line 122 in ed4ad67