From 5ce138539b272dd275b793747dc7b1481d854873 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 20 Apr 2021 19:02:45 +0200 Subject: [PATCH] network calls to accept and reject invite --- src/matrix/net/HomeServerApi.js | 8 ++++++++ src/matrix/room/Invite.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/matrix/net/HomeServerApi.js b/src/matrix/net/HomeServerApi.js index 051bb44a..77e02d76 100644 --- a/src/matrix/net/HomeServerApi.js +++ b/src/matrix/net/HomeServerApi.js @@ -185,6 +185,14 @@ export class HomeServerApi { getPushers(options = null) { return this._get("/pushers", null, null, options); } + + join(roomId, options = null) { + return this._post(`/rooms/${encodeURIComponent(roomId)}/join`, null, null, options); + } + + leave(roomId, options = null) { + return this._post(`/rooms/${encodeURIComponent(roomId)}/leave`, null, null, options); + } } import {Request as MockRequest} from "../../mocks/Request.js"; diff --git a/src/matrix/room/Invite.js b/src/matrix/room/Invite.js index 3a59594e..3508d111 100644 --- a/src/matrix/room/Invite.js +++ b/src/matrix/room/Invite.js @@ -70,11 +70,13 @@ export class Invite extends EventEmitter { async accept() { this._accepting = true; this._emitChange("accepting"); + await this._hsApi.join(this._roomId).response(); } async reject() { this._rejecting = true; this._emitChange("rejecting"); + await this._hsApi.leave(this._roomId).response(); } get accepting() {