Skip to content

Commit 04c3c0f

Browse files
committed
Fix more edge cases
1 parent 7726522 commit 04c3c0f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

lib/workers/send_gmail_notification.ex

+15-8
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,29 @@ defmodule ChatApi.Workers.SendGmailNotification do
4747
last_from
4848
end
4949

50+
cc =
51+
case Google.Gmail.extract_email_address(gmail_cc) do
52+
cc when is_binary(cc) -> cc
53+
_ -> []
54+
end
55+
56+
references =
57+
case gmail_references do
58+
ref when is_binary(ref) -> ref <> " " <> gmail_message_id
59+
_ -> gmail_message_id
60+
end
61+
5062
payload = %{
5163
from: from,
52-
subject: "Re: " <> gmail_initial_subject,
64+
subject: "Re: #{gmail_initial_subject}",
5365
text: body,
5466
to: to,
67+
cc: cc,
5568
in_reply_to: gmail_message_id,
56-
references: gmail_references <> " " <> gmail_message_id,
69+
references: references,
5770
thread_id: gmail_thread_id
5871
}
5972

60-
payload =
61-
case Google.Gmail.extract_email_address(gmail_cc) do
62-
cc when is_binary(cc) -> Map.merge(payload, %{cc: cc})
63-
_ -> payload
64-
end
65-
6673
Logger.info("Sending payload to Gmail: #{inspect(payload)}")
6774

6875
%{"id" => gmail_message_id, "threadId" => ^gmail_thread_id} =

0 commit comments

Comments
 (0)