mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-01 10:23:03 +00:00
improve moderation log
This commit is contained in:
parent
fdf149cf52
commit
19bc9c20a6
7 changed files with 75 additions and 3 deletions
|
@ -2175,3 +2175,6 @@ _moderationLogTypes:
|
||||||
deleteNote: "ノートを削除"
|
deleteNote: "ノートを削除"
|
||||||
createGlobalAnnouncement: "全体のお知らせを作成"
|
createGlobalAnnouncement: "全体のお知らせを作成"
|
||||||
createUserAnnouncement: "ユーザーへお知らせを作成"
|
createUserAnnouncement: "ユーザーへお知らせを作成"
|
||||||
|
resetPassword: "パスワードをリセット"
|
||||||
|
suspendRemoteInstance: "リモートサーバーを停止"
|
||||||
|
unsuspendRemoteInstance: "リモートサーバーを再開"
|
||||||
|
|
|
@ -9,6 +9,7 @@ import type { InstancesRepository } from '@/models/_.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -34,6 +35,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private federatedInstanceService: FederatedInstanceService,
|
private federatedInstanceService: FederatedInstanceService,
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const instance = await this.instancesRepository.findOneBy({ host: this.utilityService.toPuny(ps.host) });
|
const instance = await this.instancesRepository.findOneBy({ host: this.utilityService.toPuny(ps.host) });
|
||||||
|
@ -42,9 +44,23 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new Error('instance not found');
|
throw new Error('instance not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.federatedInstanceService.update(instance.id, {
|
await this.federatedInstanceService.update(instance.id, {
|
||||||
isSuspended: ps.isSuspended,
|
isSuspended: ps.isSuspended,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (instance.isSuspended !== ps.isSuspended) {
|
||||||
|
if (ps.isSuspended) {
|
||||||
|
this.moderationLogService.log(me, 'suspendRemoteInstance', {
|
||||||
|
id: instance.id,
|
||||||
|
host: instance.host,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.moderationLogService.log(me, 'unsuspendRemoteInstance', {
|
||||||
|
id: instance.id,
|
||||||
|
host: instance.host,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { UsersRepository, UserProfilesRepository } from '@/models/_.js';
|
import type { UsersRepository, UserProfilesRepository } from '@/models/_.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -46,8 +47,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
@Inject(DI.userProfilesRepository)
|
@Inject(DI.userProfilesRepository)
|
||||||
private userProfilesRepository: UserProfilesRepository,
|
private userProfilesRepository: UserProfilesRepository,
|
||||||
|
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -69,6 +72,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
password: hash,
|
password: hash,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.moderationLogService.log(me, 'resetPassword', {
|
||||||
|
targetId: user.id,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
password: passwd,
|
password: passwd,
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,9 @@ export const moderationLogTypes = [
|
||||||
'deleteNote',
|
'deleteNote',
|
||||||
'createGlobalAnnouncement',
|
'createGlobalAnnouncement',
|
||||||
'createUserAnnouncement',
|
'createUserAnnouncement',
|
||||||
|
'resetPassword',
|
||||||
|
'suspendRemoteInstance',
|
||||||
|
'unsuspendRemoteInstance',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type ModerationLogPayloads = {
|
export type ModerationLogPayloads = {
|
||||||
|
@ -104,4 +107,15 @@ export type ModerationLogPayloads = {
|
||||||
announcement: any;
|
announcement: any;
|
||||||
userId: string;
|
userId: string;
|
||||||
};
|
};
|
||||||
|
resetPassword: {
|
||||||
|
targetId: string;
|
||||||
|
};
|
||||||
|
suspendRemoteInstance: {
|
||||||
|
id: string;
|
||||||
|
host: string;
|
||||||
|
};
|
||||||
|
unsuspendRemoteInstance: {
|
||||||
|
id: string;
|
||||||
|
host: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2556,10 +2556,19 @@ type ModerationLog = {
|
||||||
} | {
|
} | {
|
||||||
type: 'promoteQueue';
|
type: 'promoteQueue';
|
||||||
info: ModerationLogPayloads['promoteQueue'];
|
info: ModerationLogPayloads['promoteQueue'];
|
||||||
|
} | {
|
||||||
|
type: 'resetPassword';
|
||||||
|
info: ModerationLogPayloads['resetPassword'];
|
||||||
|
} | {
|
||||||
|
type: 'suspendRemoteInstance';
|
||||||
|
info: ModerationLogPayloads['suspendRemoteInstance'];
|
||||||
|
} | {
|
||||||
|
type: 'unsuspendRemoteInstance';
|
||||||
|
info: ModerationLogPayloads['unsuspendRemoteInstance'];
|
||||||
});
|
});
|
||||||
|
|
||||||
// @public (undocumented)
|
// @public (undocumented)
|
||||||
export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "assignRole", "unassignRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement"];
|
export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "assignRole", "unassignRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance"];
|
||||||
|
|
||||||
// @public (undocumented)
|
// @public (undocumented)
|
||||||
export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"];
|
export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"];
|
||||||
|
|
|
@ -61,6 +61,9 @@ export const moderationLogTypes = [
|
||||||
'deleteNote',
|
'deleteNote',
|
||||||
'createGlobalAnnouncement',
|
'createGlobalAnnouncement',
|
||||||
'createUserAnnouncement',
|
'createUserAnnouncement',
|
||||||
|
'resetPassword',
|
||||||
|
'suspendRemoteInstance',
|
||||||
|
'unsuspendRemoteInstance',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type ModerationLogPayloads = {
|
export type ModerationLogPayloads = {
|
||||||
|
@ -122,4 +125,15 @@ export type ModerationLogPayloads = {
|
||||||
announcement: any;
|
announcement: any;
|
||||||
userId: string;
|
userId: string;
|
||||||
};
|
};
|
||||||
|
resetPassword: {
|
||||||
|
targetId: string;
|
||||||
|
};
|
||||||
|
suspendRemoteInstance: {
|
||||||
|
id: string;
|
||||||
|
host: string;
|
||||||
|
};
|
||||||
|
unsuspendRemoteInstance: {
|
||||||
|
id: string;
|
||||||
|
host: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -607,4 +607,13 @@ export type ModerationLog = {
|
||||||
} | {
|
} | {
|
||||||
type: 'promoteQueue';
|
type: 'promoteQueue';
|
||||||
info: ModerationLogPayloads['promoteQueue'];
|
info: ModerationLogPayloads['promoteQueue'];
|
||||||
|
} | {
|
||||||
|
type: 'resetPassword';
|
||||||
|
info: ModerationLogPayloads['resetPassword'];
|
||||||
|
} | {
|
||||||
|
type: 'suspendRemoteInstance';
|
||||||
|
info: ModerationLogPayloads['suspendRemoteInstance'];
|
||||||
|
} | {
|
||||||
|
type: 'unsuspendRemoteInstance';
|
||||||
|
info: ModerationLogPayloads['unsuspendRemoteInstance'];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue