Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export * from './models/event.model';

// Procedures
export { makeJoinEventBuilder } from './procedures/makeJoin';
export { makeGetMissingEventsProcedure } from './procedures/getMissingEvents';
export { getPublicKeyFromRemoteServer } from './procedures/getPublicKeyFromServer';

export { createLogger, logger } from './utils/logger';
Expand Down
39 changes: 0 additions & 39 deletions packages/core/src/procedures/getMissingEvents.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/federation-sdk/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ export class FederationSDK {
}

getMissingEvents(
...args: Parameters<typeof this.profilesService.getMissingEvents>
...args: Parameters<typeof this.eventService.getMissingEvents>
) {
return this.profilesService.getMissingEvents(...args);
return this.eventService.getMissingEvents(...args);
}

eventAuth(...args: Parameters<typeof this.profilesService.eventAuth>) {
Expand Down
21 changes: 0 additions & 21 deletions packages/federation-sdk/src/services/profiles.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { createLogger } from '@rocket.chat/federation-core';
import { ConfigService } from './config.service';
import { EventService } from './event.service';

import {
EventID,
Expand All @@ -15,11 +13,8 @@ import { StateService } from './state.service';

@singleton()
export class ProfilesService {
private readonly logger = createLogger('ProfilesService');

constructor(
private readonly configService: ConfigService,
private readonly eventService: EventService,
private readonly stateService: StateService,
) {}
async queryProfile(userId: string): Promise<{
Expand Down Expand Up @@ -114,22 +109,6 @@ export class ProfilesService {
};
}

async getMissingEvents(
roomId: RoomID,
earliestEvents: EventID[],
latestEvents: EventID[],
limit = 10,
minDepth = 0,
): Promise<{ events: Pdu[] }> {
return this.eventService.getMissingEvents(
roomId,
earliestEvents,
latestEvents,
limit,
minDepth,
);
}

async eventAuth(
_roomId: RoomID,
_eventId: EventID,
Expand Down
262 changes: 133 additions & 129 deletions packages/homeserver/src/controllers/federation/profiles.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
GetMissingEventsParamsDto,
GetMissingEventsResponseDto,
MakeJoinParamsDto,
MakeJoinQueryDto,
MakeJoinResponseDto,
QueryKeysBodyDto,
QueryKeysResponseDto,
Expand All @@ -22,143 +21,148 @@ import {
} from '../../dtos';

export const profilesPlugin = (app: Elysia) => {
return app
.group('/_matrix', (app) =>
app
.use(isAuthenticatedMiddleware())
.get(
'/federation/v1/query/profile',
({ query: { user_id } }) =>
federationSDK.queryProfile(user_id as UserID),
{
query: QueryProfileQueryDto,
response: {
200: QueryProfileResponseDto,
return (
app
.group('/_matrix', (app) =>
app
.use(isAuthenticatedMiddleware())
.get(
'/federation/v1/query/profile',
({ query: { user_id } }) =>
federationSDK.queryProfile(user_id as UserID),
{
query: QueryProfileQueryDto,
response: {
200: QueryProfileResponseDto,
},
detail: {
tags: ['Federation'],
summary: 'Query profile',
description: "Query a user's profile",
},
},
detail: {
tags: ['Federation'],
summary: 'Query profile',
description: "Query a user's profile",
)
.post(
'/federation/v1/user/keys/query',
async ({ set }) => {
set.status = 501;
return {
errcode: 'M_UNRECOGNIZED',
error: 'E2EE is not implemented yet',
};
},
},
)
.post(
'/federation/v1/user/keys/query',
async ({ set }) => {
set.status = 501;
return {
errcode: 'M_UNRECOGNIZED',
error: 'E2EE is not implemented yet',
};
},
{
body: QueryKeysBodyDto,
response: {
200: QueryKeysResponseDto,
501: t.Object({
errcode: t.String(),
error: t.String(),
}),
{
body: QueryKeysBodyDto,
response: {
200: QueryKeysResponseDto,
501: t.Object({
errcode: t.String(),
error: t.String(),
}),
},
detail: {
tags: ['Federation'],
summary: 'Query keys',
description:
"Query a user's device keys (E2EE not implemented)",
},
},
detail: {
tags: ['Federation'],
summary: 'Query keys',
description: "Query a user's device keys (E2EE not implemented)",
},
},
)
.get(
'/federation/v1/user/devices/:userId',
async ({ set }) => {
set.status = 501;
return {
errcode: 'M_UNRECOGNIZED',
error: 'E2EE is not implemented yet',
};
},
{
params: GetDevicesParamsDto,
response: {
200: GetDevicesResponseDto,
501: t.Object({
errcode: t.String(),
error: t.String(),
}),
)
.get(
'/federation/v1/user/devices/:userId',
async ({ set }) => {
set.status = 501;
return {
errcode: 'M_UNRECOGNIZED',
error: 'E2EE is not implemented yet',
};
},
detail: {
tags: ['Federation'],
summary: 'Get devices',
description: "Get a user's devices (E2EE not implemented)",
{
params: GetDevicesParamsDto,
response: {
200: GetDevicesResponseDto,
501: t.Object({
errcode: t.String(),
error: t.String(),
}),
},
detail: {
tags: ['Federation'],
summary: 'Get devices',
description: "Get a user's devices (E2EE not implemented)",
},
},
},
),
)
.use(canAccessResourceMiddleware('room'))
.get(
'/_matrix/federation/v1/make_join/:roomId/:userId',
async ({ params, query: _query }) => {
const { roomId, userId } = params;
),
)
.use(canAccessResourceMiddleware('room'))
.get(
'/_matrix/federation/v1/make_join/:roomId/:userId',
async ({ params, query: _query }) => {
const { roomId, userId } = params;

// const { ver } = query;
// const { ver } = query;

return federationSDK.makeJoin(roomId as RoomID, userId as UserID, [
'10',
]);
},
{
params: MakeJoinParamsDto,
query: t.Any(),
response: {
200: MakeJoinResponseDto,
400: ErrorResponseDto,
},
detail: {
tags: ['Federation'],
summary: 'Make join',
description: 'Make a join event',
},
},
)
.post(
'/_matrix/federation/v1/get_missing_events/:roomId',
async ({ params, body }) =>
federationSDK.getMissingEvents(
params.roomId as RoomID,
body.earliest_events as EventID[],
body.latest_events as EventID[],
body.limit,
body.min_depth,
),
{
params: GetMissingEventsParamsDto,
body: GetMissingEventsBodyDto,
response: {
200: GetMissingEventsResponseDto,
return federationSDK.makeJoin(roomId as RoomID, userId as UserID, [
'10',
]);
},
detail: {
tags: ['Federation'],
summary: 'Get missing events',
description: 'Get missing events for a room',
{
params: MakeJoinParamsDto,
query: t.Any(),
response: {
200: MakeJoinResponseDto,
400: ErrorResponseDto,
},
detail: {
tags: ['Federation'],
summary: 'Make join',
description: 'Make a join event',
},
},
},
)
.get(
'/_matrix/federation/v1/event_auth/:roomId/:eventId',
({ params }) =>
federationSDK.eventAuth(
params.roomId as RoomID,
params.eventId as EventID,
),
{
params: EventAuthParamsDto,
response: {
200: EventAuthResponseDto,
)

// https://spec.matrix.org/v1.16/server-server-api/#post_matrixfederationv1get_missing_eventsroomid
.post(
'/_matrix/federation/v1/get_missing_events/:roomId',
async ({ params, body }) =>
federationSDK.getMissingEvents(
params.roomId as RoomID,
body.earliest_events as EventID[],
body.latest_events as EventID[],
body.limit || 10,
body.min_depth || 0,
),
{
params: GetMissingEventsParamsDto,
body: GetMissingEventsBodyDto,
response: {
200: GetMissingEventsResponseDto,
},
detail: {
tags: ['Federation'],
summary: 'Get missing events',
description: 'Get missing events for a room',
},
},
detail: {
tags: ['Federation'],
summary: 'Event auth',
description: 'Get event auth for a room',
)
.get(
'/_matrix/federation/v1/event_auth/:roomId/:eventId',
({ params }) =>
federationSDK.eventAuth(
params.roomId as RoomID,
params.eventId as EventID,
),
{
params: EventAuthParamsDto,
response: {
200: EventAuthResponseDto,
},
detail: {
tags: ['Federation'],
summary: 'Event auth',
description: 'Get event auth for a room',
},
},
},
);
)
);
};
Loading