@@ -243,7 +243,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
|
|||||||
) {
|
) {
|
||||||
super(container);
|
super(container);
|
||||||
this.csApi = new ClientServerApi(this.baseUrl);
|
this.csApi = new ClientServerApi(this.baseUrl);
|
||||||
this.adminApi = new Api(`${this.baseUrl}/_synapse/admin/`);
|
this.adminApi = new Api(`${this.baseUrl}/_synapse/admin`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setRequest(request: APIRequestContext): void {
|
public setRequest(request: APIRequestContext): void {
|
||||||
@@ -266,10 +266,10 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
|
|||||||
// We hide the rooms from the room directory to save time between tests and for portability between homeservers
|
// We hide the rooms from the room directory to save time between tests and for portability between homeservers
|
||||||
const { chunk: rooms } = await this.csApi.request<{
|
const { chunk: rooms } = await this.csApi.request<{
|
||||||
chunk: { room_id: string }[];
|
chunk: { room_id: string }[];
|
||||||
}>("GET", "v3/publicRooms", token, {});
|
}>("GET", "/v3/publicRooms", token, {});
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
rooms.map((room) =>
|
rooms.map((room) =>
|
||||||
this.csApi.request("PUT", `v3/directory/list/room/${room.room_id}`, token, { visibility: "private" }),
|
this.csApi.request("PUT", `/v3/directory/list/room/${room.room_id}`, token, { visibility: "private" }),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
|
|||||||
displayName?: string,
|
displayName?: string,
|
||||||
admin = false,
|
admin = false,
|
||||||
): Promise<Credentials> {
|
): Promise<Credentials> {
|
||||||
const path = `v1/register`;
|
const path = "/v1/register";
|
||||||
const { nonce } = await this.adminApi.request<{ nonce: string }>("GET", path, undefined, {});
|
const { nonce } = await this.adminApi.request<{ nonce: string }>("GET", path, undefined, {});
|
||||||
const mac = crypto
|
const mac = crypto
|
||||||
.createHmac("sha1", this.registrationSharedSecret)
|
.createHmac("sha1", this.registrationSharedSecret)
|
||||||
@@ -292,14 +292,12 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
|
|||||||
user_id: string;
|
user_id: string;
|
||||||
device_id: string;
|
device_id: string;
|
||||||
}>("POST", path, undefined, {
|
}>("POST", path, undefined, {
|
||||||
data: {
|
nonce,
|
||||||
nonce,
|
username,
|
||||||
username,
|
password,
|
||||||
password,
|
mac,
|
||||||
mac,
|
admin,
|
||||||
admin,
|
displayname: displayName,
|
||||||
displayname: displayName,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -351,7 +349,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements
|
|||||||
if (this._mas) {
|
if (this._mas) {
|
||||||
return this._mas.setThreepid(userId, medium, address);
|
return this._mas.setThreepid(userId, medium, address);
|
||||||
}
|
}
|
||||||
await this.adminRequest("PUT", `v2/users/${userId}`, {
|
await this.adminRequest("PUT", `/v2/users/${userId}`, {
|
||||||
threepids: [
|
threepids: [
|
||||||
{
|
{
|
||||||
medium,
|
medium,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export class Api {
|
|||||||
public async request<R extends {}>(verb: "GET", path: string, token?: string, data?: never): Promise<R>;
|
public async request<R extends {}>(verb: "GET", path: string, token?: string, data?: never): Promise<R>;
|
||||||
public async request<R extends {}>(verb: Verb, path: string, token?: string, data?: object): Promise<R>;
|
public async request<R extends {}>(verb: Verb, path: string, token?: string, data?: object): Promise<R>;
|
||||||
public async request<R extends {}>(verb: Verb, path: string, token?: string, data?: object): Promise<R> {
|
public async request<R extends {}>(verb: Verb, path: string, token?: string, data?: object): Promise<R> {
|
||||||
const url = `${this.baseUrl}/_matrix/client/${path}`;
|
const url = `${this.baseUrl}${path}`;
|
||||||
const res = await this._request.fetch(url, {
|
const res = await this._request.fetch(url, {
|
||||||
data,
|
data,
|
||||||
method: verb,
|
method: verb,
|
||||||
@@ -79,7 +79,7 @@ export class Api {
|
|||||||
|
|
||||||
export class ClientServerApi extends Api {
|
export class ClientServerApi extends Api {
|
||||||
constructor(baseUrl: string) {
|
constructor(baseUrl: string) {
|
||||||
super(`${baseUrl}/_matrix/client/`);
|
super(`${baseUrl}/_matrix/client`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loginUser(userId: string, password: string): Promise<Credentials> {
|
public async loginUser(userId: string, password: string): Promise<Credentials> {
|
||||||
@@ -88,7 +88,7 @@ export class ClientServerApi extends Api {
|
|||||||
user_id: string;
|
user_id: string;
|
||||||
device_id: string;
|
device_id: string;
|
||||||
home_server: string;
|
home_server: string;
|
||||||
}>("POST", "v3/login", undefined, {
|
}>("POST", "/v3/login", undefined, {
|
||||||
type: "m.login.password",
|
type: "m.login.password",
|
||||||
identifier: {
|
identifier: {
|
||||||
type: "m.id.user",
|
type: "m.id.user",
|
||||||
|
|||||||
Reference in New Issue
Block a user