• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NodeBB / NodeBB / 23549495617

25 Mar 2026 03:34PM UTC coverage: 85.438% (+0.01%) from 85.428%
23549495617

push

github

nodebb-misty
chore(i18n): fallback strings for new resources: nodebb.admin-settings-activitypub

13449 of 18458 branches covered (72.86%)

28450 of 33299 relevant lines covered (85.44%)

3336.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.29
/src/controllers/write/admin.js
1
'use strict';
2

3
const categories = require('../../categories');
4✔
4
const api = require('../../api');
4✔
5
const helpers = require('../helpers');
4✔
6
const messaging = require('../../messaging');
4✔
7
const events = require('../../events');
4✔
8
const activitypub = require('../../activitypub');
4✔
9

10
const Admin = module.exports;
4✔
11

12
Admin.updateSetting = async (req, res) => {
4✔
13
        await api.admin.updateSetting(req, {
4✔
14
                setting: req.params.setting,
15
                value: req.body.value,
16
        });
17

18
        helpers.formatApiResponse(200, res);
4✔
19
};
20

21
Admin.getAnalyticsKeys = async (req, res) => {
4✔
22
        helpers.formatApiResponse(200, res, {
4✔
23
                keys: await api.admin.getAnalyticsKeys(),
24
        });
25
};
26

27
Admin.getAnalyticsData = async (req, res) => {
4✔
28
        helpers.formatApiResponse(200, res, await api.admin.getAnalyticsData(req, {
4✔
29
                set: req.params.set,
30
                until: parseInt(req.query.until, 10) || Date.now(),
8✔
31
                amount: req.query.amount,
32
                units: req.query.units,
33
        }));
34
};
35

36
Admin.generateToken = async (req, res) => {
4✔
37
        const { uid, description } = req.body;
4✔
38
        const token = await api.utils.tokens.generate({ uid, description });
4✔
39
        helpers.formatApiResponse(200, res, await api.utils.tokens.get(token));
4✔
40
};
41

42
Admin.getToken = async (req, res) => {
4✔
43
        helpers.formatApiResponse(200, res, await api.utils.tokens.get(req.params.token));
4✔
44
};
45

46
Admin.updateToken = async (req, res) => {
4✔
47
        const { uid, description } = req.body;
4✔
48
        const { token } = req.params;
4✔
49

50
        helpers.formatApiResponse(200, res, await api.utils.tokens.update(token, { uid, description }));
4✔
51
};
52

53
Admin.rollToken = async (req, res) => {
4✔
54
        let { token } = req.params;
4✔
55

56
        token = await api.utils.tokens.roll(token);
4✔
57
        helpers.formatApiResponse(200, res, await api.utils.tokens.get(token));
4✔
58
};
59

60
Admin.deleteToken = async (req, res) => {
4✔
61
        const { token } = req.params;
4✔
62
        helpers.formatApiResponse(200, res, await api.utils.tokens.delete(token));
4✔
63
};
64

65
Admin.chats = {};
4✔
66

67
Admin.chats.deleteRoom = async (req, res) => {
4✔
68
        const roomData = await messaging.getRoomData(req.params.roomId);
4✔
69
        if (!roomData) {
4!
70
                throw new Error('[[error:no-room]]');
×
71
        }
72
        await messaging.deleteRooms([req.params.roomId]);
4✔
73

74
        events.log({
4✔
75
                type: 'chat-room-deleted',
76
                roomId: req.params.roomId,
77
                roomName: roomData.roomName ? roomData.roomName : `No room name`,
4!
78
                uid: req.uid,
79
                ip: req.ip,
80
        });
81
        helpers.formatApiResponse(200, res);
4✔
82
};
83

84
Admin.listGroups = async (req, res) => {
4✔
85
        helpers.formatApiResponse(200, res, await api.admin.listGroups());
4✔
86
};
87

88
Admin.activitypub = {};
4✔
89

90
Admin.activitypub.addRule = async (req, res) => {
4✔
91
        const { type, value, cid } = req.body;
4✔
92
        const exists = await categories.exists(cid);
4✔
93
        if (!value || !exists) {
4!
94
                return helpers.formatApiResponse(400, res);
×
95
        }
96

97
        await activitypub.rules.add(type, value, cid);
4✔
98
        helpers.formatApiResponse(200, res, await activitypub.rules.list());
4✔
99
};
100

101
Admin.activitypub.deleteRule = async (req, res) => {
4✔
102
        const { rid } = req.params;
4✔
103
        await activitypub.rules.delete(rid);
4✔
104
        helpers.formatApiResponse(200, res, await activitypub.rules.list());
4✔
105
};
106

107
Admin.activitypub.reorderRules = async (req, res) => {
4✔
108
        const { rids } = req.body;
4✔
109
        await activitypub.rules.reorder(rids);
4✔
110
        helpers.formatApiResponse(200, res, await activitypub.rules.list());
4✔
111
};
112

113
Admin.activitypub.addRelay = async (req, res, next) => {
4✔
114
        const { url } = req.body;
4✔
115
        if (!url) {
4!
116
                return next();
×
117
        }
118

119
        await activitypub.relays.add(url);
4✔
120
        helpers.formatApiResponse(200, res, await activitypub.relays.list());
4✔
121
};
122

123
Admin.activitypub.removeRelay = async (req, res) => {
4✔
124
        const { url } = req.params;
4✔
125

126
        await activitypub.relays.remove(url);
4✔
127
        helpers.formatApiResponse(200, res, await activitypub.relays.list());
4✔
128
};
129

130

131
Admin.activitypub.addBlocklist = async (req, res, next) => {
4✔
132
        const { url } = req.body;
4✔
133
        if (!url) {
4!
134
                return next();
×
135
        }
136

137
        await activitypub.blocklists.add(url);
4✔
138
        helpers.formatApiResponse(200, res, await activitypub.blocklists.list());
4✔
139
};
140

141
Admin.activitypub.viewBlocklist = async (req, res) => {
4✔
142
        const { url } = req.params;
4✔
143

144
        helpers.formatApiResponse(200, res, await activitypub.blocklists.get(url));
4✔
145
};
146

147
Admin.activitypub.removeBlocklist = async (req, res) => {
4✔
148
        const { url } = req.params;
4✔
149

150
        await activitypub.blocklists.remove(url);
4✔
151
        helpers.formatApiResponse(200, res, await activitypub.blocklists.list());
4✔
152
};
153

154
Admin.activitypub.refreshBlocklist = async (req, res) => {
4✔
155
        const { url } = req.params;
4✔
156

157
        const count = await activitypub.blocklists.refresh(url);
4✔
158
        const blocklists = await activitypub.blocklists.list();
4✔
159

160
        helpers.formatApiResponse(200, res, { blocklists, count });
4✔
161
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc