feat: implement reminder functionality and enhance notification service with logging
This commit is contained in:
@@ -301,7 +301,10 @@ const mqttOptions = {
|
||||
};
|
||||
|
||||
const mqttUrl = process.env.MQTT_HOST; // Ganti dengan broker kamu
|
||||
const topic = process.env.TOPIC_COD ?? 'morek';
|
||||
const topics = [
|
||||
process.env.TOPIC_COD ?? 'PIU_COD/ERROR_CODE',
|
||||
process.env.TOPIC_COD_REMINDER ?? 'PIU_COD/REMINDERSPAREPART'
|
||||
];
|
||||
|
||||
const mqttClient = mqtt.connect(mqttUrl, mqttOptions);
|
||||
|
||||
@@ -310,9 +313,9 @@ mqttClient.on('connect', () => {
|
||||
console.log('MQTT connected');
|
||||
|
||||
// Subscribe ke topik tertentu
|
||||
mqttClient.subscribe(topic, (err) => {
|
||||
mqttClient.subscribe(topics, (err) => {
|
||||
if (!err) {
|
||||
console.log(`Subscribed to topic "${topic}"`);
|
||||
console.log(`Subscribed to topic "${topics}"`);
|
||||
} else {
|
||||
console.error('Subscribe error:', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user