Commit 8be44224 authored by Internship UKSW 2019's avatar Internship UKSW 2019

Initial commit

parent 5354b7e3
......@@ -8,52 +8,49 @@ app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
const sendEmail = (request, response) => {
const {subject, emailcc, emailsend, message} = request.body
nodemailer.createTestAccount((err, account) => {
const htmlEmail = `
const { subject, emailcc, emailsend, message } = request.body
const htmlEmail = `
<p>${message}</p>
`
let transporter = nodemailer.createTransport({
// host: 'smtp.gmail.com',
// service: 'Gmail',
host: 'mta.visionet.co.id',
port: 587,
secure: false,
auth: {
user: 'prastowo.nugroho.int@visionet.co.id',
pass: '02Maret2020'
},
tls: {
rejectUnauthorized: false
}
// debug: true
// auth: {
// user: 'vdocmanagement@gmail.com',
// pass: 'docmgmt123'
// },
})
let maillist = [
emailsend
]
maillist.forEach(function (to, i, array) {
let mailOptions = {
from: 'prastowo.nugroho.int@visionet.co.id',//'vdocmanagement@gmail.com'
cc: emailcc,
subject: subject,
text: message,
html: htmlEmail
let transporter = nodemailer.createTransport({
// host: 'smtp.gmail.com',
// service: 'Gmail',
host: 'mta.visionet.co.id',
port: 587,
secure: false,
auth: {
user: 'prastowo.nugroho.int@visionet.co.id',
pass: '02Maret2020'
},
tls: {
rejectUnauthorized: false
}
// debug: true
// auth: {
// user: 'vdocmanagement@gmail.com',
// pass: 'docmgmt123'
// },
})
let maillist = [
emailsend
]
maillist.forEach(function (to, i, array) {
let mailOptions = {
from: 'prastowo.nugroho.int@visionet.co.id',//'vdocmanagement@gmail.com'
cc: emailcc,
subject: subject,
text: message,
html: htmlEmail
}
mailOptions.to = to;
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
throw error
}
mailOptions.to = to;
transporter.sendMail(mailOptions, (error, info) => {
if (err) {
throw error
}
console.log('Message sent: %s', info.message)
console.log('Message URL: %s', nodemailer.getTestMessageUrl(info))
response.status(200).json({ status: 'success', message: 'Email has been sent' })
})
// console.log('Message sent:', info.response)
response.status(200).json({ status: 'success', message: 'Email has been sent' })
})
})
}
......@@ -94,50 +91,50 @@ const updateDocument = (request, response) => {
}
const deleteDocument = (request, response) => {
const {doc_id} = request.body
const { doc_id } = request.body
pool.query('DELETE FROM document WHERE doc_id = $1', [doc_id], (error, results) => {
if (error) {
throw error
}
response.status(200).send(`Document deleted with ID: ${doc_id}`)
}
}
)
}
const deleteRevision = (request, response) => {
const {doc_id} = request.body
const { doc_id } = request.body
pool.query('DELETE FROM revision WHERE doc_id = $1', [doc_id], (error, results) => {
if (error) {
throw error
}
response.status(200).send(`Revision deleted with doc_id: ${doc_id}`)
}
}
)
}
const deleteContent = (request, response) => {
const {cont_id} = request.body
const { cont_id } = request.body
pool.query('DELETE FROM content WHERE cont_id = $1', [cont_id], (error, results) => {
if (error) {
throw error
}
response.status(200).send(`Content deleted with cont_id: ${cont_id}`)
}
}
)
}
const deleteUser = (request, response) => {
const {email} = request.body
const { email } = request.body
pool.query('DELETE FROM user_data WHERE email = $1', [email], (error, results) => {
if (error) {
throw error
}
response.status(200).send(`User deleted with Email: ${email}`)
}
}
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment