Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/shared/i18n/de/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "Deine Online-Identifikation ist fehlgeschlagen",
"body": "<p>Wir haben festgestellt, dass die Online-Identifizierung fehlgeschlagen ist. Wir haben jedoch bereits die Video-Identifikation freigeschaltet.<br>Weiter geht es, indem man auf der Payment Seite (Kaufen, Verkaufen & Staking) auf den Refresh Button (roter Pfeil in Kreisoptik) klickt oder <a href=\"{url}\" style=\"color:#FFFFFF\">hier</a>.</p><p>Mache den letzten Schritt und beginne noch heute deine Reise zur finanziellen Freiheit</p><p>Dein DFX Team<br>Bitcoiners by heart ♥</p>",
"title": "Online Identifikation fehlgeschlagen"
},
"success": {
"salutation": "Verifikation erfolgreich",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">Deine Verifikation ist abgeschlossen.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Viel Erfolg beim Traden</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Dein freundliches DFX Team</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Verifikation erfolgreich"
}
},
"stakingRef": {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/i18n/en/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "Your online identification has failed",
"body": "<p>We have noticed that your online identification has failed. However, we have already unlocked video identification for you.<br>Please continue by clicking on the refresh button in the limit section on the payment page (Buy, Sell & Staking) or <a href=\"{url}\" style=\"color:#FFFFFF\">here</a>.</p><p>Take the final step and start working on your financial freedom today</p><p>Your DFX Team<br>Bitcoiners by heart ♥</p>",
"title": "Online identification failed"
},
"success": {
"salutation": "Verification successful",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">Your verification is complete.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Happy Trading</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Your DFX Team</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Verification successful"
}
},
"stakingRef": {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/i18n/es/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "Tu identificación online ha fallado",
"body": "<p>Nos hemos dado cuenta de que tu identificación online ha fallado. De todas formas, hemos desbloquado la identificación por video para ti.<br>Por favor, continúa apretando el botón de refresco en la sección \"límite\" en la página de pago (Compra, Vende y Staking) o <a href=\"{url}\" style=\"color:#FFFFFF\">aquí</a>.</p><p>Da el último paso y empieza a crear tu libertad financiera hoy</p><p>Tu Equipo DFX<br>Bitcoiners de corazón ♥</p>",
"title": "Tu identificación online ha fallado"
},
"success": {
"salutation": "Verificación exitosa",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">Su verificación está completa.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">¡Que disfrutes al comerciar!</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Tu Equipo DFX</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Verificación exitosa"
}
},
"stakingRef": {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/i18n/fr/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "Votre identification en ligne a échoué",
"body": "<p>Nous avons remarqué que votre identification en ligne a échoué. Nous avons cependant déjà débloqué l'identification vidéo pour vous.<br>Veuillez continuer en cliquant sur le bouton d'actualisation dans la section Limites de la page de paiement (Achat, Vente & Staking) ou <a href=\"{url}\" style=\"color:#FFFFFF\">ici</a>.</p><p>Franchissez le dernier pas et développez votre liberté financière dès aujourd'hui</p><p>Votre équipe DFX<br>Bitcoiners de coeur ♥</p>",
"title": "Votre identification en ligne a échoué"
},
"success": {
"salutation": "Vérification réussie",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">Votre vérification est terminée.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Bon trading</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Votre équipe DFX</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Vérification réussie"
}
},
"stakingRef": {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/i18n/it/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "La tua identificazione online non è riuscita",
"body": "<p>Abbiamo notato che la sua identificazione online è fallita. Tuttavia, abbiamo già sbloccato l'identificazione video per te.<br>Si prega di continuare cliccando sul pulsante di aggiornamento nella sezione dei limiti della pagina di pagamento (Compra, Vendi e Staking) o <a href=\"{url}\" style=\"color:#FFFFFF\">qui</a>.</p><p>Fai il passo finale e inizia a lavorare sulla tua libertà finanziaria oggi stesso</p><p>Tuo DFX team<br>Bitcoiners by heart ♥</p>",
"title": "La tua identificazione online non è riuscita"
},
"success": {
"salutation": "Verifica riuscita",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">La verifica è stata completata.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Buon trading</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Tuo DFX team</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Verifica riuscita"
}
},
"stakingRef": {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/i18n/pt/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"salutation": "Your online identification has failed",
"body": "<p>We have noticed that your online identification has failed. However, we have already unlocked video identification for you.<br>Please continue by clicking on the refresh button in the limit section on the payment page (Buy, Sell & Staking) or <a href=\"{url}\" style=\"color:#FFFFFF\">here</a>.</p><p>Take the final step and start working on your financial freedom today</p><p>Your DFX Team<br>Bitcoiners by heart ♥</p>",
"title": "Online identification failed"
},
"success": {
"salutation": "Verification successful",
"body": "<table style=\"font-family:Open Sans,Helvetica,Arial,sans-serif;width:60%;padding:8px;font-size:85%\" align=\"center\"><tr><td colspan=\"3\" align=\"center\">Your verification is complete.</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Happy Trading</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"font-family:Open Sans,Helvetica,Arial,sans-serif\"><td colspan=\"3\" align=\"center\">Your DFX Team</td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr style=\"padding:1px\"><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\" align=\"center\"><span style=\"font-family:Zapfino\">Bitcoiners by heart ♥️</span></td></tr></table>",
"title": "Verification successful"
}
},
"stakingRef": {
Expand Down
19 changes: 15 additions & 4 deletions src/user/models/kyc/kyc-process.service.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Injectable, ServiceUnavailableException } from '@nestjs/common';
import { UserRole } from 'src/shared/auth/user-role.enum';
import { SpiderDataRepository } from 'src/user/models/spider-data/spider-data.repository';
import { KycInProgress, KycState, KycStatus, UserData } from 'src/user/models/user-data/user-data.entity';
import { KycDocument, KycDocuments, InitiateResponse } from '../../services/spider/dto/spider.dto';
import { AccountType } from 'src/user/models/user-data/account-type.enum';
import { MailService } from 'src/shared/services/mail.service';
import { IdentResultDto } from 'src/user/models/ident/dto/ident-result.dto';
import { DocumentState, SpiderService } from 'src/user/services/spider/spider.service';
import { UserDataService } from '../user-data/user-data.service';
import { UserRole } from 'src/shared/auth/user-role.enum';
import { UserRepository } from '../user/user.repository';

