@@ -13,7 +13,6 @@ import {
1313 GetMissingEventsParamsDto ,
1414 GetMissingEventsResponseDto ,
1515 MakeJoinParamsDto ,
16- MakeJoinQueryDto ,
1716 MakeJoinResponseDto ,
1817 QueryKeysBodyDto ,
1918 QueryKeysResponseDto ,
@@ -22,143 +21,148 @@ import {
2221} from '../../dtos' ;
2322
2423export const profilesPlugin = ( app : Elysia ) => {
25- return app
26- . group ( '/_matrix' , ( app ) =>
27- app
28- . use ( isAuthenticatedMiddleware ( ) )
29- . get (
30- '/federation/v1/query/profile' ,
31- ( { query : { user_id } } ) =>
32- federationSDK . queryProfile ( user_id as UserID ) ,
33- {
34- query : QueryProfileQueryDto ,
35- response : {
36- 200 : QueryProfileResponseDto ,
24+ return (
25+ app
26+ . group ( '/_matrix' , ( app ) =>
27+ app
28+ . use ( isAuthenticatedMiddleware ( ) )
29+ . get (
30+ '/federation/v1/query/profile' ,
31+ ( { query : { user_id } } ) =>
32+ federationSDK . queryProfile ( user_id as UserID ) ,
33+ {
34+ query : QueryProfileQueryDto ,
35+ response : {
36+ 200 : QueryProfileResponseDto ,
37+ } ,
38+ detail : {
39+ tags : [ 'Federation' ] ,
40+ summary : 'Query profile' ,
41+ description : "Query a user's profile" ,
42+ } ,
3743 } ,
38- detail : {
39- tags : [ 'Federation' ] ,
40- summary : 'Query profile' ,
41- description : "Query a user's profile" ,
44+ )
45+ . post (
46+ '/federation/v1/user/keys/query' ,
47+ async ( { set } ) => {
48+ set . status = 501 ;
49+ return {
50+ errcode : 'M_UNRECOGNIZED' ,
51+ error : 'E2EE is not implemented yet' ,
52+ } ;
4253 } ,
43- } ,
44- )
45- . post (
46- '/federation/v1/user/keys/query' ,
47- async ( { set } ) => {
48- set . status = 501 ;
49- return {
50- errcode : 'M_UNRECOGNIZED' ,
51- error : 'E2EE is not implemented yet' ,
52- } ;
53- } ,
54- {
55- body : QueryKeysBodyDto ,
56- response : {
57- 200 : QueryKeysResponseDto ,
58- 501 : t . Object ( {
59- errcode : t . String ( ) ,
60- error : t . String ( ) ,
61- } ) ,
54+ {
55+ body : QueryKeysBodyDto ,
56+ response : {
57+ 200 : QueryKeysResponseDto ,
58+ 501 : t . Object ( {
59+ errcode : t . String ( ) ,
60+ error : t . String ( ) ,
61+ } ) ,
62+ } ,
63+ detail : {
64+ tags : [ 'Federation' ] ,
65+ summary : 'Query keys' ,
66+ description :
67+ "Query a user's device keys (E2EE not implemented)" ,
68+ } ,
6269 } ,
63- detail : {
64- tags : [ 'Federation' ] ,
65- summary : 'Query keys' ,
66- description : "Query a user's device keys (E2EE not implemented)" ,
67- } ,
68- } ,
69- )
70- . get (
71- '/federation/v1/user/devices/:userId' ,
72- async ( { set } ) => {
73- set . status = 501 ;
74- return {
75- errcode : 'M_UNRECOGNIZED' ,
76- error : 'E2EE is not implemented yet' ,
77- } ;
78- } ,
79- {
80- params : GetDevicesParamsDto ,
81- response : {
82- 200 : GetDevicesResponseDto ,
83- 501 : t . Object ( {
84- errcode : t . String ( ) ,
85- error : t . String ( ) ,
86- } ) ,
70+ )
71+ . get (
72+ '/federation/v1/user/devices/:userId' ,
73+ async ( { set } ) => {
74+ set . status = 501 ;
75+ return {
76+ errcode : 'M_UNRECOGNIZED' ,
77+ error : 'E2EE is not implemented yet' ,
78+ } ;
8779 } ,
88- detail : {
89- tags : [ 'Federation' ] ,
90- summary : 'Get devices' ,
91- description : "Get a user's devices (E2EE not implemented)" ,
80+ {
81+ params : GetDevicesParamsDto ,
82+ response : {
83+ 200 : GetDevicesResponseDto ,
84+ 501 : t . Object ( {
85+ errcode : t . String ( ) ,
86+ error : t . String ( ) ,
87+ } ) ,
88+ } ,
89+ detail : {
90+ tags : [ 'Federation' ] ,
91+ summary : 'Get devices' ,
92+ description : "Get a user's devices (E2EE not implemented)" ,
93+ } ,
9294 } ,
93- } ,
94- ) ,
95- )
96- . use ( canAccessResourceMiddleware ( 'room' ) )
97- . get (
98- '/_matrix/federation/v1/make_join/:roomId/:userId' ,
99- async ( { params, query : _query } ) => {
100- const { roomId, userId } = params ;
95+ ) ,
96+ )
97+ . use ( canAccessResourceMiddleware ( 'room' ) )
98+ . get (
99+ '/_matrix/federation/v1/make_join/:roomId/:userId' ,
100+ async ( { params, query : _query } ) => {
101+ const { roomId, userId } = params ;
101102
102- // const { ver } = query;
103+ // const { ver } = query;
103104
104- return federationSDK . makeJoin ( roomId as RoomID , userId as UserID , [
105- '10' ,
106- ] ) ;
107- } ,
108- {
109- params : MakeJoinParamsDto ,
110- query : t . Any ( ) ,
111- response : {
112- 200 : MakeJoinResponseDto ,
113- 400 : ErrorResponseDto ,
114- } ,
115- detail : {
116- tags : [ 'Federation' ] ,
117- summary : 'Make join' ,
118- description : 'Make a join event' ,
119- } ,
120- } ,
121- )
122- . post (
123- '/_matrix/federation/v1/get_missing_events/:roomId' ,
124- async ( { params, body } ) =>
125- federationSDK . getMissingEvents (
126- params . roomId as RoomID ,
127- body . earliest_events as EventID [ ] ,
128- body . latest_events as EventID [ ] ,
129- body . limit ,
130- body . min_depth ,
131- ) ,
132- {
133- params : GetMissingEventsParamsDto ,
134- body : GetMissingEventsBodyDto ,
135- response : {
136- 200 : GetMissingEventsResponseDto ,
105+ return federationSDK . makeJoin ( roomId as RoomID , userId as UserID , [
106+ '10' ,
107+ ] ) ;
137108 } ,
138- detail : {
139- tags : [ 'Federation' ] ,
140- summary : 'Get missing events' ,
141- description : 'Get missing events for a room' ,
109+ {
110+ params : MakeJoinParamsDto ,
111+ query : t . Any ( ) ,
112+ response : {
113+ 200 : MakeJoinResponseDto ,
114+ 400 : ErrorResponseDto ,
115+ } ,
116+ detail : {
117+ tags : [ 'Federation' ] ,
118+ summary : 'Make join' ,
119+ description : 'Make a join event' ,
120+ } ,
142121 } ,
143- } ,
144- )
145- . get (
146- '/_matrix/federation/v1/event_auth/:roomId/:eventId' ,
147- ( { params } ) =>
148- federationSDK . eventAuth (
149- params . roomId as RoomID ,
150- params . eventId as EventID ,
151- ) ,
152- {
153- params : EventAuthParamsDto ,
154- response : {
155- 200 : EventAuthResponseDto ,
122+ )
123+
124+ // https://spec.matrix.org/v1.16/server-server-api/#post_matrixfederationv1get_missing_eventsroomid
125+ . post (
126+ '/_matrix/federation/v1/get_missing_events/:roomId' ,
127+ async ( { params, body } ) =>
128+ federationSDK . getMissingEvents (
129+ params . roomId as RoomID ,
130+ body . earliest_events as EventID [ ] ,
131+ body . latest_events as EventID [ ] ,
132+ body . limit || 10 ,
133+ body . min_depth || 0 ,
134+ ) ,
135+ {
136+ params : GetMissingEventsParamsDto ,
137+ body : GetMissingEventsBodyDto ,
138+ response : {
139+ 200 : GetMissingEventsResponseDto ,
140+ } ,
141+ detail : {
142+ tags : [ 'Federation' ] ,
143+ summary : 'Get missing events' ,
144+ description : 'Get missing events for a room' ,
145+ } ,
156146 } ,
157- detail : {
158- tags : [ 'Federation' ] ,
159- summary : 'Event auth' ,
160- description : 'Get event auth for a room' ,
147+ )
148+ . get (
149+ '/_matrix/federation/v1/event_auth/:roomId/:eventId' ,
150+ ( { params } ) =>
151+ federationSDK . eventAuth (
152+ params . roomId as RoomID ,
153+ params . eventId as EventID ,
154+ ) ,
155+ {
156+ params : EventAuthParamsDto ,
157+ response : {
158+ 200 : EventAuthResponseDto ,
159+ } ,
160+ detail : {
161+ tags : [ 'Federation' ] ,
162+ summary : 'Event auth' ,
163+ description : 'Get event auth for a room' ,
164+ } ,
161165 } ,
162- } ,
163- ) ;
166+ )
167+ ) ;
164168} ;
0 commit comments