0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-02 21:59:02 +02:00

modules/client/profile: Return 404 rather than {} for empty profiles.

This commit is contained in:
Jason Volk 2019-03-03 15:54:05 -08:00
parent bfb2efc1ac
commit f1bca6de7e

View file

@ -198,6 +198,28 @@ get__profile_full(client &client,
const resource::request &request,
const m::user &user)
{
const m::user::profile profile
{
user
};
// Have to return a 404 if the profile is empty rather than a {},
// so we iterate for at least one element first to check that.
bool empty{true};
profile.for_each([&empty]
(const string_view &, const string_view &)
{
empty = false;
return false;
});
if(empty)
throw m::NOT_FOUND
{
"Profile for %s is empty.",
string_view{user.user_id}
};
resource::response::chunked response
{
client, http::OK
@ -213,11 +235,6 @@ get__profile_full(client &client,
out
};
const m::user::profile profile
{
user
};
profile.for_each([&top]
(const string_view &param, const string_view &value)
{