Skip to content

Commit 347f8b0

Browse files
jbair06Copilot
andauthored
feat: email visual improvements (hashgraph#2495)
* fix: improve email templates and notification content for various transaction states Signed-off-by: John Bair <john.bair@swirldslabs.com> * fix: enhance email notifications with download URL and improve content structure Signed-off-by: John Bair <john.bair@swirldslabs.com> * fix: improve email templates for reset password and transaction notifications Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: update email links to point to relevant Hedera Transaction Tool documentation Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: improve email content with additional key action links Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: enhance user registration emails with download URL and improve email content Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: update frontend repository URL and adjust download link structure Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: update repository URL structure for frontend version checks Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: improve email sender format and enhance email content structure Signed-off-by: John Bair <john.bair@swirldslabs.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * chore: improve email subject lines for transaction notifications Signed-off-by: John Bair <john.bair@swirldslabs.com> * feat: add validStart field to transaction notifications and update email rendering Signed-off-by: John Bair <john.bair@swirldslabs.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> * test: add unit test for default filtering behavior in transaction history Signed-off-by: John Bair <john.bair@swirldslabs.com> --------- Signed-off-by: John Bair <john.bair@swirldslabs.com> Signed-off-by: John Bair <117694970+jbair06@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 09a28a1 commit 347f8b0

28 files changed

Lines changed: 2391 additions & 1904 deletions

back-end/apps/api/example.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ NODE_ENV=development
4949
# Frontend version control (optional)
5050
LATEST_SUPPORTED_FRONTEND_VERSION=0.24.0
5151
MINIMUM_SUPPORTED_FRONTEND_VERSION=0.23.0
52-
FRONTEND_REPO_URL=https://github.com/hashgraph/hedera-transaction-tool/releases/download
52+
FRONTEND_REPO_URL=https://github.com/hashgraph/hedera-transaction-tool/releases

back-end/apps/api/src/auth/auth.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Injectable,
44
InternalServerErrorException,
55
UnauthorizedException,
6+
Logger,
67
} from '@nestjs/common';
78
import { ConfigService } from '@nestjs/config';
89
import { JwtService } from '@nestjs/jwt';
@@ -34,6 +35,8 @@ totp.options = {
3435

3536
@Injectable()
3637
export class AuthService {
38+
private readonly logger = new Logger(AuthService.name);
39+
3740
constructor(
3841
private readonly usersService: UsersService,
3942
private readonly configService: ConfigService,
@@ -43,6 +46,9 @@ export class AuthService {
4346

4447
/* Register a new user by admins and send an email with the temporary password */
4548
async signUpByAdmin(dto: SignUpUserDto, url: string): Promise<User> {
49+
const rawRepoUrl = this.configService.get<string>('FRONTEND_REPO_URL');
50+
const repoUrl = rawRepoUrl ? rawRepoUrl.replace(/\/+$/, '') : '';
51+
const downloadUrl = `${repoUrl}/latest`;
4652
const tempPassword = this.generatePassword();
4753

4854
const existingUser = await this.usersService.getUser({ email: dto.email }, true);
@@ -55,7 +61,9 @@ export class AuthService {
5561
user = await this.usersService.createUser(dto.email, tempPassword);
5662
}
5763

58-
emitUserRegistrationEmail(this.notificationsPublisher, [{ email: user.email, additionalData: { url, tempPassword } }])
64+
this.logger.log(`User ${user.id} registered and temporary password generated.`);
65+
66+
emitUserRegistrationEmail(this.notificationsPublisher, [{ email: user.email, additionalData: { url, tempPassword, downloadUrl } }]);
5967

6068
return user;
6169
}

back-end/apps/api/src/guards/frontend-version.guard.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ describe('FrontendVersionGuard', () => {
291291
});
292292

293293
describe('updateUrl in 426 responses', () => {
294-
const repoUrl = 'https://github.com/hashgraph/hedera-transaction-tool/releases/download';
294+
const repoUrl = 'https://github.com/hashgraph/hedera-transaction-tool/releases';
295295
const latestVersion = '2.0.0';
296296

297297
beforeEach(() => {
@@ -317,7 +317,7 @@ describe('FrontendVersionGuard', () => {
317317
guard.canActivate(context);
318318
} catch (error) {
319319
const response = (error as HttpException).getResponse() as Record<string, unknown>;
320-
expect(response.updateUrl).toBe(`${repoUrl}/v${latestVersion}/`);
320+
expect(response.updateUrl).toBe(`${repoUrl}/download/v${latestVersion}/`);
321321
}
322322
});
323323

@@ -328,7 +328,7 @@ describe('FrontendVersionGuard', () => {
328328
guard.canActivate(context);
329329
} catch (error) {
330330
const response = (error as HttpException).getResponse() as Record<string, unknown>;
331-
expect(response.updateUrl).toBe(`${repoUrl}/v${latestVersion}/`);
331+
expect(response.updateUrl).toBe(`${repoUrl}/download/v${latestVersion}/`);
332332
}
333333
});
334334

@@ -339,7 +339,7 @@ describe('FrontendVersionGuard', () => {
339339
guard.canActivate(context);
340340
} catch (error) {
341341
const response = (error as HttpException).getResponse() as Record<string, unknown>;
342-
expect(response.updateUrl).toBe(`${repoUrl}/v${latestVersion}/`);
342+
expect(response.updateUrl).toBe(`${repoUrl}/download/v${latestVersion}/`);
343343
}
344344
});
345345

@@ -417,7 +417,7 @@ describe('FrontendVersionGuard', () => {
417417
case 'MINIMUM_SUPPORTED_FRONTEND_VERSION':
418418
return '1.0.0';
419419
case 'FRONTEND_REPO_URL':
420-
return 'https://github.com/hashgraph/hedera-transaction-tool/releases/download///';
420+
return 'https://github.com/hashgraph/hedera-transaction-tool/releases///';
421421
case 'LATEST_SUPPORTED_FRONTEND_VERSION':
422422
return '2.0.0';
423423
default:

back-end/apps/api/src/guards/frontend-version.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class FrontendVersionGuard implements CanActivate {
3030

3131
const baseUrl = repoUrl.replace(/\/+$/, '');
3232

33-
return `${baseUrl}/v${cleanLatest}/`;
33+
return `${baseUrl}/download/v${cleanLatest}/`;
3434
}
3535

3636
canActivate(context: ExecutionContext): boolean {

back-end/apps/api/src/transactions/transactions.service.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,26 @@ describe('TransactionsService', () => {
22212221
}),
22222222
);
22232223
});
2224+
2225+
it('should return default where if filtering has no status filter', async () => {
2226+
const queryBuilder = mockQueryBuilder();
2227+
2228+
await service.getHistoryTransactions(defaultPagination, [
2229+
{
2230+
property: 'name', // any property that isn't 'status'
2231+
rule: 'eq',
2232+
value: 'some transaction name',
2233+
},
2234+
]);
2235+
2236+
expect(queryBuilder.setFindOptions).toHaveBeenCalledWith(
2237+
expect.objectContaining({
2238+
where: expect.objectContaining({
2239+
status: Not(In(forbiddenStatuses)),
2240+
}),
2241+
}),
2242+
);
2243+
});
22242244
});
22252245

22262246
describe('getTransactionForCreator', () => {

back-end/apps/notifications/src/email/email.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class EmailService {
8686
const html = generateMessage(event.additionalData);
8787

8888
await this.transporter.sendMail({
89-
from: `"Transaction Tool" ${this.sender}`,
89+
from: `"Transaction Tool" <${this.sender}>`,
9090
to: event.email,
9191
subject: subject,
9292
text: html.replace(/<\/?[^>]+(>|$)/g, ''), // Plain text fallback
@@ -153,11 +153,14 @@ export class EmailService {
153153
console.log(`Processing email batch for ${groupKey} with ${notifications.length} notifications in ${groupedNotifications.size} groups.`);
154154

155155
for (const [type, notifs] of groupedNotifications.entries()) {
156+
const htmlContent = generateEmailContent(type, ...notifs);
157+
156158
const mailOptions: SendMailOptions = {
157-
from: `"Transaction Tool" ${this.sender}`,
159+
from: `"Transaction Tool" <${this.sender}>`,
158160
to: groupKey,
159161
subject: NotificationTypeEmailSubjects[type],
160-
text: generateEmailContent(type, ...notifs),
162+
text: htmlContent.replace(/<\/?[^>]+(>|$)/g, ''),
163+
html: htmlContent,
161164
};
162165

163166
try {

back-end/k8s/dev/deployments/api-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
- name: MINIMUM_SUPPORTED_FRONTEND_VERSION
6565
value: '0.23.0'
6666
- name: FRONTEND_REPO_URL
67-
value: 'https://github.com/hashgraph/hedera-transaction-tool/releases/download'
67+
value: 'https://github.com/hashgraph/hedera-transaction-tool/releases'
6868
ports:
6969
- containerPort: 3000
7070
---

back-end/libs/common/src/templates/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { generateTransactionCancelledContent } from '@app/common/templates/trans
99
import { generateTransactionExecutedContent } from '@app/common/templates/transaction-executed';
1010
import { generateTransactionExpiredContent } from '@app/common/templates/transaction-expired';
1111

12+
export * from './layout';
1213
export * from './remind-signers';
1314
export * from './reset-password';
1415
export * from './transaction-cancelled';
@@ -30,7 +31,7 @@ export const generateEmailContent = (type: string | NotificationType, ...notific
3031
case NotificationType.TRANSACTION_CANCELLED:
3132
return generateTransactionCancelledContent(...notifications);
3233
case NotificationType.USER_REGISTERED:
33-
return generateNotifyUserRegisteredContent(notifications);
34+
return generateNotifyUserRegisteredContent(...notifications);
3435
case NotificationType.TRANSACTION_EXPIRED:
3536
return generateTransactionExpiredContent(...notifications);
3637
default:

0 commit comments

Comments
 (0)