diff --git a/apps/server/src/modules/email/service.ts b/apps/server/src/modules/email/service.ts
index bd82cca..c7abd2a 100644
--- a/apps/server/src/modules/email/service.ts
+++ b/apps/server/src/modules/email/service.ts
@@ -167,7 +167,7 @@ export class EmailService {
});
}
- async sendShareNotification(to: string, shareLink: string, shareName?: string) {
+ async sendShareNotification(to: string, shareLink: string, shareName?: string, senderName?: string) {
const transporter = await this.createTransporter();
if (!transporter) {
throw new Error("SMTP is not enabled");
@@ -178,19 +178,67 @@ export class EmailService {
const appName = await this.configService.getValue("appName");
const shareTitle = shareName || "Files";
+ const sender = senderName || "Someone";
await transporter.sendMail({
from: `"${fromName}" <${fromEmail}>`,
to,
subject: `${appName} - ${shareTitle} shared with you`,
html: `
-
${appName} - Shared Files
- Someone has shared "${shareTitle}" with you.
- Click the link below to access the shared files:
-
- Access Shared Files
-
- Note: This share may have an expiration date or view limit.
+
+
+
+
+
+ ${appName} - Shared Files
+
+
+
+
+
+
${appName}
+
Shared Files
+
+
+
+
+
+
Files Shared With You
+
+ ${sender} has shared "${shareTitle}" with you.
+
+
+
+
+
+
+
+
+
+ Important: This share may have an expiration date or view limit. Access it as soon as possible to ensure availability.
+
+
+
+
+
+
+
+ This email was sent by ${appName}
+
+
+ If you didn't expect this email, you can safely ignore it.
+
+
+ Powered by Kyantech Solutions
+
+
+
+
+
`,
});
}
diff --git a/apps/server/src/modules/share/service.ts b/apps/server/src/modules/share/service.ts
index ab9a505..7ab0de2 100644
--- a/apps/server/src/modules/share/service.ts
+++ b/apps/server/src/modules/share/service.ts
@@ -2,6 +2,7 @@ import bcrypt from "bcryptjs";
import { prisma } from "../../shared/prisma";
import { EmailService } from "../email/service";
+import { UserService } from "../user/service";
import { CreateShareInput, ShareResponseSchema, UpdateShareInput } from "./dto";
import { IShareRepository, PrismaShareRepository } from "./repository";
@@ -9,6 +10,7 @@ export class ShareService {
constructor(private readonly shareRepository: IShareRepository = new PrismaShareRepository()) {}
private emailService = new EmailService();
+ private userService = new UserService();
private formatShareResponse(share: any) {
return {
@@ -339,11 +341,26 @@ export class ShareService {
throw new Error("No recipients found for this share");
}
+ // Get sender information
+ let senderName = "Someone";
+ try {
+ const sender = await this.userService.getUserById(userId);
+ if (sender.firstName && sender.lastName) {
+ senderName = `${sender.firstName} ${sender.lastName}`;
+ } else if (sender.firstName) {
+ senderName = sender.firstName;
+ } else if (sender.username) {
+ senderName = sender.username;
+ }
+ } catch (error) {
+ console.error(`Failed to get sender information for user ${userId}:`, error);
+ }
+
const notifiedRecipients: string[] = [];
for (const recipient of share.recipients) {
try {
- await this.emailService.sendShareNotification(recipient.email, shareLink, share.name || undefined);
+ await this.emailService.sendShareNotification(recipient.email, shareLink, share.name || undefined, senderName);
notifiedRecipients.push(recipient.email);
} catch (error) {
console.error(`Failed to send email to ${recipient.email}:`, error);