0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-29 07:18:20 +02:00

modules/media: Add file download command.

This commit is contained in:
Jason Volk 2018-04-27 14:40:44 -07:00
parent 9168477e69
commit 8cf95a6ba0

View file

@ -4507,3 +4507,54 @@ console_cmd__file__room(opt &out, const string_view &line)
out << file_room_id(buf, server, file) << std::endl;
return true;
}
bool
console_cmd__file__download(opt &out, const string_view &line)
{
const params param{line, " ",
{
"server|amalgam", "file"
}};
auto server
{
param.at(0)
};
auto file
{
param[1]
};
auto remote
{
has(server, '/')? param[1] : param[2]
};
if(has(server, '/'))
{
const auto s(split(server, '/'));
server = s.first;
file = s.second;
}
if(!remote)
remote = server;
using prototype = m::room::id::buf (const string_view &server,
const string_view &file,
const net::hostport &remote);
static m::import<prototype> download
{
"media_media", "download"
};
const m::room::id::buf room_id
{
download(server, file, remote)
};
out << room_id << std::endl;
return true;
}