Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
This commit is contained in:
		| @@ -61,30 +61,15 @@ class Queue { | |||||||
| 			// the site is permanently down, there's no reason to attempt delivery at all, or at most not more than once  | 			// the site is permanently down, there's no reason to attempt delivery at all, or at most not more than once  | ||||||
| 			// or twice a day.  | 			// or twice a day.  | ||||||
| 	 | 	 | ||||||
| 			// FIXME: can we sort postgres on outq_priority and maintain the 'distinct' ? | 			$r = q("SELECT * FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s ", | ||||||
| 			// The order by max(outq_priority) might be a dodgy query because of the group by. | 				db_utcnow() | ||||||
| 			// The desired result is to return a sequence in the order most likely to be delivered in this run. |  | ||||||
| 			// If a hub has already been sitting in the queue for a few days, they should be delivered last; |  | ||||||
| 			// hence every failure should drop them further down the priority list. |  | ||||||
|   |  | ||||||
| 			if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { |  | ||||||
| 				$prefix = 'DISTINCT ON (outq_posturl)'; |  | ||||||
| 				$suffix = 'ORDER BY outq_posturl'; |  | ||||||
| 			} else { |  | ||||||
| 				$prefix = ''; |  | ||||||
| 				$suffix = 'GROUP BY outq_posturl ORDER BY max(outq_priority)'; |  | ||||||
| 			} |  | ||||||
| 			$r = q("SELECT $prefix * FROM outq WHERE outq_delivered = 0 and (( outq_created > %s - INTERVAL %s and outq_updated < %s - INTERVAL %s ) OR ( outq_updated < %s - INTERVAL %s )) $suffix", |  | ||||||
| 				db_utcnow(), db_quoteinterval('12 HOUR'), |  | ||||||
| 				db_utcnow(), db_quoteinterval('15 MINUTE'), |  | ||||||
| 				db_utcnow(), db_quoteinterval('1 HOUR') |  | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 		if(! $r) | 		if(! $r) | ||||||
| 			return; | 			return; | ||||||
|  |  | ||||||
| 		foreach($r as $rr) { | 		foreach($r as $rv) { | ||||||
| 			queue_deliver($rr); | 			queue_deliver($rv); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -248,23 +248,25 @@ class Import extends \Zotlabs\Web\Controller { | |||||||
| 					dbesc($channel['channel_hash']) | 					dbesc($channel['channel_hash']) | ||||||
| 				); | 				); | ||||||
|  |  | ||||||
| 				$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d )", |  | ||||||
| 					dbesc($channel['channel_hash']), | 				$r = xchan_store_lowlevel( | ||||||
| 					dbesc($channel['channel_guid']), | 					[ | ||||||
| 					dbesc($channel['channel_guid_sig']), | 						'xchan_hash'           => $channel['channel_hash'], | ||||||
| 					dbesc($channel['channel_pubkey']), | 						'xchan_guid'           => $channel['channel_guid'], | ||||||
| 					dbesc(z_root() . "/photo/profile/l/" . $channel['channel_id']), | 						'xchan_guid_sig'       => $channel['channel_guid_sig'], | ||||||
| 					dbesc(z_root() . "/photo/profile/m/" . $channel['channel_id']), | 						'xchan_pubkey'         => $channel['channel_pubkey'], | ||||||
| 					dbesc(z_root() . "/photo/profile/s/" . $channel['channel_id']), | 						'xchan_photo_l'        => z_root() . "/photo/profile/l/" . $channel['channel_id'], | ||||||
| 					dbesc(channel_reddress($channel)), | 						'xchan_photo_m'        => z_root() . "/photo/profile/m/" . $channel['channel_id'], | ||||||
| 					dbesc(z_root() . '/channel/' . $channel['channel_address']), | 						'xchan_photo_s'        => z_root() . "/photo/profile/s/" . $channel['channel_id'], | ||||||
| 					dbesc(z_root() . '/follow?f=&url=%s'), | 						'xchan_addr'           => channel_reddress($channel), | ||||||
| 					dbesc(z_root() . '/poco/' . $channel['channel_address']), | 						'xchan_url'            => z_root() . '/channel/' . $channel['channel_address'], | ||||||
| 					dbesc($channel['channel_name']), | 						'xchan_connurl'        => z_root() . '/poco/' . $channel['channel_address'], | ||||||
| 					dbesc('zot'), | 						'xchan_follow'         => z_root() . '/follow?f=&url=%s', | ||||||
| 					dbesc(datetime_convert()), | 						'xchan_name'           => $channel['channel_name'], | ||||||
| 					dbesc(datetime_convert()), | 						'xchan_network'        => 'zot', | ||||||
| 					0,0,0,0,0,0,0 | 						'xchan_photo_date'     => datetime_convert(), | ||||||
|  | 						'xchan_name_date'      => datetime_convert() | ||||||
|  | 					] | ||||||
| 				);	 | 				);	 | ||||||
| 			} | 			} | ||||||
| 			logger('import step 6'); | 			logger('import step 6'); | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								boot.php
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								boot.php
									
									
									
									
									
								
							| @@ -45,13 +45,14 @@ require_once('include/channel.php'); | |||||||
