Skip to content

Commit

Permalink
enhance: improve moderation log
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Sep 28, 2023
1 parent 440f314 commit 055464a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,7 @@ export interface Locale {
"markSensitiveDriveFile": string;
"unmarkSensitiveDriveFile": string;
"resolveAbuseReport": string;
"createInvitation": string;
};
}
declare const locales: {
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2190,3 +2190,4 @@ _moderationLogTypes:
markSensitiveDriveFile: "ファイルをセンシティブ付与"
unmarkSensitiveDriveFile: "ファイルをセンシティブ解除"
resolveAbuseReport: "通報を解決"
createInvitation: "招待コードを作成"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { InviteCodeEntityService } from '@/core/entities/InviteCodeEntityService
import { IdService } from '@/core/IdService.js';
import { DI } from '@/di-symbols.js';
import { generateInviteCode } from '@/misc/generate-invite-code.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
import { ApiError } from '../../../error.js';

export const meta = {
Expand Down Expand Up @@ -60,6 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-

private inviteCodeEntityService: InviteCodeEntityService,
private idService: IdService,
private moderationLogService: ModerationLogService,
) {
super(meta, paramDef, async (ps, me) => {
if (ps.expiresAt && isNaN(Date.parse(ps.expiresAt))) {
Expand All @@ -78,6 +80,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}

const tickets = await Promise.all(ticketsPromises);

this.moderationLogService.log(me, 'createInvitation', {
invitations: tickets,
});

return await this.inviteCodeEntityService.packMany(tickets, me);
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const moderationLogTypes = [
'markSensitiveDriveFile',
'unmarkSensitiveDriveFile',
'resolveAbuseReport',
'createInvitation',
] as const;

export type ModerationLogPayloads = {
Expand Down Expand Up @@ -198,4 +199,7 @@ export type ModerationLogPayloads = {
report: any;
forwarded: boolean;
};
createInvitation: {
invitations: any[];
};
};
5 changes: 4 additions & 1 deletion packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2604,10 +2604,13 @@ type ModerationLog = {
} | {
type: 'unmarkSensitiveDriveFile';
info: ModerationLogPayloads['unmarkSensitiveDriveFile'];
} | {
type: 'createInvitation';
info: ModerationLogPayloads['createInvitation'];
});

// @public (undocumented)
export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport"];
export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation"];

// @public (undocumented)
export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"];
Expand Down
4 changes: 4 additions & 0 deletions packages/misskey-js/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const moderationLogTypes = [
'markSensitiveDriveFile',
'unmarkSensitiveDriveFile',
'resolveAbuseReport',
'createInvitation',
] as const;

export type ModerationLogPayloads = {
Expand Down Expand Up @@ -216,4 +217,7 @@ export type ModerationLogPayloads = {
report: any;
forwarded: boolean;
};
createInvitation: {
invitations: any[];
};
};
3 changes: 3 additions & 0 deletions packages/misskey-js/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,7 @@ export type ModerationLog = {
} | {
type: 'unmarkSensitiveDriveFile';
info: ModerationLogPayloads['unmarkSensitiveDriveFile'];
} | {
type: 'createInvitation';
info: ModerationLogPayloads['createInvitation'];
});

0 comments on commit 055464a

Please sign in to comment.