aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Cron.php9
-rw-r--r--Zotlabs/Daemon/Importfile.php4
-rw-r--r--Zotlabs/Daemon/Onepoll.php6
-rw-r--r--Zotlabs/Lib/Activity.php238
-rw-r--r--Zotlabs/Lib/ActivityStreams.php13
-rw-r--r--Zotlabs/Lib/Apps.php6
-rw-r--r--Zotlabs/Lib/Chatroom.php4
-rw-r--r--Zotlabs/Lib/Connect.php2
-rw-r--r--Zotlabs/Lib/Enotify.php3
-rw-r--r--Zotlabs/Lib/NativeWiki.php6
-rw-r--r--Zotlabs/Lib/Share.php3
-rw-r--r--Zotlabs/Lib/ThreadItem.php2
-rw-r--r--Zotlabs/Module/Activity.php2
-rw-r--r--Zotlabs/Module/Channel_calendar.php8
-rw-r--r--Zotlabs/Module/Chat.php6
-rw-r--r--Zotlabs/Module/Connedit.php5
-rw-r--r--Zotlabs/Module/Cover_photo.php6
-rw-r--r--Zotlabs/Module/Defperms.php3
-rw-r--r--Zotlabs/Module/Display.php5
-rw-r--r--Zotlabs/Module/File_upload.php6
-rw-r--r--Zotlabs/Module/Filestorage.php12
-rw-r--r--Zotlabs/Module/Group.php3
-rw-r--r--Zotlabs/Module/Item.php100
-rw-r--r--Zotlabs/Module/Like.php5
-rw-r--r--Zotlabs/Module/Moderate.php4
-rw-r--r--Zotlabs/Module/Notes.php3
-rw-r--r--Zotlabs/Module/Pconfig.php4
-rw-r--r--Zotlabs/Module/Pdledit.php3
-rw-r--r--Zotlabs/Module/Permcats.php5
-rw-r--r--Zotlabs/Module/Photos.php10
-rw-r--r--Zotlabs/Module/Profile_photo.php8
-rw-r--r--Zotlabs/Module/Profiles.php4
-rw-r--r--Zotlabs/Module/Settings/Calendar.php3
-rw-r--r--Zotlabs/Module/Settings/Channel.php3
-rw-r--r--Zotlabs/Module/Settings/Channel_home.php4
-rw-r--r--Zotlabs/Module/Settings/Connections.php3
-rw-r--r--Zotlabs/Module/Settings/Conversation.php3
-rw-r--r--Zotlabs/Module/Settings/Directory.php3
-rw-r--r--Zotlabs/Module/Settings/Display.php3
-rw-r--r--Zotlabs/Module/Settings/Editor.php3
-rw-r--r--Zotlabs/Module/Settings/Events.php3
-rw-r--r--Zotlabs/Module/Settings/Featured.php3
-rw-r--r--Zotlabs/Module/Settings/Features.php4
-rw-r--r--Zotlabs/Module/Settings/Manage.php4
-rw-r--r--Zotlabs/Module/Settings/Network.php3
-rw-r--r--Zotlabs/Module/Settings/Photos.php3
-rw-r--r--Zotlabs/Module/Settings/Profiles.php4
-rw-r--r--Zotlabs/Module/Share.php3
-rw-r--r--Zotlabs/Module/Sharedwithme.php99
-rw-r--r--Zotlabs/Module/Sse_bs.php22
-rw-r--r--Zotlabs/Module/Starred.php3
-rw-r--r--Zotlabs/Module/Tagger.php4
-rw-r--r--Zotlabs/Module/Thing.php8
-rw-r--r--Zotlabs/Module/Wall_attach.php4
-rw-r--r--Zotlabs/Storage/Directory.php9
-rw-r--r--Zotlabs/Storage/File.php7
-rw-r--r--Zotlabs/Update/_1236.php46
57 files changed, 501 insertions, 251 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index bd4e0b294..46f4e4071 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Daemon;
+use Zotlabs\Lib\Libsync;
+
class Cron {
static public function run($argc,$argv) {
@@ -36,11 +38,6 @@ class Cron {
Master::Summon(array('Poller'));
- // maintenance for mod sharedwithme - check for updated items and remove them
-
- require_once('include/sharedwithme.php');
- apply_updates();
-
/**
* Chatpresence: if somebody hasn't pinged recently, they've most likely left the page
* and shouldn't count as online anymore. We allow an expection for bots.
@@ -147,7 +144,7 @@ class Cron {
if($z) {
xchan_query($z);
$sync_item = fetch_post_tags($z);
- build_sync_packet($sync_item[0]['uid'],
+ Libsync::build_sync_packet($sync_item[0]['uid'],
[
'item' => [ encode_item($sync_item[0],true) ]
]
diff --git a/Zotlabs/Daemon/Importfile.php b/Zotlabs/Daemon/Importfile.php
index c68ed21cf..749949679 100644
--- a/Zotlabs/Daemon/Importfile.php
+++ b/Zotlabs/Daemon/Importfile.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Daemon;
+use Zotlabs\Lib\Libsync;
+
class Importfile {
static public function run($argc,$argv){
@@ -40,7 +42,7 @@ class Importfile {
$sync = attach_export_data($channel,$hash);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
return;
}
diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php
index 2f06ec125..fdcb907d1 100644
--- a/Zotlabs/Daemon/Onepoll.php
+++ b/Zotlabs/Daemon/Onepoll.php
@@ -76,7 +76,11 @@ class Onepoll {
// update permissions
- $x = zot_refresh($contact,$importer);
+ if($contact['xchan_network'] === 'zot6')
+ $x = Libzot::refresh($contact,$importer);
+
+ if($contact['xchan_network'] === 'zot')
+ $x = zot_refresh($contact,$importer);
$responded = false;
$updated = datetime_convert();
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 3c16a5367..5c72a1175 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -178,7 +178,6 @@ class Activity {
static function fetch_image($x) {
-
$ret = [
'type' => 'Image',
'id' => $x['id'],
@@ -419,7 +418,71 @@ class Activity {
$ret['attachment'] = $a;
}
+ $public = (($i['item_private']) ? false : true);
+ $top_level = (($i['mid'] === $i['parent_mid']) ? true : false);
+
+ if ($public) {
+ $ret['to'] = [ ACTIVITY_PUBLIC_INBOX ];
+ $ret['cc'] = [ z_root() . '/followers/' . substr($i['author']['xchan_addr'],0,strpos($i['author']['xchan_addr'],'@')) ];
+ }
+ else {
+
+ // private activity
+
+ if ($top_level) {
+ $ret['to'] = self::map_acl($i);
+ }
+ else {
+ $ret['to'] = [];
+ if ($ret['tag']) {
+ foreach ($ret['tag'] as $mention) {
+ if (is_array($mention) && array_key_exists('href',$mention) && $mention['href']) {
+ $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1",
+ dbesc($mention['href'])
+ );
+ if ($h) {
+ if ($h[0]['hubloc_network'] === 'activitypub') {
+ $addr = $h[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $h[0]['hubloc_id_url'];
+ }
+ if (! in_array($addr,$ret['to'])) {
+ $ret['to'][] = $addr;
+ }
+ }
+ }
+ }
+ }
+ $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d limit 1",
+ intval($i['parent'])
+ );
+ if ($d) {
+ if ($d[0]['hubloc_network'] === 'activitypub') {
+ $addr = $d[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $d[0]['hubloc_id_url'];
+ }
+ if (! in_array($addr,$ret['to'])) {
+ $ret['cc'][] = $addr;
+ }
+ }
+ }
+ }
+
+ $mentions = self::map_mentions($i);
+ if (count($mentions) > 0) {
+ if (! $ret['to']) {
+ $ret['to'] = $mentions;
+ }
+ else {
+ $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions)));
+ }
+ }
+
return $ret;
+
}
static function decode_taxonomy($item) {
@@ -756,57 +819,155 @@ class Activity {
return [];
}
+ $t = self::encode_taxonomy($i);
+ if ($t) {
+ $ret['tag'] = $t;
+ }
+
+ // addressing madness
+
+ $public = (($i['item_private']) ? false : true);
+ $top_level = (($reply) ? false : true);
+
+ if ($public) {
+ $ret['to'] = [ ACTIVITY_PUBLIC_INBOX ];
+ $ret['cc'] = [ z_root() . '/followers/' . substr($i['author']['xchan_addr'],0,strpos($i['author']['xchan_addr'],'@')) ];
+ }
+ else {
+
+ // private activity
+
+ if ($top_level) {
+ $ret['to'] = self::map_acl($i);
+ }
+ else {
+ $ret['to'] = [];
+ if ($ret['tag']) {
+ foreach ($ret['tag'] as $mention) {
+ if (is_array($mention) && array_key_exists('href',$mention) && $mention['href']) {
+ $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1",
+ dbesc($mention['href'])
+ );
+ if ($h) {
+ if ($h[0]['hubloc_network'] === 'activitypub') {
+ $addr = $h[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $h[0]['hubloc_id_url'];
+ }
+ if (! in_array($addr,$ret['to'])) {
+ $ret['to'][] = $addr;
+ }
+ }
+ }
+ }
+ }
+
+ $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d limit 1",
+ intval($i['parent'])
+ );
+ if ($d) {
+ if ($d[0]['hubloc_network'] === 'activitypub') {
+ $addr = $d[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $d[0]['hubloc_id_url'];
+ }
+ if (! in_array($addr,$ret['to'])) {
+ $ret['cc'][] = $addr;
+ }
+ }
+ }
+ }
+
+ $mentions = self::map_mentions($i);
+ if (count($mentions) > 0) {
+ if (! $ret['to']) {
+ $ret['to'] = $mentions;
+ }
+ else {
+ $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions)));
+ }
+ }
+
return $ret;
}
+ // Returns an array of URLS for any mention tags found in the item array $i.
+
static function map_mentions($i) {
- if(! $i['term']) {
+
+ if (! $i['term']) {
return [];
}
$list = [];
foreach ($i['term'] as $t) {
- if($t['ttype'] == TERM_MENTION) {
- $list[] = $t['url'];
+ if (! $t['url']) {
+ continue;
+ }
+ if ($t['ttype'] == TERM_MENTION) {
+ $url = self::lookup_term_url($t['url']);
+ $list[] = (($url) ? $url : $t['url']);
}
}
return $list;
}
- static function map_acl($i,$mentions = false) {
-
- $private = false;
- $list = [];
- $x = collect_recipients($i,$private);
- if($x) {
- stringify_array_elms($x);
- if(! $x)
- return;
+ // Returns an array of all recipients targeted by private item array $i.
- $strict = (($mentions) ? true : get_config('activitypub','compliance'));
+ static function map_acl($i) {
+ $ret = [];
- $sql_extra = (($strict) ? " and xchan_network = 'activitypub' " : '');
+ if (! $i['item_private']) {
+ return $ret;
+ }
- $details = q("select xchan_url, xchan_addr, xchan_name from xchan where xchan_hash in (" . implode(',',$x) . ") $sql_extra");
+ if ($i['allow_gid']) {
+ $tmp = expand_acl($i['allow_gid']);
+ if ($tmp) {
+ foreach ($tmp as $t) {
+ $ret[] = z_root() . '/lists/' . $t;
+ }
+ }
+ }
- if($details) {
- foreach($details as $d) {
- if($mentions) {
- $list[] = [ 'type' => 'Mention', 'href' => $d['xchan_url'], 'name' => '@' . (($d['xchan_addr']) ? $d['xchan_addr'] : $d['xchan_name']) ];
- }
- else {
- $list[] = $d['xchan_url'];
+ if ($i['allow_cid']) {
+ $tmp = expand_acl($i['allow_cid']);
+ $list = stringify_array($tmp,true);
+ if ($list) {
+ $details = q("select hubloc_id_url from hubloc where hubloc_hash in (" . $list . ") and hubloc_id_url != ''");
+ if ($details) {
+ foreach ($details as $d) {
+ $ret[] = $d['hubloc_id_url'];
}
}
}
}
- return $list;
-
+ return $ret;
}
+ static function lookup_term_url($url) {
+
+ // The xchan_url for mastodon is a text/html rendering. This is called from map_mentions where we need
+ // to convert the mention url to an ActivityPub id. If this fails for any reason, return the url we have
+
+ $r = q("select hubloc_network, hubloc_hash, hubloc_id_url from hubloc where hubloc_id_url = '%s' limit 1",
+ dbesc($url)
+ );
+
+ if ($r) {
+ if ($r[0]['hubloc_network'] === 'activitypub') {
+ return $r[0]['hubloc_hash'];
+ }
+ return $r[0]['hubloc_id_url'];
+ }
+
+ return $url;
+ }
static function encode_person($p, $extended = true) {
@@ -969,7 +1130,6 @@ class Activity {
'http://activitystrea.ms/schema/1.0/photo' => 'Image',
'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon',
'http://activitystrea.ms/schema/1.0/event' => 'Event',
- 'http://activitystrea.ms/schema/1.0/wiki' => 'Document',
'http://purl.org/zot/activity/location' => 'Place',
'http://purl.org/zot/activity/chessgame' => 'Game',
'http://purl.org/zot/activity/tagterm' => 'zot:Tag',
@@ -977,7 +1137,10 @@ class Activity {
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
'Invite' => 'Invite',
- 'Question' => 'Question'
+ 'Question' => 'Question',
+ 'Document' => 'Document',
+ 'Audio' => 'Audio',
+ 'Video' => 'Video'
];
call_hooks('activity_obj_decode_mapper',$objs);
@@ -1005,7 +1168,6 @@ class Activity {
'http://activitystrea.ms/schema/1.0/photo' => 'Image',
'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon',
'http://activitystrea.ms/schema/1.0/event' => 'Event',
- 'http://activitystrea.ms/schema/1.0/wiki' => 'Document',
'http://purl.org/zot/activity/location' => 'Place',
'http://purl.org/zot/activity/chessgame' => 'Game',
'http://purl.org/zot/activity/tagterm' => 'zot:Tag',
@@ -1013,7 +1175,9 @@ class Activity {
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
'Invite' => 'Invite',
- 'Question' => 'Question'
+ 'Question' => 'Question',
+ 'Audio' => 'Audio',
+ 'Video' => 'Video'
];
call_hooks('activity_obj_mapper',$objs);
@@ -2077,9 +2241,7 @@ class Activity {
}
- // avoid double images from hubzilla to zap/osada
-
- if($act->obj['type'] === 'Image' && strpos($s['body'],'zrl=') === false) {
+ if($act->obj['type'] === 'Image') {
$ptr = null;
@@ -2093,10 +2255,11 @@ class Activity {
}
foreach($ptr as $vurl) {
if(strpos($s['body'],$vurl['href']) === false) {
- $s['body'] .= '[zmg]' . $vurl['href'] . '[/zmg]' . "\n\n" . $s['body'];
+ $bb_imgs .= '[zmg]' . $vurl['href'] . '[/zmg]' . "\n\n";
break;
}
}
+ $s['body'] = $bb_imgs . $s['body'];
}
elseif(is_string($act->obj['url'])) {
if(strpos($s['body'],$act->obj['url']) === false) {
@@ -2177,8 +2340,13 @@ class Activity {
$s['plink'] = $s['mid'];
}
- if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips)))
- $s['item_private'] = 1;
+ // assume this is private unless specifically told otherwise.
+
+ $s['item_private'] = 1;
+
+ if ($act->recips && in_array(ACTIVITY_PUBLIC_INBOX, $act->recips)) {
+ $s['item_private'] = 0;
+ }
if (is_array($act->obj)) {
if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) {
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index d8bd72943..b1ef59364 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -146,15 +146,20 @@ class ActivityStreams {
*/
function collect_recips($base = '', $namespace = '') {
$x = [];
+
$fields = [ 'to', 'cc', 'bto', 'bcc', 'audience'];
foreach($fields as $f) {
$y = $this->get_compound_property($f, $base, $namespace);
if($y) {
- $x = array_merge($x, $y);
- if(! is_array($this->raw_recips))
+ if (! is_array($this->raw_recips)) {
$this->raw_recips = [];
+ }
- $this->raw_recips[$f] = $x;
+ if (! is_array($y)) {
+ $y = [ $y ];
+ }
+ $this->raw_recips[$f] = $y;
+ $x = array_merge($x, $y);
}
}
// not yet ready for prime time
@@ -411,4 +416,4 @@ class ActivityStreams {
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 9d60e9eae..d65eed14f 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Lib;
+use Zotlabs\Lib\Libsync;
+
require_once('include/plugin.php');
require_once('include/channel.php');
@@ -603,7 +605,7 @@ class Apps {
intval(TERM_OBJ_APP),
intval($r[0]['id'])
);
- build_sync_packet($uid,array('app' => $r[0]));
+ Libsync::build_sync_packet($uid,array('app' => $r[0]));
}
}
}
@@ -669,7 +671,7 @@ class Apps {
);
}
if(! intval($x[0]['app_system'])) {
- build_sync_packet($uid,array('app' => $x));
+ Libsync::build_sync_packet($uid,array('app' => $x));
}
}
else {
diff --git a/Zotlabs/Lib/Chatroom.php b/Zotlabs/Lib/Chatroom.php
index 882c846cd..34853b6ab 100644
--- a/Zotlabs/Lib/Chatroom.php
+++ b/Zotlabs/Lib/Chatroom.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Lib;
+use Zotlabs\Lib\Libsync;
+
/**
* @brief A class with chatroom related static methods.
*/
@@ -91,7 +93,7 @@ class Chatroom {
return $ret;
}
- 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'])
diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php
index 5fc0e3fe1..caac30f7a 100644
--- a/Zotlabs/Lib/Connect.php
+++ b/Zotlabs/Lib/Connect.php
@@ -97,7 +97,7 @@ class Connect {
$feeds = get_config('system','feed_contacts');
if (($feeds) && (in_array($protocol, [ '', 'feed', 'rss' ]))) {
- $d = discover_feed($url);
+ $d = discover_by_url($url);
}
else {
$result['message'] = t('Remote channel or protocol unavailable.');
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 85e90d67c..a4fc8aa75 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -818,6 +818,9 @@ class Enotify {
$itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]');
}
+ if(in_array($item['obj_type'], ['Document', 'Video', 'Audio', 'Image'])) {
+ $itemem_text = t('shared a file with you');
+ }
}
$edit = false;
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php
index 662fddad0..3ec032075 100644
--- a/Zotlabs/Lib/NativeWiki.php
+++ b/Zotlabs/Lib/NativeWiki.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Lib;
+use Zotlabs\Lib\Libsync;
+
define ( 'NWIKI_ITEM_RESOURCE_TYPE', 'nwiki' );
class NativeWiki {
@@ -71,7 +73,7 @@ class NativeWiki {
$arr['item_thread_top'] = 1;
$arr['item_private'] = intval($acl->is_private());
$arr['verb'] = ACTIVITY_CREATE;
- $arr['obj_type'] = ACTIVITY_OBJ_WIKI;
+ $arr['obj_type'] = 'Document';
$arr['body'] = '[table][tr][td][h1]New Wiki[/h1][/td][/tr][tr][td][zrl=' . $wiki_url . ']' . $wiki['htmlName'] . '[/zrl][/td][/tr][/table]';
$arr['public_policy'] = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_wiki'),true);
@@ -178,7 +180,7 @@ class NativeWiki {
foreach($sync_item as $w) {
$pkt[] = encode_item($w,true);
}
- build_sync_packet($uid,array('wiki' => $pkt));
+ Libsync::build_sync_packet($uid,array('wiki' => $pkt));
}
}
}
diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php
index 3a2ab1783..f8b636c10 100644
--- a/Zotlabs/Lib/Share.php
+++ b/Zotlabs/Lib/Share.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Lib;
+use Zotlabs\Lib\Activity;
class Share {
@@ -54,7 +55,7 @@ class Share {
if(! $this->item)
return $obj;
- $obj['asld'] = $this->item['mid'];
+ $obj['asld'] = Activity::fetch_item( [ 'id' => $this->item['mid'] ] );
$obj['type'] = $this->item['obj_type'];
$obj['id'] = $this->item['mid'];
$obj['content'] = $this->item['body'];
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index dee7cda56..a5dd81d40 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -113,7 +113,7 @@ class ThreadItem {
if(intval($item['item_private']) && ($item['owner']['xchan_network'] === 'activitypub')) {
$recips = get_iconfig($item['parent'], 'activitypub', 'recips');
- if(! in_array($observer['xchan_url'], $recips['to']))
+ if(! is_array($recips['to']) || ! in_array($observer['xchan_url'], $recips['to']))
$privacy_warning = true;
}
diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php
index 93b5a15fc..9971ee60f 100644
--- a/Zotlabs/Module/Activity.php
+++ b/Zotlabs/Module/Activity.php
@@ -170,6 +170,8 @@ class Activity extends Controller {
}
+ goaway(z_root() . '/item/' . argv(1));
+
}
}
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 5d5fe300a..ae4afb2f3 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/conversation.php');
require_once('include/bbcode.php');
require_once('include/datetime.php');
@@ -188,7 +190,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
intval($channel['channel_id'])
);
if($z) {
- 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));
}
}
}
@@ -430,7 +432,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($r) {
$sync_event['event_deleted'] = 1;
- build_sync_packet(0,array('event' => array($sync_event)));
+ Libsync::build_sync_packet(0,array('event' => array($sync_event)));
$i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d",
dbesc($event_id),
@@ -479,7 +481,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($ii) {
xchan_query($ii);
$sync_item = fetch_post_tags($ii);
- 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) {
diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php
index db77e2612..6a46cdace 100644
--- a/Zotlabs/Module/Chat.php
+++ b/Zotlabs/Module/Chat.php
@@ -7,9 +7,7 @@ use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Chatroom;
use Zotlabs\Access\AccessList;
-
-
-
+use Zotlabs\Lib\Libsync;
require_once('include/bookmarks.php');
@@ -80,7 +78,7 @@ class Chat extends Controller {
intval(local_channel())
);
- 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']);
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index acd7cb769..c0df57390 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -9,6 +9,7 @@ namespace Zotlabs\Module;
use Zotlabs\Lib\Apps;
use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Libsync;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@@ -382,7 +383,7 @@ class Connedit extends \Zotlabs\Web\Controller {
if($abconfig)
$clone['abconfig'] = $abconfig;
- 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
@@ -558,7 +559,7 @@ class Connedit extends \Zotlabs\Web\Controller {
// PLACEHOLDER
contact_remove(local_channel(), $orig_record[0]['abook_id']);
- 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))
diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php
index d97014f9c..615ca6fe0 100644
--- a/Zotlabs/Module/Cover_photo.php
+++ b/Zotlabs/Module/Cover_photo.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
/*
@file cover_photo.php
@brief Module-file with functions for handling of cover-photos
@@ -66,7 +68,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$r[0]['resource_id']);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
// Update directory in background
@@ -230,7 +232,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
// Update directory in background
\Zotlabs\Daemon\Master::Summon(array('Directory',$channel['channel_id']));
diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php
index 463ecb57a..f2f7c10e5 100644
--- a/Zotlabs/Module/Defperms.php
+++ b/Zotlabs/Module/Defperms.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
+use Zotlabs\Lib\Libsync;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@@ -164,7 +165,7 @@ class Defperms extends Controller {
if($abconfig)
$clone['abconfig'] = $abconfig;
- 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
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index 777d183e1..f45f37001 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -101,7 +101,7 @@ class Display extends \Zotlabs\Web\Controller {
if($decoded)
$item_hash = $decoded;
- $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1",
+ $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1",
dbesc($item_hash . '%')
);
@@ -159,14 +159,17 @@ class Display extends \Zotlabs\Web\Controller {
}
}
if($target_item['item_type'] == ITEM_TYPE_CARD) {
+
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
+
$y = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'CARD' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['parent'])
);
+
if($x && $y) {
goaway(z_root() . '/cards/' . $x[0]['channel_address'] . '/' . $y[0]['v']);
}
diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php
index 4d1cc4cda..1735e9487 100644
--- a/Zotlabs/Module/File_upload.php
+++ b/Zotlabs/Module/File_upload.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/attach.php');
require_once('include/channel.php');
require_once('include/photos.php');
@@ -41,7 +43,7 @@ class File_upload extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$hash);
if($sync) {
- 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']);
@@ -97,7 +99,7 @@ class File_upload extends \Zotlabs\Web\Controller {
if($r['success']) {
$sync = attach_export_data($channel,$r['data']['hash']);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
}
diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php
index 2c247cd65..0c6233493 100644
--- a/Zotlabs/Module/Filestorage.php
+++ b/Zotlabs/Module/Filestorage.php
@@ -5,7 +5,7 @@ namespace Zotlabs\Module;
*
*/
-
+use Zotlabs\Lib\Libsync;
class Filestorage extends \Zotlabs\Web\Controller {
@@ -35,12 +35,12 @@ class Filestorage extends \Zotlabs\Web\Controller {
$url = get_cloud_url($channel_id, $channel['channel_address'], $resource);
- //get the object before permissions change so we can catch eventual former allowed members
- $object = get_file_activity_object($channel_id, $resource, $url);
-
attach_change_permissions($channel_id, $resource, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], $recurse, true);
- file_activity($channel_id, $object, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], 'post', $notify);
+ if($notify) {
+ $observer = \App::get_observer();
+ attach_store_item($channel, $observer, $resource);
+ }
goaway(dirname($url));
}
@@ -131,7 +131,7 @@ class Filestorage extends \Zotlabs\Web\Controller {
if(! $admin_delete) {
$sync = attach_export_data($channel, $f['hash'], true);
if($sync) {
- build_sync_packet($channel['channel_id'], array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'], array('file' => array($sync)));
}
}
diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php
index f836978ee..993d428f5 100644
--- a/Zotlabs/Module/Group.php
+++ b/Zotlabs/Module/Group.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
require_once('include/group.php');
@@ -80,7 +81,7 @@ class Group extends Controller {
info( t('Privacy group updated.') . EOL );
- build_sync_packet(local_channel(),null,true);
+ Libsync::build_sync_packet(local_channel(),null,true);
}
goaway(z_root() . '/group/' . argv(1) . '/' . argv(2));
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index cdfc3c9a8..95359ccad 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module;
+use Zotlabs\Lib\Config;
use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Enotify;
use Zotlabs\Web\Controller;
@@ -43,9 +44,11 @@ class Item extends Controller {
if (Libzot::is_zot_request()) {
+ $conversation = false;
+
$item_id = argv(1);
- if (! $item_id)
+ if(! $item_id)
http_status_exit(404, 'Not found');
$portable_id = EMPTY_STR;
@@ -66,32 +69,24 @@ class Item extends Controller {
// process an authenticated fetch
- $sigdata = HTTPSig::verify(EMPTY_STR);
- if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $sigdata = HTTPSig::verify(($_SERVER['REQUEST_METHOD'] === 'POST') ? file_get_contents('php://input') : EMPTY_STR);
+ if ($sigdata['portable_id'] && $sigdata['header_valid']) {
$portable_id = $sigdata['portable_id'];
+ if (! check_channelallowed($portable_id)) {
+ http_status_exit(403, 'Permission denied');
+ }
+ if (! check_siteallowed($sigdata['signer'])) {
+ http_status_exit(403, 'Permission denied');
+ }
observer_auth($portable_id);
- // first see if we have a copy of this item's parent owned by the current signer
- // include xchans for all zot-like networks - these will have the same guid and public key
-
- $x = q("select * from xchan where xchan_hash = '%s'",
- dbesc($sigdata['portable_id'])
+ $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1",
+ dbesc($r[0]['parent_mid']),
+ dbesc($portable_id)
);
-
- if ($x) {
- $xchans = q("select xchan_hash from xchan where xchan_hash = '%s' OR ( xchan_guid = '%s' AND xchan_pubkey = '%s' ) ",
- dbesc($sigdata['portable_id']),
- dbesc($x[0]['xchan_guid']),
- dbesc($x[0]['xchan_pubkey'])
- );
-
- if ($xchans) {
- $hashes = ids_to_querystr($xchans,'xchan_hash',true);
- $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
- dbesc($r[0]['parent_mid'])
- );
- }
- }
+ }
+ elseif (Config::get('system','require_authenticated_fetch',false)) {
+ http_status_exit(403,'Permission denied');
}
// if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access
@@ -111,7 +106,7 @@ class Item extends Controller {
$parents_str = ids_to_querystr($i,'item_id');
- $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal ",
+ $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal order by item.id asc",
dbesc($parents_str)
);
@@ -122,43 +117,10 @@ class Item extends Controller {
xchan_query($items,true);
$items = fetch_post_tags($items,true);
- $observer = App::get_observer();
- $parent = $items[0];
- $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []);
- $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null);
- $nitems = [];
- foreach($items as $i) {
-
- $mids = [];
-
- if(intval($i['item_private'])) {
- if(! $observer) {
- continue;
- }
- // ignore private reshare, possibly from hubzilla
- if($i['verb'] === 'Announce') {
- if(! in_array($i['thr_parent'],$mids)) {
- $mids[] = $i['thr_parent'];
- }
- continue;
- }
- // also ignore any children of the private reshares
- if(in_array($i['thr_parent'],$mids)) {
- continue;
- }
-
- if((! $to) || (! in_array($observer['xchan_url'],$to))) {
- continue;
- }
-
- }
- $nitems[] = $i;
- }
-
- if(! $nitems)
+ if(! $items)
http_status_exit(404, 'Not found');
- $chan = channelx_by_n($nitems[0]['uid']);
+ $chan = channelx_by_n($items[0]['uid']);
if(! $chan)
http_status_exit(404, 'Not found');
@@ -166,7 +128,8 @@ class Item extends Controller {
if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
http_status_exit(403, 'Forbidden');
- $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection');
+
+ $i = Activity::encode_item_collection($items, 'conversation/' . $item_id, 'OrderedCollection');
if($portable_id) {
ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id);
}
@@ -194,8 +157,9 @@ class Item extends Controller {
}
if(argc() > 1 && argv(1) !== 'drop') {
- $x = q("select uid, item_wall, llink, mid from item where mid = '%s' ",
- dbesc(z_root() . '/item/' . argv(1))
+ $x = q("select uid, item_wall, llink, mid from item where mid = '%s' or mid = '%s' ",
+ dbesc(z_root() . '/item/' . argv(1)),
+ dbesc(z_root() . '/activity/' . argv(1))
);
if($x) {
foreach($x as $xv) {
@@ -712,6 +676,8 @@ class Item extends Controller {
$str_group_allow = $gacl['allow_gid'];
$str_contact_deny = $gacl['deny_cid'];
$str_group_deny = $gacl['deny_gid'];
+
+ $post_tags = [];
if($mimetype === 'text/bbcode') {
@@ -746,7 +712,6 @@ class Item extends Controller {
// Set permissions based on tag replacements
set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private);
- $post_tags = array();
foreach($results as $result) {
$success = $result['success'];
if($success['replaced']) {
@@ -759,6 +724,7 @@ class Item extends Controller {
);
}
}
+
}
if(($str_contact_allow) && (! $str_group_allow)) {
@@ -990,8 +956,9 @@ class Item extends Controller {
}
if ((! $plink) && ($item_thread_top)) {
- $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid);
- $plink = substr($plink,0,190);
+ // $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid);
+ // $plink = substr($plink,0,190);
+ $plink = $mid;
}
if ($datarray['obj']) {
@@ -1055,10 +1022,9 @@ class Item extends Controller {
$datarray['layout_mid'] = $layout_mid;
$datarray['public_policy'] = $public_policy;
$datarray['comment_policy'] = map_scope($comment_policy);
- $datarray['term'] = $post_tags;
+ $datarray['term'] = array_unique($post_tags, SORT_REGULAR);
$datarray['plink'] = $plink;
$datarray['route'] = $route;
-
// A specific ACL over-rides public_policy completely
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index e4636a4a6..61f73bfd5 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\Libsync;
require_once('include/security.php');
require_once('include/bbcode.php');
@@ -235,7 +236,7 @@ class Like extends \Zotlabs\Web\Controller {
if($z) {
$z[0]['deleted'] = 1;
- 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'])
@@ -566,7 +567,7 @@ class Like extends \Zotlabs\Web\Controller {
dbesc($obj_id)
);
if($r)
- build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
+ Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
}
diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php
index a7c98e05e..f1bff3c50 100644
--- a/Zotlabs/Module/Moderate.php
+++ b/Zotlabs/Module/Moderate.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/conversation.php');
@@ -77,7 +79,7 @@ class Moderate extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- 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));
diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php
index 7572f7420..b448cff83 100644
--- a/Zotlabs/Module/Notes.php
+++ b/Zotlabs/Module/Notes.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
/**
* @brief Notes Module controller.
@@ -38,7 +39,7 @@ class Notes extends Controller {
if((argc() > 1) && (argv(1) === 'sync')) {
require_once('include/zot.php');
- build_sync_packet();
+ Libsync::build_sync_packet();
}
logger('notes saved.', LOGGER_DEBUG);
diff --git a/Zotlabs/Module/Pconfig.php b/Zotlabs/Module/Pconfig.php
index 06b94b34f..b2b5d4386 100644
--- a/Zotlabs/Module/Pconfig.php
+++ b/Zotlabs/Module/Pconfig.php
@@ -1,7 +1,7 @@
<?php
namespace Zotlabs\Module;
-
+use Zotlabs\Lib\Libsync;
@@ -38,7 +38,7 @@ class Pconfig extends \Zotlabs\Web\Controller {
}
set_pconfig(local_channel(),$cat,$k,$v);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($aj)
killme();
diff --git a/Zotlabs/Module/Pdledit.php b/Zotlabs/Module/Pdledit.php
index 5cedb29a8..36201544f 100644
--- a/Zotlabs/Module/Pdledit.php
+++ b/Zotlabs/Module/Pdledit.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
class Pdledit extends Controller {
@@ -22,7 +23,7 @@ class Pdledit extends Controller {
goaway(z_root() . '/pdledit');
}
set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content']));
- build_sync_packet();
+ Libsync::build_sync_packet();
info( t('Layout updated.') . EOL);
goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
}
diff --git a/Zotlabs/Module/Permcats.php b/Zotlabs/Module/Permcats.php
index 75ac2ac87..6a599282c 100644
--- a/Zotlabs/Module/Permcats.php
+++ b/Zotlabs/Module/Permcats.php
@@ -5,6 +5,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
class Permcats extends Controller {
@@ -42,7 +43,7 @@ class Permcats extends Controller {
\Zotlabs\Lib\Permcat::update(local_channel(),$name,$pcarr);
- build_sync_packet();
+ Libsync::build_sync_packet();
info( t('Permission category saved.') . EOL);
@@ -71,7 +72,7 @@ class Permcats extends Controller {
if(argc() > 2 && argv(2) === 'drop') {
\Zotlabs\Lib\Permcat::delete(local_channel(),$name);
- build_sync_packet();
+ Libsync::build_sync_packet();
json_return_and_die([ 'success' => true ]);
}
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 43c9f86ee..fae8c17f6 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/photo/photo_driver.php');
require_once('include/photos.php');
require_once('include/items.php');
@@ -162,7 +164,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$folder_hash, true);
if($sync)
- build_sync_packet($page_owner_uid,array('file' => array($sync)));
+ Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
}
@@ -189,7 +191,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$r[0]['resource_id'], true);
if($sync)
- 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
@@ -210,7 +212,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],argv(2),true);
if($sync)
- 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']);
@@ -420,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller {
$sync = attach_export_data(\App::$data['channel'],$resource_id);
if($sync)
- 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
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index a812ca210..d6c80b653 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
/*
* @file Profile_photo.php
* @brief Module-file with functions for handling of profile-photos
@@ -73,7 +75,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$r[0]['resource_id']);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync:: build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
$_SESSION['reload_avatar'] = true;
@@ -243,7 +245,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
- 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.
@@ -411,7 +413,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$resource_id);
if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
$_SESSION['reload_avatar'] = true;
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index 33e7d8a9d..7deceabab 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/channel.php');
require_once('include/selectors.php');
@@ -599,7 +601,7 @@ class Profiles extends \Zotlabs\Web\Controller {
);
if($r) {
require_once('include/zot.php');
- build_sync_packet(local_channel(),array('profile' => $r));
+ Libsync::build_sync_packet(local_channel(),array('profile' => $r));
}
$channel = \App::get_channel();
diff --git a/Zotlabs/Module/Settings/Calendar.php b/Zotlabs/Module/Settings/Calendar.php
index 0298b412e..ab85eb450 100644
--- a/Zotlabs/Module/Settings/Calendar.php
+++ b/Zotlabs/Module/Settings/Calendar.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Calendar {
@@ -15,7 +16,7 @@ class Calendar {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php
index b0115d352..ab9b72490 100644
--- a/Zotlabs/Module/Settings/Channel.php
+++ b/Zotlabs/Module/Settings/Channel.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Module\Settings;
use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
require_once('include/selectors.php');
@@ -286,7 +287,7 @@ class Channel {
\Zotlabs\Daemon\Master::Summon(array('Directory',local_channel()));
- build_sync_packet();
+ Libsync::build_sync_packet();
if($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) {
diff --git a/Zotlabs/Module/Settings/Channel_home.php b/Zotlabs/Module/Settings/Channel_home.php
index b6ecf4ff1..e8faa7fb2 100644
--- a/Zotlabs/Module/Settings/Channel_home.php
+++ b/Zotlabs/Module/Settings/Channel_home.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
+
require_once('include/menu.php');
class Channel_home {
@@ -24,7 +26,7 @@ class Channel_home {
$channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu']),ENT_QUOTES) : '');
set_pconfig(local_channel(),'system','channel_menu',$channel_menu);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Connections.php b/Zotlabs/Module/Settings/Connections.php
index cac357791..4369deb27 100644
--- a/Zotlabs/Module/Settings/Connections.php
+++ b/Zotlabs/Module/Settings/Connections.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Connections {
@@ -15,7 +16,7 @@ class Connections {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Conversation.php b/Zotlabs/Module/Settings/Conversation.php
index 43e59a3c2..aa0ff6a7e 100644
--- a/Zotlabs/Module/Settings/Conversation.php
+++ b/Zotlabs/Module/Settings/Conversation.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Conversation {
@@ -15,7 +16,7 @@ class Conversation {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['aj']) {
if($_POST['auto_update'] == 1)
diff --git a/Zotlabs/Module/Settings/Directory.php b/Zotlabs/Module/Settings/Directory.php
index 13fe6eb79..d1dd0677e 100644
--- a/Zotlabs/Module/Settings/Directory.php
+++ b/Zotlabs/Module/Settings/Directory.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Directory {
@@ -15,7 +16,7 @@ class Directory {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php
index 45d80e011..f553fc057 100644
--- a/Zotlabs/Module/Settings/Display.php
+++ b/Zotlabs/Module/Settings/Display.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Display {
@@ -78,7 +79,7 @@ class Display {
);
call_hooks('display_settings_post', $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
goaway(z_root() . '/settings/display' );
return; // NOTREACHED
}
diff --git a/Zotlabs/Module/Settings/Editor.php b/Zotlabs/Module/Settings/Editor.php
index 5e7a9473a..cf6dd2807 100644
--- a/Zotlabs/Module/Settings/Editor.php
+++ b/Zotlabs/Module/Settings/Editor.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Editor {
@@ -15,7 +16,7 @@ class Editor {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Events.php b/Zotlabs/Module/Settings/Events.php
index eb6dda99b..ab393c932 100644
--- a/Zotlabs/Module/Settings/Events.php
+++ b/Zotlabs/Module/Settings/Events.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Events {
@@ -15,7 +16,7 @@ class Events {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php
index d5d740aff..d615e176c 100644
--- a/Zotlabs/Module/Settings/Featured.php
+++ b/Zotlabs/Module/Settings/Featured.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Featured {
@@ -10,7 +11,7 @@ class Featured {
call_hooks('feature_settings_post', $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
return;
}
diff --git a/Zotlabs/Module/Settings/Features.php b/Zotlabs/Module/Settings/Features.php
index 6a3ab104b..553ff0836 100644
--- a/Zotlabs/Module/Settings/Features.php
+++ b/Zotlabs/Module/Settings/Features.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
+
class Features {
@@ -19,7 +21,7 @@ class Features {
set_pconfig(local_channel(),'feature', $k, '');
}
}
- build_sync_packet();
+ Libsync::build_sync_packet();
return;
}
diff --git a/Zotlabs/Module/Settings/Manage.php b/Zotlabs/Module/Settings/Manage.php
index 9bae12022..cbc494cf8 100644
--- a/Zotlabs/Module/Settings/Manage.php
+++ b/Zotlabs/Module/Settings/Manage.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
+
class Manage {
@@ -15,7 +17,7 @@ class Manage {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Network.php b/Zotlabs/Module/Settings/Network.php
index ae02b06e9..9f5bdb2e5 100644
--- a/Zotlabs/Module/Settings/Network.php
+++ b/Zotlabs/Module/Settings/Network.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Network {
@@ -21,7 +22,7 @@ class Network {
set_pconfig(local_channel(),'system','network_divmore_height', $network_divmore_height);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Photos.php b/Zotlabs/Module/Settings/Photos.php
index 9edbaa929..8195d660b 100644
--- a/Zotlabs/Module/Settings/Photos.php
+++ b/Zotlabs/Module/Settings/Photos.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
class Photos {
@@ -15,7 +16,7 @@ class Photos {
process_module_features_post(local_channel(), $features, $_POST);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Settings/Profiles.php b/Zotlabs/Module/Settings/Profiles.php
index fb6abf664..67b03e04f 100644
--- a/Zotlabs/Module/Settings/Profiles.php
+++ b/Zotlabs/Module/Settings/Profiles.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module\Settings;
+use Zotlabs\Lib\Libsync;
+
require_once('include/selectors.php');
class Profiles {
@@ -19,7 +21,7 @@ class Profiles {
$profile_assign = ((x($_POST,'profile_assign')) ? notags(trim($_POST['profile_assign'])) : '');
set_pconfig(local_channel(),'system','profile_assign',$profile_assign);
- build_sync_packet();
+ Libsync::build_sync_packet();
if($_POST['rpath'])
goaway($_POST['rpath']);
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index a18a81937..c0db9978e 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Daemon\Master;
use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\Libsync;
require_once('include/security.php');
@@ -124,7 +125,7 @@ class Share extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
+ Libsync::build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
}
Master::Summon([ 'Notifier','like',$post_id ]);
diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php
index c986f6695..4211a3af8 100644
--- a/Zotlabs/Module/Sharedwithme.php
+++ b/Zotlabs/Module/Sharedwithme.php
@@ -1,5 +1,8 @@
<?php
namespace Zotlabs\Module;
+
+use Zotlabs\Web\Controller;
+
require_once('include/conversation.php');
require_once('include/text.php');
@@ -9,7 +12,7 @@ require_once('include/text.php');
*
*/
-class Sharedwithme extends \Zotlabs\Web\Controller {
+class Sharedwithme extends Controller {
function get() {
if(! local_channel()) {
@@ -20,81 +23,80 @@ class Sharedwithme extends \Zotlabs\Web\Controller {
$channel = \App::get_channel();
$is_owner = (local_channel() && (local_channel() == $channel['channel_id']));
-
- //check for updated items and remove them
- require_once('include/sharedwithme.php');
- apply_updates();
+
+ $item_normal = item_normal();
//drop single file - localuser
if((argc() > 2) && (argv(2) === 'drop')) {
-
+
$id = intval(argv(1));
-
- q("DELETE FROM item WHERE id = %d AND uid = %d",
- intval($id),
- intval(local_channel())
- );
-
+
+ drop_item($id);
+
goaway(z_root() . '/sharedwithme');
+
}
//drop all files - localuser
if((argc() > 1) && (argv(1) === 'dropall')) {
-
- q("DELETE FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d",
+
+ $r = q("SELECT id FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal",
dbesc(ACTIVITY_POST),
- dbesc(ACTIVITY_OBJ_FILE),
- intval(local_channel())
+ intval(local_channel()),
+ dbesc($channel['channel_hash'])
);
-
+
+ $ids = ids_to_array($r);
+
+ if($ids)
+ drop_items($ids);
+
goaway(z_root() . '/sharedwithme');
+
}
-
+
//list files
- $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'",
+ $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal",
dbesc(ACTIVITY_POST),
- dbesc(ACTIVITY_OBJ_FILE),
intval(local_channel()),
dbesc($channel['channel_hash'])
);
-
- $items =array();
- $ids = '';
-
+
+ $items = [];
+ $ids = [];
+
if($r) {
foreach($r as $rr) {
$object = json_decode($rr['obj'],true);
-
- $item = array();
+ $meta = self::get_meta($object);
+
+ $item = [];
$item['id'] = $rr['id'];
- $item['objfiletype'] = $object['filetype'];
- $item['objfiletypeclass'] = getIconFromType($object['filetype']);
- $item['objurl'] = rawurldecode(get_rel_link($object['link'],'alternate')) . '?f=&zid=' . $channel['xchan_addr'];
- $item['objfilename'] = $object['filename'];
- $item['objfilesize'] = userReadableSize($object['filesize']);
- $item['objedited'] = $object['edited'];
+ $item['objfiletype'] = $meta['type'];
+ $item['objfiletypeclass'] = getIconFromType($meta['type']);
+ $item['objurl'] = $meta['path'] . '?f=&zid=' . $channel['xchan_addr'];
+ $item['objfilename'] = $object['name'];
+ $item['objfilesize'] = userReadableSize($meta['size']);
+ $item['objedited'] = $meta['edited'];
$item['unseen'] = $rr['item_unseen'];
$items[] = $item;
- if($item['unseen'] > 0) {
- $ids .= " '" . $rr['id'] . "',";
+ if($item['unseen']) {
+ $ids[] = $rr['id'];
}
}
}
-
+
+ $ids = implode(',', $ids);
+
if($ids) {
-
- //remove trailing ,
- $ids = rtrim($ids, ",");
-
q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d",
intval(local_channel())
);
-
}
$o = '';
@@ -114,5 +116,22 @@ class Sharedwithme extends \Zotlabs\Web\Controller {
}
+ function get_meta($object) {
+
+ $ret = [];
+
+ if(! is_array($object['attachment']))
+ return;
+
+ foreach($object['attachment'] as $a) {
+ if($a['name'] === 'zot.attach.meta') {
+ $ret = $a['value'];
+ break;
+ }
+ }
+
+ return $ret;
+
+ }
}
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 89e852120..cb4c54961 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -119,7 +119,7 @@ class Sse_bs extends Controller {
$sql_extra2 = '';
if(self::$xchans)
- $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) ";
+ $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") ";
$item_normal = item_normal();
@@ -128,6 +128,7 @@ class Sse_bs extends Controller {
WHERE uid = %d
AND created <= '%s'
AND item_unseen = 1 AND item_wall = 0
+ AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
$item_normal
$sql_extra
@@ -183,7 +184,7 @@ class Sse_bs extends Controller {
$sql_extra2 = '';
if(self::$xchans)
- $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) ";
+ $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") ";
$item_normal = item_normal();
@@ -193,6 +194,7 @@ class Sse_bs extends Controller {
WHERE uid = %d
AND created <= '%s'
AND item_unseen = 1 AND item_wall = 1
+ AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
$item_normal
$sql_extra
@@ -259,7 +261,7 @@ class Sse_bs extends Controller {
$sql_extra2 = '';
if(self::$xchans)
- $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) ";
+ $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") ";
$item_normal = item_normal();
@@ -268,6 +270,7 @@ class Sse_bs extends Controller {
WHERE uid = %d
AND created <= '%s'
AND item_unseen = 1
+ AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
AND created > '%s'
$item_normal
@@ -446,21 +449,24 @@ class Sse_bs extends Controller {
if(! self::$uid)
return $result;
+ $item_normal = item_normal();
+
$r = q("SELECT * FROM item
WHERE verb = '%s'
- AND obj_type = '%s'
+ AND obj_type IN ('Document', 'Video', 'Audio', 'Image')
AND uid = %d
- AND owner_xchan != '%s'
- AND item_unseen = 1",
+ AND author_xchan != '%s'
+ AND item_unseen = 1
+ $item_normal
+ ORDER BY created DESC",
dbesc(ACTIVITY_POST),
- dbesc(ACTIVITY_OBJ_FILE),
intval(self::$uid),
dbesc(self::$ob_hash)
);
if($r) {
xchan_query($r);
foreach($r as $rr) {
- $result['files']['notifications'][] = Enotify::format_files($rr);
+ $result['files']['notifications'][] = Enotify::format($rr);
}
$result['files']['count'] = count($r);
}
diff --git a/Zotlabs/Module/Starred.php b/Zotlabs/Module/Starred.php
index 8349ae25c..2d7063669 100644
--- a/Zotlabs/Module/Starred.php
+++ b/Zotlabs/Module/Starred.php
@@ -1,6 +1,7 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
class Starred extends \Zotlabs\Web\Controller {
@@ -37,7 +38,7 @@ class Starred extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- build_sync_packet(local_channel(),[
+ Libsync::build_sync_packet(local_channel(),[
'item' => [
encode_item($sync_item[0],true)
]
diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php
index e6e80dce3..4fbfb7070 100644
--- a/Zotlabs/Module/Tagger.php
+++ b/Zotlabs/Module/Tagger.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
@@ -149,7 +151,7 @@ class Tagger extends \Zotlabs\Web\Controller {
$ret = post_activity_item($arr);
if($ret['success']) {
- build_sync_packet(local_channel(),
+ Libsync::build_sync_packet(local_channel(),
[
'item' => [ encode_item($ret['activity'],true) ]
]
diff --git a/Zotlabs/Module/Thing.php b/Zotlabs/Module/Thing.php
index c3d8ff802..b065b0022 100644
--- a/Zotlabs/Module/Thing.php
+++ b/Zotlabs/Module/Thing.php
@@ -5,6 +5,8 @@
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/items.php');
require_once('include/security.php');
require_once('include/selectors.php');
@@ -124,7 +126,7 @@ class Thing extends \Zotlabs\Web\Controller {
dbesc($term_hash)
);
if($r) {
- build_sync_packet(0, array('obj' => $r));
+ Libsync::build_sync_packet(0, array('obj' => $r));
}
return;
@@ -180,7 +182,7 @@ class Thing extends \Zotlabs\Web\Controller {
dbesc($hash)
);
if($r) {
- build_sync_packet(0, array('obj' => $r));
+ Libsync::build_sync_packet(0, array('obj' => $r));
}
if($activity) {
@@ -353,7 +355,7 @@ class Thing extends \Zotlabs\Web\Controller {
$r[0]['obj_deleted'] = 1;
- build_sync_packet(0,array('obj' => $r));
+ Libsync::build_sync_packet(0,array('obj' => $r));
return $o;
}
diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php
index e1088d18f..2c0eeec77 100644
--- a/Zotlabs/Module/Wall_attach.php
+++ b/Zotlabs/Module/Wall_attach.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/attach.php');
require_once('include/photos.php');
@@ -134,7 +136,7 @@ class Wall_attach extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$r['data']['hash']);
if($sync) {
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
if($using_api)
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index ae36fc1c0..8cda75fd1 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
+use Zotlabs\Lib\Libsync;
/**
* @brief RedDirectory class.
@@ -179,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)
- 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;
@@ -368,7 +369,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
$sync = attach_export_data($c[0], $hash);
if ($sync)
- build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
+ Libsync::build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
}
/**
@@ -401,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) {
- build_sync_packet($r[0]['channel_id'], array('file' => array($sync)));
+ Libsync::build_sync_packet($r[0]['channel_id'], array('file' => array($sync)));
}
}
else {
@@ -432,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)
- build_sync_packet($ch['channel_id'], array('file' => array($sync)));
+ Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
}
diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php
index 36aff1e05..68edde166 100644
--- a/Zotlabs/Storage/File.php
+++ b/Zotlabs/Storage/File.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
+use Zotlabs\Lib\Libsync;
/**
* @brief This class represents a file in DAV.
@@ -106,7 +107,7 @@ class File extends DAV\Node implements DAV\IFile {
if($ch) {
$sync = attach_export_data($ch,$this->data['hash']);
if($sync)
- build_sync_packet($ch['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($ch['channel_id'],array('file' => array($sync)));
}
}
@@ -254,7 +255,7 @@ class File extends DAV\Node implements DAV\IFile {
$sync = attach_export_data($c[0],$this->data['hash']);
if($sync)
- build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
+ Libsync::build_sync_packet($c[0]['channel_id'],array('file' => array($sync)));
}
@@ -378,7 +379,7 @@ class File extends DAV\Node implements DAV\IFile {
if($ch) {
$sync = attach_export_data($ch, $this->data['hash'], true);
if($sync)
- build_sync_packet($ch['channel_id'], array('file' => array($sync)));
+ Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
}
}
diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php
index 6b4e7b299..e57338e16 100644
--- a/Zotlabs/Update/_1236.php
+++ b/Zotlabs/Update/_1236.php
@@ -61,6 +61,34 @@ class _1236 {
xchan_store_lowlevel($rec);
}
+ // Now try again
+ $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'",
+ dbesc($guid)
+ );
+
+ if(! $xchan) {
+ logger('Could not create zot6 xchan record for: ' . $zot_xchan);
+ continue;
+ }
+
+ }
+
+ $zot6_xchan = $xchan[0]['xchan_hash'];
+ $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig'];
+
+ $hubloc = q("SELECT hubloc_hash FROM hubloc WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6'",
+ dbesc($guid),
+ dbesc(z_root())
+ );
+
+ if(! $hubloc) {
+ // This should not actually happen.
+ // A local zot6 hubloc for every channel should have been
+ // created in update _1226.
+
+ // In case this failed, we will try to fix it here.
+ logger('No local zot6 hubloc found for: ' . $rr['channel_hash']);
+
$h = q("SELECT * FROM hubloc WHERE hubloc_hash = '%s' AND hubloc_url = '%s' LIMIT 1",
dbesc($zot_xchan),
dbesc(z_root())
@@ -68,31 +96,23 @@ class _1236 {
if($h) {
$rec = $h[0];
- $rec['hubloc_hash'] = $zhash;
+ $rec['hubloc_hash'] = $zot6_xchan;
$rec['hubloc_guid_sig'] = 'sha256.' . $rec['hubloc_guid_sig'];
$rec['hubloc_network'] = 'zot6';
$rec['hubloc_url_sig'] = 'sha256.' . $rec['hubloc_url_sig'];
$rec['hubloc_callback'] = z_root() . '/zot';
$rec['hubloc_id_url'] = channel_url($rr);
$rec['hubloc_site_id'] = Libzot::make_xchan_hash(z_root(),get_config('system','pubkey'));
- hubloc_store_lowlevel($rec);
- }
- // Now try again
- $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'",
- dbesc($guid)
- );
+ $hubloc = hubloc_store_lowlevel($rec);
+ }
- if(!$xchan) {
- logger('Could not create zot6 xchan record for: ' . $zot_xchan);
+ if(! $hubloc) {
+ logger('Could not create local zot6 hubloc record for: ' . $zot_xchan);
continue;
}
-
}
- $zot6_xchan = $xchan[0]['xchan_hash'];
- $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig'];
-
logger('Transforming channel: ' . $zot_xchan);
q("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s'",
dbesc($zot6_xchan),