Skip to content

Commit e4f7e68

Browse files
totalimmersionarnautov-anton
authored andcommitted
feat: [CHA-855] - Refactoring partial update member (#1517)
Creating a new endpoint /channels/{type}/{id}/member for partially updating members, this endpoint is functionally the same as /channels/{type}/{id}/member/{id} (which is now deprecated). The user id is automatically provided for clientside request, so it doesn't make sense to have it as a mandatory field in the url path. The new endpoint optionally accepts ?user_id=... At some point we must sunset the deprecated endpoint Signed-off-by: Lennart Kuijs <[email protected]>
1 parent 318825a commit e4f7e68

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/channel.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,25 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
311311
}
312312

313313
/**
314+
* updateMemberPartial - Partial update a member
315+
*
316+
* @param {PartialUpdateMember<StreamChatGenerics>} updates
317+
* @param {{ user_id?: string }} [options] Option object, {user_id: 'jane'} to optionally specify the user id
318+
319+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} Updated member
320+
*/
321+
async updateMemberPartial(updates: PartialUpdateMember<StreamChatGenerics>, options?: { userId?: string }) {
322+
const url = new URL(`${this._channelURL()}/member`);
323+
324+
if (options?.userId) {
325+
url.searchParams.append('user_id', options.userId);
326+
}
327+
328+
return await this.getClient().patch<PartialUpdateMemberAPIResponse<StreamChatGenerics>>(url.toString(), updates);
329+
}
330+
331+
/**
332+
* @deprecated Use `updateMemberPartial` instead
314333
* partialUpdateMember - Partial update a member
315334
*
316335
* @param {string} user_id member user id

0 commit comments

Comments
 (0)