split off libsync from libzot

This commit is contained in:
zotlabs 2018-06-04 18:40:11 -07:00
parent 9232351cb2
commit 4846ae5326
45 changed files with 897 additions and 879 deletions

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Cron {
@ -111,7 +111,7 @@ class Cron {
if($z) {
xchan_query($z);
$sync_item = fetch_post_tags($z);
Libzot::build_sync_packet($sync_item[0]['uid'],
Libsync::build_sync_packet($sync_item[0]['uid'],
[
'item' => [ encode_item($sync_item[0],true) ]
]

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Importfile {
@ -42,7 +42,7 @@ class Importfile {
$sync = attach_export_data($channel,$hash);
if($sync)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
return;
}

View file

@ -3,6 +3,7 @@
namespace Zotlabs\Lib;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Activity {
@ -903,7 +904,7 @@ class Activity {
if($abconfig)
$clone['abconfig'] = $abconfig;
Libzot::build_sync_packet($channel['channel_id'], [ 'abook' => array($clone) ] );
Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => array($clone) ] );
}
}

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Lib;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/**
* Apps
@ -447,7 +447,7 @@ class Apps {
intval(TERM_OBJ_APP),
intval($r[0]['id'])
);
Libzot::build_sync_packet($uid,array('app' => $r[0]));
Libsync::build_sync_packet($uid,array('app' => $r[0]));
}
}
}
@ -485,7 +485,7 @@ class Apps {
);
// we don't sync system apps - they may be completely different on the other system
Libzot::build_sync_packet($uid,array('app' => $x));
Libsync::build_sync_packet($uid,array('app' => $x));
}
}
else {

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Lib;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/**
* @brief A class with chatroom related static methods.
@ -93,7 +93,7 @@ class Chatroom {
return $ret;
}
Libzot::build_sync_packet($channel['channel_id'],array('chatroom' => $r));
Libsync::build_sync_packet($channel['channel_id'],array('chatroom' => $r));
q("delete from chatroom where cr_id = %d",
intval($r[0]['cr_id'])

780
Zotlabs/Lib/Libsync.php Normal file
View file

@ -0,0 +1,780 @@
<?php
namespace Zotlabs\Lib;
use Zotlabs\Lib\Libzot;
class Libsync {
/**
* @brief Builds and sends a sync packet.
*
* Send a zot packet to all hubs where this channel is duplicated, refreshing
* such things as personal settings, channel permissions, address book updates, etc.
*
* @param int $uid (optional) default 0
* @param array $packet (optional) default null
* @param boolean $groups_changed (optional) default false
*/
static function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
logger('build_sync_packet');
$keychange = (($packet && array_key_exists('keychange',$packet)) ? true : false);
if($keychange) {
logger('keychange sync');
}
if(! $uid)
$uid = local_channel();
if(! $uid)
return;
$r = q("select * from channel where channel_id = %d limit 1",
intval($uid)
);
if(! $r)
return;
$channel = $r[0];
// don't provide these in the export
unset($channel['channel_active']);
unset($channel['channel_password']);
unset($channel['channel_salt']);
if(intval($channel['channel_removed']))
return;
$h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0",
dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_hash'])
);
if(! $h)
return;
$synchubs = array();
foreach($h as $x) {
if($x['hubloc_host'] == \App::get_hostname())
continue;
$y = q("select site_dead from site where site_url = '%s' limit 1",
dbesc($x['hubloc_url'])
);
if((! $y) || ($y[0]['site_dead'] == 0))
$synchubs[] = $x;
}
if(! $synchubs)
return;
$r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash = '%s' limit 1",
dbesc($channel['channel_hash'])
);
if(! $r)
return;
$env_recips = array();
$env_recips[] = array('guid' => $r[0]['xchan_guid'],'guid_sig' => $r[0]['xchan_guid_sig']);
if($packet)
logger('packet: ' . print_r($packet, true),LOGGER_DATA, LOG_DEBUG);
$info = (($packet) ? $packet : array());
$info['type'] = 'channel_sync';
$info['encoding'] = 'red'; // note: not zot, this packet is very platform specific
$info['relocate'] = ['channel_address' => $channel['channel_address'], 'url' => z_root() ];
if(array_key_exists($uid,App::$config) && array_key_exists('transient',App::$config[$uid])) {
$settings = App::$config[$uid]['transient'];
if($settings) {
$info['config'] = $settings;
}
}
if($channel) {
$info['channel'] = array();
foreach($channel as $k => $v) {
// filter out any joined tables like xchan
if(strpos($k,'channel_') !== 0)
continue;
// don't pass these elements, they should not be synchronised
$disallowed = [
'channel_id','channel_account_id','channel_primary','channel_address',
'channel_deleted','channel_removed','channel_system'
];
if(! $keychange) {
$disallowed[] = 'channel_prvkey';
}
if(in_array($k,$disallowed))
continue;
$info['channel'][$k] = $v;
}
}
if($groups_changed) {
$r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d",
intval($uid)
);
if($r)
$info['collections'] = $r;
$r = q("select groups.hash as collection, group_member.xchan as member from groups left join group_member on groups.id = group_member.gid where group_member.uid = %d",
intval($uid)
);
if($r)
$info['collection_members'] = $r;
}
$interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
logger('Packet: ' . print_r($info,true), LOGGER_DATA, LOG_DEBUG);
$total = count($synchubs);
foreach($synchubs as $hub) {
$hash = random_string();
$n = self::build_packet($channel,'notify',$env_recips,json_encode($info),$hub['hubloc_sitekey'],$hub['site_crypto'],$hash);
queue_insert(array(
'hash' => $hash,
'account_id' => $channel['channel_account_id'],
'channel_id' => $channel['channel_id'],
'posturl' => $hub['hubloc_callback'],
'notify' => $n,
'msg' => json_encode($info)
));
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;
}
\Zotlabs\Daemon\Master::Summon(array('Deliver', $hash));
$total = $total - 1;
if($interval && $total)
@time_sleep_until(microtime(true) + (float) $interval);
}
}
/**
* @brief
*
* @param array $sender
* @param array $arr
* @param array $deliveries
* @return array
*/
static function process_channel_sync_delivery($sender, $arr, $deliveries) {
require_once('include/import.php');
/** @FIXME this will sync red structures (channel, pconfig and abook).
Eventually we need to make this application agnostic. */
$result = [];
$keychange = ((array_key_exists('keychange',$arr)) ? true : false);
foreach ($deliveries as $d) {
$r = q("select * from channel where channel_hash = '%s' limit 1",
dbesc(($keychange) ? $arr['keychange']['old_hash'] : $d['hash'])
);
if (! $r) {
$result[] = array($d['hash'],'not found');
continue;
}
$channel = $r[0];
$max_friends = service_class_fetch($channel['channel_id'],'total_channels');
$max_feeds = account_service_class_fetch($channel['channel_account_id'],'total_feeds');
if($channel['channel_hash'] != $sender['hash']) {
logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_hash']);
$result[] = array($d['hash'],'channel mismatch',$channel['channel_name'],'');
continue;
}
if($keychange) {
// verify the keychange operation
if(! self::verify($arr['channel']['channel_pubkey'],$arr['keychange']['new_sig'],$channel['channel_prvkey'])) {
logger('sync keychange: verification failed');
continue;
}
$sig = self::sign($channel['channel_guid'],$arr['channel']['channel_prvkey']);
$hash = self::make_xchan_hash($channel['channel_guid'],$arr['channel']['channel_pubkey']);
$r = q("update channel set channel_prvkey = '%s', channel_pubkey = '%s', channel_guid_sig = '%s',
channel_hash = '%s' where channel_id = %d",
dbesc($arr['channel']['channel_prvkey']),
dbesc($arr['channel']['channel_pubkey']),
dbesc($sig),
dbesc($hash),
intval($channel['channel_id'])
);
if(! $r) {
logger('keychange sync: channel update failed');
continue;
}
$r = q("select * from channel where channel_id = %d",
intval($channel['channel_id'])
);
if(! $r) {
logger('keychange sync: channel retrieve failed');
continue;
}
$channel = $r[0];
$h = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' ",
dbesc($arr['keychange']['old_hash']),
dbesc(z_root())
);
if($h) {
foreach($h as $hv) {
$hv['hubloc_guid_sig'] = $sig;
$hv['hubloc_hash'] = $hash;
$hv['hubloc_url_sig'] = self::sign(z_root(),$channel['channel_prvkey']);
hubloc_store_lowlevel($hv);
}
}
$x = q("select * from xchan where xchan_hash = '%s' ",
dbesc($arr['keychange']['old_hash'])
);
$check = q("select * from xchan where xchan_hash = '%s'",
dbesc($hash)
);
if(($x) && (! $check)) {
$oldxchan = $x[0];
foreach($x as $xv) {
$xv['xchan_guid_sig'] = $sig;
$xv['xchan_hash'] = $hash;
$xv['xchan_pubkey'] = $channel['channel_pubkey'];
xchan_store_lowlevel($xv);
$newxchan = $xv;
}
}
$a = q("select * from abook where abook_xchan = '%s' and abook_self = 1",
dbesc($arr['keychange']['old_hash'])
);
if($a) {
q("update abook set abook_xchan = '%s' where abook_id = %d",
dbesc($hash),
intval($a[0]['abook_id'])
);
}
xchan_change_key($oldxchan,$newxchan,$arr['keychange']);
// keychange operations can end up in a confused state if you try and sync anything else
// besides the channel keys, so ignore any other packets.
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) {
foreach($arr['config'][$cat] as $k => $v)
set_pconfig($channel['channel_id'],$cat,$k,$v);
}
}
if(array_key_exists('obj',$arr) && $arr['obj'])
sync_objs($channel,$arr['obj']);
if(array_key_exists('likes',$arr) && $arr['likes'])
import_likes($channel,$arr['likes']);
if(array_key_exists('app',$arr) && $arr['app'])
sync_apps($channel,$arr['app']);
if(array_key_exists('chatroom',$arr) && $arr['chatroom'])
sync_chatrooms($channel,$arr['chatroom']);
if(array_key_exists('conv',$arr) && $arr['conv'])
import_conv($channel,$arr['conv']);
if(array_key_exists('mail',$arr) && $arr['mail'])
sync_mail($channel,$arr['mail']);
if(array_key_exists('event',$arr) && $arr['event'])
sync_events($channel,$arr['event']);
if(array_key_exists('event_item',$arr) && $arr['event_item'])
sync_items($channel,$arr['event_item'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
if(array_key_exists('item',$arr) && $arr['item'])
sync_items($channel,$arr['item'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
// deprecated, maintaining for a few months for upward compatibility
// this should sync webpages, but the logic is a bit subtle
if(array_key_exists('item_id',$arr) && $arr['item_id'])
sync_items($channel,$arr['item_id']);
if(array_key_exists('menu',$arr) && $arr['menu'])
sync_menus($channel,$arr['menu']);
if(array_key_exists('file',$arr) && $arr['file'])
sync_files($channel,$arr['file']);
if(array_key_exists('wiki',$arr) && $arr['wiki'])
sync_items($channel,$arr['wiki'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) {
$remote_channel = $arr['channel'];
$remote_channel['channel_id'] = $channel['channel_id'];
translate_channel_perms_inbound($remote_channel);
if(array_key_exists('channel_pageflags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) {
// These flags cannot be sync'd.
// remove the bits from the incoming flags.
// These correspond to PAGE_REMOVED and PAGE_SYSTEM on redmatrix
if($arr['channel']['channel_pageflags'] & 0x8000)
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x8000;
if($arr['channel']['channel_pageflags'] & 0x1000)
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x1000;
}
$disallowed = [
'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey',
'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted',
'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook',
'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
'channel_a_delegate'
];
$clean = array();
foreach($arr['channel'] as $k => $v) {
if(in_array($k,$disallowed))
continue;
$clean[$k] = $v;
}
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE channel set " . dbesc($k) . " = '" . dbesc($v)
. "' where channel_id = " . intval($channel['channel_id']) );
}
}
}
if(array_key_exists('abook',$arr) && is_array($arr['abook']) && count($arr['abook'])) {
$total_friends = 0;
$total_feeds = 0;
$r = q("select abook_id, abook_feed from abook where abook_channel = %d",
intval($channel['channel_id'])
);
if($r) {
// don't count yourself
$total_friends = ((count($r) > 0) ? count($r) - 1 : 0);
foreach($r as $rr)
if(intval($rr['abook_feed']))
$total_feeds ++;
}
$disallowed = array('abook_id','abook_account','abook_channel','abook_rating','abook_rating_text','abook_not_here');
foreach($arr['abook'] as $abook) {
$abconfig = null;
if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig']))
$abconfig = $abook['abconfig'];
if(! array_key_exists('abook_blocked',$abook)) {
// convert from redmatrix
$abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001) ? 1 : 0);
$abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002) ? 1 : 0);
$abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004) ? 1 : 0);
$abook['abook_archived'] = (($abook['abook_flags'] & 0x0008) ? 1 : 0);
$abook['abook_pending'] = (($abook['abook_flags'] & 0x0010) ? 1 : 0);
$abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020) ? 1 : 0);
$abook['abook_self'] = (($abook['abook_flags'] & 0x0080) ? 1 : 0);
$abook['abook_feed'] = (($abook['abook_flags'] & 0x0100) ? 1 : 0);
}
$clean = array();
if($abook['abook_xchan'] && $abook['entry_deleted']) {
logger('Removing abook entry for ' . $abook['abook_xchan']);
$r = q("select abook_id, abook_feed from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($abook['abook_xchan']),
intval($channel['channel_id'])
);
if($r) {
contact_remove($channel['channel_id'],$r[0]['abook_id']);
if($total_friends)
$total_friends --;
if(intval($r[0]['abook_feed']))
$total_feeds --;
}
continue;
}
// Perform discovery if the referenced xchan hasn't ever been seen on this hub.
// This relies on the undocumented behaviour that red sites send xchan info with the abook
// and import_author_xchan will look them up on all federated networks
if($abook['abook_xchan'] && $abook['xchan_addr']) {
$h = self::get_hublocs($abook['abook_xchan']);
if(! $h) {
$xhash = import_author_xchan(encode_item_xchan($abook));
if(! $xhash) {
logger('Import of ' . $abook['xchan_addr'] . ' failed.');
continue;
}
}
}
foreach($abook as $k => $v) {
if(in_array($k,$disallowed) || (strpos($k,'abook') !== 0))
continue;
$clean[$k] = $v;
}
if(! array_key_exists('abook_xchan',$clean))
continue;
if(array_key_exists('abook_instance',$clean) && $clean['abook_instance'] && strpos($clean['abook_instance'],z_root()) === false) {
$clean['abook_not_here'] = 1;
}
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($clean['abook_xchan']),
intval($channel['channel_id'])
);
// make sure we have an abook entry for this xchan on this system
if(! $r) {
if($max_friends !== false && $total_friends > $max_friends) {
logger('total_channels service class limit exceeded');
continue;
}
if($max_feeds !== false && intval($clean['abook_feed']) && $total_feeds > $max_feeds) {
logger('total_feeds service class limit exceeded');
continue;
}
abook_store_lowlevel(
[
'abook_xchan' => $clean['abook_xchan'],
'abook_account' => $channel['channel_account_id'],
'abook_channel' => $channel['channel_id']
]
);
$total_friends ++;
if(intval($clean['abook_feed']))
$total_feeds ++;
}
if(count($clean)) {
foreach($clean as $k => $v) {
if($k == 'abook_dob')
$v = dbescdate($v);
$r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v)
. "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id']));
}
}
// This will set abconfig vars if the sender is using old-style fixed permissions
// using the raw abook record as passed to us. New-style permissions will fall through
// and be set using abconfig
translate_abook_perms_inbound($channel,$abook);
if($abconfig) {
/// @fixme does not handle sync of del_abconfig
foreach($abconfig as $abc) {
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
}
}
}
}
// sync collections (privacy groups) oh joy...
if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) {
$x = q("select * from groups where uid = %d",
intval($channel['channel_id'])
);
foreach($arr['collections'] as $cl) {
$found = false;
if($x) {
foreach($x as $y) {
if($cl['collection'] == $y['hash']) {
$found = true;
break;
}
}
if($found) {
if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible'])
|| ($y['deleted'] != $cl['deleted'])) {
q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d",
dbesc($cl['name']),
intval($cl['visible']),
intval($cl['deleted']),
dbesc($cl['collection']),
intval($channel['channel_id'])
);
}
if(intval($cl['deleted']) && (! intval($y['deleted']))) {
q("delete from group_member where gid = %d",
intval($y['id'])
);
}
}
}
if(! $found) {
$r = q("INSERT INTO groups ( hash, uid, visible, deleted, gname )
VALUES( '%s', %d, %d, %d, '%s' ) ",
dbesc($cl['collection']),
intval($channel['channel_id']),
intval($cl['visible']),
intval($cl['deleted']),
dbesc($cl['name'])
);
}
// now look for any collections locally which weren't in the list we just received.
// They need to be removed by marking deleted and removing the members.
// This shouldn't happen except for clones created before this function was written.
if($x) {
$found_local = false;
foreach($x as $y) {
foreach($arr['collections'] as $cl) {
if($cl['collection'] == $y['hash']) {
$found_local = true;
break;
}
}
if(! $found_local) {
q("delete from group_member where gid = %d",
intval($y['id'])
);
q("update groups set deleted = 1 where id = %d and uid = %d",
intval($y['id']),
intval($channel['channel_id'])
);
}
}
}
}
// reload the group list with any updates
$x = q("select * from groups where uid = %d",
intval($channel['channel_id'])
);
// now sync the members
if(array_key_exists('collection_members', $arr)
&& is_array($arr['collection_members'])
&& count($arr['collection_members'])) {
// first sort into groups keyed by the group hash
$members = array();
foreach($arr['collection_members'] as $cm) {
if(! array_key_exists($cm['collection'],$members))
$members[$cm['collection']] = array();
$members[$cm['collection']][] = $cm['member'];
}
// our group list is already synchronised
if($x) {
foreach($x as $y) {
// for each group, loop on members list we just received
if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) {
$found = false;
$z = q("select xchan from group_member where gid = %d and uid = %d and xchan = '%s' limit 1",
intval($y['id']),
intval($channel['channel_id']),
dbesc($member)
);
if($z)
$found = true;
// if somebody is in the group that wasn't before - add them
if(! $found) {
q("INSERT INTO group_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
intval($channel['channel_id']),
intval($y['id']),
dbesc($member)
);
}
}
}
// now retrieve a list of members we have on this site
$m = q("select xchan from group_member where gid = %d and uid = %d",
intval($y['id']),
intval($channel['channel_id'])
);
if($m) {
foreach($m as $mm) {
// if the local existing member isn't in the list we just received - remove them
if(! in_array($mm['xchan'],$members[$y['hash']])) {
q("delete from group_member where xchan = '%s' and gid = %d and uid = %d",
dbesc($mm['xchan']),
intval($y['id']),
intval($channel['channel_id'])
);
}
}
}
}
}
}
}
if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) {
$disallowed = array('id','aid','uid','guid');
foreach($arr['profile'] as $profile) {
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
);
if(! $x) {
profile_store_lowlevel(
[
'aid' => $channel['channel_account_id'],
'uid' => $channel['channel_id'],
'profile_guid' => $profile['profile_guid'],
]
);
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
);
if(! $x)
continue;
}
$clean = array();
foreach($profile as $k => $v) {
if(in_array($k,$disallowed))
continue;
if($profile['is_default'] && in_array($k,['photo','thumb']))
continue;
if($k === 'name')
$clean['fullname'] = $v;
elseif($k === 'with')
$clean['partner'] = $v;
elseif($k === 'work')
$clean['employment'] = $v;
elseif(array_key_exists($k,$x[0]))
$clean[$k] = $v;
/**
* @TODO
* We also need to import local photos if a custom photo is selected
*/
if((strpos($profile['thumb'],'/photo/profile/l/') !== false) || intval($profile['is_default'])) {
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
}
else {
$profile['photo'] = z_root() . '/photo/' . basename($profile['photo']);
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
}
}
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE profile set " . TQUOT . dbesc($k) . TQUOT . " = '" . dbesc($v)
. "' where profile_guid = '" . dbesc($profile['profile_guid'])
. "' and uid = " . intval($channel['channel_id']));
}
}
}
}
$addon = ['channel' => $channel, 'data' => $arr];
/**
* @hooks process_channel_sync_delivery
* Called when accepting delivery of a 'sync packet' containing structure and table updates from a channel clone.
* * \e array \b channel
* * \e array \b data
*/
call_hooks('process_channel_sync_delivery', $addon);
// we should probably do this for all items, but usually we only send one.
if(array_key_exists('item',$arr) && is_array($arr['item'][0])) {
$DR = new \Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed');
$DR->addto_recipient($channel['channel_name'] . ' <' . channel_reddress($channel) . '>');
}
else
$DR = new \Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered');
$result[] = $DR->get();
}
return $result;
}
}

