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

hicommonwealth / commonwealth / 13708091035

06 Mar 2025 09:02PM UTC coverage: 45.452%. First build
13708091035

Pull #11321

github

web-flow
Merge 4ba1f7ed9 into 44d469090
Pull Request #11321: Skip cast deleted event

1313 of 3203 branches covered (40.99%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 1 file covered. (0.0%)

2510 of 5208 relevant lines covered (48.2%)

38.51 hits per line

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

2.86
/libs/model/src/contest/UpdateContestManagerFrameHashes.command.ts
1
import { Command } from '@hicommonwealth/core';
2
import { config, models } from '@hicommonwealth/model';
3
import * as schemas from '@hicommonwealth/schemas';
4
import { NeynarAPIClient } from '@neynar/nodejs-sdk';
5
import { Mutex } from 'async-mutex';
6
import _ from 'lodash';
7
import { Op } from 'sequelize';
8
import { mustExist } from '../middleware/guards';
9

10
const neynarMutex = new Mutex();
30✔
11

12
export function UpdateContestManagerFrameHashes(): Command<
13
  typeof schemas.UpdateContestManagerFrameHashes
14
> {
15
  return {
×
16
    ...schemas.UpdateContestManagerFrameHashes,
17
    auth: [],
18
    body: async ({ payload }) => {
19
      // skip deletes for now
20
      if (payload.frames_to_remove?.length) {
×
21
        return;
×
22
      }
23
      await neynarMutex.runExclusive(async () => {
×
24
        const contestManager = await models.ContestManager.findOne({
×
25
          where: {
26
            contest_address: payload.contest_address,
27
            cancelled: {
28
              [Op.not]: true,
29
            },
30
            ended: {
31
              [Op.not]: true,
32
            },
33
          },
34
        });
35
        mustExist('Contest Manager', contestManager);
×
36

37
        // find webhook by ID
38
        const client = new NeynarAPIClient(config.CONTESTS.NEYNAR_API_KEY!);
×
39
        const { webhook: existingCastWebhook } = await client.lookupWebhook(
×
40
          config.CONTESTS.NEYNAR_CAST_WEBHOOK_ID!,
41
        );
42
        mustExist('Neynar Webhook', existingCastWebhook);
×
43

44
        // remove and add hashes to subscription
45
        const parent_hashes = _.uniq([
×
46
          ...(existingCastWebhook?.subscription?.filters['cast.created']
×
47
            ?.parent_hashes || []),
48
          ...(existingCastWebhook?.subscription?.filters['cast.deleted']
×
49
            ?.parent_hashes || []),
50
        ])
51
          .filter((hash) => {
52
            return !(payload.frames_to_remove || []).includes(hash);
×
53
          })
54
          .concat(payload.frames_to_add || []);
×
55

56
        const subscription = {
×
57
          ...(existingCastWebhook.subscription?.filters || {}),
×
58
          // reply cast created on parent
59
          'cast.created': {
60
            ...(existingCastWebhook.subscription?.filters['cast.created'] ||
×
61
              {}),
62
            parent_hashes,
63
          },
64
          // reply cast deleted on parent
65
          'cast.deleted': {
66
            ...(existingCastWebhook.subscription?.filters['cast.deleted'] ||
×
67
              {}),
68
            parent_hashes,
69
          },
70
        };
71

72
        await client.updateWebhook(
×
73
          existingCastWebhook.webhook_id,
74
          existingCastWebhook.title,
75
          existingCastWebhook.target_url,
76
          {
77
            subscription,
78
          },
79
        );
80

NEW
81
        if (!payload.webhooks_only) {
×
82
          // update contest manager frame hashes
NEW
83
          contestManager.farcaster_frame_hashes = parent_hashes;
×
NEW
84
          await contestManager.save();
×
85
        }
86
      });
87
    },
88
  };
89
}
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