{"name":"Log published posts in Airtable","nodes":[{"name":"Posthoop webhook","webhookId":"51536f0e-8d6a-45c6-bc29-154ef0374fd6","parameters":{"httpMethod":"POST","path":"published-to-airtable","responseMode":"responseNode","options":{"rawBody":true}},"type":"n8n-nodes-base.webhook","typeVersion":2,"position":[0,0],"id":"c96063a8-fdcb-450b-abd2-000000000001"},{"name":"Verify Posthoop signature","parameters":{"mode":"runOnceForAllItems","jsCode":"const { createHmac, timingSafeEqual } = require('crypto');\nconst secret = 'REPLACE_WITH_SIGNING_SECRET';\nconst signature = $input.first().json.headers['posthoop-signature'];\nconst body = await this.helpers.getBinaryDataBuffer(0, 'data');\nconst match = /^t=([1-9]\\d{0,15}),v1=([0-9a-f]{64})$/.exec(signature ?? '');\nif (!secret || secret === 'REPLACE_WITH_SIGNING_SECRET' || !match ||\n    Math.abs(Math.floor(Date.now() / 1000) - Number(match[1])) > 300) {\n  throw new Error('Invalid Posthoop signature');\n}\nconst expected = createHmac('sha256', secret).update(match[1] + '.').update(body).digest();\nif (!timingSafeEqual(expected, Buffer.from(match[2], 'hex'))) {\n  throw new Error('Invalid Posthoop signature');\n}\nreturn [{ json: JSON.parse(body.toString('utf8')) }];"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[250,0],"id":"c96063a8-fdcb-450b-abd2-000000000002"},{"name":"Acknowledge event","parameters":{"respondWith":"noData","options":{"responseCode":204}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[500,0],"id":"c96063a8-fdcb-450b-abd2-000000000003"},{"name":"Published events only","parameters":{"mode":"runOnceForAllItems","jsCode":"return $input.all().filter(item => item.json.type === 'post.target.published');"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[750,0],"id":"c96063a8-fdcb-450b-abd2-000000000004"},{"name":"Upsert Airtable row","parameters":{"method":"PATCH","url":"https://api.airtable.com/v0/REPLACE_BASE_ID/REPLACE_TABLE_ID","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","options":{},"sendBody":true,"specifyBody":"json","jsonBody":"={{ {\"performUpsert\":{\"fieldsToMergeOn\":[\"Event ID\"]},\"records\":[{\"fields\":{\"Event ID\":$json.id,\"Post ID\":$json.data.postId,\"Target ID\":$json.data.targetId,\"Post URL\":$json.data.externalUrl ?? ''}}]} }}"},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1000,0],"id":"c96063a8-fdcb-450b-abd2-000000000005"}],"connections":{"Posthoop webhook":{"main":[[{"node":"Verify Posthoop signature","type":"main","index":0}]]},"Verify Posthoop signature":{"main":[[{"node":"Acknowledge event","type":"main","index":0}]]},"Acknowledge event":{"main":[[{"node":"Published events only","type":"main","index":0}]]},"Published events only":{"main":[[{"node":"Upsert Airtable row","type":"main","index":0}]]}},"active":false,"settings":{"executionOrder":"v1"}}