View file

@ -7,6 +7,9 @@ namespace Zotlabs\Lib;
*
*/
use Zotlabs\Lib\Libsync;
require_once('include/crypto.php');
require_once('include/queue_fn.php');
@ -1321,7 +1324,7 @@ class Libzot {
logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG);
$result = self::process_channel_sync_delivery($i['notify']['sender'],$arr,$deliveries);
$result = Libsync::process_channel_sync_delivery($i['notify']['sender'],$arr,$deliveries);
}
elseif($i['message']['type'] === 'location') {
$arr = $i['message'];
@ -3052,776 +3055,6 @@ class Libzot {
return $update;
}
/**
* @brief Builds and sends a sync packet.
*
* Send a zot packet to all hubs where this channel is duplicated, refreshing
* such things as personal settings, channel permissions, address book updates, etc.
*
* @param int $uid (optional) default 0
* @param array $packet (optional) default null
* @param boolean $groups_changed (optional) default false
*/
static function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
logger('build_sync_packet');
$keychange = (($packet && array_key_exists('keychange',$packet)) ? true : false);
if($keychange) {
logger('keychange sync');
}
if(! $uid)
$uid = local_channel();
if(! $uid)
return;
$r = q("select * from channel where channel_id = %d limit 1",
intval($uid)
);
if(! $r)
return;
$channel = $r[0];
// don't provide these in the export
unset($channel['channel_active']);
unset($channel['channel_password']);
unset($channel['channel_salt']);
if(intval($channel['channel_removed']))
return;
$h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0",
dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_hash'])
);
if(! $h)
return;
$synchubs = array();
foreach($h as $x) {
if($x['hubloc_host'] == \App::get_hostname())
continue;
$y = q("select site_dead from site where site_url = '%s' limit 1",
dbesc($x['hubloc_url'])
);
if((! $y) || ($y[0]['site_dead'] == 0))
$synchubs[] = $x;
}
if(! $synchubs)
return;
$r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash = '%s' limit 1",
dbesc($channel['channel_hash'])
);
if(! $r)
return;
$env_recips = array();
$env_recips[] = array('guid' => $r[0]['xchan_guid'],'guid_sig' => $r[0]['xchan_guid_sig']);
if($packet)
logger('packet: ' . print_r($packet, true),LOGGER_DATA, LOG_DEBUG);
$info = (($packet) ? $packet : array());
$info['type'] = 'channel_sync';
$info['encoding'] = 'red'; // note: not zot, this packet is very platform specific
$info['relocate'] = ['channel_address' => $channel['channel_address'], 'url' => z_root() ];
if(array_key_exists($uid,App::$config) && array_key_exists('transient',App::$config[$uid])) {
$settings = App::$config[$uid]['transient'];
if($settings) {
$info['config'] = $settings;
}
}
if($channel) {
$info['channel'] = array();
foreach($channel as $k => $v) {
// filter out any joined tables like xchan
if(strpos($k,'channel_') !== 0)
continue;
// don't pass these elements, they should not be synchronised
$disallowed = [
'channel_id','channel_account_id','channel_primary','channel_address',
'channel_deleted','channel_removed','channel_system'
];
if(! $keychange) {
$disallowed[] = 'channel_prvkey';
}
if(in_array($k,$disallowed))
continue;
$info['channel'][$k] = $v;
}
}
if($groups_changed) {
$r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d",
intval($uid)
);
if($r)
$info['collections'] = $r;
$r = q("select groups.hash as collection, group_member.xchan as member from groups left join group_member on groups.id = group_member.gid where group_member.uid = %d",
intval($uid)
);
if($r)
$info['collection_members'] = $r;
}
$interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
logger('Packet: ' . print_r($info,true), LOGGER_DATA, LOG_DEBUG);
$total = count($synchubs);
foreach($synchubs as $hub) {
$hash = random_string();
$n = self::build_packet($channel,'notify',$env_recips,json_encode($info),$hub['hubloc_sitekey'],$hub['site_crypto'],$hash);
queue_insert(array(
'hash' => $hash,
'account_id' => $channel['channel_account_id'],
'channel_id' => $channel['channel_id'],
'posturl' => $hub['hubloc_callback'],
'notify' => $n,
'msg' => json_encode($info)
));
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;
}
\Zotlabs\Daemon\Master::Summon(array('Deliver', $hash));
$total = $total - 1;
if($interval && $total)
@time_sleep_until(microtime(true) + (float) $interval);
}
}
/**
* @brief
*
* @param array $sender
* @param array $arr
* @param array $deliveries
* @return array
*/
static function process_channel_sync_delivery($sender, $arr, $deliveries) {
require_once('include/import.php');
/** @FIXME this will sync red structures (channel, pconfig and abook).
Eventually we need to make this application agnostic. */
$result = [];
$keychange = ((array_key_exists('keychange',$arr)) ? true : false);
foreach ($deliveries as $d) {
$r = q("select * from channel where channel_hash = '%s' limit 1",
dbesc(($keychange) ? $arr['keychange']['old_hash'] : $d['hash'])
);
if (! $r) {
$result[] = array($d['hash'],'not found');
continue;
}
$channel = $r[0];
$max_friends = service_class_fetch($channel['channel_id'],'total_channels');
$max_feeds = account_service_class_fetch($channel['channel_account_id'],'total_feeds');
if($channel['channel_hash'] != $sender['hash']) {
logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_hash']);
$result[] = array($d['hash'],'channel mismatch',$channel['channel_name'],'');
continue;
}
if($keychange) {
// verify the keychange operation
if(! self::verify($arr['channel']['channel_pubkey'],$arr['keychange']['new_sig'],$channel['channel_prvkey'])) {
logger('sync keychange: verification failed');
continue;
}
$sig = self::sign($channel['channel_guid'],$arr['channel']['channel_prvkey']);
$hash = self::make_xchan_hash($channel['channel_guid'],$arr['channel']['channel_pubkey']);
$r = q("update channel set channel_prvkey = '%s', channel_pubkey = '%s', channel_guid_sig = '%s',
channel_hash = '%s' where channel_id = %d",
dbesc($arr['channel']['channel_prvkey']),
dbesc($arr['channel']['channel_pubkey']),
dbesc($sig),
dbesc($hash),
intval($channel['channel_id'])
);
if(! $r) {
logger('keychange sync: channel update failed');
continue;
}
$r = q("select * from channel where channel_id = %d",
intval($channel['channel_id'])
);
if(! $r) {
logger('keychange sync: channel retrieve failed');
continue;
}
$channel = $r[0];
$h = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' ",
dbesc($arr['keychange']['old_hash']),
dbesc(z_root())
);
if($h) {
foreach($h as $hv) {
$hv['hubloc_guid_sig'] = $sig;
$hv['hubloc_hash'] = $hash;
$hv['hubloc_url_sig'] = self::sign(z_root(),$channel['channel_prvkey']);
hubloc_store_lowlevel($hv);
}
}
$x = q("select * from xchan where xchan_hash = '%s' ",
dbesc($arr['keychange']['old_hash'])
);
$check = q("select * from xchan where xchan_hash = '%s'",
dbesc($hash)
);
if(($x) && (! $check)) {
$oldxchan = $x[0];
foreach($x as $xv) {
$xv['xchan_guid_sig'] = $sig;
$xv['xchan_hash'] = $hash;
$xv['xchan_pubkey'] = $channel['channel_pubkey'];
xchan_store_lowlevel($xv);
$newxchan = $xv;
}
}
$a = q("select * from abook where abook_xchan = '%s' and abook_self = 1",
dbesc($arr['keychange']['old_hash'])
);
if($a) {
q("update abook set abook_xchan = '%s' where abook_id = %d",
dbesc($hash),
intval($a[0]['abook_id'])
);
}
xchan_change_key($oldxchan,$newxchan,$arr['keychange']);
// keychange operations can end up in a confused state if you try and sync anything else
// besides the channel keys, so ignore any other packets.
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) {
foreach($arr['config'][$cat] as $k => $v)
set_pconfig($channel['channel_id'],$cat,$k,$v);
}
}
if(array_key_exists('obj',$arr) && $arr['obj'])
sync_objs($channel,$arr['obj']);
if(array_key_exists('likes',$arr) && $arr['likes'])
import_likes($channel,$arr['likes']);
if(array_key_exists('app',$arr) && $arr['app'])
sync_apps($channel,$arr['app']);
if(array_key_exists('chatroom',$arr) && $arr['chatroom'])
sync_chatrooms($channel,$arr['chatroom']);
if(array_key_exists('conv',$arr) && $arr['conv'])
import_conv($channel,$arr['conv']);
if(array_key_exists('mail',$arr) && $arr['mail'])
sync_mail($channel,$arr['mail']);
if(array_key_exists('event',$arr) && $arr['event'])
sync_events($channel,$arr['event']);
if(array_key_exists('event_item',$arr) && $arr['event_item'])
sync_items($channel,$arr['event_item'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
if(array_key_exists('item',$arr) && $arr['item'])
sync_items($channel,$arr['item'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
// deprecated, maintaining for a few months for upward compatibility
// this should sync webpages, but the logic is a bit subtle
if(array_key_exists('item_id',$arr) && $arr['item_id'])
sync_items($channel,$arr['item_id']);
if(array_key_exists('menu',$arr) && $arr['menu'])
sync_menus($channel,$arr['menu']);
if(array_key_exists('file',$arr) && $arr['file'])
sync_files($channel,$arr['file']);
if(array_key_exists('wiki',$arr) && $arr['wiki'])
sync_items($channel,$arr['wiki'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) {
$remote_channel = $arr['channel'];
$remote_channel['channel_id'] = $channel['channel_id'];
translate_channel_perms_inbound($remote_channel);
if(array_key_exists('channel_pageflags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) {
// These flags cannot be sync'd.
// remove the bits from the incoming flags.
// These correspond to PAGE_REMOVED and PAGE_SYSTEM on redmatrix
if($arr['channel']['channel_pageflags'] & 0x8000)
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x8000;
if($arr['channel']['channel_pageflags'] & 0x1000)
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x1000;
}
$disallowed = [
'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey',
'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted',
'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook',
'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
'channel_a_delegate'
];
$clean = array();
foreach($arr['channel'] as $k => $v) {
if(in_array($k,$disallowed))
continue;
$clean[$k] = $v;
}
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE channel set " . dbesc($k) . " = '" . dbesc($v)
. "' where channel_id = " . intval($channel['channel_id']) );
}
}
}
if(array_key_exists('abook',$arr) && is_array($arr['abook']) && count($arr['abook'])) {
$total_friends = 0;
$total_feeds = 0;
$r = q("select abook_id, abook_feed from abook where abook_channel = %d",
intval($channel['channel_id'])
);
if($r) {
// don't count yourself
$total_friends = ((count($r) > 0) ? count($r) - 1 : 0);
foreach($r as $rr)
if(intval($rr['abook_feed']))
$total_feeds ++;
}
$disallowed = array('abook_id','abook_account','abook_channel','abook_rating','abook_rating_text','abook_not_here');
foreach($arr['abook'] as $abook) {
$abconfig = null;
if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig']))
$abconfig = $abook['abconfig'];
if(! array_key_exists('abook_blocked',$abook)) {
// convert from redmatrix
$abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001) ? 1 : 0);
$abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002) ? 1 : 0);
$abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004) ? 1 : 0);
$abook['abook_archived'] = (($abook['abook_flags'] & 0x0008) ? 1 : 0);
$abook['abook_pending'] = (($abook['abook_flags'] & 0x0010) ? 1 : 0);
$abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020) ? 1 : 0);
$abook['abook_self'] = (($abook['abook_flags'] & 0x0080) ? 1 : 0);
$abook['abook_feed'] = (($abook['abook_flags'] & 0x0100) ? 1 : 0);
}
$clean = array();
if($abook['abook_xchan'] && $abook['entry_deleted']) {
logger('Removing abook entry for ' . $abook['abook_xchan']);
$r = q("select abook_id, abook_feed from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($abook['abook_xchan']),
intval($channel['channel_id'])
);
if($r) {
contact_remove($channel['channel_id'],$r[0]['abook_id']);
if($total_friends)
$total_friends --;
if(intval($r[0]['abook_feed']))
$total_feeds --;
}
continue;
}
// Perform discovery if the referenced xchan hasn't ever been seen on this hub.
// This relies on the undocumented behaviour that red sites send xchan info with the abook
// and import_author_xchan will look them up on all federated networks
if($abook['abook_xchan'] && $abook['xchan_addr']) {
$h = self::get_hublocs($abook['abook_xchan']);
if(! $h) {
$xhash = import_author_xchan(encode_item_xchan($abook));
if(! $xhash) {
logger('Import of ' . $abook['xchan_addr'] . ' failed.');
continue;
}
}
}
foreach($abook as $k => $v) {
if(in_array($k,$disallowed) || (strpos($k,'abook') !== 0))
continue;
$clean[$k] = $v;
}
if(! array_key_exists('abook_xchan',$clean))
continue;
if(array_key_exists('abook_instance',$clean) && $clean['abook_instance'] && strpos($clean['abook_instance'],z_root()) === false) {
$clean['abook_not_here'] = 1;
}
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($clean['abook_xchan']),
intval($channel['channel_id'])
);
// make sure we have an abook entry for this xchan on this system
if(! $r) {
if($max_friends !== false && $total_friends > $max_friends) {
logger('total_channels service class limit exceeded');
continue;
}
if($max_feeds !== false && intval($clean['abook_feed']) && $total_feeds > $max_feeds) {
logger('total_feeds service class limit exceeded');
continue;
}
abook_store_lowlevel(
[
'abook_xchan' => $clean['abook_xchan'],
'abook_account' => $channel['channel_account_id'],
'abook_channel' => $channel['channel_id']
]
);
$total_friends ++;
if(intval($clean['abook_feed']))
$total_feeds ++;
}
if(count($clean)) {
foreach($clean as $k => $v) {
if($k == 'abook_dob')
$v = dbescdate($v);
$r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v)
. "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id']));
}
}
// This will set abconfig vars if the sender is using old-style fixed permissions
// using the raw abook record as passed to us. New-style permissions will fall through
// and be set using abconfig
translate_abook_perms_inbound($channel,$abook);
if($abconfig) {
/// @fixme does not handle sync of del_abconfig
foreach($abconfig as $abc) {
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
}
}
}
}
// sync collections (privacy groups) oh joy...
if(array_key_exists('collections',$arr) && is_array($arr['collections']) && count($arr['collections'])) {
$x = q("select * from groups where uid = %d",
intval($channel['channel_id'])
);
foreach($arr['collections'] as $cl) {
$found = false;
if($x) {
foreach($x as $y) {
if($cl['collection'] == $y['hash']) {
$found = true;
break;
}
}
if($found) {
if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible'])
|| ($y['deleted'] != $cl['deleted'])) {
q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d",
dbesc($cl['name']),
intval($cl['visible']),
intval($cl['deleted']),
dbesc($cl['collection']),
intval($channel['channel_id'])
);
}
if(intval($cl['deleted']) && (! intval($y['deleted']))) {
q("delete from group_member where gid = %d",
intval($y['id'])
);
}
}
}
if(! $found) {
$r = q("INSERT INTO groups ( hash, uid, visible, deleted, gname )
VALUES( '%s', %d, %d, %d, '%s' ) ",
dbesc($cl['collection']),
intval($channel['channel_id']),
intval($cl['visible']),
intval($cl['deleted']),
dbesc($cl['name'])
);
}
// now look for any collections locally which weren't in the list we just received.
// They need to be removed by marking deleted and removing the members.
// This shouldn't happen except for clones created before this function was written.
if($x) {
$found_local = false;
foreach($x as $y) {
foreach($arr['collections'] as $cl) {
if($cl['collection'] == $y['hash']) {
$found_local = true;
break;
}
}
if(! $found_local) {
q("delete from group_member where gid = %d",
intval($y['id'])
);
q("update groups set deleted = 1 where id = %d and uid = %d",
intval($y['id']),
intval($channel['channel_id'])
);
}
}
}
}
// reload the group list with any updates
$x = q("select * from groups where uid = %d",
intval($channel['channel_id'])
);
// now sync the members
if(array_key_exists('collection_members', $arr)
&& is_array($arr['collection_members'])
&& count($arr['collection_members'])) {
// first sort into groups keyed by the group hash
$members = array();
foreach($arr['collection_members'] as $cm) {
if(! array_key_exists($cm['collection'],$members))
$members[$cm['collection']] = array();
$members[$cm['collection']][] = $cm['member'];
}
// our group list is already synchronised
if($x) {
foreach($x as $y) {
// for each group, loop on members list we just received
if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) {
$found = false;
$z = q("select xchan from group_member where gid = %d and uid = %d and xchan = '%s' limit 1",
intval($y['id']),
intval($channel['channel_id']),
dbesc($member)
);
if($z)
$found = true;
// if somebody is in the group that wasn't before - add them
if(! $found) {
q("INSERT INTO group_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
intval($channel['channel_id']),
intval($y['id']),
dbesc($member)
);
}
}
}
// now retrieve a list of members we have on this site
$m = q("select xchan from group_member where gid = %d and uid = %d",
intval($y['id']),
intval($channel['channel_id'])
);
if($m) {
foreach($m as $mm) {
// if the local existing member isn't in the list we just received - remove them
if(! in_array($mm['xchan'],$members[$y['hash']])) {
q("delete from group_member where xchan = '%s' and gid = %d and uid = %d",
dbesc($mm['xchan']),
intval($y['id']),
intval($channel['channel_id'])
);
}
}
}
}
}
}
}
if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) {
$disallowed = array('id','aid','uid','guid');
foreach($arr['profile'] as $profile) {
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
);
if(! $x) {
profile_store_lowlevel(
[
'aid' => $channel['channel_account_id'],
'uid' => $channel['channel_id'],
'profile_guid' => $profile['profile_guid'],
]
);
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
);
if(! $x)
continue;
}
$clean = array();
foreach($profile as $k => $v) {
if(in_array($k,$disallowed))
continue;
if($profile['is_default'] && in_array($k,['photo','thumb']))
continue;
if($k === 'name')
$clean['fullname'] = $v;
elseif($k === 'with')
$clean['partner'] = $v;
elseif($k === 'work')
$clean['employment'] = $v;
elseif(array_key_exists($k,$x[0]))
$clean[$k] = $v;
/**
* @TODO
* We also need to import local photos if a custom photo is selected
*/
if((strpos($profile['thumb'],'/photo/profile/l/') !== false) || intval($profile['is_default'])) {
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
}
else {
$profile['photo'] = z_root() . '/photo/' . basename($profile['photo']);
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
}
}
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE profile set " . TQUOT . dbesc($k) . TQUOT . " = '" . dbesc($v)
. "' where profile_guid = '" . dbesc($profile['profile_guid'])
. "' and uid = " . intval($channel['channel_id']));
}
}
}
}
$addon = ['channel' => $channel, 'data' => $arr];
/**
* @hooks process_channel_sync_delivery
* Called when accepting delivery of a 'sync packet' containing structure and table updates from a channel clone.
* * \e array \b channel
* * \e array \b data
*/
call_hooks('process_channel_sync_delivery', $addon);
// we should probably do this for all items, but usually we only send one.
if(array_key_exists('item',$arr) && is_array($arr['item'][0])) {
$DR = new \Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed');
$DR->addto_recipient($channel['channel_name'] . ' <' . channel_reddress($channel) . '>');
}
else
$DR = new \Zotlabs\Lib\DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered');
$result[] = $DR->get();
}
return $result;
}
/**
* @brief Returns path to /rpost
*

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/bookmarks.php');
@ -76,7 +76,7 @@ class Chat extends \Zotlabs\Web\Controller {
intval(local_channel())
);
Libzot::build_sync_packet(0, array('chatroom' => $x));
Libsync::build_sync_packet(0, array('chatroom' => $x));
if($x)
goaway(z_root() . '/chat/' . $channel['channel_address'] . '/' . $x[0]['cr_id']);

View file

@ -2,6 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/* @file connedit.php
* @brief In this file the connection-editor form is generated and evaluated.
@ -374,7 +375,7 @@ class Connedit extends \Zotlabs\Web\Controller {
if($abconfig)
$clone['abconfig'] = $abconfig;
Libzot::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
}
/* @brief Generate content of connection edit page
@ -546,7 +547,7 @@ class Connedit extends \Zotlabs\Web\Controller {
// PLACEHOLDER
contact_remove(local_channel(), $orig_record[0]['abook_id']);
Libzot::build_sync_packet(0 /* use the current local_channel */,
Libsync::build_sync_packet(0 /* use the current local_channel */,
array('abook' => array(array(
'abook_xchan' => $orig_record[0]['abook_xchan'],
'entry_deleted' => true))

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@ -157,7 +157,7 @@ class Defperms extends \Zotlabs\Web\Controller {
if($abconfig)
$clone['abconfig'] = $abconfig;
Libzot::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
}
/* @brief Generate content of connection default permissions page

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/conversation.php');
require_once('include/bbcode.php');
@ -233,7 +233,7 @@ class Events extends \Zotlabs\Web\Controller {
intval($channel['channel_id'])
);
if($z) {
Libzot::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
}
}
}
@ -727,7 +727,7 @@ class Events extends \Zotlabs\Web\Controller {
intval(local_channel())
);
$sync_event['event_deleted'] = 1;
Libzot::build_sync_packet(0,array('event' => array($sync_event)));
Libsync::build_sync_packet(0,array('event' => array($sync_event)));
info( t('Event removed') . EOL);
}

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/attach.php');
require_once('include/channel.php');
@ -43,7 +43,7 @@ class File_upload extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$hash);
if($sync) {
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
goaway(z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path']);
@ -99,7 +99,7 @@ class File_upload extends \Zotlabs\Web\Controller {
if($r['success']) {
$sync = attach_export_data($channel,$r['data']['hash']);
if($sync)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
}

View file

@ -6,7 +6,7 @@ namespace Zotlabs\Module;
*/
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Filestorage extends \Zotlabs\Web\Controller {
@ -127,7 +127,7 @@ class Filestorage extends \Zotlabs\Web\Controller {
if(! $admin_delete) {
$sync = attach_export_data($channel, $f['hash'], true);
if($sync) {
Libzot::build_sync_packet($channel['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'], array('file' => array($sync)));
}
}

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/follow.php');
@ -51,7 +51,7 @@ class Follow extends \Zotlabs\Web\Controller {
if($abconfig)
$clone['abconfig'] = $abconfig;
Libzot::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)), true);
Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)), true);
$can_view_stream = their_perms_contains($channel['channel_id'],$clone['abook_xchan'],'view_stream');

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/group.php');
@ -59,7 +59,7 @@ class Group extends \Zotlabs\Web\Controller {
);
if($r)
info( t('Privacy group updated.') . EOL );
Libzot::build_sync_packet(local_channel(),null,true);
Libsync::build_sync_packet(local_channel(),null,true);
}
goaway(z_root() . '/group/' . argv(1) . '/' . argv(2));

