diff options
author | RedMatrix <info@friendica.com> | 2014-07-29 18:25:25 +1000 |
---|---|---|
committer | RedMatrix <info@friendica.com> | 2014-07-29 18:25:25 +1000 |
commit | f09102157030c0cf49feff30e7368b8ddbd62444 (patch) | |
tree | c45a56dccd1a48c1180c56bd82b28cd3328e4683 /include | |
parent | 28c43395dc23beefccdb2a5b443bc0659a7fb808 (diff) | |
parent | d6d795efc92336936142db13a3d9fc2d720f2297 (diff) | |
download | volse-hubzilla-f09102157030c0cf49feff30e7368b8ddbd62444.tar.gz volse-hubzilla-f09102157030c0cf49feff30e7368b8ddbd62444.tar.bz2 volse-hubzilla-f09102157030c0cf49feff30e7368b8ddbd62444.zip |
Merge pull request #548 from tuscanhobbit/master
Chatroom lines are deleted after a while or the chat becomes slow to load
Diffstat (limited to 'include')
-rw-r--r-- | include/chat.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/chat.php b/include/chat.php index 4c79319ee..9d2341dfa 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,19 @@ 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) { + $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), + datetime_convert('','', $date_limit)); + return true; +} |