mirror of
https://github.com/sim1222/misskey.git
synced 2025-07-07 19:30:07 +09:00
feat: Log user ips (#8872)
* wip * store ip and headers * Update admin-file.vue * require admin for view ip/headers * IP (recent) 消した * admin必須 * opt in * clean ips periodically * respect logging setting in drive/files/create
This commit is contained in:
@ -2,6 +2,9 @@ import httpSignature from '@peertube/http-signature';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import config from '@/config/index.js';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { IActivity } from '@/remote/activitypub/type.js';
|
||||
import { Webhook, webhookEventTypes } from '@/models/entities/webhook.js';
|
||||
import { envOption } from '../env.js';
|
||||
|
||||
import processDeliver from './processors/deliver.js';
|
||||
@ -12,18 +15,15 @@ import processSystemQueue from './processors/system/index.js';
|
||||
import processWebhookDeliver from './processors/webhook-deliver.js';
|
||||
import { endedPollNotification } from './processors/ended-poll-notification.js';
|
||||
import { queueLogger } from './logger.js';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { getJobInfo } from './get-job-info.js';
|
||||
import { systemQueue, dbQueue, deliverQueue, inboxQueue, objectStorageQueue, endedPollNotificationQueue, webhookDeliverQueue } from './queues.js';
|
||||
import { ThinUser } from './types.js';
|
||||
import { IActivity } from '@/remote/activitypub/type.js';
|
||||
import { Webhook, webhookEventTypes } from '@/models/entities/webhook.js';
|
||||
|
||||
function renderError(e: Error): any {
|
||||
return {
|
||||
stack: e?.stack,
|
||||
message: e?.message,
|
||||
name: e?.name,
|
||||
stack: e.stack,
|
||||
message: e.message,
|
||||
name: e.name,
|
||||
};
|
||||
}
|
||||
|
||||
@ -314,6 +314,12 @@ export default function() {
|
||||
removeOnComplete: true,
|
||||
});
|
||||
|
||||
systemQueue.add('clean', {
|
||||
}, {
|
||||
repeat: { cron: '0 0 * * *' },
|
||||
removeOnComplete: true,
|
||||
});
|
||||
|
||||
systemQueue.add('checkExpiredMutings', {
|
||||
}, {
|
||||
repeat: { cron: '*/5 * * * *' },
|
||||
|
18
packages/backend/src/queue/processors/system/clean.ts
Normal file
18
packages/backend/src/queue/processors/system/clean.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import Bull from 'bull';
|
||||
import { LessThan } from 'typeorm';
|
||||
import { UserIps } from '@/models/index.js';
|
||||
|
||||
import { queueLogger } from '../../logger.js';
|
||||
|
||||
const logger = queueLogger.createSubLogger('clean');
|
||||
|
||||
export async function clean(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
|
||||
logger.info('Cleaning...');
|
||||
|
||||
UserIps.delete({
|
||||
createdAt: LessThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 90))),
|
||||
});
|
||||
|
||||
logger.succ('Cleaned.');
|
||||
done();
|
||||
}
|
@ -3,12 +3,14 @@ import { tickCharts } from './tick-charts.js';
|
||||
import { resyncCharts } from './resync-charts.js';
|
||||
import { cleanCharts } from './clean-charts.js';
|
||||
import { checkExpiredMutings } from './check-expired-mutings.js';
|
||||
import { clean } from './clean.js';
|
||||
|
||||
const jobs = {
|
||||
tickCharts,
|
||||
resyncCharts,
|
||||
cleanCharts,
|
||||
checkExpiredMutings,
|
||||
clean,
|
||||
} as Record<string, Bull.ProcessCallbackFunction<Record<string, unknown>> | Bull.ProcessPromiseFunction<Record<string, unknown>>>;
|
||||
|
||||
export default function(dbQueue: Bull.Queue<Record<string, unknown>>) {
|
||||
|
Reference in New Issue
Block a user