From 838ebbcb62aaaca8f19e338fe89c484f9d4ececd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 29 Jan 2014 18:29:03 -0800 Subject: apply service class limits (at the account level) to chatroom creation as chat has the potential to adversely affect system performance. In the future we may also want to service_class restrict the number of participants in a room. --- include/chat.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/chat.php b/include/chat.php index a8c3db429..aef154fe6 100644 --- a/include/chat.php +++ b/include/chat.php @@ -20,6 +20,18 @@ function chatroom_create($channel,$arr) { return $ret; } + $r = q("select count(cr_id) as total from chatroom where cr_aid = %d", + intval($channel['channel_account_id']) + ); + if($r) + $limit = service_class_fetch($channel_id,'chatrooms'); + + if(($r) && ($limit !== false) && ($r[0]['total'] >= $limit)) { + $ret['message'] = upgrade_message(); + return $ret; + } + + $created = datetime_convert(); $x = q("insert into chatroom ( cr_aid, cr_uid, cr_name, cr_created, cr_edited, allow_cid, allow_gid, deny_cid, deny_gid ) -- cgit v1.2.3