ircd:Ⓜ️:media: Add optional file name to file room state.

This commit is contained in:
Jason Volk 2023-03-11 14:14:35 -08:00
parent 96119166fa
commit 8ebd2089f2
3 changed files with 10 additions and 3 deletions

View File

@ -33,7 +33,7 @@ namespace ircd::m::media::file
room::id::buf room_id(const mxc &);
size_t read(const room &, const closure &);
size_t write(const room &, const user::id &, const const_buffer &content, const string_view &content_type);
size_t write(const room &, const user::id &, const const_buffer &content, const string_view &content_type, const string_view &name = {});
room::id::buf
download(const mxc &,

View File

@ -221,7 +221,8 @@ size_t
ircd::m::media::file::write(const m::room &room,
const m::user::id &user_id,
const const_buffer &content,
const string_view &content_type)
const string_view &content_type,
const string_view &name)
try
{
static const size_t BLK_SZ
@ -256,6 +257,12 @@ try
{ "mime_type", content_type }
});
if(name)
send(room, user_id, "ircd.file.stat.name", "", json::members
{
{ "name", name }
});
size_t off{0}, wrote{0};
while(off < size(content))
{

View File

@ -75,7 +75,7 @@ post__upload(client &client,
const size_t written
{
m::media::file::write(room, request.user_id, buf, content_type)
m::media::file::write(room, request.user_id, buf, content_type, filename)
};
char uribuf[256];