aboutsummaryrefslogtreecommitdiffstats
path: root/include/chat.php
diff options
context:
space:
mode:
authorPaolo Tacconi <p.tacconi@giunti.it>2014-07-29 09:06:04 +0200
committerPaolo Tacconi <p.tacconi@giunti.it>2014-07-29 09:06:04 +0200
commit87f5544f1f41aa67b03ee6b8810e235a4ee909bd (patch)
tree8dfd88f073e42cdf8699c972b8a8df0004e08b76 /include/chat.php
parent7b8edeaead0672708ad4a77d15f43bb97430cfdd (diff)
downloadvolse-hubzilla-87f5544f1f41aa67b03ee6b8810e235a4ee909bd.tar.gz
volse-hubzilla-87f5544f1f41aa67b03ee6b8810e235a4ee909bd.tar.bz2
volse-hubzilla-87f5544f1f41aa67b03ee6b8810e235a4ee909bd.zip
Chatroom lines are deleted after MAX_CHATROOM_HOURS or the chat becomes slow to load
Diffstat (limited to 'include/chat.php')
-rw-r--r--include/chat.php15
1 files changed, 15 insertions, 0 deletions
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;
+}