Skip to content

Commit

Permalink
fix types in moderation.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dnouv committed Apr 12, 2023
1 parent f3f322f commit 1813ccf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/meteor/app/api/server/v1/moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Reports } from '@rocket.chat/models';

import { API } from '../api';
import { deleteReportedMessages } from '../../../../server/lib/moderation/deleteReportedMessages';
import { getPaginationItems } from '../helpers/getPaginationItems';

API.v1.addRoute(
'moderation.getReports',
Expand All @@ -15,8 +16,8 @@ API.v1.addRoute(
async get() {
const { latest, oldest, selector } = this.queryParams;

const { count = 20, offset = 0 } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();
const { count = 20, offset = 0 } = await getPaginationItems(this.queryParams);
const { sort } = await this.parseJsonQuery();

const cursor = Reports.findGroupedReports(
latest ? new Date(latest) : new Date(),
Expand Down Expand Up @@ -55,9 +56,9 @@ API.v1.addRoute(
async get() {
const { userId } = this.queryParams;

const { sort } = this.parseJsonQuery();
const { sort } = await this.parseJsonQuery();

const { count: pagCount = 50, offset = 0 } = this.getPaginationItems();
const { count: pagCount = 50, offset = 0 } = await getPaginationItems(this.queryParams);

if (!userId || userId.trim() === '') {
return API.v1.failure('The required "userId" body param is missing or empty.');
Expand Down Expand Up @@ -85,7 +86,7 @@ API.v1.addRoute(
},
{
async post() {
const { userId, reasonForHiding } = this.requestParams();
const { userId, reasonForHiding } = this.bodyParams;

const reasonProvided = reasonForHiding && reasonForHiding.trim() !== '';
const sanitizedReason = reasonProvided ? reasonForHiding : 'No reason provided';
Expand Down Expand Up @@ -122,7 +123,7 @@ API.v1.addRoute(
},
{
async post() {
const { userId, msgId, reasonForHiding, actionTaken } = this.requestParams();
const { userId, msgId, reasonForHiding, actionTaken } = this.bodyParams;

// check if at least one of the required params is present

Expand Down Expand Up @@ -159,8 +160,8 @@ API.v1.addRoute(
async get() {
const { msgId } = this.queryParams;

const { count = 50, offset = 0 } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();
const { count = 50, offset = 0 } = await getPaginationItems(this.queryParams);
const { sort } = await this.parseJsonQuery();
const { selector } = this.queryParams;

if (!msgId) {
Expand Down

0 comments on commit 1813ccf

Please sign in to comment.