Add mutex around incoming email processing
This commit is contained in:
parent
2a5a01af2e
commit
80435cf2af
|
@ -39,12 +39,16 @@ module Email
|
||||||
|
|
||||||
def process!
|
def process!
|
||||||
return if is_blacklisted?
|
return if is_blacklisted?
|
||||||
@from_email, @from_display_name = parse_from_field(@mail)
|
DistributedMutex.synchronize(@message_id) do
|
||||||
@incoming_email = find_or_create_incoming_email
|
begin
|
||||||
process_internal
|
@from_email, @from_display_name = parse_from_field(@mail)
|
||||||
rescue => e
|
@incoming_email = find_or_create_incoming_email
|
||||||
@incoming_email.update_columns(error: e.to_s) if @incoming_email
|
process_internal
|
||||||
raise
|
rescue => e
|
||||||
|
@incoming_email.update_columns(error: e.to_s) if @incoming_email
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_blacklisted?
|
def is_blacklisted?
|
||||||
|
|
Loading…
Reference in New Issue