MCPcopy Create free account
hub / github.com/hashintel/hash / linearWebhook

Function linearWebhook

apps/hash-api/src/integrations/linear/webhook.ts:40–188  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

38 string,
39 string
40> = async (req, res) => {
41 const secret = process.env.LINEAR_WEBHOOK_SECRET;
42
43 if (!secret) {
44 throw new Error("LINEAR_WEBHOOK_SECRET is not set");
45 }
46
47 const expectedSignature = crypto
48 .createHmac("sha256", secret)
49 .update(req.body)
50 .digest("hex");
51
52 const linearSignature = req.headers["linear-signature"];
53 if (
54 typeof linearSignature !== "string" ||
55 !timingSafeCompare(expectedSignature, linearSignature)
56 ) {
57 res.sendStatus(400);
58 return;
59 }
60
61 const payload = JSON.parse(req.body) as LinearWebhookPayload;
62
63 const temporalClient = await createTemporalClient();
64
65 const organizationId = payload.organizationId;
66
67 if (!payload.data) {
68 res
69 .status(400)
70 .send(
71 `No data sent with ${payload.action} ${payload.type} webhook payload`,
72 );
73 return;
74 }
75
76 const linearId = payload.data.id;
77
78 if (!linearId) {
79 res
80 .status(400)
81 .send(`No ID found in ${payload.action} ${payload.type} webhook payload`);
82 return;
83 }
84
85 const { graphApi, vaultClient } = req.context;
86
87 if (!vaultClient) {
88 logger.error("No vault client found in Linear webhook");
89 res.sendStatus(500);
90 return;
91 }
92
93 const linearBotAccountId = await getMachineIdByIdentifier(
94 req.context,
95 { actorId: systemAccountId },
96 { identifier: "linear" },
97 ).then((maybeMachineId) => {

Callers

nothing calls this directly

Calls 15

timingSafeCompareFunction · 0.90
createTemporalClientFunction · 0.90
getMachineIdByIdentifierFunction · 0.90
tupleIncludesFunction · 0.90
generateUuidFunction · 0.90
thenMethod · 0.80
sendMethod · 0.65
updateMethod · 0.45

Tested by

no test coverage detected