mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-02-01 23:21:40 +01:00
add more hs api
This commit is contained in:
parent
4cb11a130e
commit
fe4e84c762
@ -146,6 +146,10 @@ export class HomeServerApi {
|
||||
send(roomId: string, eventType: string, txnId: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(`/rooms/${encodeURIComponent(roomId)}/send/${encodeURIComponent(eventType)}/${encodeURIComponent(txnId)}`, {}, content, options);
|
||||
}
|
||||
|
||||
event(roomId: string, eventId: string , options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(`/rooms/${encodeURIComponent(roomId)}/event/${encodeURIComponent(eventId)}`, undefined, undefined, options);
|
||||
}
|
||||
|
||||
redact(roomId: string, eventId: string, txnId: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(`/rooms/${encodeURIComponent(roomId)}/redact/${encodeURIComponent(eventId)}/${encodeURIComponent(txnId)}`, {}, content, options);
|
||||
@ -275,6 +279,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);
|
||||
}
|
||||
@ -283,10 +293,35 @@ export class HomeServerApi {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/forget`, {}, {}, options);
|
||||
}
|
||||
|
||||
kick(roomId: string, userId: string, reason?: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/kick`, {}, {
|
||||
user_id: userId,
|
||||
reason: reason,
|
||||
}, options);
|
||||
}
|
||||
|
||||
ban(roomId: string, userId: string, reason?: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/ban`, {}, {
|
||||
user_id: userId,
|
||||
reason: reason,
|
||||
}, options);
|
||||
}
|
||||
|
||||
unban(roomId: string, userId: string, reason?: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/rooms/${encodeURIComponent(roomId)}/unban`, {}, {
|
||||
user_id: userId,
|
||||
reason: reason,
|
||||
}, options);
|
||||
}
|
||||
|
||||
logout(options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/logout`, {}, {}, options);
|
||||
}
|
||||
|
||||
whoami(options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(`/account/whoami`, undefined, undefined, options);
|
||||
}
|
||||
|
||||
getDehydratedDevice(options: BaseRequestOptions = {}): IHomeServerRequest {
|
||||
options.prefix = DEHYDRATION_PREFIX;
|
||||
return this._get(`/dehydrated_device`, undefined, undefined, options);
|
||||
@ -302,18 +337,60 @@ 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)}`);
|
||||
}
|
||||
|
||||
setProfileDisplayName(userId, displayName, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(`/profile/${encodeURIComponent(userId)}/displayname`, {}, { displayname: displayName }, options);
|
||||
}
|
||||
|
||||
setProfileAvatarUrl(userId, avatarUrl, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(`/profile/${encodeURIComponent(userId)}/avatar_url`, {}, { avatar_url: avatarUrl }, options);
|
||||
}
|
||||
|
||||
createRoom(payload: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._post(`/createRoom`, {}, payload, options);
|
||||
}
|
||||
|
||||
accountData(ownUserId: string, type: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(
|
||||
`/user/${encodeURIComponent(ownUserId)}/account_data/${encodeURIComponent(type)}`,
|
||||
undefined,
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
setAccountData(ownUserId: string, type: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(`/user/${encodeURIComponent(ownUserId)}/account_data/${encodeURIComponent(type)}`, {}, content, options);
|
||||
}
|
||||
|
||||
roomAccountData(ownUserId: string, roomId: string, type: string, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(
|
||||
`/user/${encodeURIComponent(ownUserId)}/rooms/${encodeURIComponent(roomId)}/account_data/${encodeURIComponent(type)}`,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
setRoomAccountData(ownUserId: string, roomId: string, type: string, content: Record<string, any>, options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._put(
|
||||
`/user/${encodeURIComponent(ownUserId)}/rooms/${encodeURIComponent(roomId)}/account_data/${encodeURIComponent(type)}`,
|
||||
{},
|
||||
content,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
getTurnServer(options?: BaseRequestOptions): IHomeServerRequest {
|
||||
return this._get(`/voip/turnServer`, undefined, undefined, options);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user