HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
11.98k stars 4.09k forks source link

API must have exception to not include Tavern in list of guilds #12407

Closed Alys closed 4 years ago

Alys commented 4 years ago

If you use the api/v3/groups route to get a list of guilds for a user, then the returned list includes the Tavern. The Tavern should not be included.

I.e., if you do this command: curl -s -X GET -H "x-api-user: $HRPG_USER_USERID" -H "x-api-key: $HRPG_USER_APITOKEN" https://habitica.com/api/v3/groups"?type=publicGuilds&paginate=false" then the returned list includes all appropriate guilds but also this entry: {"_id":"00000000-0000-4000-A000-000000000000","privacy":"public","memberCount":7577,"balance":0,"leader":"7bde7864-ebc5-4ee2-a4b7-1070d464cdb0","name":"Tavern","type":"guild","categories":[]}

That entry represents the Tavern and it's included in the data from that route because from a technical perspective the Tavern is stored as a guild (however from a user's perspective it's not a guild).

The desired fix is that the api/v3/groups GET route should have an exception coded into it to prevent the group with the ID "00000000-0000-4000-A000-000000000000" from being included.

Note that that group ID is available as a constant: https://github.com/HabitRPG/habitica/blob/fef9c74f9b9ab9b49ae4a8f9380faa7007fb5535/website/common/script/constants.js#L7

This issue was created from https://github.com/HabitRPG/habitica/issues/7431

AlexanderColen commented 4 years ago

Is this issue still looking for help? Seems like a good issue that I could start with.

If I am not mistaken, a straightforward fix would probably be to use the $ne operator to exclude the entry with the tavern ID.

paglias commented 4 years ago

@AlexanderColen it's still looking for help!

These two methods are the ones most commonly used to fetch one or more groups https://github.com/HabitRPG/habitica/blob/develop/website/server/models/group.js#L230-L363