Merge pull request #548 from tuscanhobbit/master
Chatroom lines are deleted after a while or the chat becomes slow to load
This commit is contained in:
commit
f091021570
5
boot.php
5
boot.php
@ -358,6 +358,11 @@ define ( 'MAX_LIKERS', 10);
|
|||||||
|
|
||||||
define ( 'ZCURL_TIMEOUT' , (-1));
|
define ( 'ZCURL_TIMEOUT' , (-1));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hours before chat lines are deleted
|
||||||
|
*/
|
||||||
|
|
||||||
|
define ( 'MAX_CHATROOM_HOURS' , 36);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* email notification options
|
* email notification options
|
||||||
|
@ -152,6 +152,8 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
|
|||||||
dbesc($status),
|
dbesc($status),
|
||||||
dbesc($client)
|
dbesc($client)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
chatroom_flush($room_id,$xchan);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,5 +226,19 @@ function chat_message($uid,$room_id,$xchan,$text) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
|
chatroom_flush($room_id,$xchan);
|
||||||
return $ret;
|
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;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user