feat: fedi stats api

This commit is contained in:
lesion 2024-02-28 22:37:41 +01:00
parent 71e13bd61f
commit 6ce01287e4
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -1,4 +1,4 @@
const { APUser, Instance, Resource } = require('../models/models')
const { APUser, Instance, Resource, Event } = require('../models/models')
const { getActor, unfollowActor, followActor, getNodeInfo, getInstance } = require('../../federation/helpers')
const axios = require('axios')
const get = require('lodash/get')
@ -69,6 +69,13 @@ const instancesController = {
return res.json(instance)
},
// get following
async stats (req, res) {
const n_followers = await APUser.count({ where: { follower: true }, include: [Instance]})
const n_events = await Event.count({ where: { ap_id: { [Sequelize.Op.not]: null } } })
const n_resources = await Resource.count()
return res.json({ n_followers, n_events, n_resources })
},
async removeTrust (req, res) {
let ap_id = req.query.ap_id