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

hicommonwealth / commonwealth / 14520966124

17 Apr 2025 05:05PM UTC coverage: 46.287% (+0.01%) from 46.275%
14520966124

Pull #11858

github

web-flow
Merge 4a0cfba55 into ae20f116a
Pull Request #11858: basic privy auth via hooks.

1622 of 3866 branches covered (41.96%)

Branch coverage included in aggregate %.

2978 of 6072 relevant lines covered (49.04%)

39.55 hits per line

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

7.69
/libs/model/src/aggregates/discordBot/createDiscordBotConfig.command.ts
1
import { type Command } from '@hicommonwealth/core';
2
import * as schemas from '@hicommonwealth/schemas';
3
import { models } from '../../database';
4
import { isSuperAdmin } from '../../middleware';
5

6
const TOKEN_EXPIRATION_MINUTES = 5;
32✔
7

8
export function CreateDiscordBotConfig(): Command<
9
  typeof schemas.CreateDiscordBotConfig
10
> {
11
  return {
×
12
    ...schemas.CreateDiscordBotConfig,
13
    auth: [isSuperAdmin],
14
    secure: true,
15
    body: async ({ payload }) => {
16
      const { community_id, verification_token } = payload;
×
17
      const token_expiration = new Date(
×
18
        +new Date() + TOKEN_EXPIRATION_MINUTES * 60 * 1000,
19
      );
20

21
      const existing = await models.DiscordBotConfig.findOne({
×
22
        where: {
23
          community_id,
24
        },
25
      });
26

27
      if (existing) {
×
28
        const existingConfig = await existing.update(
×
29
          {
30
            verification_token,
31
            token_expiration,
32
          },
33
          {
34
            where: {
35
              community_id,
36
            },
37
          },
38
        );
39

40
        await models.Community.update(
×
41
          { discord_config_id: existingConfig.id },
42
          { where: { id: community_id } },
43
        );
44

45
        return { message: 'Updated an existing discord bot config' };
×
46
      }
47

48
      await models.DiscordBotConfig.create({
×
49
        community_id,
50
        verification_token,
51
        token_expiration,
52
      });
53

54
      return { message: 'Created a new discord bot config' };
×
55
    },
56
  };
57
}
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