getDefaultReplyRecipients()
function getDefaultReplyRecipients(args: {
comments: readonly Pick<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}, "groups" | "creator" | "systemMessage" | "recipients" | "deleted">[];
currentUserId: number;
isClosingThread?: boolean;
thread: Pick<Thread, "creator" | "recipients" | "groups" | "closed">;
}): DefaultReplyRecipients;
Works out who a new reply in a thread notifies by default, as the current user writes it.
- The newest comment that counts sets the default: its author, and the people and groups it notified. Deleted comments, system messages (such as closing, reopening or moving the thread) and masked posts from integrations or imports don't count. A comment that notified one person does.
- With no comment that counts, the thread sets it the same way, except that a thread to everyone in the channel defaults to everyone who interacted.
- Closing a thread, or replying in a closed one, defaults to everyone who interacted, and nobody else.
- The current user is never one of the people.
Everyone in the channel and everyone who interacted come back as
notifyAudience rather than in groups. If a comment notified both, the
channel wins. The lists are always there, empty or not, so the result can be
spread straight into createComment or closeThread.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { comments: readonly Pick<{ actions?: unknown[] | null; attachments?: | { [key: string]: unknown; attachmentId: string; description?: string | null; duration?: string | null; fileName?: string | null; fileSize?: number | null; image?: string | null; imageHeight?: number | null; imageWidth?: number | null; title?: string | null; underlyingType?: string | null; uploadState?: string | null; url?: string | null; urlType: string; video?: string | null; videoAutoPlay?: boolean | null; videoType?: string | null; }[] | null; channelId: string; content: string; conversationId?: string | null; creator: number; creatorName?: string | null; deleted?: boolean | null; deletedBy?: number | null; directGroupMentions?: string[] | null; directMentions?: number[] | null; groups?: string[] | null; id: string; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, unknown> | null; recipients?: number[] | null; systemMessage?: unknown; threadId: string; toEmails?: string[] | null; url: string; version?: number | null; workspaceId: number; }, "groups" | "creator" | "systemMessage" | "recipients" | "deleted">[]; currentUserId: number; isClosingThread?: boolean; thread: Pick<Thread, "creator" | "recipients" | "groups" | "closed">; } | The arguments for working out the recipients. |
args.comments | readonly Pick<{ actions?: unknown[] | null; attachments?: | { [key: string]: unknown; attachmentId: string; description?: string | null; duration?: string | null; fileName?: string | null; fileSize?: number | null; image?: string | null; imageHeight?: number | null; imageWidth?: number | null; title?: string | null; underlyingType?: string | null; uploadState?: string | null; url?: string | null; urlType: string; video?: string | null; videoAutoPlay?: boolean | null; videoType?: string | null; }[] | null; channelId: string; content: string; conversationId?: string | null; creator: number; creatorName?: string | null; deleted?: boolean | null; deletedBy?: number | null; directGroupMentions?: string[] | null; directMentions?: number[] | null; groups?: string[] | null; id: string; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, unknown> | null; recipients?: number[] | null; systemMessage?: unknown; threadId: string; toEmails?: string[] | null; url: string; version?: number | null; workspaceId: number; }, "groups" | "creator" | "systemMessage" | "recipients" | "deleted">[] | The thread's comments, oldest first, as getComments returns them. |
args.currentUserId | number | The ID of the user writing the reply. |
args.isClosingThread? | boolean | Whether the reply closes the thread. Defaults to false. |
args.thread | Pick<Thread, "creator" | "recipients" | "groups" | "closed"> | The thread's creator, recipients, groups and closed flag. |
Returns
A new object on every call.
Example
const comments = await api.comments.getComments({ threadId: thread.id })
await api.comments.createComment({
threadId: thread.id,
content: 'On it',
...getDefaultReplyRecipients({ thread, comments, currentUserId: me.id }),
})