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

hicommonwealth / commonwealth / 14475476648

15 Apr 2025 05:18PM UTC coverage: 46.141% (-0.1%) from 46.287%
14475476648

Pull #11664

github

web-flow
Merge faa64a68e into 84ecac07e
Pull Request #11664: Added `XpChainEventCreated` support

1622 of 3876 branches covered (41.85%)

Branch coverage included in aggregate %.

0 of 25 new or added lines in 2 files covered. (0.0%)

58 existing lines in 14 files now uncovered.

2976 of 6089 relevant lines covered (48.88%)

39.44 hits per line

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

0.0
/libs/model/src/aggregates/comment/ToggleCommentSpam.command.ts
1
import { type Command } from '@hicommonwealth/core';
2
import { getCommentSearchVector, models } from '@hicommonwealth/model';
3
import * as schemas from '@hicommonwealth/schemas';
4
import { authComment } from '../../middleware';
5
import { mustBeAuthorizedComment } from '../../middleware/guards';
6

7
export function ToggleCommentSpam(): Command<typeof schemas.ToggleCommentSpam> {
8
  return {
×
9
    ...schemas.ToggleCommentSpam,
10
    auth: [
11
      authComment({ author: true, roles: ['admin', 'moderator', 'member'] }),
12
    ],
13
    body: async ({ actor, payload, context }) => {
14
      const { comment } = mustBeAuthorizedComment(actor, context);
×
15

16
      if (payload.spam && !comment.marked_as_spam_at) {
×
17
        comment.marked_as_spam_at = new Date();
×
18
        comment.search = null;
×
19
        await comment.save();
×
20
      } else if (!payload.spam && comment.marked_as_spam_at) {
×
21
        // Update search index when unmarking as spam
UNCOV
22
        let body = comment.body;
×
UNCOV
23
        if (comment.content_url) {
×
24
          const res = await fetch(comment.content_url);
×
UNCOV
25
          body = await res.text();
×
26
        }
UNCOV
27
        comment.search = getCommentSearchVector(body);
×
UNCOV
28
        comment.marked_as_spam_at = null;
×
UNCOV
29
        await comment.save();
×
30
      }
31

UNCOV
32
      comment.Address = await models.Address.findOne({
×
33
        where: {
34
          id: comment.address_id,
35
        },
36
        include: [
37
          {
38
            model: models.User,
39
            required: true,
40
          },
41
        ],
42
      });
43

UNCOV
44
      return comment;
×
45
    },
46
  };
47
}
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