issues uncovered whilst testing the chatroom API
This commit is contained in:
parent
f84ba95e87
commit
10b51a9471
@ -23,8 +23,8 @@ function chatroom_create($channel,$arr) {
|
|||||||
$created = datetime_convert();
|
$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 )
|
$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' ) ",
|
values ( %d, %d , '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
|
||||||
intval($channel['account_id']),
|
intval($channel['channel_account_id']),
|
||||||
intval($channel['channel_id']),
|
intval($channel['channel_id']),
|
||||||
dbesc($name),
|
dbesc($name),
|
||||||
dbesc($created),
|
dbesc($created),
|
||||||
@ -34,6 +34,7 @@ function chatroom_create($channel,$arr) {
|
|||||||
dbesc($arr['deny_cid']),
|
dbesc($arr['deny_cid']),
|
||||||
dbesc($arr['deny_gid'])
|
dbesc($arr['deny_gid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if($x)
|
if($x)
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
|
|
||||||
@ -74,8 +75,8 @@ function chatroom_destroy($channel,$arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function chatroom_enter($observer_xchan,$room_id,$status) {
|
function chatroom_enter($observer_xchan,$room_id,$status,$client) {
|
||||||
if(! $room_id || ! $observer)
|
if(! $room_id || ! $observer_xchan)
|
||||||
return;
|
return;
|
||||||
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
|
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
|
||||||
dbesc($observer_xchan),
|
dbesc($observer_xchan),
|
||||||
@ -90,19 +91,20 @@ function chatroom_enter($observer_xchan,$room_id,$status) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("insert into chatpresence ( cp_room, cp_xchan, cp_last, cp_status )
|
$r = q("insert into chatpresence ( cp_room, cp_xchan, cp_last, cp_status, cp_client )
|
||||||
values ( %d, '%s', '%s', '%s' )",
|
values ( %d, '%s', '%s', '%s', '%s' )",
|
||||||
intval($room_id),
|
intval($room_id),
|
||||||
dbesc($observer_xchan),
|
dbesc($observer_xchan),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($status)
|
dbesc($status),
|
||||||
|
dbesc($client)
|
||||||
);
|
);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function chatroom_leave($observer_xchan,$room_id,$status) {
|
function chatroom_leave($observer_xchan,$room_id,$status) {
|
||||||
if(! $room_id || ! $observer)
|
if(! $room_id || ! $observer_xchan)
|
||||||
return;
|
return;
|
||||||
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
|
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
|
||||||
dbesc($observer_xchan),
|
dbesc($observer_xchan),
|
||||||
|
10
mod/ping.php
10
mod/ping.php
@ -44,18 +44,22 @@ function ping_init(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(get_observer_hash() && (! $result['invalid'])) {
|
if(get_observer_hash() && (! $result['invalid'])) {
|
||||||
$r = q("select cp_id from chatpresence where cp_xchan = '%s'",
|
$r = q("select cp_id from chatpresence where cp_xchan = '%s' and cp_client = '%s'",
|
||||||
dbesc(get_observer_hash())
|
dbesc(get_observer_hash()),
|
||||||
|
dbesc($_SERVER['REMOTE_ADDR'])
|
||||||
);
|
);
|
||||||
|
$basic_presence = false;
|
||||||
if($r) {
|
if($r) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
|
if($rr['cp_id'] == 0)
|
||||||
|
$basic_presence = true;
|
||||||
q("update chatpresence set cp_last = '%s' where cp_id = %d limit 1",
|
q("update chatpresence set cp_last = '%s' where cp_id = %d limit 1",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($rr['cp_id'])
|
intval($rr['cp_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
if(! $basic_presence) {
|
||||||
q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)
|
q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)
|
||||||
values( '%s', '%s', '%s', '%s' ) ",
|
values( '%s', '%s', '%s', '%s' ) ",
|
||||||
dbesc(get_observer_hash()),
|
dbesc(get_observer_hash()),
|
||||||
|
Reference in New Issue
Block a user