| require_once('include/connections.php'); | require_once('include/connections.php'); | ||||||
| require_once('include/account.php'); | require_once('include/account.php'); | ||||||
| require_once('include/zid.php'); | require_once('include/zid.php'); | ||||||
|  | require_once('include/xchan.php'); | ||||||
|  |  | ||||||
|  |  | ||||||
| define ( 'PLATFORM_NAME',           'hubzilla' ); | define ( 'PLATFORM_NAME',           'hubzilla' ); | ||||||
| define ( 'STD_VERSION',             '2.1' ); | define ( 'STD_VERSION',             '2.1' ); | ||||||
| define ( 'ZOT_REVISION',            '1.2' ); | define ( 'ZOT_REVISION',            '1.2' ); | ||||||
|  |  | ||||||
| define ( 'DB_UPDATE_VERSION',       1187  ); | define ( 'DB_UPDATE_VERSION',       1188  ); | ||||||
|  |  | ||||||
| define ( 'PROJECT_BASE',   __DIR__ ); | define ( 'PROJECT_BASE',   __DIR__ ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -311,23 +311,25 @@ function create_identity($arr) { | |||||||
|  |  | ||||||
| 	$newuid = $ret['channel']['channel_id']; | 	$newuid = $ret['channel']['channel_id']; | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", | 	$r = xchan_store_lowlevel( | ||||||
| 		dbesc($hash), | 		[ | ||||||
| 		dbesc($guid), | 			'xchan_hash'       => $hash, | ||||||
| 		dbesc($sig), | 			'xchan_guid'       => $guid, | ||||||
| 		dbesc($key['pubkey']), | 			'xchan_guid_sig'   => $sig, | ||||||
| 		dbesc(z_root() . "/photo/profile/l/{$newuid}"), | 			'xchan_pubkey'     => $key['pubkey'], | ||||||
| 		dbesc(z_root() . "/photo/profile/m/{$newuid}"), | 			'xchan_photo_l'    => z_root() . "/photo/profile/l/{$newuid}", | ||||||
| 		dbesc(z_root() . "/photo/profile/s/{$newuid}"), | 			'xchan_photo_m'    => z_root() . "/photo/profile/m/{$newuid}", | ||||||
| 		dbesc(channel_reddress($ret['channel'])), | 			'xchan_photo_s'    => z_root() . "/photo/profile/s/{$newuid}", | ||||||
| 		dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']), | 			'xchan_addr'       => channel_reddress($ret['channel']), | ||||||
| 		dbesc(z_root() . '/follow?f=&url=%s'), | 			'xchan_url'        => z_root() . '/channel/' . $ret['channel']['channel_address'], | ||||||
| 		dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']), | 			'xchan_follow'     => z_root() . '/follow?f=&url=%s', | ||||||
| 		dbesc($ret['channel']['channel_name']), | 			'xchan_connurl'    => z_root() . '/poco/' . $ret['channel']['channel_address'], | ||||||
| 		dbesc('zot'), | 			'xchan_name'       => $ret['channel']['channel_name'], | ||||||
| 		dbesc(datetime_convert()), | 			'xchan_network'    => 'zot', | ||||||
| 		dbesc(datetime_convert()), | 			'xchan_photo_date' => datetime_convert(), | ||||||
| 		intval($system) | 			'xchan_name_date'  => datetime_convert(), | ||||||
|  | 			'xchan_system'     => $system | ||||||
|  | 		] | ||||||
| 	); | 	); | ||||||
|  |  | ||||||
| 	// Not checking return value. | 	// Not checking return value. | ||||||
|   | |||||||
| @@ -176,110 +176,6 @@ function hubloc_mark_as_down($posturl) { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| function xchan_store($arr) { |  | ||||||
|  |  | ||||||
| 	logger('xchan_store: ' . print_r($arr,true)); |  | ||||||
|  |  | ||||||
| 	if(! $arr['hash']) |  | ||||||
| 		$arr['hash'] = $arr['guid']; |  | ||||||
| 	if(! $arr['hash']) |  | ||||||
| 		return false; |  | ||||||
|  |  | ||||||
| 	$r = q("select * from xchan where xchan_hash = '%s' limit 1", |  | ||||||
| 		dbesc($arr['hash']) |  | ||||||
| 	); |  | ||||||
| 	if($r) |  | ||||||
| 		return true; |  | ||||||
|  |  | ||||||
| 	if(! $arr['network']) |  | ||||||
| 		$arr['network'] = 'unknown'; |  | ||||||
| 	if(! $arr['name']) |  | ||||||
| 		$arr['name'] = 'unknown'; |  | ||||||
| 	if(! $arr['url']) |  | ||||||
| 		$arr['url'] = z_root(); |  | ||||||
| 	if(! $arr['photo']) |  | ||||||
| 		$arr['photo'] = z_root() . '/' . get_default_profile_photo(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 	if($arr['network'] === 'zot') { |  | ||||||
| 		if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) { |  | ||||||
| 			logger('Unable to verify signature for ' . $arr['hash']); |  | ||||||
| 			return false; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d, %d, %d, %d, %d, %d, %d, '%s') ", |  | ||||||
| 		dbesc($arr['hash']), |  | ||||||
| 		dbesc($arr['guid']), |  | ||||||
| 		dbesc($arr['guid_sig']), |  | ||||||
| 		dbesc($arr['pubkey']), |  | ||||||
| 		dbesc($arr['address']), |  | ||||||
| 		dbesc($arr['url']), |  | ||||||
| 		dbesc($arr['connurl']), |  | ||||||
| 		dbesc($arr['follow']), |  | ||||||
| 		dbesc($arr['connpage']), |  | ||||||
| 		dbesc($arr['name']), |  | ||||||
| 		dbesc($arr['network']), |  | ||||||
| 		dbesc($arr['instance_url']), |  | ||||||
| 		intval($arr['hidden']), |  | ||||||
| 		intval($arr['orphan']), |  | ||||||
| 		intval($arr['censored']), |  | ||||||
| 		intval($arr['selfcensored']), |  | ||||||
| 		intval($arr['system']), |  | ||||||
| 		intval($arr['pubforum']), |  | ||||||
| 		intval($arr['deleted']), |  | ||||||
| 		dbesc(datetime_convert()) |  | ||||||
| 	); |  | ||||||
| 	if(! $r) |  | ||||||
| 		return $r; |  | ||||||
|  |  | ||||||
| 	$photos = import_xchan_photo($arr['photo'],$arr['hash']); |  | ||||||
| 	$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", |  | ||||||
| 		dbesc(datetime_convert()), |  | ||||||
| 		dbesc($photos[0]), |  | ||||||
| 		dbesc($photos[1]), |  | ||||||
| 		dbesc($photos[2]), |  | ||||||
| 		dbesc($photos[3]), |  | ||||||
| 		dbesc($arr['hash']) |  | ||||||
| 	); |  | ||||||
| 	return $r; |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| function xchan_fetch($arr) { |  | ||||||
|  |  | ||||||
| 	$key = ''; |  | ||||||
| 	if($arr['hash']) { |  | ||||||
| 		$key = 'xchan_hash'; |  | ||||||
| 		$v = $arr['hash']; |  | ||||||
| 	} |  | ||||||
| 	elseif($arr['guid']) { |  | ||||||
| 		$key = 'xchan_guid'; |  | ||||||
| 		$v = $arr['guid']; |  | ||||||
| 	} |  | ||||||
| 	elseif($arr['address']) { |  | ||||||
| 		$key = 'xchan_addr'; |  | ||||||
| 		$v = $arr['address']; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if(! $key) |  | ||||||
| 		return false; |  | ||||||
|  |  | ||||||
| 	$r = q("select * from xchan where $key = '$v' limit 1"); |  | ||||||
| 	if(! $r) |  | ||||||
| 		return false; |  | ||||||
|  |  | ||||||
| 	$ret = array(); |  | ||||||
| 	foreach($r[0] as $k => $v) { |  | ||||||
| 		if($k === 'xchan_addr') |  | ||||||
| 			$ret['address'] = $v; |  | ||||||
| 		else |  | ||||||
| 			$ret[str_replace('xchan_','',$k)] = $v; |  | ||||||
| 	} |  | ||||||
| 	return $ret; |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| function ping_site($url) { | function ping_site($url) { | ||||||
|   | |||||||
| @@ -833,13 +833,15 @@ function import_author_rss($x) { | |||||||
| 	} | 	} | ||||||
| 	$name = trim($x['name']); | 	$name = trim($x['name']); | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_url, xchan_name, xchan_network ) | 	$r = xchan_store_lowlevel( | ||||||
| 		values ( '%s', '%s', '%s', '%s', '%s' )", | 		[ | ||||||
| 		dbesc($x['guid']), | 			'xchan_hash'         => $x['guid'], | ||||||
| 		dbesc($x['guid']), | 			'xchan_guid'         => $x['guid'], | ||||||
| 		dbesc($x['url']), | 			'xchan_url'          => $x['url'], | ||||||
| 		dbesc(($name) ? $name : t('(Unknown)')), | 			'xchan_name'         => (($name) ? $name : t('(Unknown)')), | ||||||
| 		dbesc('rss') | 			'xchan_name_date'    => datetime_convert(), | ||||||
|  | 			'xchan_network'      => 'rss' | ||||||
|  | 		] | ||||||
| 	); | 	); | ||||||
|  |  | ||||||
| 	if($r && $x['photo']) { | 	if($r && $x['photo']) { | ||||||
| @@ -878,14 +880,17 @@ function import_author_unknown($x) { | |||||||
|  |  | ||||||
| 	$name = trim($x['name']); | 	$name = trim($x['name']); | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_url, xchan_name, xchan_network ) | 	$r = xchan_store_lowlevel( | ||||||
| 		values ( '%s', '%s', '%s', '%s', '%s' )", | 		[ | ||||||
| 		dbesc($x['url']), | 			'xchan_hash'         => $x['url'], | ||||||
| 		dbesc($x['url']), | 			'xchan_guid'         => $x['url'], | ||||||
| 		dbesc($x['url']), | 			'xchan_url'          => $x['url'], | ||||||
| 		dbesc(($name) ? $name : t('(Unknown)')), | 			'xchan_name'         => (($name) ? $name : t('(Unknown)')), | ||||||
| 		dbesc('unknown') | 			'xchan_name_date'    => datetime_convert(), | ||||||
|  | 			'xchan_network'      => 'unknown' | ||||||
|  | 		] | ||||||
| 	); | 	); | ||||||
|  |  | ||||||
| 	if($r && $x['photo']) { | 	if($r && $x['photo']) { | ||||||
|  |  | ||||||
| 		$photos = import_xchan_photo($x['photo']['src'],$x['url']); | 		$photos = import_xchan_photo($x['photo']['src'],$x['url']); | ||||||
| @@ -1516,6 +1521,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { | |||||||
| 	$arr['deny_cid']      = ((x($arr,'deny_cid'))      ? trim($arr['deny_cid'])              : ''); | 	$arr['deny_cid']      = ((x($arr,'deny_cid'))      ? trim($arr['deny_cid'])              : ''); | ||||||
| 	$arr['deny_gid']      = ((x($arr,'deny_gid'))      ? trim($arr['deny_gid'])              : ''); | 	$arr['deny_gid']      = ((x($arr,'deny_gid'))      ? trim($arr['deny_gid'])              : ''); | ||||||
| 	$arr['postopts']      = ((x($arr,'postopts'))      ? trim($arr['postopts'])              : ''); | 	$arr['postopts']      = ((x($arr,'postopts'))      ? trim($arr['postopts'])              : ''); | ||||||
|  | 	$arr['route']         = ((x($arr,'route'))         ? trim($arr['route'])                 : ''); | ||||||
| 	$arr['item_private']  = ((x($arr,'item_private'))  ? intval($arr['item_private'])        : 0 ); | 	$arr['item_private']  = ((x($arr,'item_private'))  ? intval($arr['item_private'])        : 0 ); | ||||||
| 	$arr['item_wall']     = ((x($arr,'item_wall'))     ? intval($arr['item_wall'])           : 0 ); | 	$arr['item_wall']     = ((x($arr,'item_wall'))     ? intval($arr['item_wall'])           : 0 ); | ||||||
| 	$arr['item_type']     = ((x($arr,'item_type'))     ? intval($arr['item_type'])           : 0 ); | 	$arr['item_type']     = ((x($arr,'item_type'))     ? intval($arr['item_type'])           : 0 ); | ||||||
|   | |||||||
| @@ -1121,16 +1121,17 @@ function discover_by_url($url,$arr = null) { | |||||||
| 	if(! $photo) | 	if(! $photo) | ||||||
| 		$photo = z_root() . '/images/rss_icon.png'; | 		$photo = z_root() . '/images/rss_icon.png'; | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", | 	$r = xchan_store_lowlevel( | ||||||
| 		dbesc($guid), | 		[ | ||||||
| 		dbesc($guid), | 			'xchan_hash'         => $guid, | ||||||
| 		dbesc($pubkey), | 			'xchan_guid'         => $guid, | ||||||
| 		dbesc($addr), | 			'xchan_pubkey'       => $pubkey, | ||||||
| 		dbesc($profile), | 			'xchan_addr'         => $addr, | ||||||
| 		dbesc($name), | 			'xchan_url'          => $profile, | ||||||
| 		dbesc($network), | 			'xchan_name'         => $name, | ||||||
| 		dbesc(z_root()), | 			'xchan_name_date'    => datetime_convert(), | ||||||
| 		dbesc(datetime_convert()) | 			'xchan_network'      => $network | ||||||
|  | 		] | ||||||
| 	); | 	); | ||||||
|  |  | ||||||
| 	$photos = import_xchan_photo($photo,$guid); | 	$photos = import_xchan_photo($photo,$guid); | ||||||
| @@ -1449,15 +1450,17 @@ function discover_by_webbie($webbie) { | |||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", | 			$r = xchan_store_lowlevel( | ||||||
| 				dbesc($address), | 				[ | ||||||
| 				dbesc(($diaspora_guid) ? $diaspora_guid : $location), | 					'xchan_hash'         => $address, | ||||||
| 				dbesc($pubkey), | 					'xchan_guid'         => (($diaspora_guid) ? $diaspora_guid : $location), | ||||||
| 				dbesc($address), | 					'xchan_pubkey'       => $pubkey, | ||||||
| 				dbesc($location), | 					'xchan_addr'         => $address, | ||||||
| 				dbesc($fullname), | 					'xchan_url'          => $location, | ||||||
| 				dbesc($network), | 					'xchan_name'         => $fullname, | ||||||
| 				dbescdate(datetime_convert()) | 					'xchan_name_date'    => datetime_convert(), | ||||||
|  | 					'xchan_network'      => $network | ||||||
|  | 				] | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,9 +2,42 @@ | |||||||
|  |  | ||||||
| function update_queue_item($id, $add_priority = 0) { | function update_queue_item($id, $add_priority = 0) { | ||||||
| 	logger('queue: requeue item ' . $id,LOGGER_DEBUG); | 	logger('queue: requeue item ' . $id,LOGGER_DEBUG); | ||||||
| 	q("UPDATE outq SET outq_updated = '%s', outq_priority = outq_priority + %d WHERE outq_hash = '%s'", | 	$x = q("select outq_created, outq_posturl from outq where outq_hash = '%s' limit 1", | ||||||
|  | 		dbesc($id) | ||||||
|  | 	); | ||||||
|  | 	if(! $x) | ||||||
|  | 		return; | ||||||
|  |  | ||||||
|  | 	// Set all other records for this destination way into the future.  | ||||||
|  | 	// The queue delivers by destination. We'll keep one queue item for | ||||||
|  | 	// this destination (this one) with a shorter delivery. If we succeed | ||||||
|  | 	// once, we'll try to deliver everything for that destination. | ||||||
|  | 	// The delivery will be set to at most once per hour, and if the  | ||||||
|  | 	// queue item is less than 12 hours old, we'll schedule for fifteen | ||||||
|  | 	// minutes.  | ||||||
|  |  | ||||||
|  | 	$r = q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'", | ||||||
|  | 		dbesc(datetime_convert('UTC','UTC','now + 5 days')), | ||||||
|  | 		dbesc($x[0]['outq_posturl']) | ||||||
|  | 	); | ||||||
|  |   | ||||||
|  | 	$since = datetime_convert('UTC','UTC',$x[0]['outq_created']); | ||||||
|  |  | ||||||
|  | 	if($since < datetime_convert('UTC','UTC','now - 12 hour')) { | ||||||
|  | 		$next = datetime_convert('UTC','UTC','now + 1 hour'); | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		$next = datetime_convert('UTC','UTC','now + 15 minutes'); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	q("UPDATE outq SET outq_updated = '%s',  | ||||||
|  | 		outq_priority = outq_priority + %d,  | ||||||
|  | 		outq_scheduled = '%s'  | ||||||
|  | 		WHERE outq_hash = '%s'", | ||||||
|  |  | ||||||
| 		dbesc(datetime_convert()), | 		dbesc(datetime_convert()), | ||||||
| 		intval($add_priority), | 		intval($add_priority), | ||||||
|  | 		dbesc($next), | ||||||
| 		dbesc($id) | 		dbesc($id) | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
| @@ -33,8 +66,12 @@ function queue_set_delivered($id,$channel = 0) { | |||||||
| 	logger('queue: set delivered ' . $id,LOGGER_DEBUG); | 	logger('queue: set delivered ' . $id,LOGGER_DEBUG); | ||||||
| 	$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : ''); | 	$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : ''); | ||||||
|  |  | ||||||
| 	q("update outq set outq_delivered = 1, outq_updated = '%s' where outq_hash = '%s' $sql_extra ", | 	// Set the next scheduled run date so far in the future that it will be expired | ||||||
|  | 	// long before it ever makes it back into the delivery chain.  | ||||||
|  |  | ||||||
|  | 	q("update outq set outq_delivered = 1, outq_updated = '%s', outq_scheduled = '%s' where outq_hash = '%s' $sql_extra ", | ||||||
| 		dbesc(datetime_convert()), | 		dbesc(datetime_convert()), | ||||||
|  | 		dbesc(datetime_convert('UTC','UTC','now + 5 days')), | ||||||
| 		dbesc($id) | 		dbesc($id) | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
| @@ -44,8 +81,8 @@ function queue_set_delivered($id,$channel = 0) { | |||||||
| function queue_insert($arr) { | function queue_insert($arr) { | ||||||
|  |  | ||||||
| 	$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority, | 	$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority, | ||||||
| 		outq_created, outq_updated, outq_notify, outq_msg )  | 		outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )  | ||||||
| 		values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )", | 		values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )", | ||||||
| 		dbesc($arr['hash']), | 		dbesc($arr['hash']), | ||||||
| 		intval($arr['account_id']), | 		intval($arr['account_id']), | ||||||
| 		intval($arr['channel_id']), | 		intval($arr['channel_id']), | ||||||
| @@ -55,6 +92,7 @@ function queue_insert($arr) { | |||||||
| 		intval(($arr['priority']) ? $arr['priority'] : 0), | 		intval(($arr['priority']) ? $arr['priority'] : 0), | ||||||
| 		dbesc(datetime_convert()), | 		dbesc(datetime_convert()), | ||||||
| 		dbesc(datetime_convert()), | 		dbesc(datetime_convert()), | ||||||
|  | 		dbesc(datetime_convert()), | ||||||
| 		dbesc($arr['notify']), | 		dbesc($arr['notify']), | ||||||
| 		dbesc(($arr['msg']) ? $arr['msg'] : '') | 		dbesc(($arr['msg']) ? $arr['msg'] : '') | ||||||
| 	); | 	); | ||||||
|   | |||||||
| @@ -171,19 +171,16 @@ function atoken_create_xchan($xchan) { | |||||||
| 	if($r) | 	if($r) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s ) | 	$xchan['xchan_guid'] = $xchan['xchan_hash']; | ||||||
| 		values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", |  | ||||||
| 		dbesc($xchan['xchan_hash']), | 	$store = []; | ||||||
| 		dbesc($xchan['xchan_hash']), | 	foreach($xchan as $k => $v) { | ||||||
| 		dbesc($xchan['xchan_addr']), | 		if(strpos($k,'xchan_') === 0) { | ||||||
| 		dbesc($xchan['xchan_url']), | 			$store[$k] = $v; | ||||||
| 		dbesc($xchan['xchan_name']), | 		} | ||||||
| 		dbesc($xchan['xchan_network']), | 	} | ||||||
| 		dbesc($xchan['xchan_photo_mimetype']), | 	 | ||||||
| 		dbesc($xchan['xchan_photo_l']), | 	$r = xchan_store_lowlevel($store); | ||||||
| 		dbesc($xchan['xchan_photo_m']), |  | ||||||
| 		dbesc($xchan['xchan_photo_s']) |  | ||||||
| 	); |  | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										139
									
								
								include/xchan.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								include/xchan.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,139 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function xchan_store_lowlevel($arr) { | ||||||
|  |  | ||||||
|  | 	$store = [ | ||||||
|  | 		'xchan_hash' => ((array_key_exists('xchan_hash',$arr)) ? $arr['xchan_hash'] : ''), | ||||||
|  | 		'xchan_guid' => ((array_key_exists('xchan_guid',$arr)) ? $arr['xchan_guid'] : ''), | ||||||
|  | 		'xchan_guid_sig' => ((array_key_exists('xchan_guid_sig',$arr)) ? $arr['xchan_guid_sig'] : ''), | ||||||
|  | 		'xchan_pubkey' => ((array_key_exists('xchan_pubkey',$arr)) ? $arr['xchan_pubkey'] : ''), | ||||||
|  | 		'xchan_photo_mimetype'  => ((array_key_exists('xchan_photo_mimetype',$arr)) ? $arr['xchan_photo_mimetype'] : ''), | ||||||
|  | 		'xchan_photo_l'  => ((array_key_exists('xchan_photo_l',$arr)) ? $arr['xchan_photo_l'] : ''), | ||||||
|  | 		'xchan_photo_m' => ((array_key_exists('xchan_photo_m',$arr)) ? $arr['xchan_photo_m'] : ''), | ||||||
|  | 		'xchan_photo_s' => ((array_key_exists('xchan_photo_s',$arr)) ? $arr['xchan_photo_s'] : ''), | ||||||
|  | 		'xchan_addr' => ((array_key_exists('xchan_addr',$arr)) ? $arr['xchan_addr'] : ''), | ||||||
|  | 		'xchan_url' => ((array_key_exists('xchan_url',$arr)) ? $arr['xchan_url'] : ''), | ||||||
|  | 		'xchan_connurl' => ((array_key_exists('xchan_connurl',$arr)) ? $arr['xchan_connurl'] : ''), | ||||||
|  | 		'xchan_follow' => ((array_key_exists('xchan_follow',$arr)) ? $arr['xchan_follow'] : ''), | ||||||
|  | 		'xchan_connpage' => ((array_key_exists('xchan_connpage',$arr)) ? $arr['xchan_connpage'] : ''), | ||||||
|  | 		'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? $arr['xchan_name'] : ''), | ||||||
|  | 		'xchan_network' => ((array_key_exists('xchan_network',$arr)) ? $arr['xchan_network'] : ''), | ||||||
|  | 		'xchan_instance_url' => ((array_key_exists('xchan_instance_url',$arr)) ? $arr['xchan_instance_url'] : ''), | ||||||
|  | 		'xchan_flags' => ((array_key_exists('xchan_flags',$arr)) ? intval($arr['xchan_flags']) : 0), | ||||||
|  | 		'xchan_photo_date' => ((array_key_exists('xchan_photo_date',$arr)) ? datetime_convert('UTC','UTC',$arr['xchan_photo_date']) : NULL_DATE), | ||||||
|  | 		'xchan_name_date' => ((array_key_exists('xchan_name_date',$arr)) ? datetime_convert('UTC','UTC',$arr['xchan_name_date']) : NULL_DATE), | ||||||
|  | 		'xchan_hidden' => ((array_key_exists('xchan_hidden',$arr)) ? intval($arr['xchan_hidden']) : 0), | ||||||
|  | 		'xchan_orphan' => ((array_key_exists('xchan_orphan',$arr)) ? intval($arr['xchan_orphan']) : 0), | ||||||
|  | 		'xchan_censored' => ((array_key_exists('xchan_censored',$arr)) ? intval($arr['xchan_censored']) : 0), | ||||||
|  | 		'xchan_selfcensored' => ((array_key_exists('xchan_selfcensored',$arr)) ? intval($arr['xchan_selfcensored']) : 0), | ||||||
|  | 		'xchan_system' => ((array_key_exists('xchan_system',$arr)) ? intval($arr['xchan_system']) : 0), | ||||||
|  | 		'xchan_pubforum' => ((array_key_exists('xchan_pubforum',$arr)) ? intval($arr['xchan_pubforum']) : 0), | ||||||
|  | 		'xchan_deleted' => ((array_key_exists('xchan_deleted',$arr)) ? intval($arr['xchan_deleted']) : 0) | ||||||
|  | 	]; | ||||||
|  |  | ||||||
|  | 	return create_table_from_array('xchan',$store); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function xchan_store($arr) { | ||||||
|  |  | ||||||
|  | 	logger('xchan_store: ' . print_r($arr,true)); | ||||||
|  |  | ||||||
|  | 	if(! $arr['hash']) | ||||||
|  | 		$arr['hash'] = $arr['guid']; | ||||||
|  | 	if(! $arr['hash']) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	$r = q("select * from xchan where xchan_hash = '%s' limit 1", | ||||||
|  | 		dbesc($arr['hash']) | ||||||
|  | 	); | ||||||
|  | 	if($r) | ||||||
|  | 		return true; | ||||||
|  |  | ||||||
|  | 	if(! $arr['network']) | ||||||
|  | 		$arr['network'] = 'unknown'; | ||||||
|  | 	if(! $arr['name']) | ||||||
|  | 		$arr['name'] = 'unknown'; | ||||||
|  | 	if(! $arr['url']) | ||||||
|  | 		$arr['url'] = z_root(); | ||||||
|  | 	if(! $arr['photo']) | ||||||
|  | 		$arr['photo'] = z_root() . '/' . get_default_profile_photo(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	if($arr['network'] === 'zot') { | ||||||
|  | 		if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) { | ||||||
|  | 			logger('Unable to verify signature for ' . $arr['hash']); | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$x = []; | ||||||
|  | 	foreach($arr as $k => $v) { | ||||||
|  | 		if($k === 'key') { | ||||||
|  | 			$x['xchan_pubkey'] = $v; | ||||||
|  | 			continue; | ||||||
|  | 		} | ||||||
|  | 		if($k === 'photo') { | ||||||
|  | 			continue; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		$x['xchan_' . $k] = $v; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	$x['xchan_name_date'] = datetime_convert(); | ||||||
|  |  | ||||||
|  | 	$r = xchan_store_lowlevel($x); | ||||||
|  |  | ||||||
|  | 	if(! $r) | ||||||
|  | 		return $r; | ||||||
|  |  | ||||||
|  | 	$photos = import_xchan_photo($arr['photo'],$arr['hash']); | ||||||
|  | 	$r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", | ||||||
|  | 		dbesc(datetime_convert()), | ||||||
|  | 		dbesc($photos[0]), | ||||||
|  | 		dbesc($photos[1]), | ||||||
|  | 		dbesc($photos[2]), | ||||||
|  | 		dbesc($photos[3]), | ||||||
|  | 		dbesc($arr['hash']) | ||||||
|  | 	); | ||||||
|  | 	return $r; | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function xchan_fetch($arr) { | ||||||
|  |  | ||||||
|  | 	$key = ''; | ||||||
|  | 	if($arr['hash']) { | ||||||
|  | 		$key = 'xchan_hash'; | ||||||
|  | 		$v = $arr['hash']; | ||||||
|  | 	} | ||||||
|  | 	elseif($arr['guid']) { | ||||||
|  | 		$key = 'xchan_guid'; | ||||||
|  | 		$v = $arr['guid']; | ||||||
|  | 	} | ||||||
|  | 	elseif($arr['address']) { | ||||||
|  | 		$key = 'xchan_addr'; | ||||||
|  | 		$v = $arr['address']; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if(! $key) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	$r = q("select * from xchan where $key = '$v' limit 1"); | ||||||
|  | 	if(! $r) | ||||||
|  | 		return false; | ||||||
|  |  | ||||||
|  | 	$ret = array(); | ||||||
|  | 	foreach($r[0] as $k => $v) { | ||||||
|  | 		if($k === 'xchan_addr') | ||||||
|  | 			$ret['address'] = $v; | ||||||
|  | 		else | ||||||
|  | 			$ret[str_replace('xchan_','',$k)] = $v; | ||||||
|  | 	} | ||||||
|  | 	return $ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -759,28 +759,28 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { | |||||||
| 				&& ($arr['site']['url'] != z_root())) | 				&& ($arr['site']['url'] != z_root())) | ||||||
| 			$arr['searchable'] = false; | 			$arr['searchable'] = false; | ||||||
|  |  | ||||||
| 		$x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, | 		$x = xchan_store_lowlevel( | ||||||
| 				xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum ) | 			[ | ||||||
| 				values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ", | 				'xchan_hash'           => $xchan_hash,  | ||||||
| 			dbesc($xchan_hash), | 				'xchan_guid'           => $arr['guid'], | ||||||
| 			dbesc($arr['guid']), | 				'xchan_guid_sig'       => $arr['guid_sig'], | ||||||
| 			dbesc($arr['guid_sig']), | 				'xchan_pubkey'         => $arr['key'], | ||||||
| 			dbesc($arr['key']), | 				'xchan_photo_mimetype' => $arr['photo_mimetype'], | ||||||
| 			dbesc($arr['photo_mimetype']), | 				'xchan_photo_l'        => $arr['photo'], | ||||||
| 			dbesc($arr['photo']), | 				'xchan_addr'           => $arr['address'], | ||||||
| 			dbesc($arr['address']), | 				'xchan_url'            => $arr['url'], | ||||||
| 			dbesc($arr['url']), | 				'xchan_connurl'        => $arr['connections_url'], | ||||||
| 			dbesc($arr['connections_url']), | 				'xchan_follow'         => $arr['follow_url'], | ||||||
| 			dbesc($arr['follow_url']), | 				'xchan_connpage'       => $arr['connect_url'], | ||||||
| 			dbesc($arr['connect_url']), | 				'xchan_name'           => (($arr['name']) ? $arr['name'] : '-'), | ||||||
| 			dbesc(($arr['name']) ? $arr['name'] : '-'), | 				'xchan_network'        => 'zot', | ||||||
| 			dbesc('zot'), | 				'xchan_photo_date'     => $arr['photo_updated'], | ||||||
| 			dbescdate($arr['photo_updated']), | 				'xchan_name_date'      => $arr['name_updated'], | ||||||
| 			dbescdate($arr['name_updated']), | 				'xchan_hidden'         => intval(1 - intval($arr['searchable'])), | ||||||
| 			intval(1 - intval($arr['searchable'])), | 				'xchan_selfcensored'   => $arr['adult_content'], | ||||||
| 			intval($arr['adult_content']), | 				'xchan_deleted'        => $arr['deleted'], | ||||||
| 			intval($arr['deleted']), | 				'xchan_pubforum'       => $arr['public_forum'] | ||||||
| 			intval($arr['public_forum']) | 			] | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
| 		$what .= 'new_xchan'; | 		$what .= 'new_xchan'; | ||||||
|   | |||||||
| @@ -898,6 +898,7 @@ CREATE TABLE IF NOT EXISTS `outq` ( | |||||||
|   `outq_delivered` tinyint(1) NOT NULL DEFAULT '0', |   `outq_delivered` tinyint(1) NOT NULL DEFAULT '0', | ||||||
|   `outq_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', |   `outq_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|   `outq_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', |   `outq_updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|  |   `outq_scheduled` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|   `outq_notify` mediumtext NOT NULL, |   `outq_notify` mediumtext NOT NULL, | ||||||
|   `outq_msg` mediumtext NOT NULL, |   `outq_msg` mediumtext NOT NULL, | ||||||
|   `outq_priority` smallint(6) NOT NULL DEFAULT '0', |   `outq_priority` smallint(6) NOT NULL DEFAULT '0', | ||||||
| @@ -907,6 +908,7 @@ CREATE TABLE IF NOT EXISTS `outq` ( | |||||||
|   KEY `outq_hub` (`outq_posturl`), |   KEY `outq_hub` (`outq_posturl`), | ||||||
|   KEY `outq_created` (`outq_created`), |   KEY `outq_created` (`outq_created`), | ||||||
|   KEY `outq_updated` (`outq_updated`), |   KEY `outq_updated` (`outq_updated`), | ||||||
|  |   KEY `outq_scheduled` (`outq_scheduled`), | ||||||
|   KEY `outq_async` (`outq_async`), |   KEY `outq_async` (`outq_async`), | ||||||
|   KEY `outq_delivered` (`outq_delivered`), |   KEY `outq_delivered` (`outq_delivered`), | ||||||
|   KEY `outq_priority` (`outq_priority`) |   KEY `outq_priority` (`outq_priority`) | ||||||
|   | |||||||
| @@ -884,6 +884,7 @@ CREATE TABLE "outq" ( | |||||||
|   "outq_delivered" numeric(1) NOT NULL DEFAULT '0', |   "outq_delivered" numeric(1) NOT NULL DEFAULT '0', | ||||||
|   "outq_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', |   "outq_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|   "outq_updated" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', |   "outq_updated" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|  |   "outq_scheduled" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||||
|   "outq_notify" text NOT NULL, |   "outq_notify" text NOT NULL, | ||||||
|   "outq_msg" text NOT NULL, |   "outq_msg" text NOT NULL, | ||||||
|   "outq_priority" smallint NOT NULL DEFAULT '0', |   "outq_priority" smallint NOT NULL DEFAULT '0', | ||||||
| @@ -894,6 +895,7 @@ create index "outq_channel" on outq ("outq_channel"); | |||||||
| create index "outq_hub" on outq ("outq_posturl"); | create index "outq_hub" on outq ("outq_posturl"); | ||||||
| create index "outq_created" on outq ("outq_created"); | create index "outq_created" on outq ("outq_created"); | ||||||
| create index "outq_updated" on outq ("outq_updated"); | create index "outq_updated" on outq ("outq_updated"); | ||||||
|  | create index "outq_scheduled" on outq ("outq_scheduled"); | ||||||
| create index "outq_async" on outq ("outq_async"); | create index "outq_async" on outq ("outq_async"); | ||||||
| create index "outq_delivered" on outq ("outq_delivered"); | create index "outq_delivered" on outq ("outq_delivered"); | ||||||
| create index "outq_priority" on outq ("outq_priority"); | create index "outq_priority" on outq ("outq_priority"); | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| define( 'UPDATE_VERSION' , 1187 ); | define( 'UPDATE_VERSION' , 1188 ); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * |  * | ||||||
| @@ -2484,7 +2484,7 @@ function update_r1185() { | |||||||
|  |  | ||||||
| function update_r1186() { | function update_r1186() { | ||||||
|  |  | ||||||
| 	$r1 = q("alter table profile add profile_vcard text not null default '' "); | 	$r1 = q("alter table profile add profile_vcard text not null"); | ||||||
|  |  | ||||||
| 	if($r1) | 	if($r1) | ||||||
| 		return UPDATE_SUCCESS; | 		return UPDATE_SUCCESS; | ||||||
| @@ -2492,3 +2492,20 @@ function update_r1186() { | |||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function update_r1187() { | ||||||
|  |  | ||||||
|  | 	if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { | ||||||
|  | 		$r1 = q("alter table outq add outq_scheduled timestamp not null default '0001-01-01 00:00:00' "); | ||||||
|  | 	} | ||||||
|  | 	else { | ||||||
|  | 		$r1 = q("alter table outq add outq_scheduled datetime not null default '0001-01-01 00:00:00' "); | ||||||
|  | 	} | ||||||
|  | 	$r2 = q("create index outq_scheduled_idx on outq (outq_scheduled)"); | ||||||
|  |  | ||||||
|  | 	if($r1 && $r2) | ||||||
|  | 		return UPDATE_SUCCESS; | ||||||
|  | 	return UPDATE_FAILED; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user