diff --git a/modules/client/profile.cc b/modules/client/profile.cc index cfd52408e..19054fab8 100644 --- a/modules/client/profile.cc +++ b/modules/client/profile.cc @@ -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 ¶m, const string_view &value) {