chore: add notif service for new criticisms ticket and subscribtion
This commit is contained in:
@@ -6,6 +6,7 @@ import { AuthMessage, UserMessage } from "../../../common/enums/message.enum";
|
||||
import { NotificationsService } from "../../notifications/providers/notifications.service";
|
||||
import { ReferralsService } from "../../referrals/providers/referrals.service";
|
||||
import { Role } from "../../users/entities/role.entity";
|
||||
import { AdminsService } from "../../users/providers/admins.service";
|
||||
import { UsersService } from "../../users/providers/users.service";
|
||||
import { OTPService } from "../../utils/providers/otp.service";
|
||||
import { PasswordService } from "../../utils/providers/password.service";
|
||||
@@ -15,11 +16,11 @@ import { CompleteRegistrationDto } from "../DTO/complete-register.dto";
|
||||
import { CheckUserExistDto, LoginPasswordDTO } from "../DTO/loginPassword.dto";
|
||||
import { RequestOtpDto } from "../DTO/request-otp.dto";
|
||||
import { VerifyOtpDto } from "../DTO/verify-otp.dto";
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(
|
||||
private readonly usersService: UsersService,
|
||||
private readonly adminsService: AdminsService,
|
||||
private readonly passwordService: PasswordService,
|
||||
private readonly otpService: OTPService,
|
||||
private readonly tokensService: TokensService,
|
||||
@@ -56,9 +57,10 @@ export class AuthService {
|
||||
const { phone, code, referralCode } = completeRegistrationDto;
|
||||
const queryRunner = this.dataSource.createQueryRunner();
|
||||
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
//
|
||||
const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER");
|
||||
|
||||
if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP);
|
||||
@@ -71,6 +73,20 @@ export class AuthService {
|
||||
|
||||
const tokens = await this.tokensService.generateTokens(user, queryRunner);
|
||||
|
||||
const superAdmins = await this.adminsService.getSuperAdmins(queryRunner);
|
||||
|
||||
for (const admin of superAdmins) {
|
||||
await this.notificationService.createNewCustomerNotification(
|
||||
admin.id,
|
||||
{
|
||||
userPhone: user.phone,
|
||||
fullName: `${user.firstName} ${user.lastName}`,
|
||||
mobile: user.phone,
|
||||
},
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user