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

user_id type is different in Identity compared with user_id and room_id of messages #234

Open
liquidnya opened this issue Jan 11, 2021 · 1 comment

Comments

@liquidnya
Copy link

The user_id in Identity::Full has the type i64, but other room_id and user_id functions of messages e.g. Privmsg::user_id uses u64 as the user id type.

When comparing the user_id or room_id with the bot identity user_id I have to convert between the types and handle the error cases:

  • Converting from u64 to i64 would break if there is an user id that is greater than i64::MAX
  • Converting from i64 to u64 would work fine if there are no negative user ids

If there are no negative user ids I suggest changing the type of user_id in Identity::Full to u64.

@museun
Copy link
Owner

museun commented Jan 13, 2021

Twitch does not specify the numeric bounds for those types. Being that most of their system speaks JSON, ideally those should be i64 (which matches the integer type most JSON implementations use (including serde_json)).

Its a mistake on my end to have u64s there. I intentionally used i64 but there has been some oversight. There isn't really any schema or spec to follow, so I'm just going off the cuff and hoping things stay relatively the same. I highly doubt Twitch would ever send a negative id, but my types->json would require a conversion, likely.

I agree they should all be the same type. I would prefer they be u64s but there is a sound reason for them to be i64s.

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

No branches or pull requests

2 participants