Skip to content

Commit

Permalink
feat: Add unpinMessage Method & pinMessage Fix (#24)
Browse files Browse the repository at this point in the history
* Update chat.endpoint.ts

added unpin endpoint

* Fix: pinMessage endpoint fixed

pinMessage endpoint currently unnecesarily stringifies the body causing 422 error with kick. Removed this which fixes the endpoint

* Update chat.endpoint.ts

Body simplified

* unpinMessage renamed
  • Loading branch information
bananacity authored and zSoulweaver committed Oct 21, 2024
1 parent 2635e4a commit cbdecfb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/endpoints/chat/chat.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class ChatEndpoint extends BaseEndpoint {
endpoint: `api/v2/channels/${channel}/pinned-message`,
method: 'post',
options: {
body: JSON.stringify(body),
body
},
})
if (response.status !== 200)
Expand All @@ -105,6 +105,23 @@ export class ChatEndpoint extends BaseEndpoint {
return deserializedResponse
}

public async unpinMessage(channel: string) {
this.checkAuthenticated()

const response = await this._apiClient.callKickApi({
endpoint: `api/v2/channels/${channel}/pinned-message`,
method: 'delete',
})
if (response.status !== 200)
throw new KientApiError('Failed to unpin chatroom message', { cause: response })

const deserializedResponse = cast<GenericApiResponse<null>>(response.body)
if (deserializedResponse.status.error)
throw new KientApiError(deserializedResponse.status, { cause: response })

return deserializedResponse
}

public async banUser(channel: string, target: string, duration?: number) {
this.checkAuthenticated()

Expand Down

0 comments on commit cbdecfb

Please sign in to comment.