forked from FoundKeyGang/FoundKey
server: add webhook stat to nodeinfo
This will show the number of active web hooks in the node info. This is desired to be able to gauge webhook usage in Foundkey. Changelog: Added
This commit is contained in:
parent
f181a8805d
commit
cc0915775b
1 changed files with 4 additions and 1 deletions
|
@ -2,7 +2,7 @@ import Router from '@koa/router';
|
|||
import { IsNull, MoreThan } from 'typeorm';
|
||||
import config from '@/config/index.js';
|
||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Users, Notes } from '@/models/index.js';
|
||||
import { Users, Notes, Webhooks } from '@/models/index.js';
|
||||
import { MONTH, DAY } from '@/const.js';
|
||||
|
||||
const router = new Router();
|
||||
|
@ -52,12 +52,14 @@ const nodeinfo2 = async (): Promise<NodeInfo2Base> => {
|
|||
activeHalfyear,
|
||||
activeMonth,
|
||||
localPosts,
|
||||
activeWebhooks,
|
||||
] = await Promise.all([
|
||||
fetchMeta(true),
|
||||
Users.count({ where: { host: IsNull() } }),
|
||||
Users.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - 180 * DAY)) } }),
|
||||
Users.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - MONTH)) } }),
|
||||
Notes.count({ where: { userHost: IsNull() } }),
|
||||
Webhooks.countBy({ active: true }),
|
||||
]);
|
||||
|
||||
const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null;
|
||||
|
@ -100,6 +102,7 @@ const nodeinfo2 = async (): Promise<NodeInfo2Base> => {
|
|||
enableEmail: meta.enableEmail,
|
||||
proxyAccountName: proxyAccount?.username ?? null,
|
||||
themeColor: meta.themeColor || '#86b300',
|
||||
activeWebhooks,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue