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

feat: add support for decoding roomID from Space events #55

Merged
merged 8 commits into from
Dec 21, 2023

Conversation

sgrimee
Copy link
Contributor

@sgrimee sgrimee commented Dec 19, 2023

Space events have a different way to report the target room id than message events. It also varies based on the Space event type, and the Create event requires patching of the UUID. §

This PR includes changes to make this all transparent in the get_global_id.

At the same time, it deprecates get_global_id in favour of try_global_id with error reporting.

deprecates get_global_id in favour of try_global_id with error reporting
@sgrimee
Copy link
Contributor Author

sgrimee commented Dec 19, 2023

If the approach is ok, I will modify the examples to use try_global_id instead of get_global_id

src/types.rs Outdated
if uuid.as_bytes()[7] == b'2' {
uuid.replace_range(7..8, "0");
} else {
panic!("Space created uuid {uuid} could not be not patched");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really do not like a panic, I would rather return an Error since we already are returning a Result

Copy link
Collaborator

@aknarts aknarts Dec 19, 2023

Choose a reason for hiding this comment

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

something like

crate::error::ErrorKind::Api(
                "Space created uuid {uuid} could not be not patched",
            )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yes, that one slipped through the cracks from a previous version! I'll remove it

@aknarts aknarts merged commit 902b528 into wr-org:master Dec 21, 2023
1 check passed
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.

2 participants