Refactor moderation actions to include channel and source metadata
- Updated moderation action functions to include `channelId` and `source` in the metadata for better tracking of actions. - Introduced an `auditFrom` function to streamline the addition of audit information across various commands. - Removed `prisma/migrations` from .gitignore to ensure migration files are tracked. - Enhanced the `CreateCaseInput` type to accommodate new metadata structure.
This commit is contained in:
24
packages/shared/src/audit.test.ts
Normal file
24
packages/shared/src/audit.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildCaseMetadata } from './audit.js';
|
||||
|
||||
describe('buildCaseMetadata', () => {
|
||||
it('builds standardized purge metadata', () => {
|
||||
const metadata = buildCaseMetadata({
|
||||
source: 'button_confirmation',
|
||||
channelId: '123',
|
||||
extras: {
|
||||
confirmed: true,
|
||||
purge: {
|
||||
requestedAmount: 10,
|
||||
deletedCount: 8,
|
||||
filters: { botsOnly: true }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(metadata.source).toBe('button_confirmation');
|
||||
expect(metadata.channelId).toBe('123');
|
||||
expect(metadata.purge?.deletedCount).toBe(8);
|
||||
expect(metadata.recordedAt).toBeTypeOf('string');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user