Skip to content

Commit 2a68d15

Browse files
committed
ensure no duplicate mails
1 parent beab13f commit 2a68d15

1 file changed

Lines changed: 4 additions & 44 deletions

File tree

src/web/Jordnaer/Features/Membership/MembershipService.cs

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,7 @@ public async Task<OneOf<Success, Error<MembershipStatus>, Error<string>>> Reques
9191
existingMembership.UserInitiatedMembership = true;
9292
await context.SaveChangesAsync(cancellationToken);
9393

94-
// Send email notification - don't fail the request if notification fails
95-
try
96-
{
97-
await emailService.SendMembershipRequestEmails(groupName, cancellationToken);
98-
}
99-
catch (Exception notificationException)
100-
{
101-
logger.LogError(notificationException, "Failed to send membership request emails for group {GroupName}", groupName);
102-
}
103-
104-
// Send in-app notifications to group admins
94+
// Send in-app notifications to group admins (includes email if enabled in preferences)
10595
await NotifyAdminsOfMembershipRequestAsync(context, group, cancellationToken);
10696

10797
return new Success();
@@ -124,17 +114,7 @@ public async Task<OneOf<Success, Error<MembershipStatus>, Error<string>>> Reques
124114

125115
await context.SaveChangesAsync(cancellationToken);
126116

127-
// Send email notification - don't fail the request if notification fails
128-
try
129-
{
130-
await emailService.SendMembershipRequestEmails(groupName, cancellationToken);
131-
}
132-
catch (Exception notificationException)
133-
{
134-
logger.LogError(notificationException, "Failed to send membership request emails for group {GroupName}", groupName);
135-
}
136-
137-
// Send in-app notifications to group admins
117+
// Send in-app notifications to group admins (includes email if enabled in preferences)
138118
await NotifyAdminsOfMembershipRequestAsync(context, group, cancellationToken);
139119

140120
return new Success();
@@ -242,17 +222,7 @@ public async Task<OneOf<Success, Error<string>>> InviteUserToGroupAsync(
242222
existingMembership.UserInitiatedMembership = false;
243223
await context.SaveChangesAsync(cancellationToken);
244224

245-
// Send email notification
246-
try
247-
{
248-
await emailService.SendGroupInviteEmail(group.Name, userId, cancellationToken);
249-
}
250-
catch (Exception notificationException)
251-
{
252-
logger.LogError(notificationException, "Failed to send invite email for group {GroupName}", group.Name);
253-
}
254-
255-
// Send in-app notification to the invited user
225+
// Send in-app notification to the invited user (includes email if enabled in preferences)
256226
await SendGroupInviteNotificationAsync(group, userId, cancellationToken);
257227

258228
return new Success();
@@ -276,17 +246,7 @@ public async Task<OneOf<Success, Error<string>>> InviteUserToGroupAsync(
276246

277247
await context.SaveChangesAsync(cancellationToken);
278248

279-
// Send email notification - don't fail the request if notification fails
280-
try
281-
{
282-
await emailService.SendGroupInviteEmail(group.Name, userId, cancellationToken);
283-
}
284-
catch (Exception notificationException)
285-
{
286-
logger.LogError(notificationException, "Failed to send invite email for group {GroupName}", group.Name);
287-
}
288-
289-
// Send in-app notification to the invited user
249+
// Send in-app notification to the invited user (includes email if enabled in preferences)
290250
await SendGroupInviteNotificationAsync(group, userId, cancellationToken);
291251

292252
return new Success();

0 commit comments

Comments
 (0)