0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/media: Consolidate media modules for easier linkages.

This commit is contained in:
Jason Volk 2018-04-12 14:44:30 -07:00
parent a08684c9e7
commit a8b143d6c2
6 changed files with 55 additions and 53 deletions

View file

@ -280,14 +280,15 @@ federation_module_LTLIBRARIES = \
media_moduledir = @moduledir@
media_media_download_la_SOURCES = media/download.cc
media_media_upload_la_SOURCES = media/upload.cc
media_media_thumbnail_la_SOURCES = media/thumbnail.cc
media_media_media_la_SOURCES = \
media/download.cc \
media/upload.cc \
media/thumbnail.cc \
media/media.cc \
###
media_module_LTLIBRARIES = \
media/media_download.la \
media/media_upload.la \
media/media_thumbnail.la \
media/media_media.la \
###
###############################################################################

View file

@ -10,12 +10,6 @@
#include "media.h"
mapi::header
IRCD_MODULE
{
"Client 11.7 :Content repository (download)"
};
resource
download_resource
{
@ -73,13 +67,13 @@ get__download(client &client,
};
}
resource::method
static resource::method
method_get
{
download_resource, "GET", get__download
};
resource::method
static resource::method
method_get__legacy
{
download_resource__legacy, "GET", get__download

37
modules/media/media.cc Normal file
View file

@ -0,0 +1,37 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 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.
#include "media.h"
mapi::header
IRCD_MODULE
{
"11.7 :Content respository"
};
m::room::id::buf
file_room_id(const string_view &server,
const string_view &file)
{
size_t len;
thread_local char buf[512];
len = strlcpy(buf, server);
len = strlcat(buf, "/"_sv);
len = strlcat(buf, file);
const sha256::buf hash
{
sha256{string_view{buf, len}}
};
return m::room::id::buf
{
b58encode(buf, hash), my_host()
};
}

View file

@ -10,22 +10,4 @@
using namespace ircd;
static m::room::id::buf
file_room_id(const string_view &server,
const string_view &file)
{
size_t len;
thread_local char buf[512];
len = strlcpy(buf, server);
len = strlcat(buf, "/"_sv);
len = strlcat(buf, file);
const sha256::buf hash
{
sha256{string_view{buf, len}}
};
return m::room::id::buf
{
b58encode(buf, hash), my_host()
};
}
m::room::id::buf file_room_id(const string_view &server, const string_view &file);

View file

@ -16,18 +16,12 @@
#include "media.h"
mapi::header
IRCD_MODULE
{
"Client 11.7.1.4 :Media thumbnails"
};
resource
thumbnail_resource__legacy
{
"/_matrix/media/v1/thumbnail/",
{
"Media thumbnails (legacy version)",
"(11.7.1.4) thumbnails (legacy version)",
resource::DIRECTORY,
}
};
@ -37,7 +31,7 @@ thumbnail_resource
{
"/_matrix/media/r0/thumbnail/",
{
"Media thumbnails",
"(11.7.1.4) thumbnails",
resource::DIRECTORY,
}
};
@ -105,13 +99,13 @@ get__thumbnail(client &client,
};
}
resource::method
static resource::method
method_get__legacy
{
thumbnail_resource__legacy, "GET", get__thumbnail
};
resource::method
static resource::method
method_get
{
thumbnail_resource, "GET", get__thumbnail

View file

@ -10,12 +10,6 @@
#include "media.h"
mapi::header
IRCD_MODULE
{
"Client 11.7 :Content repository (upload)"
};
resource
upload_resource__legacy
{
@ -135,8 +129,8 @@ post__upload(client &client,
};
}
struct resource::method::opts
const method_post_opts
static const struct resource::method::opts
method_post_opts
{
resource::method::REQUIRES_AUTH |
resource::method::CONTENT_DISCRETION,
@ -144,13 +138,13 @@ const method_post_opts
8_MiB //TODO: conf; (this is the payload max option)
};
resource::method
static resource::method
method_post
{
upload_resource, "POST", post__upload, method_post_opts
};
resource::method
static resource::method
method_post__legacy
{
upload_resource__legacy, "POST", post__upload, method_post_opts