wip
This commit is contained in:
parent
d1bcb54719
commit
6c5d7e9e89
|
@ -9,6 +9,7 @@ import type { ModerationLogsRepository } from '@/models/_.js';
|
|||
import type { MiUser } from '@/models/User.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { ModerationLogPayloads, moderationLogTypes } from '@/types.js';
|
||||
|
||||
@Injectable()
|
||||
export class ModerationLogService {
|
||||
|
@ -21,13 +22,13 @@ export class ModerationLogService {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async log(moderator: { id: MiUser['id'] }, type: string, info?: Record<string, any>) {
|
||||
public async log<T extends typeof moderationLogTypes[number]>(moderator: { id: MiUser['id'] }, type: T, info?: ModerationLogPayloads[T]) {
|
||||
await this.moderationLogsRepository.insert({
|
||||
id: this.idService.genId(),
|
||||
createdAt: new Date(),
|
||||
userId: moderator.id,
|
||||
type: type,
|
||||
info: info ?? {},
|
||||
info: (info as any) ?? {},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -416,7 +416,7 @@ export class RoleService implements OnApplicationShutdown {
|
|||
roleId: roleId,
|
||||
roleName: role.name,
|
||||
userId: userId,
|
||||
expiresAt: expiresAt,
|
||||
expiresAt: expiresAt ? expiresAt.toISOString() : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,8 +441,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
set.manifestJsonOverride = ps.manifestJsonOverride;
|
||||
}
|
||||
|
||||
const before = await this.metaService.fetch(true);
|
||||
|
||||
await this.metaService.update(set);
|
||||
this.moderationLogService.log(me, 'updateMeta');
|
||||
|
||||
const after = await this.metaService.fetch(true);
|
||||
|
||||
this.moderationLogService.log(me, 'updateMeta', {
|
||||
before,
|
||||
after,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,3 +26,46 @@ export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as
|
|||
export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const;
|
||||
|
||||
export const ffVisibility = ['public', 'followers', 'private'] as const;
|
||||
|
||||
export const moderationLogTypes = ['updateMeta', 'suspend', 'unsuspend', 'userNoteUpdated', 'addEmoji', 'roleAssigned', 'roleUnassigned', 'roleUpdated', 'roleDeleted'] as const;
|
||||
|
||||
export type ModerationLogPayloads = {
|
||||
updateMeta: {
|
||||
before: any | null;
|
||||
after: any | null;
|
||||
};
|
||||
suspend: {
|
||||
targetId: string;
|
||||
};
|
||||
unsuspend: {
|
||||
targetId: string;
|
||||
};
|
||||
userNoteUpdated: {
|
||||
userId: string;
|
||||
before: string | null;
|
||||
after: string | null;
|
||||
};
|
||||
addEmoji: {
|
||||
emojiId: string;
|
||||
};
|
||||
roleAssigned: {
|
||||
userId: string;
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
expiresAt: string | null;
|
||||
};
|
||||
roleUnassigned: {
|
||||
userId: string;
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
};
|
||||
roleUpdated: {
|
||||
roleId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
};
|
||||
roleDeleted: {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2278,7 +2278,8 @@ declare namespace entities {
|
|||
Invite,
|
||||
InviteLimit,
|
||||
UserSorting,
|
||||
OriginType
|
||||
OriginType,
|
||||
ModerationLog
|
||||
}
|
||||
}
|
||||
export { entities }
|
||||
|
@ -2516,6 +2517,16 @@ type MessagingMessage = {
|
|||
groupId: UserGroup['id'] | null;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
type ModerationLog = {
|
||||
id: ID;
|
||||
createdAt: DateString;
|
||||
type: string;
|
||||
info: Record<string, any>;
|
||||
userId: User['id'];
|
||||
user: UserDetailed | null;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"];
|
||||
|
||||
|
|
Loading…
Reference in New Issue