|
|
@@ -121,7 +121,7 @@ exports.reminderKeberatan = handleError(async (req, res) => {
|
|
|
})
|
|
|
.populate('user')
|
|
|
.populate('laporan')
|
|
|
- Promise.all(
|
|
|
+ const notif = await Promise.all(
|
|
|
dataSanksi.map(async (e) => {
|
|
|
if (
|
|
|
e.batas_waktu.jawaban_keberatan &&
|
|
|
@@ -166,8 +166,11 @@ exports.reminderKeberatan = handleError(async (req, res) => {
|
|
|
})
|
|
|
)
|
|
|
|
|
|
+ let message = 'Tidak ada notifikasi yang dikirim'
|
|
|
+ if (notif.length) message = 'Notifikasi berhasil terkirim'
|
|
|
+
|
|
|
return response.success(res, {
|
|
|
- message: 'Notifikasi berhasil terkirim',
|
|
|
+ message,
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -185,7 +188,7 @@ exports.reminderBanding = handleError(async (req, res) => {
|
|
|
})
|
|
|
.populate('user')
|
|
|
.populate('laporan')
|
|
|
- Promise.all(
|
|
|
+ const notif = await Promise.all(
|
|
|
dataSanksi.map(async (e) => {
|
|
|
if (
|
|
|
e.batas_waktu.jawaban_banding &&
|
|
|
@@ -230,7 +233,31 @@ exports.reminderBanding = handleError(async (req, res) => {
|
|
|
})
|
|
|
)
|
|
|
|
|
|
+ let message = 'Tidak ada notifikasi yang dikirim'
|
|
|
+ if (notif.length) message = 'Notifikasi berhasil terkirim'
|
|
|
+
|
|
|
return response.success(res, {
|
|
|
- message: 'Notifikasi berhasil terkirim',
|
|
|
+ message,
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+exports.updateStatusSanksi = handleError(async (req, res) => {
|
|
|
+ const sanksi = await sanksiModel.find({
|
|
|
+ 'masa_berlaku.to_date': {
|
|
|
+ $lte: new Date().toISOString(),
|
|
|
+ },
|
|
|
+ aktif: true,
|
|
|
+ })
|
|
|
+
|
|
|
+ Promise.all(
|
|
|
+ sanksi.map(async (e) =>
|
|
|
+ sanksiModel.findByIdAndUpdate(e._id, {
|
|
|
+ aktif: false,
|
|
|
+ })
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ return response.success(res, {
|
|
|
+ message: 'update status sanksi berhasil',
|
|
|
})
|
|
|
})
|