Files

50 lines
1.4 KiB
C++

#pragma once
#include "session/network/key_types.hpp"
#include "session/network/session_network_types.hpp"
#include "session/platform.hpp"
namespace session::network::config {
struct OpenGroupServer {
std::string base_url;
std::string room;
std::string pubkey_hex;
bool use_stream_encryption;
};
} // namespace session::network::config
namespace session::network::open_group_server {
struct DownloadInfo {
std::string base_url;
std::string room;
uint64_t file_id;
bool wants_stream_decryption; // If 'd' fragment present
};
/// API: open_group_server/parse_download_url
///
/// Parses a url to extract the information required to download the file.
///
/// Inputs:
/// - `url` -- [in] url to parse.
///
/// Outputs:
/// - returns struct containing the information required to download the file.
std::optional<DownloadInfo> parse_download_url(std::string_view url);
/// API: open_group_server/generate_download_url
///
/// Generates a download url to the configured file server for a given file id.
///
/// Inputs:
/// - `file_id` -- [in] id for the file generated by uploading to the open group server.
/// - `config` -- [in] open group server configuration to use to generate the download url.
///
/// Outputs:
/// - returns url which can be used to download the file.
std::string generate_download_url(uint64_t file_id, const config::OpenGroupServer& config);
} // namespace session::network::open_group_server