Skip to content

Commit

Permalink
fix normal emails
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaffrey committed Aug 22, 2024
1 parent 1bf4ef2 commit 02d1c88
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/request/messages_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ impl<'a> ::std::future::IntoFuture for FluentRequest<'a, MessagesSendRequest> {
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = &format!(
"/gmail/v1/users/{user_id}/messages/send",
user_id = self.params.user_id
);

let mut r = self.client.client.post(url);

if let Some(thread_id) = &self.params.thread_id {
let mut r = if let Some(thread_id) = &self.params.thread_id {
let url = format!("/gmail/v1/users/{}/messages/send", self.params.user_id);
let encoded_message = URL_SAFE.encode(self.params.message.bytes().unwrap());
r = r.json(json!({"raw": encoded_message, "threadId": self.params.thread_id}));
self.client.client.post(&url)
.json(json!({"raw": encoded_message, "threadId": thread_id}))
} else {
r = r.content_type("message/rfc822").body(self.params.message);
}
let url = format!("/upload/gmail/v1/users/{}/messages/send", self.params.user_id);
self.client.client.post(&url)
.content_type("message/rfc822")
.body(self.params.message)
};

r = self.client.authenticate(r);
let res = r.await?;
Expand Down

0 comments on commit 02d1c88

Please sign in to comment.