diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-07-02 15:12:11 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-02 15:12:11 +0900 |
| commit | eccc90c843f63b2dc08d8fbf80e4f54a601e477d (patch) | |
| tree | a26e23b56d711806862bdfaafeb9b826d25465a8 /packages/backend/src/queue/processors | |
| parent | refactor(client): refactoring (diff) | |
| download | sharkey-eccc90c843f63b2dc08d8fbf80e4f54a601e477d.tar.gz sharkey-eccc90c843f63b2dc08d8fbf80e4f54a601e477d.tar.bz2 sharkey-eccc90c843f63b2dc08d8fbf80e4f54a601e477d.zip | |
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
Diffstat (limited to 'packages/backend/src/queue/processors')
| -rw-r--r-- | packages/backend/src/queue/processors/system/clean.ts | 18 | ||||
| -rw-r--r-- | packages/backend/src/queue/processors/system/index.ts | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/packages/backend/src/queue/processors/system/clean.ts b/packages/backend/src/queue/processors/system/clean.ts new file mode 100644 index 0000000000..c4f978d7c9 --- /dev/null +++ b/packages/backend/src/queue/processors/system/clean.ts @@ -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(); +} diff --git a/packages/backend/src/queue/processors/system/index.ts b/packages/backend/src/queue/processors/system/index.ts index f90f6efafd..9527d40b0f 100644 --- a/packages/backend/src/queue/processors/system/index.ts +++ b/packages/backend/src/queue/processors/system/index.ts @@ -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>>) { |