View file

@ -17,7 +17,7 @@ namespace Zotlabs\Module;
*
*/
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/crypto.php');
require_once('include/attach.php');
@ -916,7 +916,7 @@ logger('linkify: ' . print_r($results,true));
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
}
}
if(! $nopush)
@ -1025,7 +1025,7 @@ logger('linkify: ' . print_r($results,true));
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true))));
}
}
@ -1124,7 +1124,7 @@ logger('linkify: ' . print_r($results,true));
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
}
if($complex) {

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/security.php');
require_once('include/bbcode.php');
@ -228,7 +228,7 @@ class Like extends \Zotlabs\Web\Controller {
if($z) {
$z[0]['deleted'] = 1;
Libzot::build_sync_packet($ch[0]['channel_id'],array('likes' => $z));
Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $z));
q("delete from likes where id = %d",
intval($z[0]['id'])
@ -552,7 +552,7 @@ class Like extends \Zotlabs\Web\Controller {
dbesc($obj_id)
);
if($r)
Libzot::build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
}

View file

@ -2,6 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/acl_selectors.php');
require_once('include/message.php');
@ -110,7 +111,7 @@ class Mail extends \Zotlabs\Web\Controller {
if($ret['success']) {
xchan_mail_query($ret['mail']);
Libzot::build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true))));
Libsync::build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true))));
}
else {
notice($ret['message']);
@ -188,7 +189,7 @@ class Mail extends \Zotlabs\Web\Controller {
intval(local_channel())
);
if($x) {
Libzot::build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true)));
Libsync::build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true)));
}
\Zotlabs\Daemon\Master::Summon(array('Notifier','mail',intval(argv(3))));

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/conversation.php');
@ -79,7 +79,7 @@ class Moderate extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true))));
}
if($action === 'approve') {
\Zotlabs\Daemon\Master::Summon(array('Notifier', 'comment-new', $post_id));

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module; /** @file */
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Notes extends \Zotlabs\Web\Controller {
@ -31,7 +31,7 @@ class Notes extends \Zotlabs\Web\Controller {
if((argc() > 1) && (argv(1) === 'sync')) {
require_once('include/zot.php');
Libzot::build_sync_packet();
Libsync::build_sync_packet();
}
logger('notes saved.', LOGGER_DEBUG);

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
@ -33,7 +33,7 @@ class Pconfig extends \Zotlabs\Web\Controller {
}
set_pconfig(local_channel(),$cat,$k,$v);
Libzot::build_sync_packet();
Libsync::build_sync_packet();
goaway(z_root() . '/pconfig/' . $cat . '/' . $k);

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Pdledit extends \Zotlabs\Web\Controller {
@ -18,7 +18,7 @@ class Pdledit extends \Zotlabs\Web\Controller {
goaway(z_root() . '/pdledit');
}
set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content']));
Libzot::build_sync_packet();
Libsync::build_sync_packet();
info( t('Layout updated.') . EOL);
goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
}

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/photo/photo_driver.php');
require_once('include/photos.php');
@ -163,7 +163,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$folder_hash, true);
if($sync)
Libzot::build_sync_packet($page_owner_uid,array('file' => array($sync)));
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
}
@ -190,7 +190,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$r[0]['resource_id'], true);
if($sync)
Libzot::build_sync_packet($page_owner_uid,array('file' => array($sync)));
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
elseif(is_site_admin()) {
// If the admin deletes a photo, don't sync
@ -211,7 +211,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],argv(2),true);
if($sync)
Libzot::build_sync_packet($page_owner_uid,array('file' => array($sync)));
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
if(! ($_POST['desc'] && $_POST['newtag']))
goaway(z_root() . '/' . $_SESSION['photo_return']);
@ -450,7 +450,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$resource_id);
if($sync)
Libzot::build_sync_packet($page_owner_uid,array('file' => array($sync)));
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
goaway(z_root() . '/' . $_SESSION['photo_return']);
return; // NOTREACHED

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/*
* @file Profile_photo.php
@ -212,7 +212,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles));
// Similarly, tell the nav bar to bypass the cache and update the avatar image.
@ -377,7 +377,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$resource_id);
if($sync)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
\Zotlabs\Daemon\Master::Summon(array('Directory',local_channel()));

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/channel.php');
require_once('include/selectors.php');
@ -601,7 +601,7 @@ class Profiles extends \Zotlabs\Web\Controller {
);
if($r) {
require_once('include/zot.php');
Libzot::build_sync_packet(local_channel(),array('profile' => $r));
Libsync::build_sync_packet(local_channel(),array('profile' => $r));
}
$channel = \App::get_channel();

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/selectors.php');
@ -290,7 +290,7 @@ class Channel {
\Zotlabs\Daemon\Master::Summon(array('Directory',local_channel()));
Libzot::build_sync_packet();
Libsync::build_sync_packet();
if($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) {

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Display {
@ -91,7 +91,7 @@ class Display {
);
call_hooks('display_settings_post', $_POST);
Libzot::build_sync_packet();
Libsync::build_sync_packet();
goaway(z_root() . '/settings/display' );
return; // NOTREACHED
}

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Featured {
@ -26,7 +26,7 @@ class Featured {
}
Libzot::build_sync_packet();
Libsync::build_sync_packet();
return;
}

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Features {
@ -20,7 +20,7 @@ class Features {
set_pconfig(local_channel(),'feature', $k, '');
}
}
Libzot::build_sync_packet();
Libsync::build_sync_packet();
return;
}

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Permcats {
@ -38,7 +38,7 @@ class Permcats {
\Zotlabs\Lib\Permcat::update(local_channel(),$name,$pcarr);
Libzot::build_sync_packet();
Libsync::build_sync_packet();
info( t('Permission category saved.') . EOL);
@ -59,7 +59,7 @@ class Permcats {
if(argc() > 3 && argv(3) === 'drop') {
\Zotlabs\Lib\Permcat::delete(local_channel(),$name);
Libzot::build_sync_packet();
Libsync::build_sync_packet();
json_return_and_die([ 'success' => true ]);
}

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
class Starred extends \Zotlabs\Web\Controller {
@ -38,7 +38,7 @@ class Starred extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet(local_channel(),[
Libsync::build_sync_packet(local_channel(),[
'item' => [
encode_item($sync_item[0],true)
]

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/security.php');
require_once('include/bbcode.php');
@ -151,7 +151,7 @@ class Tagger extends \Zotlabs\Web\Controller {
$ret = post_activity_item($arr);
if($ret['success']) {
Libzot::build_sync_packet(local_channel(),
Libsync::build_sync_packet(local_channel(),
[
'item' => [ encode_item($ret['activity'],true) ]
]

View file

@ -6,7 +6,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/security.php');
require_once('include/selectors.php');
@ -126,7 +126,7 @@ class Thing extends \Zotlabs\Web\Controller {
dbesc($term_hash)
);
if($r) {
Libzot::build_sync_packet(0, array('obj' => $r));
Libsync::build_sync_packet(0, array('obj' => $r));
}
return;
@ -182,7 +182,7 @@ class Thing extends \Zotlabs\Web\Controller {
dbesc($hash)
);
if($r) {
Libzot::build_sync_packet(0, array('obj' => $r));
Libsync::build_sync_packet(0, array('obj' => $r));
}
if($activity) {
@ -355,7 +355,7 @@ class Thing extends \Zotlabs\Web\Controller {
$r[0]['obj_deleted'] = 1;
Libzot::build_sync_packet(0,array('obj' => $r));
Libsync::build_sync_packet(0,array('obj' => $r));
return $o;
}

View file

@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/attach.php');
require_once('include/photos.php');
@ -104,7 +104,7 @@ class Wall_attach extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$r['data']['hash']);
if($sync) {
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
if($using_api)

View file

@ -3,7 +3,7 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/**
* @brief RedDirectory class.
@ -180,7 +180,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
if ($ch) {
$sync = attach_export_data($ch, $this->folder_hash);
if ($sync)
Libzot::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
$this->red_path = $new_path;
@ -369,7 +369,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
$sync = attach_export_data($c[0], $hash);
if ($sync)
Libzot::build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
}
/**
@ -402,7 +402,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG);
if($sync) {
Libzot::build_sync_packet($r[0]['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($r[0]['channel_id'], array('file' => array($sync)));
}
}
else {
@ -433,7 +433,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
if ($ch) {
$sync = attach_export_data($ch, $this->folder_hash, true);
if ($sync)
Libzot::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
}

View file

@ -3,7 +3,7 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
/**
* @brief This class represents a file in DAV.
@ -107,7 +107,7 @@ class File extends DAV\Node implements DAV\IFile {
if($ch) {
$sync = attach_export_data($ch,$this->data['hash']);
if($sync)
Libzot::build_sync_packet($ch['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($ch['channel_id'],array('file' => array($sync)));
}
}
@ -255,7 +255,7 @@ class File extends DAV\Node implements DAV\IFile {
$sync = attach_export_data($c[0],$this->data['hash']);
if($sync)
Libzot::build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
}
@ -379,7 +379,7 @@ class File extends DAV\Node implements DAV\IFile {
if($ch) {
$sync = attach_export_data($ch, $this->data['hash'], true);
if($sync)
Libzot::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
}
}

View file

@ -11,7 +11,7 @@
* @todo Also an 'append' option to the storage function might be a useful addition.
*/
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/permissions.php');
require_once('include/security.php');
@ -1006,7 +1006,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$sync = attach_export_data($channel,$hash);
if($sync)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
if($notify) {
@ -1393,7 +1393,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
$data = attach_export_data($channel,$resource);
if($data)
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($data)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($data)));
}
}

