mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
modules/client/profile: Return 404 rather than {} for empty profiles.
This commit is contained in:
parent
bfb2efc1ac
commit
f1bca6de7e
1 changed files with 22 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue