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

✨ Move appealed subject's review state to escalated #2198

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/ozone/src/mod-service/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ export const adjustModerationSubjectStatus = async (
subjectStatus.appealed = true
newStatus.lastAppealedAt = createdAt
subjectStatus.lastAppealedAt = createdAt
// Set reviewState to escalated when appeal events are emitted
subjectStatus.reviewState = REVIEWESCALATED
newStatus.reviewState = REVIEWESCALATED
}

if (
Expand Down
26 changes: 19 additions & 7 deletions packages/ozone/tests/moderation-appeals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('moderation-appeals', () => {
})

// Verify that appeal status changed when appeal report was emitted by moderator
const status = await assertBobsPostStatus(REVIEWOPEN, true)
const status = await assertBobsPostStatus(REVIEWESCALATED, true)
expect(status?.appealedAt).not.toBeNull()

// Create a report as normal user for carol's post
Expand All @@ -143,7 +143,11 @@ describe('moderation-appeals', () => {
subject: getCarolPostSubject(),
})
// Verify that the appeal status on carol's post is true
await assertSubjectStatus(getCarolPostSubject().uri, REVIEWOPEN, true)
await assertSubjectStatus(
getCarolPostSubject().uri,
REVIEWESCALATED,
true,
)
})
it('allows multiple appeals and updates last appealed timestamp', async () => {
// Resolve appeal with acknowledge
Expand All @@ -155,7 +159,7 @@ describe('moderation-appeals', () => {
createdBy: sc.dids.carol,
})

const previousStatus = await assertBobsPostStatus(REVIEWOPEN, false)
const previousStatus = await assertBobsPostStatus(REVIEWESCALATED, false)

await emitModerationEvent({
event: {
Expand All @@ -167,7 +171,7 @@ describe('moderation-appeals', () => {
})

// Verify that even after the appeal event by bob for his post, the appeal status is true again with new timestamp
const newStatus = await assertBobsPostStatus(REVIEWOPEN, true)
const newStatus = await assertBobsPostStatus(REVIEWESCALATED, true)
expect(
new Date(`${previousStatus?.lastAppealedAt}`).getTime(),
).toBeLessThan(new Date(`${newStatus?.lastAppealedAt}`).getTime())
Expand Down Expand Up @@ -210,7 +214,11 @@ describe('moderation-appeals', () => {
createdBy: sc.dids.alice,
})

await assertSubjectStatus(getAlicesPostSubject().uri, REVIEWOPEN, true)
await assertSubjectStatus(
getAlicesPostSubject().uri,
REVIEWESCALATED,
true,
)

// Bob reports it again
await emitModerationEvent({
Expand All @@ -222,8 +230,12 @@ describe('moderation-appeals', () => {
createdBy: sc.dids.bob,
})

// Assert that the status is still REVIEWOPEN, as report events are meant to do
await assertSubjectStatus(getAlicesPostSubject().uri, REVIEWOPEN, true)
// Assert that the status is still REVIEWESCALATED, as report events are meant to do
await assertSubjectStatus(
getAlicesPostSubject().uri,
REVIEWESCALATED,
true,
)

// Emit an escalation event
await emitModerationEvent({
Expand Down
Loading