Feat: GDPRモードを追加した
Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
parent
cb1586658e
commit
74e45b13eb
|
@ -876,6 +876,7 @@ export interface Locale {
|
|||
"on": string;
|
||||
"off": string;
|
||||
"emailRequiredForSignup": string;
|
||||
"enableGDPRMode": string;
|
||||
"unread": string;
|
||||
"filter": string;
|
||||
"controlPanel": string;
|
||||
|
|
|
@ -873,6 +873,7 @@ itsOff: "オフになっています"
|
|||
on: "オン"
|
||||
off: "オフ"
|
||||
emailRequiredForSignup: "アカウント登録にメールアドレスを必須にする"
|
||||
enableGDPRMode: "GDPRモードを有効にする"
|
||||
unread: "未読"
|
||||
filter: "フィルタ"
|
||||
controlPanel: "コントロールパネル"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export class GDPRMode1703704097603 {
|
||||
name = 'GDPRMode1703704097603'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" ADD "enableGDPRMode" boolean NOT NULL DEFAULT false`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {;
|
||||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableGDPRMode"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
export class AbusenoteId1704005554275 {
|
||||
name = 'AbusenoteId1704005554275'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "abuse_user_report" ADD "noteIds" jsonb NOT NULL DEFAULT '[]'`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "abuse_user_report" DROP COLUMN "noteIds"`);
|
||||
}
|
||||
}
|
|
@ -158,6 +158,7 @@ export interface AdminEventTypes {
|
|||
reporterId: MiUser['id'],
|
||||
comment: string;
|
||||
notes: any[];
|
||||
noteIds: string[];
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { In } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { AbuseUserReportsRepository } from '@/models/_.js';
|
||||
import type { AbuseUserReportsRepository, NotesRepository } from '@/models/_.js';
|
||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import type { MiAbuseUserReport } from '@/models/AbuseUserReport.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { UserEntityService } from './UserEntityService.js';
|
||||
|
||||
@Injectable()
|
||||
|
@ -18,7 +20,11 @@ export class AbuseUserReportEntityService {
|
|||
@Inject(DI.abuseUserReportsRepository)
|
||||
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
||||
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private noteEntityService: NoteEntityService,
|
||||
private idService: IdService,
|
||||
) {
|
||||
}
|
||||
|
@ -28,12 +34,25 @@ export class AbuseUserReportEntityService {
|
|||
src: MiAbuseUserReport['id'] | MiAbuseUserReport,
|
||||
) {
|
||||
const report = typeof src === 'object' ? src : await this.abuseUserReportsRepository.findOneByOrFail({ id: src });
|
||||
const notes = (report.notes.length === 0) ? report.notes : [];
|
||||
|
||||
if (report.noteIds && report.noteIds.length > 0) {
|
||||
for (const x of report.noteIds) {
|
||||
const exists = await this.notesRepository.countBy({ id: x });
|
||||
if (exists === 0) {
|
||||
notes.push('deleted');
|
||||
continue;
|
||||
}
|
||||
notes.push(await this.noteEntityService.pack(x));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(report.notes.length, null, notes);
|
||||
return await awaitAll({
|
||||
id: report.id,
|
||||
createdAt: this.idService.parse(report.id).date.toISOString(),
|
||||
comment: report.comment,
|
||||
notes: report.notes,
|
||||
notes,
|
||||
resolved: report.resolved,
|
||||
reporterId: report.reporterId,
|
||||
targetUserId: report.targetUserId,
|
||||
|
|
|
@ -65,6 +65,11 @@ export class MiAbuseUserReport {
|
|||
})
|
||||
public notes: any[];
|
||||
|
||||
@Column('jsonb', {
|
||||
default: [],
|
||||
})
|
||||
public noteIds: string[] | null;
|
||||
|
||||
//#region Denormalized fields
|
||||
@Index()
|
||||
@Column('varchar', {
|
||||
|
|
|
@ -541,4 +541,9 @@ export class MiMeta {
|
|||
default: 0,
|
||||
})
|
||||
public notesPerOneAd: number;
|
||||
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
})
|
||||
public enableGDPRMode: boolean;
|
||||
}
|
||||
|
|
|
@ -416,6 +416,10 @@ export const meta = {
|
|||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
enableGDPRMode: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
@ -534,6 +538,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
|
||||
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
|
||||
notesPerOneAd: instance.notesPerOneAd,
|
||||
enableGDPRMode: instance.enableGDPRMode,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ export const paramDef = {
|
|||
type: 'string',
|
||||
},
|
||||
},
|
||||
enableGDPRMode: { type: 'boolean' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
@ -209,6 +210,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (ps.infoImageUrl !== undefined) {
|
||||
set.infoImageUrl = ps.infoImageUrl;
|
||||
}
|
||||
console.log(ps.enableGDPRMode);
|
||||
if (ps.enableGDPRMode !== undefined) {
|
||||
set.enableGDPRMode = ps.enableGDPRMode;
|
||||
}
|
||||
|
||||
if (ps.notFoundImageUrl !== undefined) {
|
||||
set.notFoundImageUrl = ps.notFoundImageUrl;
|
||||
|
|
|
@ -25,7 +25,7 @@ export const meta = {
|
|||
requireCredential: true,
|
||||
kind: 'write:report-abuse',
|
||||
|
||||
description: 'User a report.',
|
||||
description: 'File a report.',
|
||||
|
||||
errors: {
|
||||
noSuchUser: {
|
||||
|
@ -91,9 +91,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
const notes = ps.noteIds ? await this.notesRepository.find({
|
||||
where: { id: In(ps.noteIds) },
|
||||
where: { id: In(ps.noteIds), userId: user.id },
|
||||
}) : [];
|
||||
const filteredNotes = notes.filter(note => note.userId === user.id);
|
||||
|
||||
const report = await this.abuseUserReportsRepository.insert({
|
||||
id: this.idService.gen(),
|
||||
targetUserId: user.id,
|
||||
|
@ -101,7 +101,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
reporterId: me.id,
|
||||
reporterHost: null,
|
||||
comment: ps.comment,
|
||||
notes: ps.noteIds ? await this.noteEntityService.packMany(filteredNotes) : [],
|
||||
notes: (ps.noteIds && !((await this.metaService.fetch()).enableGDPRMode)) ? await this.noteEntityService.packMany(notes) : [],
|
||||
noteIds: (ps.noteIds && (await this.metaService.fetch()).enableGDPRMode) ? ps.noteIds : [],
|
||||
}).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
// Publish event to moderators
|
||||
|
@ -115,6 +116,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
reporterId: report.reporterId,
|
||||
comment: report.comment,
|
||||
notes: report.notes,
|
||||
noteIds: report.noteIds ?? [],
|
||||
});
|
||||
}
|
||||
const meta = await this.metaService.fetch();
|
||||
|
|
|
@ -24,7 +24,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkFolder v-if="report.notes.length !== 0" :class="$style.notes">
|
||||
<template #label>{{ i18n.ts.reportedNote }}</template>
|
||||
<div v-for="note in report.notes" :class="$style.notes">
|
||||
<MkNoteSimple :note="note"/>
|
||||
<MkNoteSimple v-if="note !== 'deleted'" :note="note"/>
|
||||
<div v-else> note is deleted </div>
|
||||
</div>
|
||||
</MkFolder>
|
||||
</div>
|
||||
|
@ -62,7 +63,7 @@ const props = defineProps<{
|
|||
id: string;
|
||||
createdAt:string;
|
||||
targetUserId:Misskey.entities.User['id'];
|
||||
targetUser:Misskey.entities.User & {createdAt:string;};
|
||||
targetUser:Misskey.entities.User & { createdAt:string; };
|
||||
reporter:Misskey.entities.User;
|
||||
assignee:Misskey.entities.User['id'];
|
||||
comment:string;
|
||||
|
@ -109,6 +110,7 @@ function resolve() {
|
|||
padding: 24px;
|
||||
border-right: solid 1px var(--divider);
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
|
|
|
@ -18,6 +18,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #label>{{ i18n.ts.emailRequiredForSignup }}</template>
|
||||
</MkSwitch>
|
||||
|
||||
<MkSwitch v-model="enableGDPRMode">
|
||||
<template #label>{{ i18n.ts.enableGDPRMode }}</template>
|
||||
</MkSwitch>
|
||||
|
||||
<FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
|
||||
|
||||
<MkInput v-model="tosUrl" type="url">
|
||||
|
@ -79,6 +83,7 @@ const hiddenTags = ref<string>('');
|
|||
const preservedUsernames = ref<string>('');
|
||||
const tosUrl = ref<string | null>(null);
|
||||
const privacyPolicyUrl = ref<string | null>(null);
|
||||
const enableGDPRMode = ref<boolean>(false);
|
||||
|
||||
async function init() {
|
||||
const meta = await os.api('admin/meta');
|
||||
|
@ -89,6 +94,7 @@ async function init() {
|
|||
preservedUsernames.value = meta.preservedUsernames.join('\n');
|
||||
tosUrl.value = meta.tosUrl;
|
||||
privacyPolicyUrl.value = meta.privacyPolicyUrl;
|
||||
enableGDPRMode.value = meta.enableGDPRMode;
|
||||
}
|
||||
|
||||
function save() {
|
||||
|
@ -100,6 +106,7 @@ function save() {
|
|||
sensitiveWords: sensitiveWords.value.split('\n'),
|
||||
hiddenTags: hiddenTags.value.split('\n'),
|
||||
preservedUsernames: preservedUsernames.value.split('\n'),
|
||||
enableGDPRMode: enableGDPRMode.value,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue