Skip to content

Commit

Permalink
fix: Use result field in webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
storm1729 committed Jan 5, 2025
1 parent 7f0c9c4 commit d39bd9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 62 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@supabase/auth-ui-react": "^0.4.6",
"@supabase/ssr": "^0.0.10",
"@supabase/supabase-js": "^2.39.1",
"@types/amqplib": "^0.10.4",
"@types/async-retry": "^1.4.8",
"@types/cors": "^2.8.17",
"@types/mailgun-js": "^0.22.18",
Expand All @@ -44,7 +43,6 @@
"@types/react-dom": "^18.2.17",
"@types/request-ip": "^0.0.41",
"@types/uuid": "^9.0.7",
"amqplib": "^0.10.3",
"async-retry": "^1.3.3",
"axios": "^1.6.2",
"cors": "^2.8.5",
Expand Down
18 changes: 9 additions & 9 deletions src/app/api/v1/bulk/webhook/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface WebhookExtra {
}

export interface WebhookPayload {
output: CheckEmailOutput;
result: CheckEmailOutput;
extra: WebhookExtra;
}

Expand All @@ -20,23 +20,23 @@ export const POST = async (req: NextRequest): Promise<Response> => {
}

const body: WebhookPayload = await req.json();
const { output, extra } = body;
const { result, extra } = body;

// Add to supabase calls
const res1 = await supabaseAdmin
.from("calls")
.insert({
endpoint: extra.endpoint,
user_id: extra.userId,
backend: output.debug?.server_name,
domain: output.syntax.domain,
backend: result.debug?.server_name,
domain: result.syntax.domain,
duration: Math.round(
(output.debug?.duration.secs || 0) * 1000 +
(output.debug?.duration.nanos || 0) / 1000000
(result.debug?.duration.secs || 0) * 1000 +
(result.debug?.duration.nanos || 0) / 1000000
),
is_reachable: output.is_reachable,
verif_method: output.debug?.smtp?.verif_method?.type,
result: removeSensitiveData(output),
is_reachable: result.is_reachable,
verif_method: result.debug?.smtp?.verif_method?.type,
result: removeSensitiveData(result),
bulk_email_id: extra.bulkEmailId,
})
.select("*");
Expand Down
53 changes: 2 additions & 51 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==

"@acuminous/bitsyntax@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@acuminous/bitsyntax/-/bitsyntax-0.1.2.tgz#e0b31b9ee7ad1e4dd840c34864327c33d9f1f653"
integrity sha512-29lUK80d1muEQqiUsSo+3A0yP6CdspgC95EnKBMi22Xlwt79i/En4Vr67+cXhU+cZjbti3TgGGC5wy1stIywVQ==
dependencies:
buffer-more-ints "~1.0.0"
debug "^4.3.4"
safe-buffer "~5.1.2"

"@ampproject/remapping@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d"
Expand Down Expand Up @@ -3709,13 +3700,6 @@
dependencies:
"@types/estree" "*"

"@types/amqplib@^0.10.4":
version "0.10.4"
resolved "https://registry.yarnpkg.com/@types/amqplib/-/amqplib-0.10.4.tgz#0bf1ceefe280c02502b209fa9f06394b0c4cd688"
integrity sha512-Y5Sqquh/LqDxSgxYaAAFNM0M7GyONtSDCcFMJk+DQwYEjibPyW6y+Yu9H9omdkKc3epyXULmFN3GTaeBHhn2Hg==
dependencies:
"@types/node" "*"

"@types/async-retry@^1.4.8":
version "1.4.8"
resolved "https://registry.yarnpkg.com/@types/async-retry/-/async-retry-1.4.8.tgz#eb32df13aceb9ba1a8a80e7fe518ff4e3fe46bb3"
Expand Down Expand Up @@ -4583,16 +4567,6 @@ ajv@^6.0.0, ajv@^6.12.3, ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

amqplib@^0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/amqplib/-/amqplib-0.10.3.tgz#e186a2f74521eb55ec54db6d25ae82c29c1f911a"
integrity sha512-UHmuSa7n8vVW/a5HGh2nFPqAEr8+cD4dEZ6u9GjP91nHfr1a54RyAKyra7Sb5NH7NBKOUlyQSMXIp0qAixKexw==
dependencies:
"@acuminous/bitsyntax" "^0.1.2"
buffer-more-ints "~1.0.0"
readable-stream "1.x >=1.1.9"
url-parse "~1.5.10"

ansi-escapes@^4.2.1:
version "4.3.2"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"
Expand Down Expand Up @@ -5033,11 +5007,6 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

buffer-more-ints@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz#ef4f8e2dddbad429ed3828a9c55d44f05c611422"
integrity sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg==

buffer@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
Expand Down Expand Up @@ -9899,11 +9868,6 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad"
integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==

querystringify@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==

quick-lru@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932"
Expand Down Expand Up @@ -10024,7 +9988,7 @@ read-cmd-shim@^4.0.0:
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz#640a08b473a49043e394ae0c7a34dd822c73b9bb"
integrity sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==

[email protected], "[email protected] >=1.1.9":
[email protected]:
version "1.1.14"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk=
Expand Down Expand Up @@ -10256,11 +10220,6 @@ require-in-the-middle@^7.1.1:
resolved "https://registry.yarnpkg.com/require-like/-/require-like-0.1.2.tgz#ad6f30c13becd797010c468afa775c0c0a6b47fa"
integrity sha512-oyrU88skkMtDdauHDuKVrgR+zuItqr6/c//FXzvmxRGMexSDc6hNvJInGW3LL46n+8b50RykrvwSUIIQH2LQ5A==

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==

resolve-alpn@^1.0.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9"
Expand Down Expand Up @@ -10422,7 +10381,7 @@ [email protected], safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

safe-buffer@~5.1.0, safe-buffer@~5.1.1, safe-buffer@~5.1.2:
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
Expand Down Expand Up @@ -11519,14 +11478,6 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

url-parse@~1.5.10:
version "1.5.10"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1"
integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==
dependencies:
querystringify "^2.1.1"
requires-port "^1.0.0"

use-callback-ref@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/use-callback-ref/-/use-callback-ref-1.3.3.tgz#98d9fab067075841c5b2c6852090d5d0feabe2bf"
Expand Down

0 comments on commit d39bd9d

Please sign in to comment.