bloxy icon indicating copy to clipboard operation
bloxy copied to clipboard

Conflict in userPresenceType

Open JohnnyMorganz opened this issue 4 years ago • 1 comments

There seems to be a conflict in the UserPresenceType stored in the User class In the User class, the userPresenceType value in the presence field is of type string, however this can be populated in three ways:

  1. Through the Presence API The Presence API returns a string, as shown here: https://github.com/Visualizememe/bloxy/blob/25f3940d49edf3acb63d740c41e4f2e336b6ec49/src/client/apis/PresenceAPI.ts#L16

  2. Through the Friends API The UserPresenceType can be returned in the Friends API. This is stored as a string, as shown here: https://github.com/Visualizememe/bloxy/blob/25f3940d49edf3acb63d740c41e4f2e336b6ec49/src/client/apis/FriendsAPI.ts#L126

  3. Through the Profile Header In the profile header, the UserPresenceType returned is a number, as seen here: https://github.com/Visualizememe/bloxy/blob/25f3940d49edf3acb63d740c41e4f2e336b6ec49/src/client/apis/OtherAPI.ts#L14 which is then used to create the User object: https://github.com/Visualizememe/bloxy/blob/25f3940d49edf3acb63d740c41e4f2e336b6ec49/src/client/Client.ts#L103

Here is the mapping between numbers and string: 0 - "Offline" 1 - "Online" 2 - "In Game" 3 - "In Studio"

The UserPresenceType stored here is conflicted with the type for the User object. There needs to be a decision made to ensure this is kept uniform in all locations

JohnnyMorganz avatar Dec 10 '20 18:12 JohnnyMorganz

There seems to actually be an error in the Roblox Presence API docs: https://presence.roblox.com/docs#!/Presence/post_v1_presence_users

Here, they document userPresenceType to be a string, and give the example as such, but if you attempt a request, it will actually return a number.

It may make sense to either support a number everywhere, or use an enum to map the numbers to human readable enums

JohnnyMorganz avatar Dec 10 '20 18:12 JohnnyMorganz