|
|
@@ -7,6 +7,8 @@ const response = require('../../utils/responseHandler')
|
|
|
const pemantauanModel = require('../../model/pemantauan.model')
|
|
|
const { notifWA } = require('../../utils/notifFunction')
|
|
|
const { TEMPLATE_PERBAIKAN_DOKUMEN } = require('../../utils/constanta')
|
|
|
+const kontakModel = require('../../model/kontak.model')
|
|
|
+const logModel = require('../../model/log.model')
|
|
|
|
|
|
exports.add = handleError(async (req, res) => {
|
|
|
const user = req.user
|
|
|
@@ -63,7 +65,7 @@ exports.add = handleError(async (req, res) => {
|
|
|
keterangan: 'Melakukan Perbaikan Dokumen',
|
|
|
dokumen: dokumen_id,
|
|
|
})
|
|
|
- await notifWA(TEMPLATE_PERBAIKAN_DOKUMEN, [
|
|
|
+ const notif = await notifWA(TEMPLATE_PERBAIKAN_DOKUMEN, [
|
|
|
{ key: '1', value: 'pt', value_text: sanksi.laporan.pt.nama },
|
|
|
{
|
|
|
key: '2',
|
|
|
@@ -72,6 +74,15 @@ exports.add = handleError(async (req, res) => {
|
|
|
},
|
|
|
{ key: '3', value: 'no_sanksi', value_text: sanksi.no_sanksi },
|
|
|
])
|
|
|
+
|
|
|
+ let contacts = await kontakModel.find()
|
|
|
+ contacts = contacts.map((e) => e.nama).join(', ')
|
|
|
+ if (notif[0].status == 'success') {
|
|
|
+ await logModel.create({
|
|
|
+ aktivitas: `Server berhasil mengirim notif wa kepada ${contacts} perihal Dokumen Perbaikan dari PT ${sanksi.laporan.pt.nama}`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
return response.success(res, {
|
|
|
data,
|
|
|
message: 'Berhasil menambah Perbaikan',
|