2026-02-26 14:41:00 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const activitypub = require('../../activitypub');
|
2026-04-01 13:39:47 -04:00
|
|
|
const analytics = require('../../analytics');
|
2026-02-26 14:41:00 -05:00
|
|
|
|
|
|
|
|
const federationController = module.exports;
|
|
|
|
|
|
|
|
|
|
federationController.general = function (req, res) {
|
|
|
|
|
res.render(`admin/federation/general`, {
|
|
|
|
|
title: '[[admin/menu:federation/general]]',
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-26 15:43:02 -05:00
|
|
|
federationController.content = function (req, res) {
|
|
|
|
|
res.render(`admin/federation/content`, {
|
|
|
|
|
title: '[[admin/menu:federation/content]]',
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-26 14:41:00 -05:00
|
|
|
federationController.rules = async function (req, res) {
|
|
|
|
|
const rules = await activitypub.rules.list();
|
|
|
|
|
|
|
|
|
|
res.render(`admin/federation/rules`, {
|
|
|
|
|
title: '[[admin/menu:federation/rules]]',
|
|
|
|
|
rules,
|
|
|
|
|
hideSave: true,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
federationController.relays = async function (req, res) {
|
|
|
|
|
const relays = await activitypub.relays.list();
|
|
|
|
|
|
|
|
|
|
res.render(`admin/federation/relays`, {
|
|
|
|
|
title: '[[admin/menu:federation/relays]]',
|
|
|
|
|
relays,
|
|
|
|
|
hideSave: true,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
federationController.pruning = function (req, res) {
|
|
|
|
|
res.render(`admin/federation/pruning`, {
|
|
|
|
|
title: '[[admin/menu:federation/pruning]]',
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-26 15:49:41 -05:00
|
|
|
federationController.safety = async function (req, res) {
|
|
|
|
|
const instanceCount = await activitypub.instances.getCount();
|
2026-03-25 11:31:50 -04:00
|
|
|
const blocklists = await activitypub.blocklists.list();
|
2026-02-26 15:49:41 -05:00
|
|
|
|
2026-02-26 14:41:00 -05:00
|
|
|
res.render(`admin/federation/safety`, {
|
|
|
|
|
title: '[[admin/menu:federation/safety]]',
|
2026-03-25 11:31:50 -04:00
|
|
|
blocklists,
|
2026-02-26 15:49:41 -05:00
|
|
|
instanceCount,
|
2026-02-26 14:41:00 -05:00
|
|
|
});
|
|
|
|
|
};
|
2026-04-01 13:39:47 -04:00
|
|
|
|
|
|
|
|
federationController.analytics = async function (req, res) {
|
|
|
|
|
const instances = await activitypub.instances.list();
|
2026-04-01 14:32:50 -04:00
|
|
|
let { host, term } = req.query;
|
2026-04-01 13:39:47 -04:00
|
|
|
if (!instances.includes(host)) {
|
|
|
|
|
host = undefined;
|
|
|
|
|
}
|
2026-04-01 14:32:50 -04:00
|
|
|
let method = 'getHourlyStatsForSet';
|
|
|
|
|
let count = 24;
|
|
|
|
|
if (term === 'daily') {
|
|
|
|
|
method = 'getDailyStatsForSet';
|
|
|
|
|
count = 30;
|
|
|
|
|
}
|
2026-04-01 13:39:47 -04:00
|
|
|
const set = host ? `activities:byHost:${host}` : 'activities';
|
2026-04-01 14:00:04 -04:00
|
|
|
const sentSet = host ? `ap.out:byHost:${host}` : 'ap:out';
|
2026-04-01 14:32:50 -04:00
|
|
|
const received = await analytics[method](set, Date.now(), count);
|
|
|
|
|
const sent = await analytics[method](sentSet, Date.now(), count);
|
2026-04-01 13:39:47 -04:00
|
|
|
|
|
|
|
|
res.render('admin/federation/analytics', {
|
|
|
|
|
title: '[[admin/menu:federation/analytics]]',
|
|
|
|
|
instances,
|
2026-04-01 14:02:56 -04:00
|
|
|
received,
|
2026-04-01 14:00:04 -04:00
|
|
|
sent,
|
2026-04-01 13:39:47 -04:00
|
|
|
});
|
|
|
|
|
};
|