-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from elie222/webhook
Add call webhook action
- Loading branch information
Showing
24 changed files
with
295 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use client"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { regenerateWebhookSecretAction } from "@/utils/actions/webhook"; | ||
import { isActionError } from "@/utils/error"; | ||
import { toastError, toastSuccess } from "@/components/Toast"; | ||
|
||
export function RegenerateSecretButton({ hasSecret }: { hasSecret: boolean }) { | ||
const handleRegenerateSecret = async () => { | ||
const result = await regenerateWebhookSecretAction(); | ||
if (isActionError(result)) { | ||
toastError({ title: "Error", description: result.error }); | ||
} else { | ||
toastSuccess({ description: "Webhook secret regenerated" }); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button variant="outline" type="button" onClick={handleRegenerateSecret}> | ||
{hasSecret ? "Regenerate Secret" : "Generate Secret"} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { auth } from "@/app/api/auth/[...nextauth]/auth"; | ||
import { FormSection, FormSectionLeft } from "@/components/Form"; | ||
import prisma from "@/utils/prisma"; | ||
import { Card } from "@/components/ui/card"; | ||
import { CopyInput } from "@/components/CopyInput"; | ||
import { RegenerateSecretButton } from "@/app/(app)/settings/WebhookGenerate"; | ||
|
||
export async function WebhookSection() { | ||
const session = await auth(); | ||
const userId = session?.user.id; | ||
if (!userId) throw new Error("Not authenticated"); | ||
|
||
const user = await prisma.user.findUnique({ | ||
where: { id: userId }, | ||
select: { webhookSecret: true }, | ||
}); | ||
|
||
return ( | ||
<FormSection> | ||
<FormSectionLeft | ||
title="Webhooks (Developers)" | ||
description="API webhook secret for request verification. Include this in the X-Webhook-Secret header when setting up webhook endpoints." | ||
/> | ||
|
||
<div className="col-span-2"> | ||
<Card className="p-6"> | ||
<div className="space-y-4"> | ||
{!!user?.webhookSecret && <CopyInput value={user?.webhookSecret} />} | ||
|
||
<RegenerateSecretButton hasSecret={!!user?.webhookSecret} /> | ||
</div> | ||
</Card> | ||
</div> | ||
</FormSection> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
apps/web/prisma/migrations/20241230180925_call_webhook_action/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- AlterEnum | ||
ALTER TYPE "ActionType" ADD VALUE 'CALL_WEBHOOK'; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" ADD COLUMN "webhookSecret" TEXT; |
5 changes: 5 additions & 0 deletions
5
apps/web/prisma/migrations/20241230204311_action_webhook_url/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- AlterTable | ||
ALTER TABLE "Action" ADD COLUMN "url" TEXT; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ExecutedAction" ADD COLUMN "url" TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
# It should be added in your version-control system (e.g., Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ea6ab6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
inbox-zero – ./
inbox-zero-inbox-zero.vercel.app
inbox-zero.vercel.app
inbox-zero-git-main-inbox-zero.vercel.app
www.getinboxzero.com
getinboxzero.com