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

Initial commit

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