mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor(dokploy): add webhook url for new users
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { WEBSITE_URL } from "@/server/utils/stripe";
|
import { WEBSITE_URL } from "@/server/utils/stripe";
|
||||||
import {
|
import {
|
||||||
|
type Auth,
|
||||||
IS_CLOUD,
|
IS_CLOUD,
|
||||||
createAdmin,
|
createAdmin,
|
||||||
createUser,
|
createUser,
|
||||||
@@ -19,6 +20,7 @@ import {
|
|||||||
getUserByToken,
|
getUserByToken,
|
||||||
lucia,
|
lucia,
|
||||||
luciaToken,
|
luciaToken,
|
||||||
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
updateAuthById,
|
updateAuthById,
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -55,6 +57,7 @@ export const authRouter = createTRPCRouter({
|
|||||||
const newAdmin = await createAdmin(input);
|
const newAdmin = await createAdmin(input);
|
||||||
|
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
|
await sendDiscordNotificationWelcome(newAdmin);
|
||||||
await sendVerificationEmail(newAdmin.id);
|
await sendVerificationEmail(newAdmin.id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -430,3 +433,26 @@ export const sendVerificationEmail = async (authId: string) => {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const sendDiscordNotificationWelcome = async (newAdmin: Auth) => {
|
||||||
|
await sendDiscordNotification(
|
||||||
|
{
|
||||||
|
webhookUrl: process.env.DISCORD_WEBHOOK_URL || "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "✅ New User Registered",
|
||||||
|
color: 0x00ff00,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "Email",
|
||||||
|
value: newAdmin.email,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
timestamp: newAdmin.createdAt,
|
||||||
|
footer: {
|
||||||
|
text: "Dokploy User Registration Notification",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user