FEATURE: IMAP delete email sync for group inboxes (#10392)

Adds functionality to reflect topic delete in Discourse to IMAP inbox (Gmail only for now) and reflecting Gmail deletes in Discourse.

Adding lots of tests, various refactors and code improvements.

When Discourse topic is destroyed in PostDestroyer mark the topic incoming email as imap_sync: true, and do the opposite when post is recovered.
This commit is contained in:
Martin Brennan
2020-08-12 10:16:26 +10:00
committed by GitHub
parent 6391db5921
commit 95b71b35d6
11 changed files with 508 additions and 20 deletions

View File

@ -13,7 +13,7 @@ class WebhooksController < ActionController::Base
def sendgrid
events = params["_json"] || [params]
events.each do |event|
message_id = (event["smtp-id"] || "").tr("<>", "")
message_id = Email.message_id_clean((event["smtp-id"] || ""))
to_address = event["email"]
if event["event"] == "bounce"
if event["status"]["4."]
@ -150,7 +150,7 @@ class WebhooksController < ActionController::Base
return mailgun_failure unless valid_mailgun_signature?(params["token"], params["timestamp"], params["signature"])
event = params["event"]
message_id = params["Message-Id"].tr("<>", "")
message_id = Email.message_id_clean(params["Message-Id"])
to_address = params["recipient"]
# only handle soft bounces, because hard bounces are also handled