refactor: fix type of MkAbuseReport
This commit is contained in:
parent
268b7aeb3f
commit
23145c61af
8 changed files with 114 additions and 81 deletions
|
@ -33,8 +33,10 @@ import { packedGalleryPostSchema } from "@/models/schema/gallery-post.js";
|
|||
import { packedEmojiSchema } from "@/models/schema/emoji.js";
|
||||
import { packedNoteEdit } from "@/models/schema/note-edit.js";
|
||||
import { packedNoteFileSchema } from "@/models/schema/note-file.js";
|
||||
import { packedAbuseUserReportSchema } from "@/models/schema/abuse-user-report.js";
|
||||
|
||||
export const refs = {
|
||||
AbuseUserReport: packedAbuseUserReportSchema,
|
||||
UserLite: packedUserLiteSchema,
|
||||
UserDetailedNotMeOnly: packedUserDetailedNotMeOnlySchema,
|
||||
MeDetailedOnly: packedMeDetailedOnlySchema,
|
||||
|
|
|
@ -2,6 +2,7 @@ import { db } from "@/db/postgre.js";
|
|||
import { Users } from "../index.js";
|
||||
import { AbuseUserReport } from "@/models/entities/abuse-user-report.js";
|
||||
import { awaitAll } from "@/prelude/await-all.js";
|
||||
import type { Packed } from "@/misc/schema.js";
|
||||
|
||||
export const AbuseUserReportRepository = db
|
||||
.getRepository(AbuseUserReport)
|
||||
|
@ -10,7 +11,7 @@ export const AbuseUserReportRepository = db
|
|||
const report =
|
||||
typeof src === "object" ? src : await this.findOneByOrFail({ id: src });
|
||||
|
||||
return await awaitAll({
|
||||
const packed: Packed<"AbuseUserReport"> = await awaitAll({
|
||||
id: report.id,
|
||||
createdAt: report.createdAt.toISOString(),
|
||||
comment: report.comment,
|
||||
|
@ -31,9 +32,10 @@ export const AbuseUserReportRepository = db
|
|||
: null,
|
||||
forwarded: report.forwarded,
|
||||
});
|
||||
return packed;
|
||||
},
|
||||
|
||||
packMany(reports: any[]) {
|
||||
packMany(reports: (AbuseUserReport["id"] | AbuseUserReport)[]) {
|
||||
return Promise.all(reports.map((x) => this.pack(x)));
|
||||
},
|
||||
});
|
||||
|
|
69
packages/backend/src/models/schema/abuse-user-report.ts
Normal file
69
packages/backend/src/models/schema/abuse-user-report.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
export const packedAbuseUserReportSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
format: "id",
|
||||
example: "xxxxxxxxxx",
|
||||
},
|
||||
createdAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
format: "date-time",
|
||||
},
|
||||
comment: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
resolved: {
|
||||
type: "boolean",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
reporterId: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
format: "id",
|
||||
},
|
||||
targetUserId: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
format: "id",
|
||||
},
|
||||
assigneeId: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true,
|
||||
format: "id",
|
||||
},
|
||||
reporter: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "UserDetailed",
|
||||
},
|
||||
targetUser: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "UserDetailed",
|
||||
},
|
||||
assignee: {
|
||||
type: "object",
|
||||
optional: true,
|
||||
nullable: true,
|
||||
ref: "UserDetailed",
|
||||
},
|
||||
forwarded: {
|
||||
type: "boolean",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
|
@ -16,68 +16,7 @@ export const meta = {
|
|||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
format: "id",
|
||||
example: "xxxxxxxxxx",
|
||||
},
|
||||
createdAt: {
|
||||
type: "string",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
format: "date-time",
|
||||
},
|
||||
comment: {
|
||||
type: "string",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
resolved: {
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
example: false,
|
||||
},
|
||||
reporterId: {
|
||||
type: "string",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
format: "id",
|
||||
},
|
||||
targetUserId: {
|
||||
type: "string",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
format: "id",
|
||||
},
|
||||
assigneeId: {
|
||||
type: "string",
|
||||
nullable: true,
|
||||
optional: false,
|
||||
format: "id",
|
||||
},
|
||||
reporter: {
|
||||
type: "object",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
ref: "User",
|
||||
},
|
||||
targetUser: {
|
||||
type: "object",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
ref: "User",
|
||||
},
|
||||
assignee: {
|
||||
type: "object",
|
||||
nullable: true,
|
||||
optional: true,
|
||||
ref: "User",
|
||||
},
|
||||
},
|
||||
ref: "AbuseUserReport",
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
|
|
@ -72,13 +72,14 @@ import MkSwitch from "@/components/form/switch.vue";
|
|||
import MkKeyValue from "@/components/MkKeyValue.vue";
|
||||
import * as os from "@/os";
|
||||
import { i18n } from "@/i18n";
|
||||
import type { entities } from "firefish-js";
|
||||
|
||||
const props = defineProps<{
|
||||
report: any;
|
||||
report: entities.AbuseUserReport;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: "resolved", reportId: string): void;
|
||||
resolved: [reportId: string];
|
||||
}>();
|
||||
|
||||
const forward = ref(props.report.forwarded);
|
||||
|
|
|
@ -99,12 +99,13 @@ import XAbuseReport from "@/components/MkAbuseReport.vue";
|
|||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import icon from "@/scripts/icon";
|
||||
import type { entities } from "firefish-js";
|
||||
|
||||
const reports = ref<InstanceType<typeof MkPagination>>();
|
||||
|
||||
const state = ref("unresolved");
|
||||
const reporterOrigin = ref("combined");
|
||||
const targetUserOrigin = ref("combined");
|
||||
const reporterOrigin = ref<entities.OriginType>("combined");
|
||||
const targetUserOrigin = ref<entities.OriginType>("combined");
|
||||
// const searchUsername = ref("");
|
||||
// const searchHost = ref("");
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type {
|
||||
AbuseUserReport,
|
||||
Ad,
|
||||
Announcement,
|
||||
Antenna,
|
||||
|
@ -68,7 +69,18 @@ type NoteSubmitReq = {
|
|||
|
||||
export type Endpoints = {
|
||||
// admin
|
||||
"admin/abuse-user-reports": { req: TODO; res: TODO };
|
||||
"admin/abuse-user-reports": {
|
||||
req: {
|
||||
limit?: number;
|
||||
sinceId?: AbuseUserReport["id"];
|
||||
untilId?: AbuseUserReport["id"];
|
||||
state?: string;
|
||||
reporterOrigin?: OriginType;
|
||||
targetUserOrigin?: OriginType;
|
||||
forwarded?: boolean;
|
||||
};
|
||||
res: AbuseUserReport[];
|
||||
};
|
||||
"admin/delete-all-files-of-a-user": {
|
||||
req: { userId: User["id"] };
|
||||
res: null;
|
||||
|
|
|
@ -18,10 +18,7 @@ export type UserLite = {
|
|||
avatarBlurhash: string;
|
||||
alsoKnownAs: string[];
|
||||
movedToUri: any;
|
||||
emojis: {
|
||||
name: string;
|
||||
url: string;
|
||||
}[];
|
||||
emojis: EmojiLite[];
|
||||
instance?: {
|
||||
name: Instance["name"];
|
||||
softwareName: Instance["softwareName"];
|
||||
|
@ -171,10 +168,7 @@ export type Note = {
|
|||
votes: number;
|
||||
}[];
|
||||
};
|
||||
emojis: {
|
||||
name: string;
|
||||
url: string;
|
||||
}[];
|
||||
emojis: EmojiLite[];
|
||||
uri?: string;
|
||||
url?: string;
|
||||
updatedAt?: DateString;
|
||||
|
@ -191,10 +185,7 @@ export type NoteEdit = {
|
|||
updatedAt: string;
|
||||
fileIds: DriveFile["id"][];
|
||||
files: DriveFile[];
|
||||
emojis: {
|
||||
name: string;
|
||||
url: string;
|
||||
}[];
|
||||
emojis: EmojiLite[];
|
||||
};
|
||||
|
||||
export type NoteReaction = {
|
||||
|
@ -325,6 +316,8 @@ export type EmojiLite = {
|
|||
id: string;
|
||||
name: string;
|
||||
url: string;
|
||||
width: number | null;
|
||||
height: number | null;
|
||||
};
|
||||
|
||||
export type LiteInstanceMetadata = {
|
||||
|
@ -547,3 +540,17 @@ export type UserSorting =
|
|||
| "+updatedAt"
|
||||
| "-updatedAt";
|
||||
export type OriginType = "combined" | "local" | "remote";
|
||||
|
||||
export type AbuseUserReport = {
|
||||
id: string;
|
||||
createdAt: DateString;
|
||||
comment: string;
|
||||
resolved: boolean;
|
||||
reporterId: User["id"];
|
||||
targetUserId: User["id"];
|
||||
assigneeId: User["id"] | null;
|
||||
reporter: UserDetailed;
|
||||
targetUser: UserDetailed;
|
||||
assignee?: UserDetailed | null;
|
||||
forwarded: boolean;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue