telegram
parent
1880bd64b8
commit
09ee0a9654
|
@ -8,7 +8,6 @@ import {
|
|||
isFeedbackValid,
|
||||
isLanguageCodeValid,
|
||||
isPasswordValid,
|
||||
isPaymentIntervalValid,
|
||||
isPaymentPlanValid,
|
||||
isUsernameValid,
|
||||
} from "../validator/validator";
|
||||
|
@ -21,7 +20,6 @@ import {
|
|||
EMAIL_VERIFICATION_STATE,
|
||||
PAYMENT_PLAN,
|
||||
PAYMENT_PLAN_SETTINGS,
|
||||
PAYMENT_PLAN_STATUS,
|
||||
Roles,
|
||||
USER_ANALYTICS_ENABLED_DEFAULT,
|
||||
} from "../utils/constants";
|
||||
|
@ -48,7 +46,6 @@ import rabbitmq from "../rabbitmq/rabbitmq";
|
|||
import verifyCaptcha from "../utils/recaptcha";
|
||||
import EmailVerification from "../models/emailVerification";
|
||||
import UserPendingEmailChange from "../models/userPendingEmailChange";
|
||||
import { CreateCheckoutSession, getPriceId } from "./paymentController";
|
||||
import UserPendingPayment from "../models/userPendingPayment";
|
||||
import StoreServiceActivity from "../models/storeServiceActivity";
|
||||
import StoreService from "../models/storeService";
|
||||
|
@ -58,6 +55,7 @@ import {
|
|||
terminPlanerRequest,
|
||||
} from "../utils/terminPlaner";
|
||||
import UserAccountExport from "../models/userAccountExport";
|
||||
import { telegramNotification } from "../utils/adminDashboard";
|
||||
|
||||
export async function SignUp(req: Request, res: Response) {
|
||||
try {
|
||||
|
@ -187,6 +185,11 @@ export async function SignUp(req: Request, res: Response) {
|
|||
|
||||
res.status(200).send({ msg: "success" });
|
||||
|
||||
telegramNotification(
|
||||
1,
|
||||
`New user signed up: user_id: ${userId} email: ${email} language: ${language} company: ${companyName} username: ${username}`
|
||||
);
|
||||
|
||||
/*
|
||||
saveSession(
|
||||
req,
|
||||
|
@ -341,6 +344,11 @@ export async function Login(req: Request, res: Response) {
|
|||
|
||||
// create session
|
||||
saveSession(req, res, user.user_id, rememberMe);
|
||||
|
||||
telegramNotification(
|
||||
1,
|
||||
`User logged in: user_id: ${user.user_id} email: ${email} language: ${user.language}`
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("login error", error as string);
|
||||
res.status(500).send({ err: "invalid request" });
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import axios from "axios";
|
||||
import logger from "../logger/logger";
|
||||
|
||||
export async function telegramNotification(
|
||||
type: Number,
|
||||
message: String,
|
||||
userIds?: String[]
|
||||
) {
|
||||
if (process.env.ADMIN_DASHBOARD_TELEGRAM_ENABLED !== "true") return;
|
||||
|
||||
axios({
|
||||
url: `${process.env.ADMIN_DASHBOARD_TELEGRAM_NOTIFICATIONS_URL}`,
|
||||
method: "post",
|
||||
data: {
|
||||
type: type,
|
||||
title: message,
|
||||
userIds: userIds || [],
|
||||
},
|
||||
}).catch((error) => {
|
||||
logger.error("Telegram notification error:", error);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue