bump: email service

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-14 13:58:14 +08:00
parent a7a72096a5
commit cd2ec55d82
+4 -6
View File
@@ -27,7 +27,6 @@ const { OAuth2Client } = require('google-auth-library');
const { emailTemplates } = require('../data/email_body.data');
const GMAIL_SEND_URL = 'https://gmail.googleapis.com/gmail/v1/users/me/messages/send';
const GMAIL_PROFILE_URL = 'https://gmail.googleapis.com/gmail/v1/users/me/profile';
// Lazily initialised so the module can be required before env is loaded.
let _oauth2Client;
@@ -85,10 +84,9 @@ const sendEmail = async ({ to, type, data = {} }) => {
}
};
// Confirms the refresh token is valid and the Gmail API is reachable.
const ping = async () => {
const accessToken = await getAccessToken();
await axios.get(GMAIL_PROFILE_URL, { headers: { Authorization: `Bearer ${accessToken}` } });
};
// Confirms the refresh token is valid and Gmail's OAuth endpoint is reachable.
// Deliberately doesn't call a Gmail read endpoint (e.g. users.getProfile) — the
// refresh token is scoped to gmail.send only, which doesn't grant read access.
const ping = () => getAccessToken();
module.exports = { sendEmail, ping };