-
Notifications
You must be signed in to change notification settings - Fork 577
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 subject tags with report type #3260
Changes from 5 commits
212bff8
f5a5d12
cf1194b
54d21fe
4b9ada3
0fa27b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,15 +22,18 @@ export class TagService { | |||||
] | ||||||
} | ||||||
|
||||||
async evaluateForSubject() { | ||||||
// Allow the caller to seed the initial tags | ||||||
async evaluateForSubject(initialTags: string[] = []) { | ||||||
try { | ||||||
const tags: string[] = [] | ||||||
const tags = new Set([...initialTags]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to copy here (the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleaned it up as recommended! |
||||||
|
||||||
await Promise.all( | ||||||
this.taggers.map(async (tagger) => { | ||||||
try { | ||||||
const newTags = await tagger.getTags() | ||||||
if (newTags.length) tags.push(...newTags) | ||||||
for (const newTag of newTags) { | ||||||
tags.add(newTag) | ||||||
} | ||||||
} catch (e) { | ||||||
// Don't let one tagger error stop the rest from running | ||||||
log.error( | ||||||
|
@@ -41,11 +44,19 @@ export class TagService { | |||||
}), | ||||||
) | ||||||
|
||||||
if (tags.length > 0) { | ||||||
// Ensure that before inserting new tags, we discard any tag that may | ||||||
// have been evaluated to be added but is already present in the subject | ||||||
if (this.subjectStatus?.tags?.length) { | ||||||
for (const tag of this.subjectStatus.tags) { | ||||||
tags.delete(tag) | ||||||
} | ||||||
} | ||||||
|
||||||
if (tags.size) { | ||||||
await this.moderationService.logEvent({ | ||||||
event: { | ||||||
$type: 'tools.ozone.moderation.defs#modEventTag', | ||||||
add: tags, | ||||||
add: [...tags], | ||||||
remove: [], | ||||||
}, | ||||||
subject: this.subject, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ReasonType } from '../lexicon/types/com/atproto/moderation/defs' | ||
|
||
export const getTagForReport = (reasonType: ReasonType) => { | ||
return `report:${reasonType.replace('com.atproto.moderation.defs#reason', '').toLowerCase()}` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ describe('report-muting', () => { | |
}) | ||
|
||
// Verify that a subject status was not created for bob's post since the reporter was muted | ||
await assertSubjectStatus(bobsPostSubject.uri, undefined) | ||
await assertSubjectStatus(bobsPostSubject.uri, REVIEWNONE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only needed changing because we are now emitting an additional tag event because of report which causes the status to change to reviewNone which is similar to not having a reviewstate so there is no functional change. |
||
// Verify, however, that the event was logged | ||
await modClient.queryEvents({ | ||
subject: bobsPostSubject.uri, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: No need to create empty unused array here.