false, 'ERROR' => 'missing_params', 'MESSAGE' => 'TaskID is required']); } if ($readerType !== 'customer' && $readerType !== 'worker') { apiAbort(['OK' => false, 'ERROR' => 'missing_params', 'MESSAGE' => "ReaderType must be 'customer' or 'worker'"]); } try { $otherType = ($readerType === 'customer') ? 'worker' : 'customer'; queryTimed(" UPDATE ChatMessages SET IsRead = 1 WHERE TaskID = ? AND SenderType = ? AND IsRead = 0 ", [$taskID, $otherType]); jsonResponse(['OK' => true, 'MESSAGE' => 'Messages marked as read']); } catch (Exception $e) { jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]); }