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

Who Added Me #614

Merged
merged 21 commits into from
Apr 15, 2024
Merged

Who Added Me #614

merged 21 commits into from
Apr 15, 2024

Conversation

zombieobject
Copy link
Contributor

@zombieobject zombieobject commented Apr 4, 2024

Save the wallet address of who added a user to a group.

@zombieobject zombieobject added enhancement New feature or request work in progress labels Apr 4, 2024
@zombieobject zombieobject self-assigned this Apr 4, 2024
@zombieobject zombieobject force-pushed the em/staged-welcome branch 2 times, most recently from 5c76b40 to d0c98df Compare April 8, 2024 23:24
@zombieobject zombieobject changed the title WIP: Staged Welcome WIP: Who Added Me Apr 9, 2024
@zombieobject zombieobject force-pushed the em/staged-welcome branch 2 times, most recently from 43f6bbc to 4b613a3 Compare April 10, 2024 22:01
@zombieobject zombieobject changed the title WIP: Who Added Me Who Added Me Apr 10, 2024
@zombieobject zombieobject marked this pull request as ready for review April 10, 2024 22:02
@zombieobject zombieobject requested a review from a team as a code owner April 10, 2024 22:02
@zombieobject zombieobject enabled auto-merge (squash) April 10, 2024 22:09
bindings_ffi/src/mls.rs Outdated Show resolved Hide resolved
bindings_ffi/src/mls.rs Outdated Show resolved Hide resolved
bindings_ffi/src/mls.rs Outdated Show resolved Hide resolved
bindings_ffi/src/mls.rs Outdated Show resolved Hide resolved
client,
group_id,
stored_group.created_at_ns,
added_by_address,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ethan and I paired and got on the same page. My initial hesitation was that I didn't understand why we needed to set the address on the MlsGroup::new and also on the StoredGroup:new seems like we should just be able to set it on the stored group and then fetch it from the stored group? Came to the conclusion that we don't do anything with the storedGroup in the bindings so this seems like the best way given our current architecture cc @richardhuaaa if I'm missing some context.

Copy link
Contributor

@richardhuaaa richardhuaaa Apr 15, 2024

Choose a reason for hiding this comment

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

@nplasterer it's a good point. Today, we're fetching the StoredGroup, and then manually caching the values (created_at_ns, added_by_address) onto the MlsGroup via the constructor so that we don't need to re-fetch it again. The drawback is that the constructor for MlsGroup is getting more complicated over time. Could be refactored one of two ways:

  1. Don't cache the values onto the MlsGroup. This is simpler code, but tradeoff is you need to re-fetch from the DB every time you need a property like added_by.

  2. Instead of manually copying the values over to the MlsGroup, have the MlsGroup hold a copy of StoredGroup inside it so there's no duplication. That's probably the best of both worlds.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like 2. do you think this will be hard to do later/a breaking change? Just seeing how we should prioritize that work. My gut is saying we should probably do it now before we filter this through the sdks.

@zombieobject
Copy link
Contributor Author

@nplasterer The requested reverted changes are now complete and ready for review.

@zombieobject zombieobject force-pushed the em/staged-welcome branch 4 times, most recently from a51b06e to ccfc9ee Compare April 15, 2024 03:41
@zombieobject
Copy link
Contributor Author

zombieobject commented Apr 15, 2024

I am passing on this flaky failing test as originally suggested by @richardhuaaa. It passes locally without fail. I have on occasion had it pass in CI. That said, it's a bad test that needs to be refactored.

With that out of the way, this PR is ready to go.

@nplasterer nplasterer dismissed their stale review April 15, 2024 16:25

This looks good from my perspective but would like someone else to review it since we paired.

Copy link
Contributor

@richardhuaaa richardhuaaa left a comment

Choose a reason for hiding this comment

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

LGTM. I have a slight preference for making the property and DB schema non-optional, and just eating the breaking change now so that devs don't have to deal with a nullable added_by. But leaving it up to you

let out = Arc::new(FfiGroup {
inner_client: self.inner_client.clone(),
group_id: convo.group_id,
created_at_ns: convo.created_at_ns,
added_by_address: Some(self.inner_client.account_address()),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should read this from convo so that the value is guaranteed to be consistent with convo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Thank you!

@nplasterer
Copy link
Contributor

just eating the breaking change now so that devs don't have to deal with a nullable added_by

I think that makes sense. Better to break things now than later. 👍

@zombieobject zombieobject merged commit e1fad9a into main Apr 15, 2024
5 of 6 checks passed
@zombieobject zombieobject deleted the em/staged-welcome branch April 15, 2024 19:28
@@ -0,0 +1,2 @@
ALTER TABLE groups
ADD COLUMN added_by_address TEXT
Copy link
Contributor

Choose a reason for hiding this comment

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

@zombieobject I think @richardhuaaa was suggesting that this is NOT NULL do you mind doing that in a follow up PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nplasterer I missed that comment just as I was merging the PR. I am more than happy to create a follow up PR to address this request.

For context, there were 2 reasons for the optionality of that parameter. The largest one IMHO was due to MLSGroup lifecycle, being that the address of "who added me" was not always available at group creation. The latter was breaking changes, but as you both stated, better to break things now, to which I concur.

I'll open up a follow up PR with the request immediately and see what I can do to address the lifecycle questions. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Group Chat - Prod
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants