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

NodeBB / NodeBB / 23305017021

19 Mar 2026 04:20PM UTC coverage: 85.425% (-0.1%) from 85.545%
23305017021

push

github

nodebb-misty
chore: update changelog for v4.10.0

13445 of 18442 branches covered (72.9%)

28384 of 33227 relevant lines covered (85.42%)

3333.35 hits per line

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

93.33
/src/controllers/posts.js
1
'use strict';
2

3
const nconf = require('nconf');
4✔
4
const querystring = require('querystring');
4✔
5

6
const meta = require('../meta');
4✔
7
const posts = require('../posts');
4✔
8
const privileges = require('../privileges');
4✔
9
// const activitypub = require('../activitypub');
10
const utils = require('../utils');
4✔
11

12
const helpers = require('./helpers');
4✔
13

14
const postsController = module.exports;
4✔
15

16
postsController.redirectToPost = async function (req, res, next) {
4✔
17
        const pid = utils.isNumber(req.params.pid) ? parseInt(req.params.pid, 10) : req.params.pid;
24✔
18
        if (!pid) {
24!
19
                return next();
×
20
        }
21

22
        // Kickstart note assertion if applicable -- might not be needed, if no ill effects, remove 1 Apr 2026
23
        // if (!utils.isNumber(pid) && req.uid && meta.config.activitypubEnabled) {
24
        // const exists = await posts.exists(pid);
25
        // if (!exists) {
26
        // await activitypub.notes.assert(req.uid, pid);
27
        // }
28
        // }
29

30
        if (!req.loggedIn && meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(pid)) {
24!
31
                return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(pid)}`);
×
32
        }
33

34
        const [canRead, path] = await Promise.all([
24✔
35
                privileges.posts.can('topics:read', pid, req.uid),
36
                posts.generatePostPath(pid, req.uid),
37
        ]);
38
        if (!path) {
24✔
39
                return next();
4✔
40
        }
41
        if (!canRead) {
20✔
42
                return helpers.notAllowed(req, res);
4✔
43
        }
44

45
        if (meta.config.activitypubEnabled) {
16!
46
                // Include link header for richer parsing
47
                res.set('Link', `<${nconf.get('url')}/post/${req.params.pid}>; rel="alternate"; type="application/activity+json"`);
16✔
48
        }
49

50
        const qs = querystring.stringify(req.query);
16✔
51
        helpers.redirect(res, qs ? `${path}?${qs}` : path, true);
16!
52
};
53

54
postsController.getRecentPosts = async function (req, res) {
4✔
55
        const page = parseInt(req.query.page, 10) || 1;
8✔
56
        const postsPerPage = 20;
8✔
57
        const start = Math.max(0, (page - 1) * postsPerPage);
8✔
58
        const stop = start + postsPerPage - 1;
8✔
59
        const data = await posts.getRecentPosts(req.uid, start, stop, req.params.term);
8✔
60
        res.json(data);
8✔
61
};
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