diff --git a/extensions/mattermost/src/mattermost/client.ts b/extensions/mattermost/src/mattermost/client.ts index 9bbf4629468..acb489cd03c 100644 --- a/extensions/mattermost/src/mattermost/client.ts +++ b/extensions/mattermost/src/mattermost/client.ts @@ -542,20 +542,10 @@ export async function patchMattermostPost( client: MattermostClient, params: { postId: string; message: string }, ): Promise { - const res = await fetch(`${client.apiBaseUrl}/posts/${params.postId}/patch`, { + await client.request(`/posts/${params.postId}/patch`, { method: "PUT", - headers: { - Authorization: `Bearer ${client.token}`, - "Content-Type": "application/json", - }, body: JSON.stringify({ message: params.message }), }); - if (!res.ok) { - const detail = await readMattermostError(res); - throw new Error( - `Mattermost patch post ${res.status} ${res.statusText}: ${detail || "unknown error"}`, - ); - } } /** @@ -565,16 +555,7 @@ export async function deleteMattermostPost( client: MattermostClient, postId: string, ): Promise { - const res = await fetch(`${client.apiBaseUrl}/posts/${postId}`, { + await client.request(`/posts/${postId}`, { method: "DELETE", - headers: { - Authorization: `Bearer ${client.token}`, - }, }); - if (!res.ok) { - const detail = await readMattermostError(res); - throw new Error( - `Mattermost delete post ${res.status} ${res.statusText}: ${detail || "unknown error"}`, - ); - } }