@@ -0,0 +1,18 @@
|
||||
import define from '../../../define';
|
||||
import { destroy } from '@/queue/index';
|
||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps, me) => {
|
||||
destroy();
|
||||
|
||||
insertModerationLog(me, 'clearQueue');
|
||||
});
|
@@ -0,0 +1,55 @@
|
||||
import { deliverQueue } from '@/queue/queues';
|
||||
import { URL } from 'url';
|
||||
import define from '../../../define';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
items: {
|
||||
type: 'array' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
items: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string' as const,
|
||||
},
|
||||
{
|
||||
type: 'number' as const,
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
example: [[
|
||||
'example.com',
|
||||
12
|
||||
]]
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps) => {
|
||||
const jobs = await deliverQueue.getJobs(['delayed']);
|
||||
|
||||
const res = [] as [string, number][];
|
||||
|
||||
for (const job of jobs) {
|
||||
const host = new URL(job.data.to).host;
|
||||
if (res.find(x => x[0] === host)) {
|
||||
res.find(x => x[0] === host)![1]++;
|
||||
} else {
|
||||
res.push([host, 1]);
|
||||
}
|
||||
}
|
||||
|
||||
res.sort((a, b) => b[1] - a[1]);
|
||||
|
||||
return res;
|
||||
});
|
@@ -0,0 +1,55 @@
|
||||
import { URL } from 'url';
|
||||
import define from '../../../define';
|
||||
import { inboxQueue } from '@/queue/queues';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
items: {
|
||||
type: 'array' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
items: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string' as const,
|
||||
},
|
||||
{
|
||||
type: 'number' as const,
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
example: [[
|
||||
'example.com',
|
||||
12
|
||||
]]
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps) => {
|
||||
const jobs = await inboxQueue.getJobs(['delayed']);
|
||||
|
||||
const res = [] as [string, number][];
|
||||
|
||||
for (const job of jobs) {
|
||||
const host = new URL(job.data.signature.keyId).host;
|
||||
if (res.find(x => x[0] === host)) {
|
||||
res.find(x => x[0] === host)![1]++;
|
||||
} else {
|
||||
res.push([host, 1]);
|
||||
}
|
||||
}
|
||||
|
||||
res.sort((a, b) => b[1] - a[1]);
|
||||
|
||||
return res;
|
||||
});
|
@@ -0,0 +1,81 @@
|
||||
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '@/queue/queues';
|
||||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {
|
||||
domain: {
|
||||
validator: $.str.or(['deliver', 'inbox', 'db', 'objectStorage']),
|
||||
},
|
||||
|
||||
state: {
|
||||
validator: $.str.or(['active', 'waiting', 'delayed']),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num,
|
||||
default: 50
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
items: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
format: 'id'
|
||||
},
|
||||
data: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const
|
||||
},
|
||||
attempts: {
|
||||
type: 'number' as const,
|
||||
optional: false as const, nullable: false as const
|
||||
},
|
||||
maxAttempts: {
|
||||
type: 'number' as const,
|
||||
optional: false as const, nullable: false as const
|
||||
},
|
||||
timestamp: {
|
||||
type: 'number' as const,
|
||||
optional: false as const, nullable: false as const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps) => {
|
||||
const queue =
|
||||
ps.domain === 'deliver' ? deliverQueue :
|
||||
ps.domain === 'inbox' ? inboxQueue :
|
||||
ps.domain === 'db' ? dbQueue :
|
||||
ps.domain === 'objectStorage' ? objectStorageQueue :
|
||||
null as never;
|
||||
|
||||
const jobs = await queue.getJobs([ps.state], 0, ps.limit!);
|
||||
|
||||
return jobs.map(job => {
|
||||
const data = job.data;
|
||||
delete data.content;
|
||||
delete data.user;
|
||||
return {
|
||||
id: job.id,
|
||||
data,
|
||||
attempts: job.attemptsMade,
|
||||
maxAttempts: job.opts ? job.opts.attempts : 0,
|
||||
timestamp: job.timestamp,
|
||||
};
|
||||
});
|
||||
});
|
@@ -0,0 +1,44 @@
|
||||
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '@/queue/queues';
|
||||
import define from '../../../define';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true as const,
|
||||
requireModerator: true,
|
||||
|
||||
params: {},
|
||||
|
||||
res: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
properties: {
|
||||
deliver: {
|
||||
ref: 'QueueCount'
|
||||
},
|
||||
inbox: {
|
||||
ref: 'QueueCount'
|
||||
},
|
||||
db: {
|
||||
ref: 'QueueCount'
|
||||
},
|
||||
objectStorage: {
|
||||
ref: 'QueueCount'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default define(meta, async (ps) => {
|
||||
const deliverJobCounts = await deliverQueue.getJobCounts();
|
||||
const inboxJobCounts = await inboxQueue.getJobCounts();
|
||||
const dbJobCounts = await dbQueue.getJobCounts();
|
||||
const objectStorageJobCounts = await objectStorageQueue.getJobCounts();
|
||||
|
||||
return {
|
||||
deliver: deliverJobCounts,
|
||||
inbox: inboxJobCounts,
|
||||
db: dbJobCounts,
|
||||
objectStorage: objectStorageJobCounts,
|
||||
};
|
||||
});
|
Reference in New Issue
Block a user