0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-18 01:48:27 +02:00

modules/client/directory/room: Add conf items for alias related.

This commit is contained in:
Jason Volk 2018-09-04 21:12:47 -07:00
parent bb6ab49fe1
commit d4a3b3c91d

View file

@ -129,6 +129,13 @@ catch(const m::NOT_FOUND &)
return false;
}
conf::item<seconds>
room_alias_cache_ttl
{
{ "name", "ircd.client.directory.room.alias.cache.ttl" },
{ "default", 60 * 60 * 72L },
};
/// Translate a room alias into a room_id. This function first checks the
/// local cache. A cache miss will then cause in a query to the remote, the
/// result of which will be added to cache.
@ -154,8 +161,7 @@ try
ircd::now() - milliseconds(at<"origin_server_ts"_>(event))
};
//TODO: Conf; cache TTL.
if(age > hours(72))
if(age > seconds(room_alias_cache_ttl))
return;
ret = string_view { data(out), copy(out, room_id) };
@ -209,6 +215,13 @@ catch(const json::not_found &e)
};
}
conf::item<seconds>
room_alias_fetch_timeout
{
{ "name", "ircd.client.directory.room.alias.fetch.timeout" },
{ "default", 20L },
};
/// 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
/// query operation.
@ -221,8 +234,7 @@ room_alias_fetch(const mutable_buffer &out,
alias, out
};
//TODO: conf
if(!federation_request.wait(seconds(8), std::nothrow))
if(!federation_request.wait(seconds(room_alias_fetch_timeout), std::nothrow))
throw http::error
{
http::REQUEST_TIMEOUT