@Injectable()
export class KycProcessService {
constructor(
private readonly userDataService: UserDataService,
private readonly spiderDataRepo: SpiderDataRepository,
private readonly spiderService: SpiderService,
private readonly mailService: MailService,
private readonly userRepo: UserRepository,
) {}

// --- GENERAL METHODS --- //
Expand Down Expand Up @@ -51,6 +51,12 @@ export class KycProcessService {
const initiateData = await this.spiderService.initiateIdentification(userData.id, identType);
userData.spiderData = await this.updateSpiderData(userData, initiateData);
}
if (status === KycStatus.MANUAL)
await this.mailService.sendTranslatedMail({
userData: userData,
translationKey: 'mail.kyc.success',
params: {},
});

return this.updateKycStatus(userData, status);
}
Expand Down Expand Up @@ -99,7 +105,8 @@ export class KycProcessService {

userData = await this.storeChatbotResult(userData);

const isVipUser = await this.userDataService.hasRole(userData.id, UserRole.VIP);
const isVipUser = await this.hasRole(userData.id, UserRole.VIP);

return isVipUser
? await this.goToStatus(userData, KycStatus.VIDEO_ID)
: await this.goToStatus(userData, KycStatus.ONLINE_ID);
Expand Down Expand Up @@ -179,6 +186,10 @@ export class KycProcessService {
}

// --- HELPER METHODS --- //
private async hasRole(userDataId: number, role: UserRole): Promise<boolean> {
return await this.userRepo.findOne({ where: { userData: { id: userDataId }, role } }).then((u) => u != null);
}

private async updateSpiderData(userData: UserData, initiateData: InitiateResponse) {
const sessionData = await this.getSessionData(userData, initiateData);

Expand Down
4 changes: 2 additions & 2 deletions src/user/models/kyc/kyc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class KycService {
}

async updateKycData(code: string, data: KycUserDataDto, userId?: number): Promise<KycInfo> {
const user = await this.getUser(code, userId);
let user = await this.getUser(code, userId);
const isPersonalAccount = (data.accountType ?? user.accountType) === AccountType.PERSONAL;

// check countries
Expand All @@ -102,7 +102,7 @@ export class KycService {
data.organizationCountry = null;
}

await this.userDataService.updateSpiderIfNeeded(user, data);
user = await this.userDataService.updateSpiderIfNeeded(user, data);

const updatedUser = await this.userDataRepo.save({ ...user, ...data });

Expand Down
30 changes: 10 additions & 20 deletions src/user/models/user-data/user-data.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
BadRequestException,
ConflictException,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { BadRequestException, ConflictException, Injectable, NotFoundException } from '@nestjs/common';
import { UpdateUserDataDto } from './dto/update-user-data.dto';
import { UserDataRepository } from './user-data.repository';
import { KycInProgress, KycState, UserData } from './user-data.entity';
Expand All @@ -20,6 +15,7 @@ import { UserRepository } from '../user/user.repository';
import { SpiderApiService } from 'src/user/services/spider/spider-api.service';
import { Util } from 'src/shared/util';
import { Cron, CronExpression } from '@nestjs/schedule';
import { KycProcessService } from '../kyc/kyc-process.service';

@Injectable()
export class UserDataService {
Expand All @@ -32,6 +28,7 @@ export class UserDataService {
private readonly fiatService: FiatService,
private readonly spiderService: SpiderService,
private readonly spiderApiService: SpiderApiService,
private readonly kycProcessService: KycProcessService,
) {}

async getUserDataByUser(userId: number): Promise<UserData> {
Expand Down Expand Up @@ -66,7 +63,7 @@ export class UserDataService {
let userData = await this.userDataRepo.findOne(userDataId);
if (!userData) throw new NotFoundException('User data not found');

userData = await this.updateUserSettings(userData, dto);
userData = await this.updateSpiderIfNeeded(userData, dto);

if (dto.countryId) {
userData.country = await this.countryService.getCountry(dto.countryId);
Expand All @@ -78,10 +75,6 @@ export class UserDataService {
if (!userData.organizationCountry) throw new BadRequestException('Country not found');
}

if (dto.kycStatus && !dto.kycState) {
dto.kycState = KycState.NA;
}

if (dto.mainBankDataId) {
userData.mainBankData = await this.bankDataRepo.findOne(dto.mainBankDataId);
if (!userData.mainBankData) throw new BadRequestException('Bank data not found');
Expand All @@ -104,9 +97,8 @@ export class UserDataService {
);
}

if (dto.kycStatus && userData.kycStatus != dto.kycStatus) {
userData.kycStatusChangeDate = new Date();
}
if (dto.kycStatus && userData.kycStatus != dto.kycStatus)
userData = await this.kycProcessService.goToStatus(userData, dto.kycStatus);

return await this.userDataRepo.save({ ...userData, ...dto });
}
Expand All @@ -125,12 +117,12 @@ export class UserDataService {
}

// update spider
await this.updateSpiderIfNeeded(user, dto)
user = await this.updateSpiderIfNeeded(user, dto);

return this.userDataRepo.save({ ...user, ...dto });
}

async updateSpiderIfNeeded(userData: UserData, dto: UpdateUserDto) {
async updateSpiderIfNeeded(userData: UserData, dto: UpdateUserDto): Promise<UserData> {
Comment thread
Yannick1712 marked this conversation as resolved.
if ((dto.phone && dto.phone != userData.phone) || (dto.mail && dto.mail != userData.mail)) {
await this.spiderService.updateCustomer(userData.id, {
telephones: dto.phone ? [dto.phone.replace('+', '').split(' ').join('')] : undefined,
Expand All @@ -141,6 +133,8 @@ export class UserDataService {
userData.kycState = KycState.FAILED;
}
}

return userData;
}

// --- VOLUMES --- //
Expand Down Expand Up @@ -203,10 +197,6 @@ export class UserDataService {
await this.updateVolumes(slaveId);
}

async hasRole(userDataId: number, role: UserRole): Promise<boolean> {
return await this.userRepo.findOne({ where: { userData: { id: userDataId }, role } }).then((u) => u != null);
}

async getAllUserDataWithEmptyFileId(): Promise<number[]> {
const userDataList = await this.userDataRepo.find({ where: { kycFileId: MoreThan(0) } });
const idList = [];
Expand Down