Feat: GDPRモードを追加した

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-12-31 18:19:59 +09:00
parent cb1586658e
commit 74e45b13eb
No known key found for this signature in database
GPG key ID: 068E54E2C33BEF9A
13 changed files with 83 additions and 8 deletions

View file

@ -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,
};
});
}

View file

@ -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;

View file

@ -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();