const axios = require('axios'); require('dotenv').config(); const ONESIGNAL_APP_ID = process.env.ONESIGNAL_APP_ID; const ONESIGNAL_REST_KEY = process.env.ONESIGNAL_REST_KEY; async function sendWelcomeEmail(email, username) { if (!ONESIGNAL_APP_ID || !ONESIGNAL_REST_KEY) return; const svgLogo = ` `; const htmlBody = `
${svgLogo}

Welcome, ${username}!

Thank you for subscribing to our email marketing. A small gift has been sent to your game email account; you can claim it anytime.

If you wish to avoid missing messages, events, or gift alerts, you can set our email address as a favorite in Gmail.

If you wish to cancel email notifications, you can do so at any time within the game via the Settings button in the Privacy section.


Thank you for your trust and support.

SkyData Studio | PowerShift


Privacy Policy | Terms of Service

`; try { await axios.post('https://onesignal.com/api/v1/notifications', { app_id: ONESIGNAL_APP_ID, include_email_tokens: [email], email_subject: "Welcome to SkyData | PowerShift", email_body: htmlBody }, { headers: { 'Authorization': `Basic ${ONESIGNAL_REST_KEY}`, 'Content-Type': 'application/json' } }); console.log(`Welcome email sent to ${email}`); } catch (err) { console.error("OneSignal Error:", err.response ? err.response.data : err.message); } } module.exports = { sendWelcomeEmail };