Skip to content

Commit

Permalink
feat: declare and export types SendMessageOptions and UpdateMessageOp…
Browse files Browse the repository at this point in the history
…tions (#1170)
  • Loading branch information
MartinCupela authored Sep 18, 2023
1 parent f350692 commit 8a2ad69
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
UserFilters,
UserResponse,
QueryChannelAPIResponse,
SendMessageOptions,
} from './types';
import { Role } from './permissions';

Expand Down Expand Up @@ -168,18 +169,7 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
*
* @return {Promise<SendMessageAPIResponse<StreamChatGenerics>>} The Server Response
*/
async sendMessage(
message: Message<StreamChatGenerics>,
options?: {
force_moderation?: boolean;
is_pending_message?: boolean;
keep_channel_hidden?: boolean;
pending?: boolean;
pending_message_metadata?: Record<string, string>;
skip_enrich_url?: boolean;
skip_push?: boolean;
},
) {
async sendMessage(message: Message<StreamChatGenerics>, options?: SendMessageOptions) {
const sendMessageResponse = await this.getClient().post<SendMessageAPIResponse<StreamChatGenerics>>(
this._channelURL() + '/message',
{
Expand Down
5 changes: 3 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ import {
UpdateCommandResponse,
UpdatedMessage,
UpdateMessageAPIResponse,
UpdateMessageOptions,
UserCustomEvent,
UserFilters,
UserOptions,
Expand Down Expand Up @@ -2439,7 +2440,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
async updateMessage(
message: UpdatedMessage<StreamChatGenerics>,
userId?: string | { id: string },
options?: { skip_enrich_url?: boolean },
options?: UpdateMessageOptions,
) {
if (!message.id) {
throw Error('Please specify the message id when calling updateMessage');
Expand Down Expand Up @@ -2510,7 +2511,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
id: string,
partialMessageObject: PartialMessageUpdate<StreamChatGenerics>,
userId?: string | { id: string },
options?: { skip_enrich_url?: boolean },
options?: UpdateMessageOptions,
) {
if (!id) {
throw Error('Please specify the message id when calling partialUpdateMessage');
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,20 @@ export type MessageBase<

export type MessageLabel = 'deleted' | 'ephemeral' | 'error' | 'regular' | 'reply' | 'system';

export type SendMessageOptions = {
force_moderation?: boolean;
is_pending_message?: boolean;
keep_channel_hidden?: boolean;
pending?: boolean;
pending_message_metadata?: Record<string, string>;
skip_enrich_url?: boolean;
skip_push?: boolean;
};

export type UpdateMessageOptions = {
skip_enrich_url?: boolean;
};

export type Mute<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
created_at: string;
target: UserResponse<StreamChatGenerics>;
Expand Down

0 comments on commit 8a2ad69

Please sign in to comment.