Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do email verification on project verification form through Ortto #1649

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
3 changes: 0 additions & 3 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ CHANGE_API_NON_PROFITS_SEARCH_URL=


FRONTEND_URL=test.giveth.io
DAPP_MAILER_URL=
DAPP_MAILER_AUTHORIZATION_KEY=
ENABLE_DAPP_MAILER=false

GIVETH_IO_DAPP_BASE_URL=https://staging.giveth.io
GIVETH_IO_BACKEND_BASE_URL=http://localhost:3040
Expand Down
3 changes: 0 additions & 3 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ PRIVATE_ETHERS_SECONDARY_TEST_KEY=0x2f8ca279705d6dfc44fb4507d02f6ef8bd0a50188695
PUBLIC_ETHERS_SECONDARY_TEST_KEY=0x05fCFaDDFEc046F393B97C8273ad0537e83EFC74

FRONTEND_URL=test.giveth.io
DAPP_MAILER_URL=
DAPP_MAILER_AUTHORIZATION_KEY=
ENABLE_DAPP_MAILER=false

GIVETH_IO_DAPP_BASE_URL=https://staging.giveth.io
GIVETH_IO_BACKEND_BASE_URL=http://localhost:3040
Expand Down
9 changes: 9 additions & 0 deletions src/adapters/notifications/MockNotificationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export class MockNotificationAdapter implements NotificationAdapterInterface {
return Promise.resolve(undefined);
}

async sendEmailConfirmation(params: {
email: string;
project: Project;
token: string;
}) {
logger.debug('MockNotificationAdapter sendEmailConfirmation', params);
return Promise.resolve(undefined);
}

userSuperTokensCritical(): Promise<void> {
return Promise.resolve(undefined);
}
Expand Down
6 changes: 6 additions & 0 deletions src/adapters/notifications/NotificationAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export interface NotificationAdapterInterface {
userId: number;
}): Promise<void>;

sendEmailConfirmation(params: {
email: string;
project: Project;
token: string;
}): Promise<void>;

userSuperTokensCritical(params: {
user: User;
eventName: UserStreamBalanceWarning;
Expand Down
26 changes: 24 additions & 2 deletions src/adapters/notifications/NotificationCenterAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios';

import Bull from 'bull';
import {
BroadCastNotificationInputParams,
Expand Down Expand Up @@ -27,10 +26,12 @@ import { RecurringDonation } from '../../entities/recurringDonation';
import { getTokenPrice } from '../../services/priceService';
import { Token } from '../../entities/token';
import { toFixNumber } from '../../services/donationService';

const notificationCenterUsername = process.env.NOTIFICATION_CENTER_USERNAME;
const notificationCenterPassword = process.env.NOTIFICATION_CENTER_PASSWORD;
const notificationCenterBaseUrl = process.env.NOTIFICATION_CENTER_BASE_URL;
const disableNotificationCenter = process.env.DISABLE_NOTIFICATION_CENTER;
const dappUrl = process.env.FRONTEND_URL as string;

const numberOfSendNotificationsConcurrentJob =
Number(
Expand All @@ -56,6 +57,27 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
}
}

async sendEmailConfirmation(params: {
email: string;
project: Project;
token: string;
}): Promise<void> {
const { email, project, token } = params;
try {
await callSendNotification({
eventName: NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION,
segment: {
payload: {
email,
verificationLink: `${dappUrl}/verification/${project.slug}/${token}`,
},
},
});
} catch (e) {
logger.error('sendEmailConfirmation >> error', e);
}
}

async userSuperTokensCritical(params: {
user: User;
eventName: UserStreamBalanceWarning;
Expand Down Expand Up @@ -1223,7 +1245,7 @@ interface SendNotificationBody {
trackId?: string;
metadata?: any;
projectId?: string;
userWalletAddress: string;
userWalletAddress?: string;
segment?: {
payload: any;
};
Expand Down
1 change: 1 addition & 0 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export enum NOTIFICATIONS_EVENT_NAMES {
SUPER_TOKENS_BALANCE_MONTH = 'One month left in stream balance',
SUPER_TOKENS_BALANCE_DEPLETED = 'Stream balance depleted',
CREATE_ORTTO_PROFILE = 'Create Ortto profile',
SEND_EMAIL_CONFIRMATION = 'Send email confirmation',
}
8 changes: 6 additions & 2 deletions src/resolvers/projectVerificationFormResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { ProjectVerificationUpdateInput } from './types/ProjectVerificationUpdat
import config from '../config';
import { countriesList } from '../utils/utils';
import { Country } from '../entities/Country';
import { sendMailConfirmationEmail } from '../services/mailerService';
import { getNotificationAdapter } from '../adapters/adaptersFactory';

@Resolver(_of => ProjectVerificationForm)
export class ProjectVerificationFormResolver {
Expand Down Expand Up @@ -182,7 +182,11 @@ export class ProjectVerificationFormResolver {
projectVerificationForm.emailConfirmationSentAt = new Date();
await projectVerificationForm.save();

await sendMailConfirmationEmail(email, project, token);
await getNotificationAdapter().sendEmailConfirmation({
email,
project,
token,
});

return projectVerificationForm;
} catch (e) {
Expand Down
44 changes: 0 additions & 44 deletions src/services/mailerService.ts

This file was deleted.

Loading