yazid138 3 years ago
parent
commit
49b8cf0eab
1 changed files with 20 additions and 0 deletions
  1. 20 0
      controller/laporan.controller.js

+ 20 - 0
controller/laporan.controller.js

@@ -63,6 +63,26 @@ exports.create = handleError(async (req, res) => {
   }
 
   data = await laporanModel.create(data)
+
+  const notif = await notifWA(TEMPLATE_LAPORAN, [
+    {
+      key: '1',
+      value: 'nama',
+      value_text: user.nama,
+    },
+    { key: '2', value: 'pt', value_text: pt[0].nama },
+    { key: '3', value: 'keterangan', value_text: keterangan },
+    { key: '4', value: 'no_laporan', value_text: no_laporan },
+  ])
+
+  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} untuk Pembuatan Laporan`,
+    })
+  }
+
   await pemantauanModel.create({
     laporan: data._id,
     action: 'CREATE LAPORAN',