mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
modules/media: Additional argument to separate server name from actual remote.
This commit is contained in:
parent
05369c5d3a
commit
a5ebd50f55
1 changed files with 20 additions and 4 deletions
|
@ -39,6 +39,7 @@ thumbnail_resource
|
||||||
static resource::response
|
static resource::response
|
||||||
get__thumbnail_remote(client &client,
|
get__thumbnail_remote(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
|
const string_view &remote,
|
||||||
const string_view &server,
|
const string_view &server,
|
||||||
const string_view &file,
|
const string_view &file,
|
||||||
const m::room &room);
|
const m::room &room);
|
||||||
|
@ -66,7 +67,7 @@ get__thumbnail(client &client,
|
||||||
http::MULTIPLE_CHOICES, "Media ID parameter required"
|
http::MULTIPLE_CHOICES, "Media ID parameter required"
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &server
|
auto &server
|
||||||
{
|
{
|
||||||
request.parv[0]
|
request.parv[0]
|
||||||
};
|
};
|
||||||
|
@ -92,11 +93,25 @@ get__thumbnail(client &client,
|
||||||
if(m::exists(room))
|
if(m::exists(room))
|
||||||
return get__thumbnail_local(client, request, server, file, room);
|
return get__thumbnail_local(client, request, server, file, room);
|
||||||
|
|
||||||
if(!my_host(server))
|
//TODO: XXX conf
|
||||||
|
//TODO: XXX vector
|
||||||
|
static const string_view secondary
|
||||||
|
{
|
||||||
|
"matrix.org"
|
||||||
|
};
|
||||||
|
|
||||||
|
const string_view &remote
|
||||||
|
{
|
||||||
|
my_host(server)?
|
||||||
|
secondary:
|
||||||
|
server
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!my_host(remote))
|
||||||
{
|
{
|
||||||
//TODO: ABA TXN
|
//TODO: ABA TXN
|
||||||
create(room, m::me.user_id, "file");
|
create(room, m::me.user_id, "file");
|
||||||
return get__thumbnail_remote(client, request, server, file, room);
|
return get__thumbnail_remote(client, request, remote, server, file, room);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw m::NOT_FOUND
|
throw m::NOT_FOUND
|
||||||
|
@ -121,6 +136,7 @@ static resource::response
|
||||||
get__thumbnail_remote(client &client,
|
get__thumbnail_remote(client &client,
|
||||||
const resource::request &request,
|
const resource::request &request,
|
||||||
const string_view &hostname,
|
const string_view &hostname,
|
||||||
|
const string_view &server,
|
||||||
const string_view &mediaid,
|
const string_view &mediaid,
|
||||||
const m::room &room)
|
const m::room &room)
|
||||||
try
|
try
|
||||||
|
@ -141,7 +157,7 @@ try
|
||||||
{
|
{
|
||||||
wb, hostname, "GET", fmt::sprintf
|
wb, hostname, "GET", fmt::sprintf
|
||||||
{
|
{
|
||||||
uri, "/_matrix/media/r0/download/%s/%s", hostname, mediaid
|
uri, "/_matrix/media/r0/download/%s/%s", server, mediaid
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue