Active channels information is a bit imprecise. Provide a higher accuracy method. This will require a transition period

This commit is contained in:
zotlabs 2018-04-16 21:40:43 -07:00
parent 120e578a67
commit 43e55eb9a6
6 changed files with 26 additions and 2 deletions

View File

@ -54,7 +54,7 @@ define ( 'STD_VERSION', '3.3.5' );
define ( 'ZOT_REVISION', '6.0a' );
define ( 'DB_UPDATE_VERSION', 1210 );
define ( 'DB_UPDATE_VERSION', 1211 );
define ( 'PROJECT_BASE', __DIR__ );

View File

@ -2563,7 +2563,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
q("DELETE FROM photo WHERE uid = %d", intval($channel_id));
q("DELETE FROM attach WHERE uid = %d", intval($channel_id));
q("DELETE FROM profile WHERE uid = %d", intval($channel_id));
q("DELETE FROM src WHERE src_channel_id = %d", intval($channel_id));
q("DELETE FROM source WHERE src_channel_id = %d", intval($channel_id));
$r = q("select hash FROM attach WHERE uid = %d", intval($channel_id));
if($r) {

View File

@ -266,6 +266,15 @@ function change_channel($change_channel) {
$_SESSION['mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme');
$_SESSION['cloud_tiles'] = get_pconfig(local_channel(),'system', 'cloud_tiles');
date_default_timezone_set($r[0]['channel_timezone']);
// Update the active timestamp at most once a day
if(substr($r[0]['channel_active'],0,10) !== substr(datetime_convert(),0,10)) {
$z = q("UPDATE channel SET channel_active = '%s' WHERE channel_id = %d",
dbesc(datetime_convert()),
intval($r[0]['channel_id'])
);
}
$ret = $r[0];
}
$x = q("select * from xchan where xchan_hash = '%s' limit 1",

View File

@ -3208,6 +3208,9 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$channel = $r[0];
// don't provide these in the export
unset($channel['channel_active']);
unset($channel['channel_password']);
unset($channel['channel_salt']);
@ -3474,6 +3477,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
continue;
}
// if the clone is active, so are we
if(substr($channel['channel_active'],0,10) !== substr(datetime_convert(),0,10)) {
q("UPDATE channel set channel_active = '%s' where channel_id = %d",
dbesc(datetime_convert()),
intval($channel['channel_id'])
);
}
if(array_key_exists('config',$arr) && is_array($arr['config']) && count($arr['config'])) {
foreach($arr['config'] as $cat => $k) {

View File

@ -259,6 +259,7 @@ CREATE TABLE IF NOT EXISTS `channel` (
`channel_dirdate` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`channel_lastpost` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`channel_deleted` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`channel_active` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`channel_max_anon_mail` int(10) unsigned NOT NULL DEFAULT 10,
`channel_max_friend_req` int(10) unsigned NOT NULL DEFAULT 10,
`channel_expire_days` int(11) NOT NULL DEFAULT 0 ,
@ -308,6 +309,7 @@ CREATE TABLE IF NOT EXISTS `channel` (
KEY `channel_hash` (`channel_hash`),
KEY `channel_expire_days` (`channel_expire_days`),
KEY `channel_deleted` (`channel_deleted`),
KEY `channel_active` (`channel_active`),
KEY `channel_dirdate` (`channel_dirdate`),
KEY `channel_removed` (`channel_removed`),
KEY `channel_system` (`channel_system`),

View File

@ -252,6 +252,7 @@ CREATE TABLE "channel" (
"channel_dirdate" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"channel_lastpost" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"channel_deleted" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"channel_active" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"channel_max_anon_mail" bigint NOT NULL DEFAULT '10',
"channel_max_friend_req" bigint NOT NULL DEFAULT '10',
"channel_expire_days" bigint NOT NULL DEFAULT '0',
@ -284,6 +285,7 @@ create index "channel_guid" on channel ("channel_guid");
create index "channel_hash" on channel ("channel_hash");
create index "channel_expire_days" on channel ("channel_expire_days");
create index "channel_deleted" on channel ("channel_deleted");
create index "channel_active" on channel ("channel_active");
create index "channel_dirdate" on channel ("channel_dirdate");
create index "channel_lastpost" on channel ("channel_lastpost");
create index "channel_removed" on channel ("channel_removed");