fix: make element not show "unknown user" warning

The 404 error for /profile in the spec says "There is no profile
information for this user or this user does not exist.", but Element
assumes every 404 is a user that does not exist.
merge-requests/22/head
Timo Kösters 4 years ago
parent df55e8ed0b
commit 515465f900
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4

@ -217,11 +217,8 @@ pub fn get_profile_route(
db: State<'_, Database>, db: State<'_, Database>,
body: Ruma<get_profile::Request>, body: Ruma<get_profile::Request>,
) -> ConduitResult<get_profile::Response> { ) -> ConduitResult<get_profile::Response> {
let avatar_url = db.users.avatar_url(&body.user_id)?; if !db.users.exists(&body.user_id)? {
let displayname = db.users.displayname(&body.user_id)?; // Return 404 if this user doesn't exist
if avatar_url.is_none() && displayname.is_none() {
// Return 404 if we don't have a profile for this id
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::NotFound, ErrorKind::NotFound,
"Profile was not found.", "Profile was not found.",
@ -229,8 +226,8 @@ pub fn get_profile_route(
} }
Ok(get_profile::Response { Ok(get_profile::Response {
avatar_url, avatar_url: db.users.avatar_url(&body.user_id)?,
displayname, displayname: db.users.displayname(&body.user_id)?,
} }
.into()) .into())
} }

Loading…
Cancel
Save