Skip to content

Conversation

@Dnouv
Copy link
Member

@Dnouv Dnouv commented Jan 20, 2023

Proposed changes (including videos or screenshots)

A new API endpoint to fetch all of the reported messages within a certain timestamp.
A new API endpoint to hide the reported messages.
A new API endpoint to fetch the reported messages of a user
A new API endpoint to fetch reports by MessageId
Two new permission view-moderation-console and manage-moderation-actions

Issue(s)

Steps to test or reproduce

  1. Please make sure there are reported messages on the server, and one should have the permission "View Moderation Console" ("Admin", "Owner", and "Moderator" will have this permission by-default) to successfully make the GET requests & the manage-moderation-actions to make the POST requests.

Test the API endpoint using the following:

curl --location --request GET 'http://localhost:3000/api/v1/moderation.getReports' \
--header 'X-Auth-Token: 7FNiLmgY7g77gxYOoa_IMkS6exghlv83YbM_Yt-w5__' \
--header 'X-User-Id: b4pSJS9BDK6xXgKea'

Or pass the latest and/or oldest parameters for filtered search:

curl --location --request GET 'https://localhost:3000/api/v1/moderation.getReports?latest=2023-09-30T13:42:25.304Z&oldest=2016-09-30T13:42:25.304Z' \
--header 'X-Auth-Token: ITIgsbLgjbIhIJTvC1XtgGnXiUD0kbN3wvj_Kg-_jfQ' \
--header 'X-User-Id: emfev66k8vpa8Qvxo'

To test the /moderation.markChecked endpoint (which hides the reported messages)

curl --location --request POST 'http://localhost:3000/api/v1/moderation.markChecked?userId/msgId=63d353bb8ead73b669b9480d' \
--header 'X-Auth-Token: flLCXwH2GL_NMxG8bwWtYc37g14uMScvGtsdtuesar1' \
--header 'X-User-Id: vYzJB8cvraoDg3Z5F'

To test the /moderation.reportsByMessage enpoint, we need a messageId; the message must have been reported:

curl --location --request GET 'http://localhost:3000/api/v1/moderation.reportsByMessage?msgId=73hkbsv90s9vs \
--header 'X-Auth-Token: 7FNiLmgY7g77gxYOoa_IMkS6exghlv83YbM_Yt-w5__' \
--header 'X-User-Id: b4pSJS9BDK6xXgKea'

GET: To test the moderation.user.getMessageHistory, we need the userId, the API returns all the messages that were reported for the userId provided

curl --location 'http://localhost:3000/api/v1/moderation.user.getMessageHistory?userId=nDaGJfjfbkFsuaECD' \
--header 'X-Auth-Token: ighlnlj-NpF7Ts' \
--header 'X-User-Id: nDaGJfjfbkFsuaECD'

POST: To test the moderation.user.deleteMessageHistory, we need the userId to delete any and all the messages that were reported for the provided userId

curl --location 'http://localhost:3000/api/v1/moderation.user.deleteMessageHistory' \
--header 'X-Auth-Token: gulgihkln-NpF7Ts' \
--header 'X-User-Id: nDaGJfjfbkFsuaECD' \
--header 'Content-Type: application/json' \
--data '{
    "userId": "7n56WrqYcNRutgYrx"
}'

Further comments

Copy link
Member

@debdutdeb debdutdeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please create raw models instead of meteor ones; take a look at apps/meteor/server/models/raw;

I think we're also reducing the use of underscore;

please also don't create meteor methods;

overall good job 👏🏼

@Dnouv Dnouv marked this pull request as ready for review January 26, 2023 13:10
@Dnouv Dnouv requested a review from a team as a code owner January 26, 2023 13:10
@debdutdeb
Copy link
Member

I'll review in a couple of hours.

@Dnouv
Copy link
Member Author

Dnouv commented Jan 26, 2023

Thank you! I just wanted to let you know that I have fixed it according to the comments.

@Dnouv Dnouv changed the title [NEW] New API endpoint for getting the reported messages [NEW] New API endpoint for getting & hiding the reported messages Jan 27, 2023
@Dnouv Dnouv requested a review from debdutdeb January 28, 2023 14:14
@Dnouv Dnouv changed the title [NEW] New API endpoint for getting & hiding the reported messages [NEW] New API endpoints for Moderation feature Feb 24, 2023
@CLAassistant
Copy link

CLAassistant commented Mar 1, 2023

CLA assistant check
All committers have signed the CLA.

@debdutdeb debdutdeb merged commit a8ee3f7 into RocketChat:feat/moderation-dashboard Mar 20, 2023
debdutdeb added a commit that referenced this pull request Mar 28, 2023
* draft getreports api

* prettier

* fix lint error

* fix lint error

* fix lint error

* add raw model

* fix prop type

* fix lint

* add oldest undefine check

* test

* fix offset and count

* add new migration and fix report history api

* add e2e tests

* check array and remove API failure and change the migration version

* add hidebyid endpoint

* add hidebymid method

* add test for report hide

* fix build

* add moderation.info enfpoint and hiddenby fields

* add test for mdoeration.info

* fix e2e tests

* add new property in reporthistoryprop

* moderation.history -> moderation.getReports

* moderation.hide -> moderation.markChecked

* moderation.info -> moderation.reportsByMessage

* add additional sort param

* add query param

* remove deprecated query

* add single report detail endpoint

* fix link

* add test for new API

* add reportedBy user details

* fix type error and add new count api endpoint

* fix type error

* fix count api return value

* add query to group together reported messages based on message content

* update test

* add totalcounts for grouped results

* reduce data overload

* add new count field

* update IReport schema and support new fields in Moderation method

* try to fix error

* revert grouping by message content

* update moderation interface

* fix type error

* add moderation.user.getMessageHistory endpoint

* avoid duplicated messsages

* fix hidereport api

* fix reportsbymsg endpoint

* flag deleteMessage method as deprecated

* add reported message delete endpoint

* add new permissions to the deactivate & reset emoji enfpoints

* fix test and try out to append roomnames

* fix api errors

* add roomname append query

* update the ireport schema and also the report function

* add more fields in schema

* reduce aggregation calls

* fix return type of API calls

* fix tests and deleteReportedMessages method

* add intial migration logic

* try to fix type error in moderation.ts

* fix the typescript error, and remove migration logic

* fix setActiveStatus persmission

* fix projection

* add count propoerty in IModerationAudit

* add _id to usermessages

* fix deletmessage function

* add new function for reportMessage, deprecate the reportMessage method, try to fix test

---------

Co-authored-by: Debdut Chakraborty <debdut.chakraborty@rocket.chat>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants