Skip to content

[engine] Tenant report system #2664 front!2476

Ben requested to merge feat/report-v2-e2664 into master

Ticket(s) / Related Merge Requests

Summary of Changes

Engine changes for the V2 report system for Tenant networks.

Testing Considerations

URL for testing https://c81e728d9d4c2f636f067f89cc14862c.bens-networks-3.oke.minds.io/api/graphql

General
  • Calls can only be made on tenant networks.
Creation
  • Can create a report for NSFW with subreasons.
  • Can create a report for ILLEGAL with subreasons.
  • Can create a report for SECURITY with subreasons.
  • Can create a report for other reasons without subreasons.
  • Can create multiple reports for the same reason.
  • Only logged-in users can submit reports.
List of reports
  • Can get a list of reports.
  • Only admins can list reports.
  • The list of reports can be paginated.
  • Will only return PENDING reports when requested.
Verdicts
  • Verdicts can be provided.
  • Only admins can provide a verdict.
  • Ban action on a user bans the user.
  • Ban action on an activity bans the owner.
  • Ban action on a group bans the owner.
  • Ban action on a comment bans the owner.
  • Delete action on a user throws an exception.
  • Delete action on an activity deletes the activity.
  • Delete action on a group deletes the group.
  • Delete action on a comment deletes the comment.
  • Status is updated appropriately in the database
  • Multiple reports for the same entity with the same reasons ALL get updated from a single verdict.
  • If entity is not found - report is flagged as ignored.
Get Reports Query

Query:

query GetReports(
  $first: Int!,
  $after: Int!,
  $status: ReportStatusEnum
) {
  reports(first: $first, after: $after, status: $status) {
    edges {
      node {
      	... on Report {
          tenantId
          reportGuid
          entityUrn
          entityGuid
          reportedByGuid
          moderatedByGuid
          createdTimestamp
          reason
          nsfwSubReason
          illegalSubReason
          securitySubReason
          createdTimestamp
          entityEdge {
            ... on ActivityEdge {
              node {
                legacy
              }
            }
            ... on UserEdge {
              node {
                legacy
              }
            }
            ... on GroupEdge {
	      node {
                legacy
              }
            }
            ... on CommentEdge {
              node {
                legacy
              }
            }
          }
        }
      }
      cursor
    } 
    pageInfo {
      hasNextPage
      startCursor
      endCursor
    }
  }
}

Variables:

{
  "first": 12,
  "after": 0,
  "status": "PENDING"
}
Create Report Query

Query:

mutation CreateNewReport(
  $entityUrn: String!
  $reason: ReportReasonEnum!
  $illegalSubReason: IllegalSubReasonEnum,
  $nsfwSubReason: NsfwSubReasonEnum,
  $securitySubReason: SecuritySubReasonEnum
) {
  createNewReport(
    reportInput: {
      entityUrn: $entityUrn,
      reason: $reason
      securitySubReason: $securitySubReason
    	illegalSubReason: $illegalSubReason
      nsfwSubReason: $nsfwSubReason
    }
  )
}

Variables:

{
    "entityUrn": "urn:comment:1569010495720001546:0:0:0:1569010529857441809",
    "reason": "NSFW",
    "nsfwSubReason": "NUDITY"
}
Provide Verdict

Query:

mutation ProvideVerdict(
  $reportGuid: String!,
  $action: ReportActionEnum!
) {
  provideVerdict(
    verdictInput: {
      reportGuid: $reportGuid,
      action: $action
    }
  )
}

Variables:

{
  "reportGuid": "1569056140593991681",
  "action": "BAN"
}

Deployment Considerations

Make sure to add the table


CREATE TABLE `minds_reports` (
  `tenant_id` int NOT NULL,
  `report_guid` bigint NOT NULL,
  `entity_guid` bigint NOT NULL,
  `entity_urn` varchar(256) NOT NULL,
  `reported_by_guid` bigint NOT NULL,
  `moderated_by_guid` bigint DEFAULT NULL,
  `reason` tinyint NOT NULL,
  `sub_reason` tinyint DEFAULT NULL,
  `status` tinyint NOT NULL,
  `action` tinyint DEFAULT NULL,
  `created_timestamp` timestamp DEFAULT CURRENT_TIMESTAMP,
  `updated_timestamp` timestamp DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`report_guid`),
  INDEX (tenant_id)
);

Regression Scope

Mostly additive changes to add a new V2 module for reports - has no impact on the existing system.

Platform Affected (web, mobile, etc)

Engine - no clients are consuming this.

Developer Testing Completed

Manual, unit (phpspec).

Screenshots / Screen Recording

Creation

Can create a report for NSFW, ILLEGAL and SECURITY with correct subreasons.

simplescreenrecorder-2023-11-09_17.33.31

Can create a report for other reasons without subreasons & Can create multiple reports for the same reason.

simplescreenrecorder-2023-11-09_17.37.00

Logged-out users cannot report

image

List of reports

List & pagination

simplescreenrecorder-2023-11-09_17.42.24

Only admins can access reports list

image

Will only return PENDING reports when requested

simplescreenrecorder-2023-11-09_17.47.11

Verdicts

Ban / Delete action on a user

simplescreenrecorder-2023-11-09_18.02.03

Ban action on an activity bans the owner.

simplescreenrecorder-2023-11-09_18.06.10

Delete action on an activity deletes the activity.

simplescreenrecorder-2023-11-09_18.08.24

Ban action on a group bans the owner.

simplescreenrecorder-2023-11-09_18.09.54

Delete action on a group deletes the group.

simplescreenrecorder-2023-11-09_18.14.17

Comment actions

Tested locally but comments seem to be broken on sandbox.

Multiple reports for the same entity with the same reasons ALL get updated from a single verdict.

simplescreenrecorder-2023-11-09_18.23.42

Only admins can provide a verdict.

image

If entity is not found - report is flagged as ignored.

simplescreenrecorder-2023-11-09_18.59.23

Does this impact

  • Localization
  • Dark/light mode
  • Guest mode

Definition of Done Checklist

  • The Acceptance Criteria has been met
  • Code is tested: Testing includes unit/spec, E2E/automated and manual testing
  • Merge requests description has been filled out
Edited by Ben

Merge request reports