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

CMU-17313Q / fall23-nodebb-inshallah-a / 6239420468

19 Sep 2023 06:18PM UTC coverage: 77.199% (+0.01%) from 77.188%
6239420468

push

github

web-flow
Merge pull request #59 from CMU-17313Q/Adding-isAnonymous-if-conditions

Adding is anonymous if conditions

9091 of 13356 branches covered (0.0%)

Branch coverage included in aggregate %.

20876 of 25462 relevant lines covered (81.99%)

2463.76 hits per line

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

14.0
/src/socket.io/topics/infinitescroll.js
1
'use strict';
2

3
const topics = require('../../topics');
4✔
4
const privileges = require('../../privileges');
4✔
5
const meta = require('../../meta');
4✔
6
const utils = require('../../utils');
4✔
7
const social = require('../../social');
4✔
8

9
module.exports = function (SocketTopics) {
4✔
10
    SocketTopics.loadMore = async function (socket, data) {
4✔
11
        if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
×
12
            throw new Error('[[error:invalid-data]]');
×
13
        }
14

15
        const [userPrivileges, topicData] = await Promise.all([
×
16
            privileges.topics.get(data.tid, socket.uid),
17
            topics.getTopicData(data.tid),
18
        ]);
19

20
        if (!userPrivileges['topics:read'] || !privileges.topics.canViewDeletedScheduled(topicData, userPrivileges)) {
×
21
            throw new Error('[[error:no-privileges]]');
×
22
        }
23

24
        const set = data.topicPostSort === 'most_votes' ? `tid:${data.tid}:posts:votes` : `tid:${data.tid}:posts`;
×
25
        const reverse = data.topicPostSort === 'newest_to_oldest' || data.topicPostSort === 'most_votes';
×
26
        let start = Math.max(0, parseInt(data.after, 10));
×
27

28
        const infScrollPostsPerPage = Math.max(0, Math.min(
×
29
            meta.config.postsPerPage || 20,
×
30
            parseInt(data.count, 10) || meta.config.postsPerPage || 20
×
31
        ));
32

33
        if (data.direction === -1) {
×
34
            start -= infScrollPostsPerPage;
×
35
        }
36

37
        let stop = start + infScrollPostsPerPage - 1;
×
38

39
        start = Math.max(0, start);
×
40
        stop = Math.max(0, stop);
×
41
        const [posts, postSharing] = await Promise.all([
×
42
            topics.getTopicPosts(topicData, set, start, stop, socket.uid, reverse),
43
            social.getActivePostSharing(),
44
        ]);
45

46
        topicData.posts = posts;
×
47
        topicData.privileges = userPrivileges;
×
48
        topicData.postSharing = postSharing;
×
49
        topicData['reputation:disabled'] = meta.config['reputation:disabled'] === 1;
×
50
        topicData['downvote:disabled'] = meta.config['downvote:disabled'] === 1;
×
51

52
        topics.modifyPostsByPrivilege(topicData, userPrivileges);
×
53
        return topicData;
×
54
    };
55
};
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

© 2025 Coveralls, Inc