mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Prevent calling internal hook email event if emailing is disabled (#8462)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -39,7 +39,6 @@ import { EnterpriseWorkflowService } from './workflow.service.ee';
|
||||
import { WorkflowExecutionService } from './workflowExecution.service';
|
||||
import { WorkflowSharingService } from './workflowSharing.service';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import { UrlService } from '@/services/url.service';
|
||||
|
||||
@Service()
|
||||
@Authorized()
|
||||
@@ -63,7 +62,6 @@ export class WorkflowsController {
|
||||
private readonly userRepository: UserRepository,
|
||||
private readonly license: License,
|
||||
private readonly mailer: UserManagementMailer,
|
||||
private readonly urlService: UrlService,
|
||||
) {}
|
||||
|
||||
@Post('/')
|
||||
@@ -403,35 +401,10 @@ export class WorkflowsController {
|
||||
|
||||
void this.internalHooks.onWorkflowSharingUpdate(workflowId, req.user.id, shareWithIds);
|
||||
|
||||
const recipients = await this.userRepository.getEmailsByIds(newShareeIds);
|
||||
|
||||
if (recipients.length === 0) return;
|
||||
|
||||
try {
|
||||
await this.mailer.notifyWorkflowShared({
|
||||
recipientEmails: recipients.map(({ email }) => email),
|
||||
workflowName: workflow.name,
|
||||
workflowId,
|
||||
sharerFirstName: req.user.firstName,
|
||||
baseUrl: this.urlService.getInstanceBaseUrl(),
|
||||
});
|
||||
} catch (error) {
|
||||
void this.internalHooks.onEmailFailed({
|
||||
user: req.user,
|
||||
message_type: 'Workflow shared',
|
||||
public_api: false,
|
||||
});
|
||||
if (error instanceof Error) {
|
||||
throw new InternalServerError(`Please contact your administrator: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.info('Sent workflow shared email successfully', { sharerId: req.user.id });
|
||||
|
||||
void this.internalHooks.onUserTransactionalEmail({
|
||||
user_id: req.user.id,
|
||||
message_type: 'Workflow shared',
|
||||
public_api: false,
|
||||
await this.mailer.notifyWorkflowShared({
|
||||
sharer: req.user,
|
||||
newShareeIds,
|
||||
workflow,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user