View file

@ -5,6 +5,7 @@
*/
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/crypto.php');
require_once('include/menu.php');
@ -570,7 +571,7 @@ function change_channel_keys($channel) {
}
}
Libzot::build_sync_packet($channel['channel_id'], [ 'keychange' => $stored ]);
Libsync::build_sync_packet($channel['channel_id'], [ 'keychange' => $stored ]);
$a = q("select * from abook where abook_xchan = '%s' and abook_self = 1",
dbesc($stored['old_hash'])
@ -2011,7 +2012,7 @@ function profiles_build_sync($channel_id,$send = true) {
);
if($r) {
if($send) {
Libzot::build_sync_packet($channel_id,array('profile' => $r));
Libsync::build_sync_packet($channel_id,array('profile' => $r));
}
else {
return $r;

View file

@ -1,6 +1,6 @@
<?php /** @file */
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
function group_add($uid,$name,$public = 0) {
@ -46,7 +46,7 @@ function group_add($uid,$name,$public = 0) {
$ret = $r;
}
Libzot::build_sync_packet($uid,null,true);
Libsync::build_sync_packet($uid,null,true);
return $ret;
}
@ -115,7 +115,7 @@ function group_rmv($uid,$name) {
}
Libzot::build_sync_packet($uid,null,true);
Libsync::build_sync_packet($uid,null,true);
return $ret;
}
@ -157,7 +157,7 @@ function group_rmv_member($uid,$name,$member) {
dbesc($member)
);
Libzot::build_sync_packet($uid,null,true);
Libsync::build_sync_packet($uid,null,true);
return $r;
@ -188,7 +188,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
dbesc($member)
);
Libzot::build_sync_packet($uid,null,true);
Libsync::build_sync_packet($uid,null,true);
return $r;
}

