@@ -17,135 +17,135 @@ const ErrorResponseSchema = t.Object({
1717export const mediaPlugin = ( app : Elysia ) => {
1818 const eventAuthService = container . resolve ( EventAuthorizationService ) ;
1919
20- return app
21- . get (
22- '/_matrix/media/v3/config' ,
23- async ( { set } ) => {
24- set . status = 404 ;
25- return {
26- errcode : 'M_UNRECOGNIZED' ,
27- error : 'This endpoint is not implemented on homeserver side' ,
28- } ;
29- } ,
30- {
31- response : {
32- 404 : ErrorResponseSchema ,
20+ return app . group ( '/_matrix' , ( app ) =>
21+ app
22+ . use ( isAuthenticatedMiddleware ( eventAuthService ) )
23+ . get (
24+ '/media/v3/config' ,
25+ async ( { set } ) => {
26+ set . status = 404 ;
27+ return {
28+ errcode : 'M_UNRECOGNIZED' ,
29+ error : 'This endpoint is not implemented on homeserver side' ,
30+ } ;
3331 } ,
34- detail : {
35- tags : [ 'Media' ] ,
36- summary : 'Get media configuration' ,
37- description : 'Get the media configuration for the homeserver' ,
38- } ,
39- } ,
40- )
41- . group ( '/_matrix' , ( app ) =>
42- app
43- . use ( canAccessResourceMiddleware ( eventAuthService , 'media' ) )
44- . get (
45- '/federation/v1/media/download/:mediaId' ,
46- async ( { set } ) => {
47- set . status = 404 ;
48- return {
49- errcode : 'M_UNRECOGNIZED' ,
50- error : 'This endpoint is not implemented on homeserver side' ,
51- } ;
32+ {
33+ response : {
34+ 404 : ErrorResponseSchema ,
35+ } ,
36+ detail : {
37+ tags : [ 'Media' ] ,
38+ summary : 'Get media configuration' ,
39+ description : 'Get the media configuration for the homeserver' ,
5240 } ,
53- {
54- params : t . Object ( {
55- mediaId : t . String ( ) ,
56- } ) ,
57- response : {
58- 404 : ErrorResponseSchema ,
59- } ,
41+ } ,
42+ )
43+ . use ( canAccessResourceMiddleware ( eventAuthService , 'media' ) )
44+ . get (
45+ '/federation/v1/media/download/:mediaId' ,
46+ async ( { set } ) => {
47+ set . status = 404 ;
48+ return {
49+ errcode : 'M_UNRECOGNIZED' ,
50+ error : 'This endpoint is not implemented on homeserver side' ,
51+ } ;
52+ } ,
53+ {
54+ params : t . Object ( {
55+ mediaId : t . String ( ) ,
56+ } ) ,
57+ response : {
58+ 404 : ErrorResponseSchema ,
6059 } ,
61- )
60+ } ,
61+ )
6262
63- . get (
64- '/media/r0/download/:serverName/:mediaId' ,
65- async ( { set } ) => {
66- set . status = 404 ;
67- return {
68- errcode : 'M_UNRECOGNIZED' ,
69- error : 'This endpoint is not implemented on homeserver side' ,
70- } ;
63+ . get (
64+ '/media/r0/download/:serverName/:mediaId' ,
65+ async ( { set } ) => {
66+ set . status = 404 ;
67+ return {
68+ errcode : 'M_UNRECOGNIZED' ,
69+ error : 'This endpoint is not implemented on homeserver side' ,
70+ } ;
71+ } ,
72+ {
73+ params : t . Object ( {
74+ serverName : t . String ( ) ,
75+ mediaId : t . String ( ) ,
76+ } ) ,
77+ response : {
78+ 404 : ErrorResponseSchema ,
7179 } ,
72- {
73- params : t . Object ( {
74- serverName : t . String ( ) ,
75- mediaId : t . String ( ) ,
76- } ) ,
77- response : {
78- 404 : ErrorResponseSchema ,
79- } ,
80- detail : {
81- tags : [ 'Media' ] ,
82- summary : 'Download media' ,
83- description : 'Download a file from the Matrix media repository' ,
84- } ,
80+ detail : {
81+ tags : [ 'Media' ] ,
82+ summary : 'Download media' ,
83+ description : 'Download a file from the Matrix media repository' ,
8584 } ,
86- )
85+ } ,
86+ )
8787
88- . get (
89- '/media/v3/download/:serverName/:mediaId' ,
90- async ( { set } ) => {
91- set . status = 404 ;
92- return {
93- errcode : 'M_UNRECOGNIZED' ,
94- error : 'This endpoint is not implemented on homeserver side' ,
95- } ;
88+ . get (
89+ '/media/v3/download/:serverName/:mediaId' ,
90+ async ( { set } ) => {
91+ set . status = 404 ;
92+ return {
93+ errcode : 'M_UNRECOGNIZED' ,
94+ error : 'This endpoint is not implemented on homeserver side' ,
95+ } ;
96+ } ,
97+ {
98+ params : t . Object ( {
99+ serverName : t . String ( ) ,
100+ mediaId : t . String ( ) ,
101+ } ) ,
102+ query : t . Object ( {
103+ allow_remote : t . Optional ( t . Boolean ( ) ) ,
104+ timeout_ms : t . Optional ( t . Number ( ) ) ,
105+ } ) ,
106+ response : {
107+ 404 : ErrorResponseSchema ,
96108 } ,
97- {
98- params : t . Object ( {
99- serverName : t . String ( ) ,
100- mediaId : t . String ( ) ,
101- } ) ,
102- query : t . Object ( {
103- allow_remote : t . Optional ( t . Boolean ( ) ) ,
104- timeout_ms : t . Optional ( t . Number ( ) ) ,
105- } ) ,
106- response : {
107- 404 : ErrorResponseSchema ,
108- } ,
109- detail : {
110- tags : [ 'Media' ] ,
111- summary : 'Download media' ,
112- description : 'Download a file from the Matrix media repository' ,
113- } ,
109+ detail : {
110+ tags : [ 'Media' ] ,
111+ summary : 'Download media' ,
112+ description : 'Download a file from the Matrix media repository' ,
114113 } ,
115- )
114+ } ,
115+ )
116116
117- . get (
118- '/media/v3/thumbnail/:serverName/:mediaId' ,
119- async ( { set } ) => {
120- set . status = 404 ;
121- return {
122- errcode : 'M_UNRECOGNIZED' ,
123- error : 'This endpoint is not implemented on homeserver side' ,
124- } ;
117+ . get (
118+ '/media/v3/thumbnail/:serverName/:mediaId' ,
119+ async ( { set } ) => {
120+ set . status = 404 ;
121+ return {
122+ errcode : 'M_UNRECOGNIZED' ,
123+ error : 'This endpoint is not implemented on homeserver side' ,
124+ } ;
125+ } ,
126+ {
127+ params : t . Object ( {
128+ serverName : t . String ( ) ,
129+ mediaId : t . String ( ) ,
130+ } ) ,
131+ query : t . Object ( {
132+ width : t . Optional ( t . Number ( { minimum : 1 , maximum : 800 } ) ) ,
133+ height : t . Optional ( t . Number ( { minimum : 1 , maximum : 600 } ) ) ,
134+ method : t . Optional (
135+ t . Union ( [ t . Literal ( 'crop' ) , t . Literal ( 'scale' ) ] ) ,
136+ ) ,
137+ allow_remote : t . Optional ( t . Boolean ( ) ) ,
138+ timeout_ms : t . Optional ( t . Number ( ) ) ,
139+ } ) ,
140+ response : {
141+ 404 : ErrorResponseSchema ,
125142 } ,
126- {
127- params : t . Object ( {
128- serverName : t . String ( ) ,
129- mediaId : t . String ( ) ,
130- } ) ,
131- query : t . Object ( {
132- width : t . Optional ( t . Number ( { minimum : 1 , maximum : 800 } ) ) ,
133- height : t . Optional ( t . Number ( { minimum : 1 , maximum : 600 } ) ) ,
134- method : t . Optional (
135- t . Union ( [ t . Literal ( 'crop' ) , t . Literal ( 'scale' ) ] ) ,
136- ) ,
137- allow_remote : t . Optional ( t . Boolean ( ) ) ,
138- timeout_ms : t . Optional ( t . Number ( ) ) ,
139- } ) ,
140- response : {
141- 404 : ErrorResponseSchema ,
142- } ,
143- detail : {
144- tags : [ 'Media' ] ,
145- summary : 'Get media thumbnail' ,
146- description : 'Get a thumbnail for a media file' ,
147- } ,
143+ detail : {
144+ tags : [ 'Media' ] ,
145+ summary : 'Get media thumbnail' ,
146+ description : 'Get a thumbnail for a media file' ,
148147 } ,
149- ) ,
150- ) ;
148+ } ,
149+ ) ,
150+ ) ;
151151} ;
0 commit comments