2019-08-22 08:57:07 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_M_MEDIA_H
|
|
|
|
|
|
|
|
namespace ircd::m::media
|
|
|
|
{
|
|
|
|
struct mxc;
|
2020-08-21 03:56:14 +02:00
|
|
|
|
|
|
|
extern log::log log;
|
|
|
|
extern conf::item<size_t> events_prefetch;
|
|
|
|
extern conf::item<seconds> download_timeout;
|
2022-08-10 21:44:56 +02:00
|
|
|
extern conf::item<size_t> journal_threshold;
|
2020-08-21 03:56:14 +02:00
|
|
|
extern std::set<m::room::id> downloading;
|
|
|
|
extern ctx::dock downloading_dock;
|
2019-08-22 08:57:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ircd::m::media::file
|
|
|
|
{
|
|
|
|
using closure = std::function<void (const const_buffer &)>;
|
|
|
|
|
2023-02-18 04:10:06 +01:00
|
|
|
constexpr bool debug_read {false};
|
|
|
|
|
2019-08-22 08:57:07 +02:00
|
|
|
room::id room_id(room::id::buf &out, const mxc &);
|
|
|
|
room::id::buf room_id(const mxc &);
|
|
|
|
|
|
|
|
size_t read(const room &, const closure &);
|
2023-03-11 23:14:35 +01:00
|
|
|
size_t write(const room &, const user::id &, const const_buffer &content, const string_view &content_type, const string_view &name = {});
|
2019-08-22 08:57:07 +02:00
|
|
|
|
|
|
|
room::id::buf
|
|
|
|
download(const mxc &,
|
|
|
|
const m::user::id &,
|
2020-03-13 20:15:15 +01:00
|
|
|
const string_view &remote = {});
|
2019-08-22 08:57:07 +02:00
|
|
|
|
|
|
|
std::pair<http::response::head, unique_buffer<mutable_buffer>>
|
|
|
|
download(const mutable_buffer &head_buf,
|
|
|
|
const mxc &mxc,
|
2020-03-08 04:20:06 +01:00
|
|
|
string_view remote = {},
|
2019-08-22 08:57:07 +02:00
|
|
|
server::request::opts *const opts = nullptr);
|
|
|
|
|
|
|
|
m::room
|
|
|
|
download(const mxc &mxc,
|
|
|
|
const m::user::id &user_id,
|
2020-03-13 20:15:15 +01:00
|
|
|
const m::room::id &room_id,
|
|
|
|
string_view remote = {});
|
2019-08-22 08:57:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ircd::m::media::mxc
|
|
|
|
{
|
|
|
|
string_view server;
|
|
|
|
string_view mediaid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
string_view path(const mutable_buffer &out) const;
|
|
|
|
string_view uri(const mutable_buffer &out) const;
|
|
|
|
|
|
|
|
// construct from server and file; note that if mediaid is empty then
|
|
|
|
// server is fed to the uri constructor.
|
|
|
|
mxc(const string_view &server, const string_view &mediaid);
|
|
|
|
|
|
|
|
// construct from "server/file" or "mxc://server/file"
|
|
|
|
mxc(const string_view &uri);
|
|
|
|
};
|