forked from mystiq/hydrogen-web
Merge pull request #774 from vector-im/add-more-hsApi
Add more homeserver api
This commit is contained in:
commit
3959968c29
4 changed files with 21 additions and 4 deletions
|
@ -271,6 +271,12 @@ export class HomeServerApi {
|
|||
return this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`, {}, {}, options);
|
||||
}
|
||||
|
||||
invite(roomId: string, userId: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/invite`, {}, {
|
||||
user_id: userId
|
||||
}, options);
|
||||
}
|
||||
|
||||
leave(roomId: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/leave`, {}, {}, options);
|
||||
}
|
||||
|
@ -298,6 +304,13 @@ export class HomeServerApi {
|
|||
return this._post(`/dehydrated_device/claim`, {}, {device_id: deviceId}, options);
|
||||
}
|
||||
|
||||
searchProfile(searchTerm: string, limit?: number, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/user_directory/search`, {}, {
|
||||
limit: limit ?? 10,
|
||||
search_term: searchTerm,
|
||||
}, options);
|
||||
}
|
||||
|
||||
profile(userId: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(`/profile/${encodeURIComponent(userId)}`);
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ export class BaseRoom extends EventEmitter {
|
|||
}
|
||||
|
||||
get type() {
|
||||
return this._summary.data.type;
|
||||
return this._summary.data.type ?? undefined;
|
||||
}
|
||||
|
||||
get lastMessageTimestamp() {
|
||||
|
|
|
@ -61,6 +61,10 @@ export class Invite extends EventEmitter {
|
|||
return this._inviteData.avatarColorId || this.id;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return this._inviteData.type ?? undefined;
|
||||
}
|
||||
|
||||
get timestamp() {
|
||||
return this._inviteData.timestamp;
|
||||
}
|
||||
|
@ -89,7 +93,7 @@ export class Invite extends EventEmitter {
|
|||
await this._platform.logger.wrapOrRun(log, "acceptInvite", async log => {
|
||||
this._accepting = true;
|
||||
this._emitChange("accepting");
|
||||
await this._hsApi.join(this._roomId, {log}).response();
|
||||
await this._hsApi.joinIdOrAlias(this.canonicalAlias ?? this._roomId, {log}).response();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,7 +193,7 @@ export class Invite extends EventEmitter {
|
|||
roomId: this.id,
|
||||
isEncrypted: !!summaryData.encryption,
|
||||
isDirectMessage: summaryData.isDirectMessage,
|
||||
// type:
|
||||
type: summaryData.type,
|
||||
name,
|
||||
avatarUrl,
|
||||
avatarColorId,
|
||||
|
|
|
@ -163,7 +163,7 @@ export class GapWriter {
|
|||
if (!Array.isArray(chunk)) {
|
||||
throw new Error("Invalid chunk in response");
|
||||
}
|
||||
if (typeof end !== "string") {
|
||||
if (typeof end !== "string" && typeof end !== "undefined") {
|
||||
throw new Error("Invalid end token in response");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue