Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add acknowledgeAllSubjectsOfAccount flag with takedown event #181

Merged
merged 8 commits into from
Sep 12, 2024
26 changes: 25 additions & 1 deletion app/actions/ModActionPanel/QuickAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ function Form(
const isMuteEvent = modEventType === MOD_EVENTS.MUTE
const isMuteReporterEvent = modEventType === MOD_EVENTS.MUTE_REPORTER
const isCommentEvent = modEventType === MOD_EVENTS.COMMENT
const isTakedownEvent = modEventType === MOD_EVENTS.TAKEDOWN
const shouldShowDurationInHoursField =
modEventType === MOD_EVENTS.TAKEDOWN || isMuteEvent || isMuteReporterEvent
isTakedownEvent || isMuteEvent || isMuteReporterEvent
const canManageChat = usePermission('canManageChat')

// navigate to next or prev report
Expand Down Expand Up @@ -258,6 +259,13 @@ function Form(
coreEvent.durationInHours = Number(formData.get('durationInHours'))
}

if (
modEventType === MOD_EVENTS.TAKEDOWN &&
formData.get('acknowledgeAccountSubjects')
) {
coreEvent.acknowledgeAccountSubjects = true
}

if (formData.get('comment')) {
coreEvent.comment = formData.get('comment')
}
Expand Down Expand Up @@ -724,6 +732,22 @@ function Form(
/>
)}

{isTakedownEvent && isSubjectDid && (
<Checkbox
value="true"
defaultChecked
id="acknowledgeAccountSubjects"
name="acknowledgeAccountSubjects"
className="mb-3 flex items-center leading-3"
label={
<span className="leading-4">
Acknowledge all open/escalated/appealed reports on
subjects created by this user
</span>
}
/>
)}

