import { type T1, T2, type T3, T5 } from '@devvit/shared-types/tid.js'; export type SubredditData = { id?: T5 | undefined; name?: string | undefined; displayName?: string | undefined; communityIcon?: string | undefined; keyColor?: string | undefined; subscribers?: number | undefined; primaryColor?: string | undefined; lastUpdated?: string | undefined; icon?: string | undefined; }; export type GetConversationsRequest = { /** modmail conversation id */ after?: string; /** array of subreddit names */ subreddits?: string[]; /** an integer between 1 and 100 (default: 25) */ limit?: number; /** * Sort by: * - `recent` - Order by whenever anyone last updated the conversation, mod or participant * - `mod` - Order by the last time a mod updated the conversation * - `user` - Order by the last time a participant user updated the conversation * - `unread` - Order by the most recent unread message in the conversation for this mod */ sort?: 'recent' | 'mod' | 'user' | 'unread'; /** * Filter by conversation state * * A conversation can be in more than one state. * For example, a conversation may be both 'highlighted' and 'inprogress'. */ state?: ConversationStateFilter; }; /** * A Conversation State is a way in which conversations may be filtered within the UI. * * A conversation can be in more than one state. * For example, a conversation may be both 'highlighted' and 'inprogress'. */ export type ConversationStateFilter = 'all' | 'new' | 'inprogress' | 'archived' | 'appeals' | 'join_requests' | 'highlighted' | 'mod' | 'notifications' | 'inbox' | 'filtered' | 'default'; /** * Conversation participant */ export type Participant = { isMod?: boolean | undefined; isAdmin?: boolean | undefined; name?: string | undefined; isOp?: boolean | undefined; isParticipant?: boolean | undefined; isApproved?: boolean | undefined; isHidden?: boolean | undefined; id?: T2 | undefined; isDeleted?: boolean | undefined; }; export type ConversationUserData = { /** User ID*/ id?: T2 | undefined; /** Username */ name?: string | undefined; /** Recent comments */ recentComments: { [id: T1]: { comment?: string | undefined; date?: string | undefined; permalink?: string | undefined; title?: string | undefined; }; }; /** Recent posts */ recentPosts: { [id: T3]: { date?: string | undefined; permalink?: string | undefined; title?: string | undefined; }; }; /** Recent conversations */ recentConvos: { [id: string]: { date?: string | undefined; permalink?: string | undefined; id?: string | undefined; subject?: string | undefined; }; }; isSuspended?: boolean | undefined; isShadowBanned?: boolean | undefined; muteStatus?: { isMuted?: boolean | undefined; muteCount?: number | undefined; endDate?: string | undefined; reason?: string | undefined; } | undefined; banStatus?: { isBanned?: boolean | undefined; isPermanent?: boolean | undefined; endDate?: string | undefined; reason?: string | undefined; } | undefined; approveStatus?: { isApproved?: boolean | undefined; } | undefined; /** When was created */ created?: string | undefined; }; export declare enum ModMailConversationState { New = "New", InProgress = "InProgress", Archived = "Archived", Appeals = "Appeals", JoinRequests = "JoinRequests", Filtered = "Filtered" } /** * An ActionType describes a particular logged action within a conversation. For example, * if a mod highlights a conversation, a ModerationAction record with the type `Highlighted` * would be created. */ export declare enum ModMailActionType { Highlighted = "Highlighted", Unhighlighted = "Unhighlighted", Archived = "Archived", Unarchived = "Unarchived", ReportedToAdmins = "ReportedToAdmins", Muted = "Muted", Unmuted = "Unmuted", Banned = "Banned", Unbanned = "Unbanned", Approved = "Approved", Disapproved = "Disapproved", Filtered = "Filtered", Unfiltered = "Unfiltered" } export type ConversationData = { /** Conversation ID */ id?: string | undefined; /** Suject of the conversation */ subject?: string | undefined; /** * Subreddit owning the modmail conversation */ subreddit?: { displayName?: string | undefined; id?: T5 | undefined; } | undefined; /** * A ConversationType specifies whether a conversation is with a subreddit * itself, with another user, or with another subreddit entirely. * - `sr_user` - This is a conversation with another user outside of the * subreddit. The participant ID is that user's ID. * - `internal` - This is a Mod Discussion, internal to the subreddit. There * is no other participant. * - `sr_sr` - This is a conversation is with another subreddit. The * participant will have a subreddit ID. */ conversationType?: string | undefined; /** Is the conversation automatically generated e.g. from automod, u/reddit */ isAuto?: boolean | undefined; /** Participant. Is absent for mod discussions */ participant?: Participant | undefined; /** The last datetime a user made any interaction with the conversation */ lastUserUpdate?: string | undefined; /** Is the conversation internal (i.e. mod only) */ isInternal?: boolean | undefined; /** * The last datetime a mod from the owning subreddit made any interaction * with the conversation. * * (Note that if this is a subreddit to subreddit conversation, the mods of * the participant subreddit are irrelevant and do not affect this field.) */ lastModUpdate?: string | undefined; /** The authors of each message in the modmail conversation. */ authors: Participant[]; /** The datetime of the last time the conversation was update. */ lastUpdated?: string | undefined; /** State of the conversation */ state?: ModMailConversationState | undefined; /** The datetime of the last unread message within this conversation for the current viewer. */ lastUnread?: string | undefined; /** Is the conversation highlighted */ isHighlighted?: boolean | undefined; /** Number of messages (not actions) in the conversation */ numMessages?: number | undefined; /** * Conversation messages * * @example * ```ts * const arrayOfMessages = Object.values(conversation.messages); * const messageById = conversation.messages[messageId]; * ``` */ messages: { [id: string]: MessageData; }; /** * Conversation mod actions * * @example * ```ts * const arrayOfModActions = Object.values(conversation.modActions); * const modActionById = conversation.modActions[modActionId]; * ``` */ modActions: { [id: string]: ModActionData; }; }; export type ModActionData = { /** Action id */ id?: string | undefined; /** Type of the action */ actionType: ModMailActionType; /** When the action happened */ date?: string | undefined; /** Action author */ author?: { /** User id */ id?: number | undefined; /** User name */ name?: string | undefined; isMod?: boolean | undefined; isAdmin?: boolean | undefined; isHidden?: boolean | undefined; isDeleted?: boolean | undefined; } | undefined; }; export type MessageData = { /** Message ID */ id?: string | undefined; /** Message body */ body?: string | undefined; /** When was created */ date?: string | undefined; author?: Participant | undefined; isInternal?: boolean | undefined; bodyMarkdown?: string | undefined; participatingAs?: string | undefined; }; export type ConversationResponse = { conversation: ConversationData; }; export type WithUserData = { user?: ConversationUserData | undefined; }; export type UnreadCountResponse = { archived?: number | undefined; appeals?: number | undefined; highlighted?: number | undefined; notifications?: number | undefined; joinRequests?: number | undefined; filtered?: number | undefined; new?: number | undefined; inprogress?: number | undefined; mod?: number | undefined; }; type ParticipantSubreddit = { id: T5; name: string; }; export type GetConversationResponse = { conversation?: ConversationData | undefined; /** If the conversation is with another subreddit, what subreddit we are communicating with. */ participantSubreddit?: ParticipantSubreddit | undefined; } & WithUserData; export type GetConversationsResponse = { /** * Conversations key-value map */ conversations: { [id: string]: ConversationData; }; viewerId?: T2 | undefined; /** * Array of conversation ids, ordered by the sort parameter specified in {@link GetConversationsRequest}. */ conversationIds: string[]; }; /** * Class providing the methods for working with Mod Mail */ export declare class ModMailService { #private; readonly notificationSubjectPrefix = "[notification]"; /** * Marks all conversations read for a particular conversation state within the passed list of subreddits. * * @param subreddits Array of subreddit names * @param state One of the possible conversation states ('all' to read all conversations) * * @returns conversationIds * * @example * ```ts * const conversationIds = await reddit.modMail.bulkReadConversations( * ['askReddit', 'myAwesomeSubreddit'], * 'filtered' * ); * ``` */ bulkReadConversations(subreddits: string[], state: ConversationStateFilter): Promise; /** * Get conversations for a logged in user or subreddits * * @param params.after id of a modmail * @param params.subreddits array of subreddit names * @param params.limit an integer between 1 and 100 (default: 25) * @param params.sort one of (recent, mod, user, unread) * @param params.state One of the possible conversation states ('all' to read all conversations) * * @example * ```ts * const {viewerId, conversations} = await reddit.modMail.getConversations({ * after: 'abcdef', * limit: 42 * }); * * const arrayOfConversations = Object.values(conversations); * ``` */ getConversations(params: GetConversationsRequest): Promise; /** * Returns all messages, mod actions and conversation metadata for a given conversation id * * @param params.conversationId id of a modmail conversation * @param params.markRead should be marked as read (default: false) * * @example * ```ts * const { conversation, messages, modActions, user } = await reddit.modMail.getConversation({ conversationId: 'abcdef', markRead: true }); * ``` */ getConversation(params: { /** a modmail conversation id */ conversationId: string; /** mark read? */ markRead?: boolean; }): Promise; /** * Returns a list of Subreddits that the user moderates with mail permission * * @example * ```ts * const subredditsData = await reddit.modMail.getSubreddits(); * * for (const subreddit of Object.values(subreddits)) { * console.log(subreddit.id); * console.log(subreddit.name); * } * ``` */ getSubreddits(): Promise<{ [key: string]: SubredditData; }>; /** * Creates a new conversation for a particular SR. * * This endpoint will create a ModmailConversation object * as well as the first ModmailMessage within the ModmailConversation object. * * @note * Note on {param.to}: * The to field for this endpoint is somewhat confusing. It can be: * - A User, passed like "username" or "u/username" * - A Subreddit, passed like "r/subreddit" * - null, meaning an internal moderator discussion * * In this way to is a bit of a misnomer in modmail conversations. * What it really means is the participant of the conversation who is not a mod of the subreddit. * * If you plan to send a message to the app-account or a moderator of the subreddit, use {@link ModMailService.createModDiscussionConversation}, {@link ModMailService.createModInboxConversation}, or {@link ModMailService.createModNotification} instead. * Otherwise, messages sent to the app-account or moderator will automatically be routed to Mod Discussions. * @param params.body markdown text * @param params.isAuthorHidden is author hidden? (default: false) * @param params.subredditName subreddit name * @param params.subject subject of the conversation. max 100 characters * @param params.to a user (e.g. u/username), a subreddit (e.g. r/subreddit) or null * * @example * ```ts * const { conversation, messages, modActions } = await reddit.modMail.createConversation({ * subredditName: 'askReddit', * subject: 'Test conversation', * body: 'Lorem ipsum sit amet', * to: null, * }); * ``` */ createConversation(params: { body: string; isAuthorHidden?: boolean; subredditName: string; subject: string; to?: string | null; }): Promise; /** * Creates a conversation in Mod Discussions with the moderators of the given subredditId. * * Note: The app must be installed in the subreddit in order to create a conversation in Mod Discussions. * * @param params.subject - The subject of the message. * @param params.bodyMarkdown - The body of the message in Markdown format, e.g. `Hello world \n\n **Have a great day**`. * @param params.subredditId - The ID (starting with `t5_`) of the subreddit to which to send the message, e.g. `t5_2qjpg`. * @returns A Promise that resolves a string representing the conversationId of the message. * @example * ```ts * const conversationId = await reddit.modMail.createModDiscussionConversation({ * subject: 'Test conversation', * bodyMarkdown: '**Hello there** \n\n _Have a great day!_', * subredditId: context.subredditId * }); * ``` */ createModDiscussionConversation(params: { subject: string; bodyMarkdown: string; subredditId: T5; }): Promise; /** * Creates a conversation in the Modmail Inbox with the moderators of the given subredditId. * * @param params.subject - The subject of the message. * @param params.bodyMarkdown - The body of the message in Markdown format, e.g. `Hello world \n\n **Have a great day**`. * @param params.subredditId - The ID (starting with `t5_`) of the subreddit to which to send the message, e.g. `t5_2qjpg`. * @returns A Promise that resolves a string representing the conversationId of the message. * @example * ```ts * const conversationId = await reddit.modMail.createModInboxConversation({ * subject: 'Test conversation', * bodyMarkdown: '**Hello there** \n\n _Have a great day!_', * subredditId: context.subredditId * }); * ``` */ createModInboxConversation(params: { subject: string; bodyMarkdown: string; subredditId: T5; }): Promise; /** * Creates a notification in the Modmail Inbox. * This function is different from {@link ModMailService.createModInboxConversation} in that the conversation also appears in the "Notifications" section of Modmail. * * @param params.subject - The subject of the message. * @param params.bodyMarkdown - The body of the message in Markdown format, e.g. `Hello world \n\n **Have a great day**`. * @param params.subredditId - The ID (starting with `t5_`) of the subreddit to which to send the message, e.g. `t5_2qjpg`. * @returns A Promise that resolves a string representing the conversationId of the message. * @example * ```ts * const conversationId = await reddit.modMail.createModNotification({ * subject: 'Test notification', * bodyMarkdown: '**Hello there** \n\n _This is a notification!_', * subredditId: context.subredditId * }); * ``` */ createModNotification(params: { subject: string; bodyMarkdown: string; subredditId: T5; }): Promise; /** * Creates a new message for a particular conversation. * * @param params.conversationId Id of a modmail conversation * @param params.body markdown text * @param params.isInternal is internal message? (default: false) * @param params.isAuthorHidden is author hidden? (default: false) * * @example * ```ts * await reddit.modMail.reply({ * body: 'Lorem ipsum sit amet', * conversationId: 'abcdef', * }); * ``` */ reply(params: { body: string; isAuthorHidden?: boolean; isInternal?: boolean; conversationId: string; }): Promise; /** * Marks a conversation as highlighted. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.highlightConversation('abcdef'); * ``` */ highlightConversation(conversationId: string): Promise; /** * Removes a highlight from a conversation. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.unhighlightConversation('abcdef'); * ``` */ unhighlightConversation(conversationId: string): Promise; /** * Marks a conversation as archived * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.archive('abcdef'); * ``` */ archiveConversation(conversationId: string): Promise; /** * Marks conversation as unarchived. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.unarchiveConversation('abcdef'); * ``` */ unarchiveConversation(conversationId: string): Promise; /** * Marks a conversation as read for the user. * * @param params.conversationId Id of a modmail conversation * @param params.numHours For how many hours the conversation needs to be muted. Must be one of 72, 168, or 672 hours * * @example * ```ts * await reddit.modMail.muteConversation({ conversationId: 'abcdef', numHours: 72 }); * ``` */ muteConversation(params: { conversationId: string; numHours: 72 | 168 | 672; }): Promise; /** * Unmutes the non mod user associated with a particular conversation. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.unmuteConversation('abcdef'); * ``` */ unmuteConversation(conversationId: string): Promise; /** * Marks a conversations as read for the user. * * @param conversationIds An array of ids * * @example * ```ts * await reddit.modMail.readConversations(['abcdef', 'qwerty']); * ``` */ readConversations(conversationIds: string[]): Promise; /** * Marks conversations as unread for the user. * * @param conversationIds An array of ids * * @example * ```ts * await reddit.modMail.unreadConversations(['abcdef', 'qwerty']); * ``` */ unreadConversations(conversationIds: string[]): Promise; /** * Approve the non mod user associated with a particular conversation. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.approveConversation('abcdef'); * ``` */ approveConversation(conversationId: string): Promise; /** * Disapprove the non mod user associated with a particular conversation. * * @param conversationId Id of a modmail conversation * * @example * ```ts * await reddit.modMail.disapproveConversation('abcdef'); * ``` */ disapproveConversation(conversationId: string): Promise; /** * Temporary ban (switch from permanent to temporary ban) the non mod user associated with a particular conversation. * * @param params.conversationId a modmail conversation id * @param params.duration duration in days, max 999 * * @example * ```ts * await reddit.modMail.tempBanConversation({ conversationId: 'abcdef', duration: 42 }); * ``` */ tempBanConversation(params: { conversationId: string; duration: number; }): Promise; /** * Unban the non mod user associated with a particular conversation. * * @param conversationId a modmail conversation id * * @example * ```ts * await reddit.modMail.unbanConversation('abcdef'); * ``` */ unbanConversation(conversationId: string): Promise; /** * Endpoint to retrieve the unread conversation count by conversation state. * * @example * ```ts * const response = await reddit.modMail.getUnreadCount(); * * console.log(response.highlighted); * console.log(response.new); * ``` */ getUnreadCount(): Promise; /** * Returns recent posts, comments and modmail conversations for a given user. * * @param conversationId Id of a modmail conversation * * @example * ```ts * const data = await reddit.modMail.getUserConversations('abcdef'); * * console.log(data.recentComments); * console.log(data.recentPosts); * ``` */ getUserConversations(conversationId: string): Promise; } export {}; //# sourceMappingURL=ModMail.d.ts.map