diff --git a/modules/Makefile.am b/modules/Makefile.am index 1fb08639e..2f917bb4f 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -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 \ ### ############################################################################### diff --git a/modules/media/download.cc b/modules/media/download.cc index c37fae4ce..b8823a27b 100644 --- a/modules/media/download.cc +++ b/modules/media/download.cc @@ -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 diff --git a/modules/media/media.cc b/modules/media/media.cc new file mode 100644 index 000000000..b98fb7f14 --- /dev/null +++ b/modules/media/media.cc @@ -0,0 +1,37 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// 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() + }; +} diff --git a/modules/media/media.h b/modules/media/media.h index 6fd61a540..ae1ae8746 100644 --- a/modules/media/media.h +++ b/modules/media/media.h @@ -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); diff --git a/modules/media/thumbnail.cc b/modules/media/thumbnail.cc index a5328b9cb..e48fd9b7b 100644 --- a/modules/media/thumbnail.cc +++ b/modules/media/thumbnail.cc @@ -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 diff --git a/modules/media/upload.cc b/modules/media/upload.cc index 988de5d08..03611ba56 100644 --- a/modules/media/upload.cc +++ b/modules/media/upload.cc @@ -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