mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 11:05:03 +01:00
Implement invite from command
This commit is contained in:
parent
2f05cd5028
commit
4f058e3b2c
@ -273,6 +273,14 @@ export class RoomViewModel extends ErrorReportViewModel {
|
||||
this.reportError(new Error("join syntax: /join <room-id>"));
|
||||
}
|
||||
break;
|
||||
case "invite":
|
||||
if (args.length === 1) {
|
||||
const userId = args[0];
|
||||
await this._room.inviteUser(userId);
|
||||
} else {
|
||||
this.reportError(new Error("invite syntax: /invite <user-id>"));
|
||||
}
|
||||
break;
|
||||
case "shrug":
|
||||
message = "¯\\_(ツ)_/¯ " + args.join(" ");
|
||||
msgtype = "m.text";
|
||||
|
@ -267,6 +267,15 @@ export class HomeServerApi {
|
||||
return this._get("/pushers", undefined, undefined, options);
|
||||
}
|
||||
|
||||
invite(roomId: string, userId: string, reason?: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(
|
||||
`/rooms/${encodeURIComponent(roomId)}/invite`,
|
||||
{},
|
||||
{ user_id: userId, reason },
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
join(roomId: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/join`, {}, {}, options);
|
||||
}
|
||||
|
@ -470,6 +470,13 @@ export class Room extends BaseRoom {
|
||||
});
|
||||
}
|
||||
|
||||
async inviteUser(userId, reason) {
|
||||
if (!userId) {
|
||||
throw new Error("userId is null/undefined");
|
||||
}
|
||||
await this._hsApi.invite(this.id, userId, reason).response();
|
||||
}
|
||||
|
||||
/* called by BaseRoom to pass pendingEvents when opening the timeline */
|
||||
_getPendingEvents() {
|
||||
return this._sendQueue.pendingEvents;
|
||||
|
Loading…
Reference in New Issue
Block a user