{submission.error && (
<div className="my-2">
<ActionError error={submission.error} />
Expand Down
8 changes: 7 additions & 1 deletion app/reports/page-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,14 @@ function useModerationQueueQuery() {
const excludeTags = params.get('excludeTags')
const queueName = params.get('queueName')
const { sortField, sortDirection } = getSortParams(params)
const { lastReviewedBy, subject, reporters } = useFluentReportSearchParams()
const { lastReviewedBy, subject, reporters, includeAllUserRecords } =
useFluentReportSearchParams()

return useInfiniteQuery({
queryKey: [
'events',
{
includeAllUserRecords,
subject,
sortField,
sortDirection,
Expand All @@ -315,6 +317,10 @@ function useModerationQueueQuery() {
cursor: pageParam,
}

if (includeAllUserRecords) {
queryParams.includeAllUserRecords = includeAllUserRecords
}

if (subject) {
queryParams.subject = subject
}
Expand Down
5 changes: 5 additions & 0 deletions components/reports/useFluentReportSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ type SearchQueryParams = {
subject?: string
lastReviewedBy?: string
reporters?: string[]
includeAllUserRecords?: boolean
}

const ParamPrefixes = {
subject: 'subject',
reporters: 'reporters',
lastReviewedBy: 'lastReviewedBy',
includeAllUserRecords: 'includeAllUserRecords',
}

export const buildQueryFromParams = (
Expand Down Expand Up @@ -73,13 +75,16 @@ export const useFluentReportSearchParams = (): SearchQueryParams => {
subject,
lastReviewedBy: undefined,
reporters: undefined,
includeAllUserRecords: undefined,
}

const paramsFromQuery = buildParamsFromQuery(subject)

// If the params built from query is not empty, that means the term is no longer just subject
if (Object.keys(paramsFromQuery).length) {
searchParams.subject = paramsFromQuery.subject
searchParams.includeAllUserRecords =
paramsFromQuery.includeAllUserRecords === 'true'
searchParams.lastReviewedBy = paramsFromQuery.lastReviewedBy
searchParams.reporters = paramsFromQuery.reporters
? paramsFromQuery.reporters.split(',')
Expand Down
16 changes: 15 additions & 1 deletion components/shell/CommandPalette/useAsyncSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,26 @@ const buildItemForDid = ({
addToWorkspace([did])
},
},
{
id: `search-subjects-of-did`,
name: `Subjects of ${handle || did}`,
keywords: `${search},search,did`,
icon: <LifebuoyIcon className={iconClassName} />,
subtitle: `Go to moderation queue and see all subjects that authored by this user`,
section: ActionSections.reports,
perform: () => {
const term = encodeURIComponent(
`subject:${did} includeAllUserRecords:true`,
)
router.push(`/reports?term=${term}`)
},
},
{
id: `search-subjects-last-reviewed-by-did`,
name: `Subjects last reviewed by ${handle || did}`,
keywords: `${search},search,did`,
icon: <LifebuoyIcon className={iconClassName} />,
subtitle: `Go to reports page and see all subjects that were last reviewed by this moderator`,
subtitle: `Go to moderation queue and see all subjects that were last reviewed by this moderator`,
section: ActionSections.reports,
perform: () => {
router.push(`/reports?term=lastReviewedBy:${did}`)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"e2e:run": "$(yarn bin)/cypress run --browser chrome"
},
"dependencies": {
"@atproto/api": "^0.13.6",
"@atproto/api": "^0.13.7",
"@atproto/oauth-client-browser": "^0.2.0",
"@atproto/oauth-types": "^0.1.4",
"@atproto/xrpc": "^0.6.1",
Expand Down
19 changes: 14 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@
resolved "https://registry.yarnpkg.com/@atproto-labs/simple-store/-/simple-store-0.1.1.tgz#e743a2722b5d8732166f0a72aca8bd10e9bff106"
integrity sha512-WKILW2b3QbAYKh+w5U2x6p5FqqLl0nAeLwGeDY+KjX01K4Dq3vQTR9b/qNp0jZm48CabPQVrqCv0PPU9LgRRRg==

"@atproto/api@^0.13.6":
version "0.13.6"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.6.tgz#2500e9d7143e6718089632300c42ce50149f8cd5"
integrity sha512-58emFFZhqY8nVWD3xFWK0yYqAmJ2un+NaTtZxBbRo00mGq1rz9VXTpVmfoHFcuXL1hoDQN3WyJfsub8r6xGOgg==
"@atproto/api@^0.13.7":
version "0.13.7"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.7.tgz#072eba2025d5251505f17b0b5d2de33749ea5ee4"
integrity sha512-41kSLmFWDbuPOenb52WRq1lnBkSZrL+X29tWcvEt6SZXK4xBoKAalw1MjF+oabhzff12iMtNaNvmmt2fu1L+cw==
dependencies:
"@atproto/common-web" "^0.3.0"
"@atproto/lexicon" "^0.4.1"
"@atproto/syntax" "^0.3.0"
"@atproto/xrpc" "^0.6.1"
"@atproto/xrpc" "^0.6.2"
await-lock "^2.2.2"
multiformats "^9.9.0"
tlds "^1.234.0"
zod "^3.23.8"

"@atproto/common-web@^0.3.0":
version "0.3.0"
Expand Down Expand Up @@ -178,6 +179,14 @@
"@atproto/lexicon" "^0.4.1"
zod "^3.23.8"

"@atproto/xrpc@^0.6.2":
version "0.6.2"
resolved "https://registry.yarnpkg.com/@atproto/xrpc/-/xrpc-0.6.2.tgz#634228a7e533de01bda2214837d11574fdadad55"
integrity sha512-as/gb08xJb02HAGNrSQSumCe10WnOAcnM6bR6KMatQyQJuEu7OY6ZDSTM/4HfjjoxsNqdvPmbYuoUab1bKTNlA==
dependencies:
"@atproto/lexicon" "^0.4.1"
zod "^3.23.8"

"@babel/runtime@^7.1.2":
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd"
Expand Down
Loading