From a1d40431f22e82b8e018dce65ced0801c40b20ff Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 30 Jan 2014 20:10:47 -0800 Subject: chat expiration (default 2 hours) - but can be set on a per-chatroom basis --- include/chat.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/chat.php b/include/chat.php index b88c63fc3..08fd154b5 100644 --- a/include/chat.php +++ b/include/chat.php @@ -31,16 +31,19 @@ function chatroom_create($channel,$arr) { return $ret; } + if(! array_key_exists('expire',$arr)) + $arr['expire'] = 120; // minutes, e.g. 2 hours $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 ) - values ( %d, %d , '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $x = q("insert into chatroom ( cr_aid, cr_uid, cr_name, cr_created, cr_edited, cr_expire, allow_cid, allow_gid, deny_cid, deny_gid ) + values ( %d, %d , '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel['channel_id']), dbesc($name), dbesc($created), dbesc($created), + intval($arr['expire']), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), @@ -111,6 +114,9 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) { return false; } + if(intval($x[0]['cr_expire'])) + $r = q("delete from chat where created < UTC_TIMESTAMP() - INTERVAL " . intval($x[0]['cr_expire']) . " MINUTE and chat_room = " . intval($x[0]['cr_id'])); + $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", dbesc($observer_xchan), intval($room_id) -- cgit v1.2.3