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

hicommonwealth / commonwealth / 17414873744

02 Sep 2025 08:14PM UTC coverage: 37.615% (-0.03%) from 37.643%
17414873744

push

github

web-flow
Merge pull request #12928 from hicommonwealth/codex/update-user-tooltip-link-to-edit-profile

fix: link trust level tooltip to edit profile

1942 of 5557 branches covered (34.95%)

Branch coverage included in aggregate %.

3426 of 8714 relevant lines covered (39.32%)

44.72 hits per line

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

67.21
/libs/model/src/aggregates/community/UpdateTopic.command.ts
1
import { InvalidState, type Command } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { models } from '../../database';
4
import { authTopic } from '../../middleware';
5
import { mustExist } from '../../middleware/guards';
6
import { decodeContent, sanitizeQuillText } from '../../utils';
7

8
const Errors = {
28✔
9
  DefaultTemplateRequired: 'Default Template required',
10
};
11

12
export function UpdateTopic(): Command<typeof schemas.UpdateTopic> {
13
  return {
5✔
14
    ...schemas.UpdateTopic,
15
    auth: [authTopic({ roles: ['admin'] })],
16
    body: async ({ actor, payload }) => {
17
      const { topic_id } = payload;
4✔
18

19
      // TODO: can use topic in auth
20
      const topic = await models.Topic.findByPk(topic_id!);
4✔
21
      mustExist('Topic', topic);
4✔
22

23
      if (topic.archived_at) {
4!
24
        throw new InvalidState('Cannot update archived topic');
×
25
      }
26

27
      const {
28
        name,
29
        description,
30
        telegram,
31
        featured_in_sidebar,
32
        featured_in_new_post,
33
        allow_tokenized_threads,
34
      } = payload;
4✔
35

36
      const decodedDescription = decodeContent(description ?? '');
4✔
37

38
      let default_community_template =
39
        payload.default_offchain_template?.trim();
4✔
40
      if (featured_in_new_post && !default_community_template) {
4!
41
        throw new InvalidState(Errors.DefaultTemplateRequired);
×
42
      }
43
      // sanitize text
44
      default_community_template = sanitizeQuillText(
4✔
45
        default_community_template!,
46
      );
47

48
      if (typeof name !== 'undefined') {
4✔
49
        topic.name = name;
1✔
50
      }
51
      if (typeof decodedDescription !== 'undefined') {
4!
52
        topic.description = decodedDescription;
4✔
53
      }
54
      if (typeof telegram !== 'undefined') {
4!
55
        topic.telegram = telegram || '';
×
56
      }
57
      if (typeof featured_in_sidebar !== 'undefined') {
4!
58
        topic.featured_in_sidebar = featured_in_sidebar || false;
×
59
      }
60
      if (typeof featured_in_new_post !== 'undefined') {
4!
61
        topic.featured_in_new_post = featured_in_new_post || false;
×
62
      }
63
      if (typeof default_community_template !== 'undefined') {
4!
64
        topic.default_offchain_template = default_community_template || '';
4✔
65
      }
66
      if (typeof allow_tokenized_threads !== 'undefined') {
4✔
67
        topic.allow_tokenized_threads = allow_tokenized_threads || false;
1!
68
      }
69
      await topic.save();
4✔
70

71
      return {
4✔
72
        topic: topic.toJSON(),
73
        user_id: actor.user.id!,
74
      };
75
    },
76
  };
77
}
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