Skip to content

fix: PermissionError on Email Queue for non-admin users#6033

Open
one-fm wants to merge 1 commit into
version-15from
issue-6020
Open

fix: PermissionError on Email Queue for non-admin users#6033
one-fm wants to merge 1 commit into
version-15from
issue-6020

Conversation

@one-fm
Copy link
Copy Markdown
Contributor

@one-fm one-fm commented Apr 29, 2026

Summary

Fixed PermissionError on Email Queue for non-admin users by bypassing UI-level permission checks during background email sending.

Changes

  • one_fm/events/email_queue.py:
    • Added send_mail(name) function to fetch Email Queue doc and call doc.send() directly. This avoids the check_permission call inside the whitelisted send_now function.
    • Updated after_insert hook to enqueue send_mail instead of send_now.
    • Updated flush_emails to use frappe.get_all (bypassing list permissions) and send_mail.

Review Checklist

  • validate_doctype_json: ✅ N/A (No JSON changes)
  • bench migrate: ❌ FAILED (Unrelated patch error in one_fm.patches.v15_0.fix_leave_allocation_carry_forward_hr_emp_02814. This patch fails because it expects a specific record HR-LAL-2024-01853 which is missing in the environment.)
  • run_tests: ✅ PASS
  • hooks.py paths verified: ✅ one_fm.events.email_queue.after_insert
  • No frappe.db.commit() in controllers: ✅ flush_emails is a utility/background function.

How to Verify

  1. Log in as a non-admin user.
  2. Trigger an email (e.g., by adding a comment to an Issue).
  3. Verify the email is enqueued and sent without PermissionError in background jobs.

Closes #6020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PermissionError on Email Queue blocks email sending for non-admin users

1 participant