11import type {
22 APIResponse ,
3+ AppealOptions ,
4+ AppealRequest ,
5+ AppealResponse ,
6+ AppealsSort ,
37 CustomCheckFlag ,
8+ DecideAppealRequest ,
9+ GetAppealResponse ,
410 GetConfigResponse ,
511 GetUserModerationReportOptions ,
612 GetUserModerationReportResponse ,
@@ -11,6 +17,9 @@ import type {
1117 ModerationRuleRequest ,
1218 MuteUserResponse ,
1319 Pager ,
20+ QueryAppealsFilters ,
21+ QueryAppealsPaginationOptions ,
22+ QueryAppealsResponse ,
1423 QueryConfigsResponse ,
1524 QueryModerationConfigsFilters ,
1625 QueryModerationConfigsSort ,
@@ -24,6 +33,7 @@ import type {
2433 ReviewQueueResponse ,
2534 ReviewQueueSort ,
2635 SubmitActionOptions ,
36+ SubmitActionResponse ,
2737 UpsertConfigResponse ,
2838 UpsertModerationRuleResponse ,
2939} from './types' ;
@@ -186,6 +196,108 @@ export class Moderation {
186196 ) ;
187197 }
188198
199+ /**
200+ * Appeal against the moderation decision
201+ * @param {AppealRequest } appealRequest Appeal request to be appealed against
202+ */
203+ async appeal ( appealRequest : AppealRequest , options : AppealOptions = { } ) {
204+ return await this . client . post < AppealResponse > (
205+ this . client . baseURL + '/api/v2/moderation/appeal' ,
206+ {
207+ appeal_reason : appealRequest . appeal_reason || appealRequest . text ,
208+ entity_id : appealRequest . entityID ,
209+ entity_type : appealRequest . entityType ,
210+ attachments : appealRequest . attachments ,
211+ ...options ,
212+ } ,
213+ ) ;
214+ }
215+
216+ /**
217+ * Decide on an appeal
218+ * @param {DecideAppealRequest } decideAppealRequest Request to decide on an appeal
219+ */
220+ async decideAppeal (
221+ decideAppealRequest : DecideAppealRequest ,
222+ options : AppealOptions = { } ,
223+ ) {
224+ return await this . client . post < APIResponse > (
225+ this . client . baseURL + '/api/v2/moderation/decide_appeal' ,
226+ {
227+ appeal_id : decideAppealRequest . appealID ,
228+ status : decideAppealRequest . status ,
229+ decision_reason : decideAppealRequest . decisionReason ,
230+ ...( decideAppealRequest . channelCIDs
231+ ? { channel_cids : decideAppealRequest . channelCIDs }
232+ : { } ) ,
233+ ...options ,
234+ } ,
235+ ) ;
236+ }
237+
238+ /**
239+ * Accept an appeal
240+ * @param {appealID } appealID ID of appeal
241+ * @param {decisionReason } decisionReason Reason for accepting an appeal
242+ */
243+ async acceptAppeal (
244+ appealID : string ,
245+ decisionReason : string ,
246+ options : AppealOptions = { } ,
247+ ) {
248+ return await this . decideAppeal (
249+ { appealID, decisionReason, status : 'accepted' } ,
250+ options ,
251+ ) ;
252+ }
253+
254+ /**
255+ * Reject an appeal
256+ * @param {appealID } appealID ID of appeal
257+ * @param {decisionReason } decisionReason Reason for rejecting an appeal
258+ */
259+ async rejectAppeal (
260+ appealID : string ,
261+ decisionReason : string ,
262+ options : AppealOptions = { } ,
263+ ) {
264+ return await this . decideAppeal (
265+ { appealID, decisionReason, status : 'rejected' } ,
266+ options ,
267+ ) ;
268+ }
269+
270+ /**
271+ * Get Appeal Item
272+ * @param {string } appealID ID of the appeal to be fetched
273+ */
274+ async getAppeal ( appealID : string ) {
275+ return await this . client . get < GetAppealResponse > (
276+ this . client . baseURL + '/api/v2/moderation/appeal/' + appealID ,
277+ ) ;
278+ }
279+
280+ /**
281+ * Query appeals
282+ * @param {Object } filterConditions Filter conditions for querying appeals
283+ * @param {Object } sort Sort conditions for querying appeals
284+ * @param {Object } options Pagination options for querying appeals
285+ */
286+ async queryAppeals (
287+ filterConditions : QueryAppealsFilters = { } ,
288+ sort : AppealsSort = [ ] ,
289+ options : QueryAppealsPaginationOptions = { } ,
290+ ) {
291+ return await this . client . post < QueryAppealsResponse > (
292+ this . client . baseURL + '/api/v2/moderation/appeals' ,
293+ {
294+ filter : filterConditions ,
295+ sort : normalizeQuerySort ( sort ) ,
296+ ...options ,
297+ } ,
298+ ) ;
299+ }
300+
189301 /**
190302 * Upsert moderation config
191303 * @param {Object } config Moderation config to be upserted
@@ -241,7 +353,7 @@ export class Moderation {
241353 itemID : string ,
242354 options : SubmitActionOptions = { } ,
243355 ) {
244- return await this . client . post < { item_id : string } & APIResponse > (
356+ return await this . client . post < SubmitActionResponse > (
245357 this . client . baseURL + '/api/v2/moderation/submit_action' ,
246358 {
247359 action_type : actionType ,
0 commit comments