aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php379
-rw-r--r--Zotlabs/Lib/Enotify.php17
-rw-r--r--Zotlabs/Lib/JSalmon.php2
-rw-r--r--Zotlabs/Lib/LDSignatures.php6
-rw-r--r--Zotlabs/Lib/Libzot.php39
-rw-r--r--Zotlabs/Lib/NativeWiki.php2
-rw-r--r--Zotlabs/Lib/ThreadItem.php4
-rw-r--r--Zotlabs/Lib/ZotURL.php2
-rw-r--r--Zotlabs/Lib/Zotfinger.php2
9 files changed, 391 insertions, 62 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 232d845c7..f86dc1604 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -3,7 +3,9 @@
namespace Zotlabs\Lib;
use Zotlabs\Daemon\Master;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
+
+require_once('include/event.php');
class Activity {
@@ -73,7 +75,7 @@ class Activity {
if($x['success']) {
$y = json_decode($x['body'],true);
- logger('returned: ' . json_encode($y,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
+ logger('returned: ' . json_encode($y,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DEBUG);
return json_decode($x['body'], true);
}
else {
@@ -149,7 +151,6 @@ class Activity {
static function fetch_image($x) {
-
$ret = [
'type' => 'Image',
'id' => $x['id'],
@@ -292,8 +293,12 @@ class Activity {
$ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME);
if($i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME);
+ if ($i['expires'] <= NULL_DATE) {
+ $ret['expires'] = datetime_convert('UTC','UTC',$i['expires'],ATOM_TIME);
+ }
+
if($i['app']) {
- $ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ];
+ $ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
}
if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ];
@@ -307,6 +312,10 @@ class Activity {
}
}
+ if (intval($i['item_private']) === 2) {
+ $ret['directMessage'] = true;
+ }
+
$ret['attributedTo'] = $i['author']['xchan_url'];
if($i['id'] != $i['parent']) {
@@ -352,7 +361,7 @@ class Activity {
switch($t['type']) {
case 'Hashtag':
- $ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ];
+ $ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => ((isset($t['href'])) ? $t['href'] : $t['id']), 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ];
break;
case 'Mention':
@@ -383,9 +392,9 @@ class Activity {
foreach($item['term'] as $t) {
switch($t['ttype']) {
case TERM_HASHTAG:
- // An id is required so if we don't have a url in the taxonomy, ignore it and keep going.
+ // href is required so if we don't have a url in the taxonomy, ignore it and keep going.
if($t['url']) {
- $ret[] = [ 'id' => $t['url'], 'name' => '#' . $t['term'] ];
+ $ret[] = [ 'type' => 'Hashtag', 'href' => $t['url'], 'name' => '#' . $t['term'] ];
}
break;
@@ -470,8 +479,27 @@ class Activity {
return $ret;
}
+ if($i['verb'] === ACTIVITY_FRIEND) {
+ // Hubzilla 'make-friend' activity, no direct mapping from AS1 to AS2 - make it a note
+ $ret['obj_type'] = ACTIVITY_OBJ_NOTE;
+ $ret['obj'] = [];
+ }
+
$ret['type'] = self::activity_mapper($i['verb']);
+ if($ret['type'] === 'emojiReaction') {
+ // There may not be an object for these items for legacy reasons - it should be the conversation parent.
+ $p = q("select * from item where mid = '%s' and uid = %d",
+ dbesc($i['parent_mid']),
+ intval($i['uid'])
+ );
+ if($p) {
+ xchan_query($p,true);
+ $p = fetch_post_tags($p,true);
+ $i['obj'] = self::encode_item($p[0]);
+ }
+ }
+
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid']));
@@ -494,7 +522,7 @@ class Activity {
if($i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME);
if($i['app']) {
- $ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ];
+ $ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
}
if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ];
@@ -1301,6 +1329,12 @@ class Activity {
elseif($act->obj['updated']) {
$s['edited'] = datetime_convert('UTC','UTC',$act->obj['updated']);
}
+ if ($act->data['expires']) {
+ $s['expires'] = datetime_convert('UTC','UTC',$act->data['expires']);
+ }
+ elseif ($act->obj['expires']) {
+ $s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
+ }
if(! $s['created'])
$s['created'] = datetime_convert();
@@ -1319,13 +1353,13 @@ class Activity {
$s['verb'] = ACTIVITY_POST;
$s['obj_type'] = ACTIVITY_OBJ_NOTE;
- $instrument = $act->get_property_obj('instrument');
- if(! $instrument)
- $instrument = $act->get_property_obj('instrument',$act->obj);
+ $generator = $act->get_property_obj('generator');
+ if(! $generator)
+ $generator = $act->get_property_obj('generator',$act->obj);
- if($instrument && array_key_exists('type',$instrument)
- && $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) {
- $s['app'] = escape_tags($instrument['name']);
+ if($generator && array_key_exists('type',$generator)
+ && in_array($generator['type'], [ 'Application','Service' ] ) && array_key_exists('name',$generator)) {
+ $s['app'] = escape_tags($generator['name']);
}
if($channel['channel_system']) {
@@ -1398,6 +1432,11 @@ class Activity {
if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips)))
$s['item_private'] = 1;
+
+ if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) {
+ $s['item_private'] = 2;
+ }
+
set_iconfig($s,'activitypub','recips',$act->raw_recips);
if($parent) {
set_iconfig($s,'activitypub','rawmsg',$act->raw,1);
@@ -1485,6 +1524,12 @@ class Activity {
elseif($act->obj['updated']) {
$s['edited'] = datetime_convert('UTC','UTC',$act->obj['updated']);
}
+ if ($act->data['expires']) {
+ $s['expires'] = datetime_convert('UTC','UTC',$act->data['expires']);
+ }
+ elseif ($act->obj['expires']) {
+ $s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']);
+ }
if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) {
@@ -1546,7 +1591,7 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type);
- if($act->type === 'Tombstone' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
+ if($act->type === 'Tombstone' || $act->type === 'Delete' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
$s['item_deleted'] = 1;
}
@@ -1582,14 +1627,14 @@ class Activity {
$s['obj'] = $act->obj;
}
- $instrument = $act->get_property_obj('instrument');
- if((! $instrument) && (! $response_activity)) {
- $instrument = $act->get_property_obj('instrument',$act->obj);
+ $generator = $act->get_property_obj('generator');
+ if((! $generator) && (! $response_activity)) {
+ $generator = $act->get_property_obj('generator',$act->obj);
}
- if($instrument && array_key_exists('type',$instrument)
- && $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) {
- $s['app'] = escape_tags($instrument['name']);
+ if($generator && array_key_exists('type',$generator)
+ && in_array($generator['type'], [ 'Application', 'Service' ] ) && array_key_exists('name',$generator)) {
+ $s['app'] = escape_tags($generator['name']);
}
@@ -1724,14 +1769,14 @@ class Activity {
}
foreach($ptr as $vurl) {
if(strpos($s['body'],$vurl['href']) === false) {
- $s['body'] .= "\n\n" . '[zmg]' . $vurl['href'] . '[/zmg]';
+ $s['body'] .= '[zmg]' . $vurl['href'] . '[/zmg]' . "\n\n" . $s['body'];
break;
}
}
}
elseif(is_string($act->obj['url'])) {
if(strpos($s['body'],$act->obj['url']) === false) {
- $s['body'] .= "\n\n" . '[zmg]' . $act->obj['url'] . '[/zmg]';
+ $s['body'] .= '[zmg]' . $act->obj['url'] . '[/zmg]' . "\n\n" . $s['body'];
}
}
}
@@ -1812,7 +1857,8 @@ class Activity {
$s['item_private'] = 1;
set_iconfig($s,'activitypub','recips',$act->raw_recips);
- // @FIXME: $parent is not defined
+
+ $parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false);
if($parent) {
set_iconfig($s,'activitypub','rawmsg',$act->raw,1);
}
@@ -1821,6 +1867,265 @@ class Activity {
}
+ static function store($channel,$observer_hash,$act,$item,$fetch_parents = true) {
+
+ $is_sys_channel = is_sys_channel($channel['channel_id']);
+
+ // Mastodon only allows visibility in public timelines if the public inbox is listed in the 'to' field.
+ // They are hidden in the public timeline if the public inbox is listed in the 'cc' field.
+ // This is not part of the activitypub protocol - we might change this to show all public posts in pubstream at some point.
+
+ $pubstream = ((is_array($act->obj) && array_key_exists('to', $act->obj) && in_array(ACTIVITY_PUBLIC_INBOX, $act->obj['to'])) ? true : false);
+ $is_parent = (($item['parent_mid'] && $item['parent_mid'] === $item['mid']) ? true : false);
+
+ if($is_parent && (! perm_is_allowed($channel['channel_id'],$observer_hash,'send_stream') && ! ($is_sys_channel && $pubstream))) {
+ logger('no permission');
+ return;
+ }
+
+ if(is_array($act->obj)) {
+ $content = self::get_content($act->obj);
+ }
+ if(! $content) {
+ logger('no content');
+ return;
+ }
+
+ $item['aid'] = $channel['channel_account_id'];
+ $item['uid'] = $channel['channel_id'];
+ $s['uuid'] = '';
+
+ // Friendica sends the diaspora guid in a nonstandard field via AP
+ if($act->obj['diaspora:guid'])
+ $s['uuid'] = $act->obj['diaspora:guid'];
+
+ if(! ( $item['author_xchan'] && $item['owner_xchan'])) {
+ logger('owner or author missing.');
+ return;
+ }
+
+ if($channel['channel_system']) {
+ if(! MessageFilter::evaluate($item,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) {
+ logger('post is filtered');
+ return;
+ }
+ }
+
+ $abook = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ dbesc($observer_hash),
+ intval($channel['channel_id'])
+ );
+
+ if($abook) {
+ if(! post_is_importable($item,$abook[0])) {
+ logger('post is filtered');
+ return;
+ }
+ }
+
+
+ if($act->obj['conversation']) {
+ set_iconfig($item,'ostatus','conversation',$act->obj['conversation'],1);
+ }
+
+ // This isn't perfect but the best we can do for now.
+
+ $item['comment_policy'] = 'authenticated';
+
+ set_iconfig($item,'activitypub','recips',$act->raw_recips);
+
+ if(! $is_parent) {
+ $p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1",
+ dbesc($item['parent_mid']),
+ intval($item['uid'])
+ );
+ if(! $p) {
+ $a = (($fetch_parents) ? self::fetch_and_store_parents($channel,$act,$item) : false);
+ if($a) {
+ $p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1",
+ dbesc($item['parent_mid']),
+ intval($item['uid'])
+ );
+ }
+ else {
+ logger('could not fetch parents');
+ return;
+
+ // @TODO we maybe could accept these is we formatted the body correctly with share_bb()
+ // or at least provided a link to the object
+ // if(in_array($act->type,[ 'Like','Dislike' ])) {
+ // return;
+ // }
+
+ // @TODO do we actually want that?
+ // if no parent was fetched, turn into a top-level post
+
+ // turn into a top level post
+ // $s['parent_mid'] = $s['mid'];
+ // $s['thr_parent'] = $s['mid'];
+ }
+ }
+ if($p[0]['parent_mid'] !== $item['parent_mid']) {
+ $item['thr_parent'] = $item['parent_mid'];
+ }
+ else {
+ $item['thr_parent'] = $p[0]['parent_mid'];
+ }
+ $item['parent_mid'] = $p[0]['parent_mid'];
+ }
+
+ $r = q("select id, created, edited from item where mid = '%s' and uid = %d limit 1",
+ dbesc($item['mid']),
+ intval($item['uid'])
+ );
+ if($r) {
+ if($item['edited'] > $r[0]['edited']) {
+ $item['id'] = $r[0]['id'];
+ $x = item_store_update($item);
+ }
+ else {
+ return;
+ }
+ }
+ else {
+ $x = item_store($item);
+ }
+
+ if(is_array($x) && $x['item_id']) {
+ if($is_parent) {
+ if($item['owner_xchan'] === $channel['channel_hash']) {
+ // We are the owner of this conversation, so send all received comments back downstream
+ Master::Summon(array('Notifier','comment-import',$x['item_id']));
+ }
+ $r = q("select * from item where id = %d limit 1",
+ intval($x['item_id'])
+ );
+ if($r) {
+ send_status_notifications($x['item_id'],$r[0]);
+ }
+ }
+ sync_an_item($channel['channel_id'],$x['item_id']);
+ }
+
+ }
+
+ static public function fetch_and_store_parents($channel,$act,$item) {
+
+ logger('fetching parents');
+
+ $p = [];
+
+ $current_act = $act;
+ $current_item = $item;
+
+ while($current_item['parent_mid'] !== $current_item['mid']) {
+ $n = ActivityStreams::fetch($current_item['parent_mid'], $channel);
+ if(! $n) {
+ break;
+ }
+ $a = new ActivityStreams($n);
+
+ //logger($a->debug());
+
+ if(! $a->is_valid()) {
+ break;
+ }
+
+ $replies = null;
+ if(isset($a->obj['replies']['first']['items'])) {
+ $replies = $a->obj['replies']['first']['items'];
+ // we already have this one
+ array_diff($replies, [$current_item['mid']]);
+ }
+
+ $item = null;
+
+ switch($a->type) {
+ case 'Create':
+ case 'Update':
+ case 'Like':
+ case 'Dislike':
+ case 'Announce':
+ $item = self::decode_note($a);
+ break;
+ default:
+ break;
+
+ }
+ if(! $item) {
+ break;
+ }
+
+ array_unshift($p,[ $a, $item, $replies]);
+
+ if($item['parent_mid'] === $item['mid'] || count($p) > 20) {
+ break;
+ }
+
+ $current_act = $a;
+ $current_item = $item;
+ }
+
+ if($p) {
+ foreach($p as $pv) {
+ self::store($channel,$pv[0]->actor['id'],$pv[0],$pv[1],false);
+ if($pv[2])
+ self::fetch_and_store_replies($channel, $pv[2]);
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ static public function fetch_and_store_replies($channel, $arr) {
+
+ logger('fetching replies');
+
+ $p = [];
+
+ foreach($arr as $url) {
+
+ $n = ActivityStreams::fetch($url, $channel);
+ if(! $n) {
+ break;
+ }
+
+ $a = new ActivityStreams($n);
+
+ if(! $a->is_valid()) {
+ break;
+ }
+
+ $item = null;
+
+ switch($a->type) {
+ case 'Create':
+ case 'Update':
+ case 'Like':
+ case 'Dislike':
+ case 'Announce':
+ $item = self::decode_note($a);
+ break;
+ default:
+ break;
+ }
+ if(! $item) {
+ break;
+ }
+
+ array_unshift($p,[ $a, $item ]);
+
+ }
+
+ if($p) {
+ foreach($p as $pv) {
+ self::store($channel,$pv[0]->actor['id'],$pv[0],$pv[1],false);
+ }
+ }
+
+ }
+
static function announce_note($channel,$observer_hash,$act) {
$s = [];
@@ -1941,25 +2246,21 @@ class Activity {
$x = item_store($s);
}
-
if(is_array($x) && $x['item_id']) {
- // @FIXME: $parent is not defined
- if($parent) {
- if($s['owner_xchan'] === $channel['channel_hash']) {
- // We are the owner of this conversation, so send all received comments back downstream
- Master::Summon(array('Notifier','comment-import',$x['item_id']));
- }
- $r = q("select * from item where id = %d limit 1",
- intval($x['item_id'])
- );
- if($r) {
- send_status_notifications($x['item_id'],$r[0]);
- }
+ if($s['owner_xchan'] === $channel['channel_hash']) {
+ // We are the owner of this conversation, so send all received comments back downstream
+ Master::Summon(array('Notifier','comment-import',$x['item_id']));
}
+ $r = q("select * from item where id = %d limit 1",
+ intval($x['item_id'])
+ );
+ if($r) {
+ send_status_notifications($x['item_id'],$r[0]);
+ }
+
sync_an_item($channel['channel_id'],$x['item_id']);
}
-
}
static function like_note($channel,$observer_hash,$act) {
@@ -2229,4 +2530,4 @@ class Activity {
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index a7082f45a..92a488f67 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -807,6 +807,11 @@ class Enotify {
$itemem_text = (($item['item_thread_top'])
? t('created a new post')
: sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name']));
+
+ if($item['verb'] === ACTIVITY_SHARE) {
+ $itemem_text = sprintf( t('repeated %s\'s post'), $item['author']['xchan_name']);
+ }
+
}
$edit = false;
@@ -825,12 +830,14 @@ class Enotify {
// convert this logic into a json array just like the system notifications
+ $who = (($item['verb'] === ACTIVITY_SHARE) ? 'owner' : 'author');
+
$x = array(
'notify_link' => $item['llink'],
- 'name' => $item['author']['xchan_name'],
- 'addr' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']),
- 'url' => $item['author']['xchan_url'],
- 'photo' => $item['author']['xchan_photo_s'],
+ 'name' => $item[$who]['xchan_name'],
+ 'addr' => (($item[$who]['xchan_addr']) ? $item[$who]['xchan_addr'] : $item[$who]['xchan_url']),
+ 'url' => $item[$who]['xchan_url'],
+ 'photo' => $item[$who]['xchan_photo_s'],
'when' => relative_date(($edit)? $item['edited'] : $item['created']),
'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'),
'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])),
@@ -838,7 +845,7 @@ class Enotify {
'thread_top' => (($item['item_thread_top']) ? true : false),
'message' => strip_tags(bbcode($itemem_text)),
// these are for the superblock addon
- 'hash' => $item['author']['xchan_hash'],
+ 'hash' => $item[$who]['xchan_hash'],
'uid' => local_channel(),
'display' => true
);
diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php
index f35bf6235..bed748432 100644
--- a/Zotlabs/Lib/JSalmon.php
+++ b/Zotlabs/Lib/JSalmon.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Lib;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
class JSalmon {
diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php
index 6d7127cde..b13c4cf4a 100644
--- a/Zotlabs/Lib/LDSignatures.php
+++ b/Zotlabs/Lib/LDSignatures.php
@@ -29,7 +29,7 @@ class LDSignatures {
$options = [
'type' => 'RsaSignature2017',
'nonce' => random_string(64),
- 'creator' => z_root() . '/channel/' . $channel['channel_address'] . '/public_key_pem',
+ 'creator' => z_root() . '/channel/' . $channel['channel_address'],
'created' => datetime_convert('UTC','UTC', 'now', 'Y-m-d\Th:i:s\Z')
];
@@ -124,7 +124,7 @@ class LDSignatures {
'meDataType' => $data_type,
'meEncoding' => $encoding,
'meAlgorithm' => $algorithm,
- 'meCreator' => z_root() . '/channel/' . $channel['channel_address'] . '/public_key_pem',
+ 'meCreator' => z_root() . '/channel/' . $channel['channel_address'],
'meSignatureValue' => $signature
]);
@@ -132,4 +132,4 @@ class LDSignatures {
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 9bf987027..2a13744a3 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Lib;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
use Zotlabs\Access\Permissions;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Daemon\Master;
@@ -2037,7 +2037,7 @@ class Libzot {
$item_found = false;
$post_id = 0;
- $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
+ $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1",
dbesc($sender),
dbesc($sender),
@@ -2047,10 +2047,12 @@ class Libzot {
);
if($r) {
- if($r[0]['author_xchan'] === $sender || $r[0]['owner_xchan'] === $sender || $r[0]['source_xchan'] === $sender)
+ $stored = $r[0];
+
+ if($stored['author_xchan'] === $sender || $stored['owner_xchan'] === $sender || $stored['source_xchan'] === $sender)
$ownership_valid = true;
- $post_id = $r[0]['id'];
+ $post_id = $stored['id'];
$item_found = true;
}
else {
@@ -2074,8 +2076,27 @@ class Libzot {
return false;
}
+ if ($stored['resource_type'] === 'event') {
+ $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($stored['resource_id']),
+ intval($uid)
+ );
+ if ($i) {
+ if ($i[0]['event_xchan'] === $sender) {
+ q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($stored['resource_id']),
+ intval($uid)
+ );
+ }
+ else {
+ logger('delete linked event: not owner');
+ return;
+ }
+ }
+ }
+
if($item_found) {
- if(intval($r[0]['item_deleted'])) {
+ if(intval($stored['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if(! $relay)
return false;
@@ -2087,10 +2108,10 @@ class Libzot {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
- if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) {
+ if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d",
- intval($r[0]['id']),
- intval($r[0]['uid'])
+ intval($stored['id']),
+ intval($stored['uid'])
);
}
}
@@ -2766,7 +2787,7 @@ class Libzot {
$profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob'];
- if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== ''))
+ if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],'UTC')) !== ''))
$profile['next_birthday'] = $bd;
if($age = age($p[0]['dob'],$e['channel_timezone'],''))
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php
index e2bd07c0d..662fddad0 100644
--- a/Zotlabs/Lib/NativeWiki.php
+++ b/Zotlabs/Lib/NativeWiki.php
@@ -191,7 +191,7 @@ class NativeWiki {
return array('item' => null, 'success' => false);
}
else {
- $drop = drop_item($item['id'], false, DROPITEM_NORMAL, true);
+ $drop = drop_item($item['id'], false, DROPITEM_NORMAL);
}
info( t('Wiki files deleted successfully'));
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 9161aa182..5e4600df2 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -98,7 +98,7 @@ class ThreadItem {
$conv = $this->get_conversation();
$observer = $conv->get_observer();
- $lock = ((($item['item_private'] == 1) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
+ $lock = (((intval($item['item_private'])) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
: false);
@@ -110,7 +110,7 @@ class ThreadItem {
$shareable = true;
$privacy_warning = false;
- if(($item['item_private'] == 1) && ($item['owner']['xchan_network'] === 'activitypub')) {
+ 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']))
diff --git a/Zotlabs/Lib/ZotURL.php b/Zotlabs/Lib/ZotURL.php
index bc14c516a..98d1febe5 100644
--- a/Zotlabs/Lib/ZotURL.php
+++ b/Zotlabs/Lib/ZotURL.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Lib;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
class ZotURL {
diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php
index d094fdc8d..2d2e6796b 100644
--- a/Zotlabs/Lib/Zotfinger.php
+++ b/Zotlabs/Lib/Zotfinger.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Lib;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
class Zotfinger {