spacebarchat / server

Spacebar server - A reimplementation of the Discord.com backend, built with Typescript and love
https://spacebar.chat
GNU Affero General Public License v3.0
1.48k stars 251 forks source link

Stop returning defaults when using User.getPublicUser() #1208

Open DEVTomatoCake opened 2 months ago

DEVTomatoCake commented 2 months ago

Slightly annoying, confusing and sending unnecessary bytes, so I've fixed the User.getPublicUser() method to only return the properties that are actually needed for, well, public users.

Currently, properties like desktop and webauthn_enabled are returned with their default values, which, while not exposing anything, are not matching the schemas.

This PR adjusts the method to call <User>.toPublicUser() and removes arguments which were rarely used and can be replaced with e.g. User.findOneOrFail().