View file

@ -5,6 +5,7 @@
*/
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
use Zotlabs\Lib as Zlib;
@ -4529,7 +4530,7 @@ function sync_an_item($channel_id,$item_id) {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet($channel_d,array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet($channel_d,array('item' => array(encode_item($sync_item[0],true))));
}
}
@ -4730,7 +4731,7 @@ function item_create_edit_activity($post) {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
Libzot::build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true))));
Libsync::build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true))));
}
}

View file

@ -1,7 +1,7 @@
<?php /** @file */
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/security.php');
require_once('include/bbcode.php');
@ -403,7 +403,7 @@ function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) {
if($m) {
if($delete)
$m['menu_delete'] = 1;
Libzot::build_sync_packet($uid,array('menu' => array(menu_element($c,$m))));
Libsync::build_sync_packet($uid,array('menu' => array(menu_element($c,$m))));
}
}
}

View file

@ -3,7 +3,7 @@
/* Private Message backend API */
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
require_once('include/crypto.php');
require_once('include/attach.php');
@ -496,7 +496,7 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation
intval($channel_id)
);
}
Libzot::build_sync_packet($channel_id,$m);
Libsync::build_sync_packet($channel_id,$m);
return true;
}
else {
@ -506,7 +506,7 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation
intval($messageitem_id),
intval($channel_id)
);
Libzot::build_sync_packet($channel_id,array('mail' => array(encode_mail($x,true))));
Libsync::build_sync_packet($channel_id,array('mail' => array(encode_mail($x,true))));
return true;
}
return false;

