Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix client params #33

Merged
merged 3 commits into from
Jul 3, 2024
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
4 changes: 4 additions & 0 deletions service/matrix-adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ matrix:
# Synapse shared secret, defined in homeserver.yaml on the Synapse instance.
shared_secret: ${SYNAPSE_SERVER_SHARED_SECRET}:n#P.uIl8IDOYPR-fiLzDoFw9ZPvTIlYg7*F9*~eaDZFK#;.KRg

client:
# The URL of the timeline support client
timelineSupport: ${MATRIX_CLIENT_TIMELINE_SUPPORT}:true

admin:
# The admin account that is created / used to administer the regular users on the Synapse server
username: ${SYNAPSE_ADMIN_USERNAME}:[email protected]
Expand Down
2 changes: 1 addition & 1 deletion service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-matrix-adapter",
"version": "0.3.2",
"version": "0.3.3",
"description": "Alkemio Matrix Adapter service",
"author": "Alkemio Foundation",
"private": false,
Expand Down
16 changes: 13 additions & 3 deletions service/src/services/matrix/agent/matrix.agent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { ConfigurationTypes, LogContext } from '@common/enums';
import { MatrixEntityNotFoundException } from '@common/exceptions';
import { Inject, Injectable, LoggerService } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { createClient, IContent, MatrixClient } from 'matrix-js-sdk';
import {
createClient,
IContent,
MatrixClient,
ICreateClientOpts,
} from 'matrix-js-sdk';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { MatrixRoom } from '../adapter-room/matrix.room';
import { MatrixRoomAdapter } from '../adapter-room/matrix.room.adapter';
Expand Down Expand Up @@ -51,12 +56,17 @@ export class MatrixAgentService {
throw new Error('Matrix configuration is not provided');
}

return createClient({
const timelineSupport: boolean = this.configService.get(
ConfigurationTypes.MATRIX
)?.client.timelineSupport;
const createClientInput: ICreateClientOpts = {
baseUrl: baseUrl,
idBaseUrl: idBaseUrl,
userId: operator.username,
accessToken: operator.accessToken,
});
timelineSupport: timelineSupport,
};
return createClient(createClientInput);
}

async getDirectRooms(matrixAgent: IMatrixAgent): Promise<MatrixRoom[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AxiosError } from 'axios';
import { Inject, Injectable, LoggerService } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
import { MatrixClient, createClient } from 'matrix-js-sdk';
import { MatrixClient, createClient, ICreateClientOpts } from 'matrix-js-sdk';
import { MatrixCryptographyService } from '@services/matrix/cryptography/matrix.cryptography.service';
import { ConfigurationTypes, LogContext } from '@common/enums';
import { MatrixUserAdapter } from '../adapter-user/matrix.user.adapter';
Expand Down Expand Up @@ -40,10 +40,15 @@ export class MatrixUserManagementService {

// Create a single instance of the matrix client - non authenticated
// Todo: should be handed (injected) to this client instance externally!
this._matrixClient = createClient({
const timelineSupport: boolean = this.configService.get(
ConfigurationTypes.MATRIX
)?.client.timelineSupport;
const createClientInput: ICreateClientOpts = {
baseUrl: this.baseUrl,
idBaseUrl: this.idBaseUrl,
});
timelineSupport: timelineSupport,
};
this._matrixClient = createClient(createClientInput);
}

public async getServerVersion(): Promise<string> {
Expand Down