Skip to content

Commit

Permalink
Rename reported-by field for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Mar 14, 2023
1 parent 15fda47 commit 7832eb2
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 79 deletions.
8 changes: 4 additions & 4 deletions lexicons/com/atproto/admin/moderationReport.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"defs": {
"view": {
"type": "object",
"required": ["id", "reasonType", "subject", "reportedByDid", "createdAt", "resolvedByActionIds"],
"required": ["id", "reasonType", "subject", "reportedBy", "createdAt", "resolvedByActionIds"],
"properties": {
"id": {"type": "integer"},
"reasonType": {"type": "ref", "ref": "com.atproto.report.reasonType"},
Expand All @@ -16,14 +16,14 @@
"com.atproto.repo.strongRef"
]
},
"reportedByDid": {"type": "string", "format": "did"},
"reportedBy": {"type": "string", "format": "did"},
"createdAt": {"type": "string", "format": "datetime"},
"resolvedByActionIds": {"type": "array", "items": {"type": "integer"}}
}
},
"viewDetail": {
"type": "object",
"required": ["id", "reasonType", "subject", "reportedByDid", "createdAt", "resolvedByActions"],
"required": ["id", "reasonType", "subject", "reportedBy", "createdAt", "resolvedByActions"],
"properties": {
"id": {"type": "integer"},
"reasonType": {"type": "ref", "ref": "com.atproto.report.reasonType"},
Expand All @@ -35,7 +35,7 @@
"com.atproto.admin.record#view"
]
},
"reportedByDid": {"type": "string", "format": "did"},
"reportedBy": {"type": "string", "format": "did"},
"createdAt": {"type": "string", "format": "datetime"},
"resolvedByActions": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationAction#view"}}
}
Expand Down
4 changes: 2 additions & 2 deletions lexicons/com/atproto/report/create.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["id", "reasonType", "subject", "reportedByDid", "createdAt"],
"required": ["id", "reasonType", "subject", "reportedBy", "createdAt"],
"properties": {
"id": {"type": "integer"},
"reasonType": {"type": "ref", "ref": "com.atproto.report.reasonType"},
Expand All @@ -39,7 +39,7 @@
"com.atproto.repo.strongRef"
]
},
"reportedByDid": {"type": "string", "format": "did"},
"reportedBy": {"type": "string", "format": "did"},
"createdAt": {"type": "string", "format": "datetime"}
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
'resolvedByActionIds',
],
Expand All @@ -704,7 +704,7 @@ export const schemaDict = {
'lex:com.atproto.repo.strongRef',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand All @@ -726,7 +726,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
'resolvedByActions',
],
Expand All @@ -748,7 +748,7 @@ export const schemaDict = {
'lex:com.atproto.admin.record#view',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand Down Expand Up @@ -1805,7 +1805,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
],
properties: {
Expand All @@ -1826,7 +1826,7 @@ export const schemaDict = {
'lex:com.atproto.repo.strongRef',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface View {
| ComAtprotoRepoRepoRef.Main
| ComAtprotoRepoStrongRef.Main
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
resolvedByActionIds: number[]
[k: string]: unknown
Expand All @@ -45,7 +45,7 @@ export interface ViewDetail {
| ComAtprotoAdminRepo.View
| ComAtprotoAdminRecord.View
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
resolvedByActions: ComAtprotoAdminModerationAction.View[]
[k: string]: unknown
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/client/types/com/atproto/report/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface OutputSchema {
| ComAtprotoRepoRepoRef.Main
| ComAtprotoRepoStrongRef.Main
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
[k: string]: unknown
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/api/com/atproto/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function (server: Server, ctx: AppContext) {
reasonType: getReasonType(reasonType),
reason,
subject: getSubject(subject),
reportedByDid: requester,
reportedBy: requester,
})

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function up(db: Kysely<unknown>, dialect: Dialect): Promise<void> {
.addColumn('subjectCid', 'varchar')
.addColumn('reasonType', 'varchar', (col) => col.notNull())
.addColumn('reason', 'text')
.addColumn('reportedByDid', 'varchar', (col) => col.notNull())
.addColumn('reportedBy', 'varchar', (col) => col.notNull())
.addColumn('createdAt', 'varchar', (col) => col.notNull())
.execute()
// Moderation report resolutions
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/db/tables/moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface ModerationReport {
subjectCid: string | null
reasonType: typeof SPAM | typeof OTHER
reason: string | null
reportedByDid: string
reportedBy: string
createdAt: string
}

Expand Down
12 changes: 6 additions & 6 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
'resolvedByActionIds',
],
Expand All @@ -704,7 +704,7 @@ export const schemaDict = {
'lex:com.atproto.repo.strongRef',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand All @@ -726,7 +726,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
'resolvedByActions',
],
Expand All @@ -748,7 +748,7 @@ export const schemaDict = {
'lex:com.atproto.admin.record#view',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand Down Expand Up @@ -1805,7 +1805,7 @@ export const schemaDict = {
'id',
'reasonType',
'subject',
'reportedByDid',
'reportedBy',
'createdAt',
],
properties: {
Expand All @@ -1826,7 +1826,7 @@ export const schemaDict = {
'lex:com.atproto.repo.strongRef',
],
},
reportedByDid: {
reportedBy: {
type: 'string',
format: 'did',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface View {
| ComAtprotoRepoRepoRef.Main
| ComAtprotoRepoStrongRef.Main
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
resolvedByActionIds: number[]
[k: string]: unknown
Expand All @@ -45,7 +45,7 @@ export interface ViewDetail {
| ComAtprotoAdminRepo.View
| ComAtprotoAdminRecord.View
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
resolvedByActions: ComAtprotoAdminModerationAction.View[]
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface OutputSchema {
| ComAtprotoRepoRepoRef.Main
| ComAtprotoRepoStrongRef.Main
| { $type: string; [k: string]: unknown }
reportedByDid: string
reportedBy: string
createdAt: string
[k: string]: unknown
}
Expand Down
6 changes: 3 additions & 3 deletions packages/pds/src/services/moderation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,13 @@ export class ModerationService {
reasonType: ModerationReportRow['reasonType']
reason?: string
subject: { did: string } | { uri: AtUri; cid?: CID }
reportedByDid: string
reportedBy: string
createdAt?: Date
}): Promise<ModerationReportRow> {
const {
reasonType,
reason,
reportedByDid,
reportedBy,
createdAt = new Date(),
subject,
} = info
Expand Down Expand Up @@ -477,7 +477,7 @@ export class ModerationService {
reasonType,
reason: reason || null,
createdAt: createdAt.toISOString(),
reportedByDid,
reportedBy,
...subjectInfo,
})
.returningAll()
Expand Down
6 changes: 3 additions & 3 deletions packages/pds/src/services/moderation/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class ModerationViews {
createdAt: res.createdAt,
reasonType: res.reasonType,
reason: res.reason ?? undefined,
reportedByDid: res.reportedByDid,
reportedBy: res.reportedBy,
subject:
res.subjectType === 'com.atproto.repo.repoRef'
? {
Expand All @@ -421,7 +421,7 @@ export class ModerationViews {
createdAt: report.createdAt,
reasonType: report.reasonType,
reason: report.reason ?? undefined,
reportedByDid: report.reportedByDid,
reportedBy: report.reportedBy,
subject:
report.subjectType === 'com.atproto.repo.repoRef'
? {
Expand Down Expand Up @@ -455,7 +455,7 @@ export class ModerationViews {
createdAt: report.createdAt,
reasonType: report.reasonType,
reason: report.reason ?? undefined,
reportedByDid: report.reportedByDid,
reportedBy: report.reportedBy,
subject,
resolvedByActions,
}
Expand Down
8 changes: 4 additions & 4 deletions packages/pds/tests/__snapshots__/moderation.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Array [
"createdAt": "1970-01-01T00:00:00.000Z",
"id": 3,
"reasonType": "com.atproto.report.reasonType#spam",
"reportedByDid": "user(0)",
"reportedBy": "user(0)",
"subject": Object {
"$type": "com.atproto.repo.strongRef",
"cid": "cids(0)",
Expand All @@ -37,7 +37,7 @@ Array [
"id": 4,
"reason": "defamation",
"reasonType": "com.atproto.report.reasonType#other",
"reportedByDid": "user(1)",
"reportedBy": "user(1)",
"subject": Object {
"$type": "com.atproto.repo.strongRef",
"cid": "cids(1)",
Expand All @@ -53,7 +53,7 @@ Array [
"createdAt": "1970-01-01T00:00:00.000Z",
"id": 1,
"reasonType": "com.atproto.report.reasonType#spam",
"reportedByDid": "user(0)",
"reportedBy": "user(0)",
"subject": Object {
"$type": "com.atproto.repo.repoRef",
"did": "user(1)",
Expand All @@ -64,7 +64,7 @@ Array [
"id": 2,
"reason": "impersonation",
"reasonType": "com.atproto.report.reasonType#other",
"reportedByDid": "user(2)",
"reportedBy": "user(2)",
"subject": Object {
"$type": "com.atproto.repo.repoRef",
"did": "user(1)",
Expand Down
6 changes: 3 additions & 3 deletions packages/pds/tests/seeds/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ export class SeedClient {
reasonType: CreateReportInput['reasonType']
subject: CreateReportInput['subject']
reason?: string
reportedByDid: string
reportedBy: string
}) {
const { reasonType, subject, reason, reportedByDid } = opts
const { reasonType, subject, reason, reportedBy } = opts
const result = await this.agent.api.com.atproto.report.create(
{ reasonType, subject, reason },
{
encoding: 'application/json',
headers: this.getHeaders(reportedByDid),
headers: this.getHeaders(reportedBy),
},
)
return result.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Object {
"id": 2,
"reason": "defamation",
"reasonType": "com.atproto.report.reasonType#other",
"reportedByDid": "user(1)",
"reportedBy": "user(1)",
"resolvedByActionIds": Array [
2,
1,
Expand Down Expand Up @@ -84,7 +84,7 @@ Object {
"id": 2,
"reason": "defamation",
"reasonType": "com.atproto.report.reasonType#other",
"reportedByDid": "user(1)",
"reportedBy": "user(1)",
"resolvedByActionIds": Array [
2,
1,
Expand All @@ -99,7 +99,7 @@ Object {
"createdAt": "1970-01-01T00:00:00.000Z",
"id": 1,
"reasonType": "com.atproto.report.reasonType#spam",
"reportedByDid": "user(2)",
"reportedBy": "user(2)",
"resolvedByActionIds": Array [
1,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Object {
"id": 2,
"reason": "defamation",
"reasonType": "com.atproto.report.reasonType#other",
"reportedByDid": "user(0)",
"reportedBy": "user(0)",
"resolvedByActions": Array [
Object {
"action": "com.atproto.admin.moderationAction#takedown",
Expand Down Expand Up @@ -96,7 +96,7 @@ Object {
"createdAt": "1970-01-01T00:00:00.000Z",
"id": 1,
"reasonType": "com.atproto.report.reasonType#spam",
"reportedByDid": "user(0)",
"reportedBy": "user(0)",
"resolvedByActions": Array [
Object {
"action": "com.atproto.admin.moderationAction#flag",
Expand Down
Loading

0 comments on commit 7832eb2

Please sign in to comment.