129 lines
3.9 KiB
JavaScript
129 lines
3.9 KiB
JavaScript
const { io } = require("socket.io-client");
|
|
|
|
const init = ()=>{
|
|
const socket = io(`ws://127.0.0.1:5000/gps`, {
|
|
reconnectionDelay: 20000,
|
|
reconnectionDelayMax: 20000,
|
|
auth: {
|
|
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NmM2ZmYyY2NkMDJiNTNkMzRkMjNiYTYiLCJpYXQiOjE3MjczNTQ3OTYsImV4cCI6MTcyOTk0Njc5Nn0.7W3ZsjZbW-fbbZWCX1wxJ8Wfmdro5wM7ow-b7xwE4Fk"
|
|
}
|
|
})
|
|
// eslint-disable-next-line node/handle-callback-err
|
|
socket.on('connect_error', err => {})
|
|
|
|
/// /////////////////////////////////////////// events
|
|
socket.on('connect', () => {
|
|
// console.log('**************** You have access to agent notifications')
|
|
socket.emit('gps:fetchNotifications')
|
|
})
|
|
|
|
socket.on(`gps:allNotifs`, data => {
|
|
console.log(data);
|
|
|
|
})
|
|
socket.on(`gps:notifications`, data => {
|
|
|
|
console.log(data);
|
|
|
|
})
|
|
|
|
socket.on(`gps:notify`, data => {
|
|
if (data.type === 'updateAgentInbox') {
|
|
// update store
|
|
console.log(data);
|
|
}
|
|
|
|
if (data.type === 'newAgentInbox') {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
})
|
|
|
|
|
|
|
|
}
|
|
init()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const nodemailer = require('nodemailer')
|
|
|
|
// function sendConfirmationEmail() {
|
|
// return new Promise(async (resolve, reject) => {
|
|
// try {
|
|
|
|
|
|
// /// //// email configs
|
|
// // const hostURL = 'www.asan-service.com'
|
|
// const transporter = nodemailer.createTransport({
|
|
// host: 'smtp.c1.liara.email',
|
|
// port: 587,
|
|
// secure: false, // true for 465, false for other ports
|
|
// auth: {
|
|
// user: 'awesome_bell_ncc1hi',
|
|
// pass: '509f8938-db95-4b8d-83e7-9ea8eccfd28b'
|
|
// },
|
|
// tls: {
|
|
// rejectUnauthorized: false
|
|
// }
|
|
// })
|
|
|
|
// const emailHTMLTemplate = `
|
|
// <div style="direction: rtl;background-color: #065495;overflow: hidden;">
|
|
// <div
|
|
// style="width: 70%;border-radius: 10px;margin: 150px auto;background: #fff;text-align: center;padding: 20px;box-shadow: 0 15px 30px #000;"
|
|
// >
|
|
// <h1 style="color: #000;font-size: 25px;margin-bottom: 20px;">
|
|
// <span> این ایمیل در وبسایت</span>
|
|
// <strong style="color: #065495"> آسان سرویس </strong>
|
|
// <span> ثبت شده است. </span>
|
|
// </h1>
|
|
// <p style="color: #000;">کد تایید آدرس ایمیل شما:</p>
|
|
// <div style="text-align: center;margin-top: 5px;">
|
|
// <p style="color: #065495;text-align: center;font-weight: bold;font-size: 20px;direction: ltr;">
|
|
// ${54534}
|
|
// </p>
|
|
// </div>
|
|
// </div>
|
|
// </div>
|
|
// `
|
|
|
|
// // send mail with defined transport object
|
|
// await transporter.sendMail({
|
|
// from: '"AsanService" <confirmation@asan-service.com>', // sender address
|
|
// to: "www.amir.com007@gmail.com", // list of receivers
|
|
// subject: 'تایید ایمیل',
|
|
// text: emailHTMLTemplate,
|
|
// html: emailHTMLTemplate
|
|
// })
|
|
|
|
// resolve()
|
|
// } catch (err) {
|
|
// reject(err)
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
// sendConfirmationEmail()
|