From 87f5544f1f41aa67b03ee6b8810e235a4ee909bd Mon Sep 17 00:00:00 2001 From: Paolo Tacconi Date: Tue, 29 Jul 2014 09:06:04 +0200 Subject: Chatroom lines are deleted after MAX_CHATROOM_HOURS or the chat becomes slow to load --- include/chat.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/chat.php') diff --git a/include/chat.php b/include/chat.php index 4c79319ee..2a978ed7c 100644 --- a/include/chat.php +++ b/include/chat.php @@ -152,6 +152,8 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) { dbesc($status), dbesc($client) ); + + chatroom_flush($room_id,$xchan); return $r; } @@ -224,5 +226,18 @@ function chat_message($uid,$room_id,$xchan,$text) { ); $ret['success'] = true; + chatroom_flush($room_id,$xchan); return $ret; } + +/** + * Reduces the number of lines shown in chat by removing those older than MAX_CHATROOM_HOURS + */ + +function chatroom_flush($room_id,$xchan) { + $d = q("delete from chat where chat_room = %d and chat_xchan = '%s' and created < '%s'", + intval($room_id), + dbesc($xchan), + datetime_convert('','', $date_limit)); + return true; +} -- cgit v1.2.3 From d6d795efc92336936142db13a3d9fc2d720f2297 Mon Sep 17 00:00:00 2001 From: Paolo Tacconi Date: Tue, 29 Jul 2014 09:41:43 +0200 Subject: deleted a command with debug code --- include/chat.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/chat.php') diff --git a/include/chat.php b/include/chat.php index 2a978ed7c..9d2341dfa 100644 --- a/include/chat.php +++ b/include/chat.php @@ -235,6 +235,7 @@ function chat_message($uid,$room_id,$xchan,$text) { */ function chatroom_flush($room_id,$xchan) { + $date_limit = date('Y-m-d H:i:s', time() - 3600 * MAX_CHATROOM_HOURS); $d = q("delete from chat where chat_room = %d and chat_xchan = '%s' and created < '%s'", intval($room_id), dbesc($xchan), -- cgit v1.2.3