Skip to content

Commit

Permalink
fix: resolve email issue (#6)
Browse files Browse the repository at this point in the history
* feat: add success_with_message

* feat: return message based on send mail function

* chore: update mail api key

* docs: add send email via MailJet
  • Loading branch information
Lzyct authored Jul 30, 2024
1 parent 0128be0 commit 45cc47e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ CLIENT_SECRET=auth_app_secret

# This email client is use mailjet.com
# You can use your own email client API key and secret key
MAIL_API_KEY=f44503037b2a83567e92c7e4cf318e64
MAIL_SECRET_KEY=2af60f86612c7dfcebfbda85c675c877
MAIL_API_KEY=your_mailjet_api_key
MAIL_SECRET_KEY=your_mailjet_secret_key

APP_HOST=localhost
APP_PORT=8000
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ cargo build
- [ ] Refresh token
- [ ] Forgot password
- [x] Update password
- [x] Send Email via [MailJet](https://app.mailjet.com)
- [ ] Email verification
- [ ] Create Tests
- [x] Create docker-compose to build the project
Expand Down
7 changes: 7 additions & 0 deletions src/core/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ impl<T> ResponseBody<T> {
data,
}
}
pub fn success_with_message(data: Option<T>, message: &str) -> ResponseBody<T> {
let data = data;
ResponseBody {
diagnostic: Diagnostic::new(STATUS_SUCCESS, message),
data,
}
}
}

#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/features/general/general_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ pub async fn test_email(
})?;
send_email(params.0)
.await
.map(|_| ResponseBody::<()>::success(None).into())
.map(|message| ResponseBody::<()>::success_with_message( None,message.as_str()).into())
}
2 changes: 1 addition & 1 deletion src/utils/mail_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub async fn send_email(params: SendEmailParams) -> AppResult<String> {
let mut message = json!({
"From":{
"Email": "lzyct@lazycatlabs.com",
"Name": "LazyCatLabs"
"Name": "Lazycat Labs"
},
"To": [
{
Expand Down

0 comments on commit 45cc47e

Please sign in to comment.