From 14608f4c6bb62488bff3e8fb9fb55446a2039fca Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 4 Apr 2018 18:36:54 -0700 Subject: [PATCH] modules/client/directory/room: Rewrite json::not_found; move cacher to after. --- modules/client/directory/room.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/client/directory/room.cc b/modules/client/directory/room.cc index ef0e361b4..abd4a7dcd 100644 --- a/modules/client/directory/room.cc +++ b/modules/client/directory/room.cc @@ -50,7 +50,7 @@ get__directory_room(client &client, }; char buf[256]; - const auto room_id + const m::room::id room_id { m::room_id(buf, room_alias) }; @@ -178,14 +178,14 @@ try room_alias_fetch(buf, alias) }; - // Cache the result - send(alias_room, m::me.user_id, "ircd.alias", alias, response); - const m::id::room &room_id { unquote(response.at("room_id")) }; + // Cache the result + send(alias_room, m::me.user_id, "ircd.alias", alias, response); + return m::room::id { string_view @@ -201,6 +201,13 @@ catch(const http::error &e) throw; } +catch(const json::not_found &e) +{ + throw m::NOT_FOUND + { + "Remote sent malformed response: %s", e.what() + }; +} /// This function makes a room alias request to a remote. The alias /// room cache is not checked or updated from here, this is only the