@@ -302,6 +302,7 @@ void NotificationClient::sendConnectionRequest()
302302
303303 connMsg[" payload" ] = payload;
304304
305+ Logger::debug (" Sending connection request to server: " + QJsonDocument (connMsg).toJson (QJsonDocument::Compact));
305306 sendMessage (connMsg);
306307}
307308
@@ -358,22 +359,42 @@ void NotificationClient::handleMessage(const QJsonObject& message)
358359 }
359360 }
360361 }
362+ else if (msgType == " notification_action" ) {
363+ if (m_handshakeComplete) {
364+ handleNotificationAction (message);
365+ }
366+ }
361367 else if (msgType == " ping" ) {
362368 Logger::debug (QString (" Received ping with ID: %1" ).arg (message.value (" id" ).toString ()));
363369 handlePing (message);
364370 }
365371 else {
366- Logger::warning (QString (" Unknown message type: %1" ).arg (msgType));
372+ Logger::warning (QString (" Unknown message type: %1, message: %2" )
373+ .arg (msgType, QJsonDocument (message).toJson (QJsonDocument::Compact)));
367374 }
368375}
369376
370377void NotificationClient::handlePing (const QJsonObject& message)
371378{
372379 QString pingId = message.value (" id" ).toString ();
373- Logger::debug (QString (" Sending pong response for ping ID: %1" ).arg (pingId));
374380 sendPong (pingId);
375381}
376382
383+ void NotificationClient::handleNotificationAction (const QJsonObject& message)
384+ {
385+ QJsonObject payload = message.value (" payload" ).toObject ();
386+ QString notificationId = payload.value (" id" ).toString ();
387+ QString actionType = payload.value (" type" ).toString ();
388+
389+ if (actionType == " notification_dismiss" ) {
390+ Logger::debug (QString (" Received dismiss action for notification: %1" ).arg (notificationId));
391+ emit notificationDismissed (notificationId);
392+ } else {
393+ // Handle other action types if needed in the future
394+ Logger::debug (QString (" Received notification action type '%1' for notification: %2" ).arg (actionType, notificationId));
395+ }
396+ }
397+
377398void NotificationClient::sendPong (const QString& pingId)
378399{
379400 QJsonObject pongMsg;
@@ -385,6 +406,7 @@ void NotificationClient::sendPong(const QString& pingId)
385406 payload[" device" ] = " Relay-PC" ;
386407 pongMsg[" payload" ] = payload;
387408
409+ Logger::debug (" Sending pong to server: " + QJsonDocument (pongMsg).toJson (QJsonDocument::Compact));
388410 sendMessage (pongMsg);
389411}
390412
@@ -404,6 +426,7 @@ void NotificationClient::sendNotificationReply(const QString& notificationId, co
404426 payload[" body" ] = replyText;
405427 actionMsg[" payload" ] = payload;
406428
429+ Logger::debug (" Sending notification reply to server: " + QJsonDocument (actionMsg).toJson (QJsonDocument::Compact));
407430 sendMessage (actionMsg);
408431}
409432
@@ -422,23 +445,26 @@ void NotificationClient::sendNotificationAction(const QString& notificationId, c
422445 payload[" type" ] = " action" ;
423446 actionMsg[" payload" ] = payload;
424447
448+ Logger::debug (" Sending notification action to server: " + QJsonDocument (actionMsg).toJson (QJsonDocument::Compact));
425449 sendMessage (actionMsg);
426450}
427451
428452void NotificationClient::sendNotificationDismiss (const QString& notificationId)
429453{
430454 if (!m_handshakeComplete) return ;
431455
432- QJsonObject dismissMsg ;
433- dismissMsg [" type" ] = " notification_dismiss " ;
434- dismissMsg [" id" ] = QUuid::createUuid ().toString (QUuid::WithoutBraces);
435- dismissMsg [" timestamp" ] = QDateTime::currentSecsSinceEpoch ();
456+ QJsonObject actionMsg ;
457+ actionMsg [" type" ] = " notification_action " ;
458+ actionMsg [" id" ] = QUuid::createUuid ().toString (QUuid::WithoutBraces);
459+ actionMsg [" timestamp" ] = QDateTime::currentSecsSinceEpoch ();
436460
437461 QJsonObject payload;
438462 payload[" id" ] = notificationId;
439- dismissMsg[" payload" ] = payload;
463+ payload[" type" ] = " notification_dismiss" ;
464+ actionMsg[" payload" ] = payload;
440465
441- sendMessage (dismissMsg);
466+ Logger::debug (" Sending notification dismiss to server: " + QJsonDocument (actionMsg).toJson (QJsonDocument::Compact));
467+ sendMessage (actionMsg);
442468}
443469
444470void NotificationClient::onReconnectTimer ()
0 commit comments