API endpoint to wait for the mail queue to drain?

Since the processing of emails is sequential, the following workaround works:

  • /admin/email/handle_mail submit a mail with a unique subject/title such as Red Lantern (timestamp) addressed to categoryname@example.com.
  • look for the category id of the category for which the email in setting is categoryname@example.com
  • search with the following parameters:
    • ‘term’ = Red Lantern (timestamp)
    • ‘search_context[type]’ = ‘category’
    • ‘search_context[id]’: category id
  • Loop over ‘topics’ in the result and compare the ‘title’ value to Red Lantern (timestamp)
  • If found it means all mails preceding this one were processed
  • delete the Red Lantern (timestamp) topic using the topic['id'] from the search results