From 97530814070a2572c07223a3dc2da21ad3e75b80 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 22 Oct 2014 14:34:06 +0000 Subject: [PATCH] Sent "Visitor closed chat window" message only if there was a chat --- src/mibew/libs/classes/Mibew/Thread.php | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mibew/libs/classes/Mibew/Thread.php b/src/mibew/libs/classes/Mibew/Thread.php index 083b8023..8aee297d 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -620,18 +620,20 @@ class Thread // Update user's last ping time $this->lastPingUser = 0; - // And send a message to operator - $message_to_post = getlocal( - 'Visitor closed chat window', - null, - $this->locale, - true - ); - $this->postMessage( - self::KIND_FOR_AGENT, - $message_to_post, - array('created' => $last_ping_other_side + self::CONNECTION_TIMEOUT) - ); + // And send a message to operator. + if ($this->state == self::STATE_CHATTING) { + $message_to_post = getlocal( + 'Visitor closed chat window', + null, + $this->locale, + true + ); + $this->postMessage( + self::KIND_FOR_AGENT, + $message_to_post, + array('created' => $last_ping_other_side + self::CONNECTION_TIMEOUT) + ); + } } }