View file

@ -3,7 +3,7 @@
// connect utility
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
if(! file_exists('include/cli_startup.php')) {
echo t('Run from the top level $Projectname web directory, as util/connect <args>') . PHP_EOL;
@ -53,7 +53,7 @@ cli_startup();
$abconfig = load_abconfig($c['channel_id'],$clone['abook_xchan']);
if($abconfig)
$clone['abconfig'] = $abconfig;
Libzot::build_sync_packet($c['channel_id'], array('abook' => array($clone)), true);
Libsync::build_sync_packet($c['channel_id'], array('abook' => array($clone)), true);
$can_view_stream = their_perms_contains($c['channel_id'],$clone['abook_xchan'],'view_stream');

View file

@ -2,7 +2,7 @@
<?php
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
// file import to DAV utility
@ -55,6 +55,6 @@ if($argc != 2) {
$sync = attach_export_data($channel,$hash);
if($sync) {
Libzot::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
}

View file

@ -3,7 +3,7 @@
// Red pconfig utility
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
if(!file_exists('include/cli_startup.php')) {
@ -65,7 +65,7 @@ if($argc > 2 && strpos($argv[2],'.')) {
if($argc > 4) {
set_pconfig($argv[1],$argv[2],$argv[3],$argv[4]);
Libzot::build_sync_packet($argv[1]);
Libsync::build_sync_packet($argv[1]);
echo "pconfig[{$argv[1]}][{$argv[2]}][{$argv[3]}] = " . get_pconfig($argv[1],$argv[2],$argv[3]) . "\n";
}