aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php162
-rw-r--r--Zotlabs/Lib/Apps.php7
-rw-r--r--Zotlabs/Lib/Connect.php2
-rw-r--r--Zotlabs/Lib/DReport.php3
-rw-r--r--Zotlabs/Lib/Enotify.php129
-rw-r--r--Zotlabs/Lib/Libsync.php3
-rw-r--r--Zotlabs/Lib/Libzot.php104
-rw-r--r--Zotlabs/Lib/Libzotdir.php48
-rw-r--r--Zotlabs/Lib/MessageFilter.php2
-rw-r--r--Zotlabs/Lib/Queue.php92
-rw-r--r--Zotlabs/Lib/Share.php42
-rw-r--r--Zotlabs/Lib/ThreadItem.php4
-rw-r--r--Zotlabs/Lib/ThreadStream.php8
13 files changed, 223 insertions, 383 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 6e8344def..784de3d2c 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -11,6 +11,7 @@ use Zotlabs\Web\HTTPSig;
require_once('include/event.php');
require_once('include/html2plain.php');
+require_once('include/items.php');
class Activity {
@@ -41,9 +42,6 @@ class Activity {
if ($x['type'] === ACTIVITY_OBJ_EVENT) {
return self::fetch_event($x);
}
- if ($x['type'] === ACTIVITY_OBJ_PHOTO) {
- return self::fetch_image($x);
- }
call_hooks('encode_object', $x);
}
@@ -193,6 +191,7 @@ class Activity {
}
static function fetch_image($x) {
+
$ret = [
'type' => 'Image',
'id' => $x['id'],
@@ -649,7 +648,7 @@ class Activity {
$atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'], true));
if ($atts) {
foreach ($atts as $att) {
- if (strpos($att['type'], 'image')) {
+ if (isset($att['type']) && strpos($att['type'], 'image')) {
$ret[] = ['type' => 'Image', 'url' => $att['href']];
}
else {
@@ -1534,8 +1533,9 @@ class Activity {
static function actor_store($url, $person_obj) {
- if (!is_array($person_obj))
+ if (!is_array($person_obj)) {
return;
+ }
$inbox = $person_obj['inbox'];
@@ -1546,11 +1546,14 @@ class Activity {
}
$name = $person_obj['name'];
- if (!$name)
+ if (!$name) {
$name = $person_obj['preferredUsername'];
- if (!$name)
+ }
+ if (!$name) {
$name = t('Unknown');
+ }
+ $icon = z_root() . '/' . get_default_profile_photo(300);
if ($person_obj['icon']) {
if (is_array($person_obj['icon'])) {
if (array_key_exists('url', $person_obj['icon']))
@@ -1615,84 +1618,85 @@ class Activity {
}
}
- $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ $m = parse_url($url);
+ if($m) {
+ $hostname = $m['host'];
+ $baseurl = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
+ $site_url = $m['scheme'] . '://' . $m['host'];
+ }
+
+ $r = q("select * from xchan join hubloc on xchan_hash = hubloc_hash where xchan_hash = '%s'",
dbesc($url)
);
- if (!$r) {
- // create a new record
-
- xchan_store_lowlevel(
- [
- 'xchan_hash' => $url,
- 'xchan_guid' => $url,
- 'xchan_pubkey' => $pubkey,
- 'xchan_addr' => '',
- 'xchan_url' => $profile,
- 'xchan_name' => $name,
- 'xchan_name_date' => datetime_convert(),
- 'xchan_network' => 'activitypub'
- ]
- );
- }
- else {
+ if($r) {
// Record exists. Cache existing records for one week at most
// then refetch to catch updated profile photos, names, etc.
-
- $d = datetime_convert('UTC', 'UTC', 'now - 1 week');
- if ($r[0]['xchan_name_date'] > $d)
+ $d = datetime_convert('UTC', 'UTC', 'now - 3 days');
+ if($r[0]['hubloc_updated'] > $d) {
return;
+ }
- // update existing record
- q("update xchan set xchan_name = '%s', xchan_pubkey = '%s', xchan_network = '%s', xchan_name_date = '%s' where xchan_hash = '%s'",
- dbesc($name),
- dbesc($pubkey),
- dbesc('activitypub'),
+ q("UPDATE site SET site_update = '%s', site_dead = 0 WHERE site_url = '%s'",
dbesc(datetime_convert()),
+ dbesc($site_url)
+ );
+
+ // update existing xchan record
+ q("update xchan set xchan_name = '%s', xchan_guid = '%s', xchan_pubkey = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'",
+ dbesc(escape_tags($name)),
+ dbesc(escape_tags($url)),
+ dbesc(escape_tags($pubkey)),
+ dbescdate(datetime_convert()),
dbesc($url)
);
- }
- if ($collections) {
- set_xconfig($url, 'activitypub', 'collections', $collections);
+ // update existing hubloc record
+ q("update hubloc set hubloc_guid = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'",
+ dbesc(escape_tags($url)),
+ dbesc(escape_tags($baseurl)),
+ dbesc(escape_tags($hostname)),
+ dbesc(escape_tags($inbox)),
+ dbescdate(datetime_convert()),
+ dbesc(escape_tags($profile)),
+ dbesc($url)
+ );
}
+ else {
+ // create a new record
- $r = q("select * from hubloc where hubloc_hash = '%s' limit 1",
- dbesc($url)
- );
-
- $m = parse_url($url);
- if ($m) {
- $hostname = $m['host'];
- $site_url = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
- }
+ xchan_store_lowlevel(
+ [
+ 'xchan_hash' => escape_tags($url),
+ 'xchan_guid' => escape_tags($url),
+ 'xchan_pubkey' => escape_tags($pubkey),
+ 'xchan_addr' => '',
+ 'xchan_url' => escape_tags($profile),
+ 'xchan_name' => escape_tags($name),
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_network' => 'activitypub'
+ ]
+ );
- if (!$r) {
hubloc_store_lowlevel(
[
- 'hubloc_guid' => $url,
- 'hubloc_hash' => $url,
+ 'hubloc_guid' => escape_tags($url),
+ 'hubloc_hash' => escape_tags($url),
'hubloc_addr' => '',
'hubloc_network' => 'activitypub',
- 'hubloc_url' => $site_url,
- 'hubloc_host' => $hostname,
- 'hubloc_callback' => $inbox,
+ 'hubloc_url' => escape_tags($baseurl),
+ 'hubloc_host' => escape_tags($hostname),
+ 'hubloc_callback' => escape_tags($inbox),
'hubloc_updated' => datetime_convert(),
'hubloc_primary' => 1,
- 'hubloc_id_url' => $profile
+ 'hubloc_id_url' => escape_tags($profile)
]
);
}
- q("UPDATE site SET site_update = '%s', site_dead = 0 WHERE site_url = '%s' AND site_update < %s - INTERVAL %s",
- dbesc(datetime_convert()),
- dbesc($site_url),
- db_utcnow(),
- db_quoteinterval('1 DAY')
- );
-
- if (!$icon)
- $icon = z_root() . '/' . get_default_profile_photo(300);
+ if ($collections) {
+ set_xconfig($url, 'activitypub', 'collections', $collections);
+ }
$photos = import_xchan_photo($icon, $url);
q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
@@ -1742,14 +1746,9 @@ class Activity {
static function create_note($channel, $observer_hash, $act) {
$s = [];
-
- // 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_sys_channel = is_sys_channel($channel['channel_id']);
-
$parent = ((array_key_exists('inReplyTo', $act->obj)) ? urldecode($act->obj['inReplyTo']) : '');
+
if ($parent) {
$r = q("select * from item where uid = %d and ( mid = '%s' or mid = '%s' ) limit 1",
@@ -1764,7 +1763,7 @@ class Activity {
}
if ($r[0]['owner_xchan'] === $channel['channel_hash']) {
- if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) {
+ if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) {
logger('no comment permission.');
return;
}
@@ -1776,7 +1775,7 @@ class Activity {
}
else {
- if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) {
+ if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) {
logger('no permission');
return;
}
@@ -2268,7 +2267,6 @@ class Activity {
$s['app'] = escape_tags($generator['name']);
}
-
if (!$response_activity) {
$a = self::decode_taxonomy($act->obj);
if ($a) {
@@ -2403,7 +2401,7 @@ class Activity {
}
- if ($act->obj['type'] === 'Image') {
+ if ($act->obj['type'] === 'Image' && strpos($s['body'],'zrl=') === false) {
$ptr = null;
@@ -2545,12 +2543,6 @@ class Activity {
return;
}*/
- // 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);
-
// TODO: this his handled in pubcrawl atm.
// very unpleasant and imperfect way of determining a Mastodon DM
/*if ($act->raw_recips && array_key_exists('to',$act->raw_recips) && is_array($act->raw_recips['to']) && count($act->raw_recips['to']) === 1 && $act->raw_recips['to'][0] === channel_url($channel) && ! $act->raw_recips['cc']) {
@@ -2611,7 +2603,7 @@ class Activity {
$allowed = true;
// reject public stream comments that weren't sent by the conversation owner
- if ($is_sys_channel && $pubstream && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) {
+ if ($is_sys_channel && $item['owner_xchan'] !== $observer_hash && !$fetch_parents) {
$allowed = false;
}
}
@@ -2626,7 +2618,7 @@ class Activity {
// The $item['item_fetched'] flag is set in fetch_and_store_parents().
// In this case we should check against author permissions because sender is not owner.
- if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || ($is_sys_channel && $pubstream)) {
+ if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) {
$allowed = true;
}
// TODO: not implemented
@@ -2764,7 +2756,7 @@ class Activity {
$fetch = false;
// TODO: debug
// if (perm_is_allowed($channel['channel_id'],$observer_hash,'send_stream') && (PConfig::Get($channel['channel_id'],'system','hyperdrive',true) || $act->type === 'Announce')) {
- if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || ($is_sys_channel && $pubstream)) {
+ if (perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') || $is_sys_channel) {
$fetch = (($fetch_parents) ? self::fetch_and_store_parents($channel, $observer_hash, $item, $force) : false);
}
if ($fetch) {
@@ -3073,15 +3065,9 @@ class Activity {
static function announce_note($channel, $observer_hash, $act) {
$s = [];
-
$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);
-
- if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !($is_sys_channel && $pubstream)) {
+ if (!perm_is_allowed($channel['channel_id'], $observer_hash, 'send_stream') && !$is_sys_channel) {
logger('no permission');
return;
}
@@ -3496,7 +3482,7 @@ class Activity {
static function find_best_identity($xchan) {
if (filter_var($xchan, FILTER_VALIDATE_URL)) {
- $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_network in ('zot6', 'zot') and hubloc_deleted = 0",
+ $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' and hubloc_deleted = 0",
dbesc($xchan)
);
if ($r) {
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 5ef4ecc8d..30c108cc1 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -76,7 +76,8 @@ class Apps {
'Directory',
'Search',
'Help',
- 'Profile Photo'
+ 'Profile Photo',
+ 'HQ'
]);
/**
@@ -374,7 +375,7 @@ class Apps {
'Permission Categories' => t('Permission Categories'),
'Public Stream' => t('Public Stream'),
'My Chatrooms' => t('My Chatrooms'),
- 'Channel Export' => t('Channel Export')
+ 'Channel Export' => t('Channel Export'),
);
if(array_key_exists('name',$arr)) {
@@ -524,7 +525,7 @@ class Apps {
}
elseif(remote_channel()) {
$observer = \App::get_observer();
- if($observer && in_array($observer['xchan_network'], ['zot6', 'zot'])) {
+ if($observer && $observer['xchan_network'] === 'zot6') {
// some folks might have xchan_url redirected offsite, use the connurl
$x = parse_url($observer['xchan_connurl']);
if($x) {
diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php
index 21bec171b..38fe69995 100644
--- a/Zotlabs/Lib/Connect.php
+++ b/Zotlabs/Lib/Connect.php
@@ -146,7 +146,7 @@ class Connect {
}
- $allowed = ((in_array($xchan['xchan_network'],['rss','zot','zot6'])) ? 1 : 0);
+ $allowed = ((in_array($xchan['xchan_network'],['rss', 'zot6'])) ? 1 : 0);
$hookdata = ['channel_id' => $uid, 'follow_address' => $url, 'xchan' => $xchan, 'allowed' => $allowed, 'singleton' => 0];
call_hooks('follow_allow',$hookdata);
diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php
index 7515d3292..2263529b2 100644
--- a/Zotlabs/Lib/DReport.php
+++ b/Zotlabs/Lib/DReport.php
@@ -87,8 +87,7 @@ class DReport {
// Is the sender one of our channels?
- $c = q("select channel_id from channel where channel_hash = '%s' or channel_portable_id = '%s' limit 1",
- dbesc($dr['sender']),
+ $c = q("select channel_id from channel where channel_hash = '%s' limit 1",
dbesc($dr['sender'])
);
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 7e33f09b8..7d741edd8 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -69,24 +69,24 @@ class Enotify {
$sender_name = $product;
$hostname = \App::get_hostname();
if(strpos($hostname,':'))
- $hostname = substr($hostname,0,strpos($hostname,':'));
+ $hostname = substr($hostname, 0, strpos($hostname,':'));
// Do not translate 'noreply' as it must be a legal 7-bit email address
- $reply_email = get_config('system','reply_address');
+ $reply_email = get_config('system', 'reply_address');
if(! $reply_email)
$reply_email = 'noreply' . '@' . $hostname;
- $sender_email = get_config('system','from_email');
+ $sender_email = get_config('system', 'from_email');
if(! $sender_email)
$sender_email = 'Administrator' . '@' . $hostname;
- $sender_name = get_config('system','from_email_name');
+ $sender_name = get_config('system', 'from_email_name');
if(! $sender_name)
$sender_name = \Zotlabs\Lib\System::get_site_name();
- $additional_mail_header = "";
+ $additional_mail_header = '';
if(array_key_exists('item', $params)) {
require_once('include/conversation.php');
@@ -114,27 +114,28 @@ class Enotify {
}
- $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices');
- $vnotify = get_pconfig($recip['channel_id'],'system','vnotify');
+ $always_show_in_notices = get_pconfig($recip['channel_id'], 'system', 'always_show_in_notices');
+ $vnotify = get_pconfig($recip['channel_id'], 'system', 'vnotify');
$salutation = $recip['channel_name'];
// e.g. "your post", "David's photo", etc.
$possess_desc = t('%s <!item_type!>');
+// @@TODO: consider using switch instead of those elseif
if ($params['type'] == NOTIFY_MAIL) {
logger('notification: mail');
- $subject = sprintf( t('[$Projectname:Notify] New mail received at %s'),$sitename);
-
- $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'), $sender['xchan_name'],$sitename);
- $epreamble = sprintf( t('%1$s sent you %2$s.'),'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a private message') . '[/zrl]');
- $sitelink = t('Please visit %s to view and/or reply to your private messages.');
- $tsitelink = sprintf( $sitelink, $siteurl . '/mail/' . $params['item']['id'] );
- $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/mail/' . $params['item']['id'] . '">' . $sitename . '</a>');
- $itemlink = $siteurl . '/mail/' . $params['item']['id'];
+ $subject = sprintf( t('[$Projectname:Notify] New direct message received at %s'), $sitename);
+
+ $preamble = sprintf( t('%1$s sent you a new direct message at %2$s.'), $sender['xchan_name'], $sitename);
+ $epreamble = sprintf( t('%1$s sent you %2$s.'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a direct message') . '[/zrl]');
+ $sitelink = t('Please visit %s to view and/or reply to your direct messages.');
+ $tsitelink = sprintf( $sitelink, $siteurl . '/hq/' . gen_link_id($params['item']['mid']));
+ $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/hq/' . gen_link_id($params['item']['mid']) . '">' . $sitename . '</a>');
+ $itemlink = $siteurl . '/hq/' . gen_link_id($params['item']['mid']);
}
- if ($params['type'] == NOTIFY_COMMENT) {
+ elseif ($params['type'] === NOTIFY_COMMENT) {
//logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false);
@@ -171,7 +172,6 @@ class Enotify {
// Check to see if there was already a notify for this post.
// If so don't create a second notification
- $p = null;
$p = q("select id from notify where link = '%s' and uid = %d limit 1",
dbesc($params['link']),
intval($recip['channel_id'])
@@ -196,6 +196,7 @@ class Enotify {
xchan_query($p);
+//@@FIXME $p can be null (line 188)
$item_post_type = item_post_type($p[0]);
// $private = $p[0]['item_private'];
$parent_id = $p[0]['id'];
@@ -250,7 +251,7 @@ class Enotify {
}
- if ($params['type'] == NOTIFY_LIKE) {
+ elseif ($params['type'] === NOTIFY_LIKE) {
// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
$itemlink = $params['link'];
@@ -268,7 +269,6 @@ class Enotify {
// Check to see if there was already a notify for this post.
// If so don't create a second notification
- $p = null;
$p = q("select id from notify where link = '%s' and uid = %d limit 1",
dbesc($params['link']),
intval($recip['channel_id'])
@@ -293,7 +293,7 @@ class Enotify {
xchan_query($p);
-
+//@@FIXME $p can be null (line 285)
$item_post_type = item_post_type($p[0]);
// $private = $p[0]['item_private'];
$parent_id = $p[0]['id'];
@@ -302,7 +302,7 @@ class Enotify {
// "your post"
- if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall']))
+ if($p[0]['owner']['xchan_name'] === $p[0]['author']['xchan_name'] && intval($p[0]['item_wall']))
$dest_str = sprintf(t('%1$s liked [zrl=%2$s]your %3$s[/zrl]'),
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
$itemlink,
@@ -328,7 +328,7 @@ class Enotify {
- if($params['type'] == NOTIFY_WALL) {
+ elseif($params['type'] === NOTIFY_WALL) {
$subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $sender['xchan_name'], $sitename);
@@ -343,9 +343,8 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_TAGSELF) {
+ elseif ($params['type'] === NOTIFY_TAGSELF) {
- $p = null;
$p = q("select id from notify where link = '%s' and uid = %d limit 1",
dbesc($params['link']),
intval($recip['channel_id'])
@@ -368,7 +367,7 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_POKE) {
+ elseif ($params['type'] === NOTIFY_POKE) {
$subject = sprintf( t('[$Projectname:Notify] %1$s poked you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s poked you at %2$s') , $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s [zrl=%2$s]poked you[/zrl].') ,
@@ -385,7 +384,7 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_TAGSHARE) {
+ elseif ($params['type'] === NOTIFY_TAGSHARE) {
$subject = sprintf( t('[$Projectname:Notify] %s tagged your post') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s tagged your post at %2$s'),$sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s tagged [zrl=%2$s]your post[/zrl]') ,
@@ -398,7 +397,7 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_INTRO) {
+ elseif ($params['type'] === NOTIFY_INTRO) {
$subject = sprintf( t('[$Projectname:Notify] Introduction received'));
$preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a new connection request[/zrl] from %2$s.'),
@@ -412,7 +411,7 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_SUGGEST) {
+ elseif ($params['type'] === NOTIFY_SUGGEST) {
$subject = sprintf( t('[$Projectname:Notify] Friend suggestion received'));
$preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s.'),
@@ -430,11 +429,11 @@ class Enotify {
$itemlink = $params['link'];
}
- if ($params['type'] == NOTIFY_CONFIRM) {
+ elseif ($params['type'] === NOTIFY_CONFIRM) {
// ?
}
- if ($params['type'] == NOTIFY_SYSTEM) {
+ elseif ($params['type'] === NOTIFY_SYSTEM) {
// ?
}
@@ -477,7 +476,7 @@ class Enotify {
} while ($dups === true);
- $datarray = array();
+ $datarray = [];
$datarray['hash'] = $hash;
$datarray['sender_hash'] = $sender['xchan_hash'];
$datarray['xname'] = $sender['xchan_name'];
@@ -514,7 +513,7 @@ class Enotify {
// (probably would be better that way)
if (!$always_show_in_notices) {
- if (($params['type'] == NOTIFY_WALL) || ($params['type'] == NOTIFY_MAIL) || ($params['type'] == NOTIFY_INTRO)) {
+ if (($params['type'] === NOTIFY_WALL) || ($params['type'] === NOTIFY_MAIL) || ($params['type'] === NOTIFY_INTRO)) {
$seen = 1;
}
}
@@ -550,12 +549,12 @@ class Enotify {
}
$itemlink = z_root() . '/notify/view/' . $notify_id;
- $msg = str_replace('$itemlink',$itemlink,$epreamble);
+ $msg = str_replace('$itemlink', $itemlink, $epreamble);
// wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation
if ((\App::$language === 'en' || (! \App::$language)) && strpos($msg,', '))
- $msg = substr($msg,strpos($msg,', ')+1);
+ $msg = substr($msg, strpos($msg,', ')+1);
$datarray['id'] = $notify_id;
$datarray['msg'] = $msg;
@@ -575,7 +574,7 @@ class Enotify {
logger('notification: sending notification email');
- $hn = get_pconfig($recip['channel_id'],'system','email_notify_host');
+ $hn = get_pconfig($recip['channel_id'], 'system', 'email_notify_host');
if($hn && (! stristr(\App::get_hostname(),$hn))) {
// this isn't the email notification host
pop_lang();
@@ -584,7 +583,7 @@ class Enotify {
$textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"), array( "", "\n"), $body))),ENT_QUOTES,'UTF-8'));
- $htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","<br />\n"),$body)));
+ $htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array('',"<br />\n"),$body)));
// use $_SESSION['zid_override'] to force zid() to use
@@ -601,7 +600,7 @@ class Enotify {
unset($_SESSION['zid_override']);
unset($_SESSION['zrl_override']);
- $datarray = array();
+ $datarray = [];
$datarray['banner'] = $banner;
$datarray['product'] = $product;
$datarray['preamble'] = $preamble;
@@ -758,9 +757,9 @@ class Enotify {
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
// generate a mime boundary
- $mimeBoundary = rand(0, 9) . "-"
- .rand(100000000, 999999999) . "-"
- .rand(100000000, 999999999) . "=:"
+ $mimeBoundary = rand(0, 9) . '-'
+ .rand(100000000, 999999999) . '-'
+ .rand(100000000, 999999999) . '=:'
.rand(10000, 99999);
// generate a multipart/alternative message header
@@ -768,7 +767,7 @@ class Enotify {
$params['additionalMailHeader'] .
"From: $fromName <{$params['fromEmail']}>" . PHP_EOL .
"Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL .
- "MIME-Version: 1.0" . PHP_EOL .
+ 'MIME-Version: 1.0' . PHP_EOL .
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
// assemble the final multipart message body with the text and html types included
@@ -776,15 +775,15 @@ class Enotify {
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
$multipartMessageBody =
- "--" . $mimeBoundary . PHP_EOL . // plain text section
- "Content-Type: text/plain; charset=UTF-8" . PHP_EOL .
- "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
+ '--' . $mimeBoundary . PHP_EOL . // plain text section
+ 'Content-Type: text/plain; charset=UTF-8' . PHP_EOL .
+ 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL .
$textBody . PHP_EOL .
- "--" . $mimeBoundary . PHP_EOL . // text/html section
- "Content-Type: text/html; charset=UTF-8" . PHP_EOL .
- "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
+ '--' . $mimeBoundary . PHP_EOL . // text/html section
+ 'Content-Type: text/html; charset=UTF-8' . PHP_EOL .
+ 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL .
$htmlBody . PHP_EOL .
- "--" . $mimeBoundary . "--" . PHP_EOL; // message ending
+ '--' . $mimeBoundary . '--' . PHP_EOL; // message ending
// send the message
$res = mail(
@@ -793,7 +792,7 @@ class Enotify {
$multipartMessageBody, // message body
$messageHeader // message headers
);
- logger("notification: enotify::send returns " . (($res) ? 'success' : 'failure'), LOGGER_DEBUG);
+ logger('notification: enotify::send returns ' . (($res) ? 'success' : 'failure'), LOGGER_DEBUG);
return $res;
}
@@ -833,13 +832,12 @@ class Enotify {
$edit = false;
if($item['edited'] > $item['created']) {
+ $edit = true;
if($item['item_thread_top']) {
$itemem_text = sprintf( t('edited a post dated %s'), relative_date($item['created']));
- $edit = true;
}
else {
$itemem_text = sprintf( t('edited a comment dated %s'), relative_date($item['created']));
- $edit = true;
}
}
@@ -860,14 +858,14 @@ class Enotify {
//'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])),
'thread_top' => (($item['item_thread_top']) ? true : false),
'message' => bbcode(escape_tags($itemem_text)),
- 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_QUOTES, 'UTF-8', false),
+ 'body' => htmlentities(html2plain(bbcode($item['body'], ['drop_media', true]), 75, true), ENT_QUOTES, 'UTF-8', false),
// these are for the superblock addon
'hash' => $item[$who]['xchan_hash'],
'uid' => $item['uid'],
'display' => true
);
- call_hooks('enotify_format',$x);
+ call_hooks('enotify_format', $x);
if(! $x['display']) {
return [];
}
@@ -886,7 +884,7 @@ class Enotify {
$b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid));
$x = [
- 'notify_link' => z_root() . '/notify/view/' . $tt['id'],
+ 'notify_link' => (($tt['ntype'] === NOTIFY_MAIL) ? $tt['link'] : z_root() . '/notify/view/' . $tt['id']),
'name' => $tt['xname'],
'url' => $tt['url'],
'photo' => $tt['photo'],
@@ -903,7 +901,7 @@ class Enotify {
static public function format_intros($rr) {
- $x = [
+ return [
'notify_link' => z_root() . '/connections/ifpending',
'name' => $rr['xchan_name'],
'addr' => $rr['xchan_addr'],
@@ -912,15 +910,13 @@ class Enotify {
'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['abook_created']),
'hclass' => ('notify-unseen'),
'message' => t('added your channel')
- ];
-
- return $x;
+ ];
}
static public function format_files($rr) {
- $x = [
+ return [
'notify_link' => z_root() . '/sharedwithme',
'name' => $rr['author']['xchan_name'],
'addr' => $rr['author']['xchan_addr'],
@@ -931,13 +927,11 @@ class Enotify {
'message' => t('shared a file with you')
];
- return $x;
-
}
static public function format_mail($rr) {
- $x = [
+ return [
'notify_link' => z_root() . '/mail/' . $rr['id'],
'name' => $rr['xchan_name'],
'addr' => $rr['xchan_addr'],
@@ -945,11 +939,9 @@ class Enotify {
'photo' => $rr['xchan_photo_s'],
'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['created']),
'hclass' => (intval($rr['mail_seen']) ? 'notify-seen' : 'notify-unseen'),
- 'message' => t('sent you a private message'),
+ 'message' => t('sent you a direct message'),
];
- return $x;
-
}
static public function format_all_events($rr) {
@@ -959,7 +951,7 @@ class Enotify {
$today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false);
$when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
- $x = [
+ return [
'notify_link' => z_root() . '/cdav/calendar/' . $rr['event_hash'],
'name' => $rr['xchan_name'],
'addr' => $rr['xchan_addr'],
@@ -970,13 +962,12 @@ class Enotify {
'message' => t('created an event')
];
- return $x;
}
static public function format_register($rr) {
- $x = [
+ return [
'notify_link' => z_root() . '/admin/accounts',
'name' => $rr['reg_did2'],
//'addr' => '',
@@ -986,7 +977,5 @@ class Enotify {
'message' => t('status verified')
];
- return $x;
-
}
}
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index 5455aa2ea..67603a0e3 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -255,9 +255,6 @@ class Libsync {
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']);
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index c7d001d21..ae8c725d7 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1142,6 +1142,7 @@ class Libzot {
}
+
$deliveries = null;
if (array_key_exists('recipients', $env) && count($env['recipients'])) {
@@ -1270,10 +1271,6 @@ class Libzot {
if ($AS->data['signed_data']) {
IConfig::Set($arr, 'activitypub', 'signed_data', $AS->data['signed_data'], false);
- $j = json_decode($AS->data['signed_data'], true);
- if ($j) {
- IConfig::Set($arr, 'activitypub', 'rawmsg', json_encode(JSalmon::unpack($j['data'])), true);
- }
}
logger('Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG);
@@ -1377,8 +1374,6 @@ class Libzot {
$check_mentions = true;
}
}
- elseif ($msg['type'] === 'mail')
- $perm = 'post_mail';
$r = [];
@@ -2210,90 +2205,6 @@ class Libzot {
return $post_id;
}
- static function process_mail_delivery($sender, $arr, $deliveries) {
-
- $result = [];
-
- if ($sender != $arr['from_xchan']) {
- logger('process_mail_delivery: sender is not mail author');
- return;
- }
-
- foreach ($deliveries as $d) {
-
- $DR = new DReport(z_root(), $sender, $d, $arr['mid']);
-
- $r = q("select * from channel where channel_hash = '%s' limit 1",
- dbesc($d['hash'])
- );
-
- if (!$r) {
- $DR->update('recipient not found');
- $result[] = $DR->get();
- continue;
- }
-
- $channel = $r[0];
- $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>');
-
-
- if (!perm_is_allowed($channel['channel_id'], $sender, 'post_mail')) {
-
- /*
- * Always allow somebody to reply if you initiated the conversation. It's anti-social
- * and a bit rude to send a private message to somebody and block their ability to respond.
- * If you are being harrassed and want to put an end to it, delete the conversation.
- */
-
- $return = false;
- if ($arr['parent_mid']) {
- $return = q("select * from mail where mid = '%s' and channel_id = %d limit 1",
- dbesc($arr['parent_mid']),
- intval($channel['channel_id'])
- );
- }
- if (!$return) {
- logger("permission denied for mail delivery {$channel['channel_id']}");
- $DR->update('permission denied');
- $result[] = $DR->get();
- continue;
- }
- }
-
-
- $r = q("select id from mail where mid = '%s' and channel_id = %d limit 1",
- dbesc($arr['mid']),
- intval($channel['channel_id'])
- );
- if ($r) {
- if (intval($arr['mail_recalled'])) {
- $x = q("delete from mail where id = %d and channel_id = %d",
- intval($r[0]['id']),
- intval($channel['channel_id'])
- );
- $DR->update('mail recalled');
- $result[] = $DR->get();
- logger('mail_recalled');
- }
- else {
- $DR->update('duplicate mail received');
- $result[] = $DR->get();
- logger('duplicate mail received');
- }
- continue;
- }
- else {
- $arr['account_id'] = $channel['channel_account_id'];
- $arr['channel_id'] = $channel['channel_id'];
- $item_id = mail_store($arr);
- $DR->update('mail delivered');
- $result[] = $DR->get();
- }
- }
-
- return $result;
- }
-
/**
* @brief Processes delivery of profile.
@@ -2664,9 +2575,9 @@ class Libzot {
// we may only end up with one; which results in posts with no author name or photo and are a bit
// of a hassle to repair. If either or both are missing, do a full discovery probe.
- //if (!array_key_exists('id', $x)) {
- //return import_author_activitypub($x);
- //}
+ if(!isset($x['id']) && !isset($x['key']) && !isset($x['id_sig'])) {
+ return false;
+ }
$hash = self::make_xchan_hash($x['id'], $x['key']);
@@ -2927,7 +2838,7 @@ class Libzot {
$hookinfo = [
'channel_id' => $id,
- 'protocols' => ['zot6', 'zot']
+ 'protocols' => ['zot6']
];
/**
* @hooks channel_protocols
@@ -3231,11 +3142,6 @@ class Libzot {
return $v;
}
}
- foreach ($arr as $v) {
- if ($v[$check] === 'zot') {
- return $v;
- }
- }
return $arr[0];
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index 41c0a54e9..4f35a1b80 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -207,8 +207,6 @@ class Libzotdir {
);
}
-
-
// If there are no directory servers, setup the fallback master
/** @FIXME What to do if we're in a different realm? */
@@ -249,11 +247,12 @@ class Libzotdir {
$syncdate = (($rr['site_sync'] <= NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']);
$x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate) . (($token) ? '&t=' . $token : ''));
+
if (! $x['success'])
continue;
$j = json_decode($x['body'],true);
- if (!($j['transactions']) || ($j['ratings']))
+ if (!$j['transactions'])
continue;
q("update site set site_sync = '%s' where site_url = '%s'",
@@ -265,6 +264,11 @@ class Libzotdir {
if (is_array($j['transactions']) && count($j['transactions'])) {
foreach ($j['transactions'] as $t) {
+
+ if (empty($t['hash']) || empty($t['transaction_id']) || empty($t['address'])) {
+ continue;
+ }
+
$r = q("select * from updates where ud_guid = '%s' limit 1",
dbesc($t['transaction_id'])
);
@@ -319,6 +323,14 @@ class Libzotdir {
}
if(array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
$xc = Libzot::import_xchan($zf['data'], 0, $ud);
+ // This is a workaround for a missing xchan_updated column
+ // TODO: implement xchan_updated in the xchan table and update this column instead
+ if($zf['data']['primary_location']['address'] && $zf['data']['primary_location']['url']) {
+ q("UPDATE hubloc SET hubloc_updated = '%s' WHERE hubloc_id_url = '%s' AND hubloc_primary = 1",
+ dbesc(datetime_convert()),
+ dbesc($zf['data']['primary_location']['url'])
+ );
+ }
}
else {
q("update updates set ud_last = '%s' where ud_addr = '%s'",
@@ -345,7 +357,7 @@ class Libzotdir {
logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG);
- $p = q("select channel.channel_hash, channel_address, channel_timezone, channel_portable_id, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1",
+ $p = q("select channel.channel_hash, channel_address, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1",
intval($uid)
);
@@ -354,7 +366,6 @@ class Libzotdir {
if ($p) {
$hash = $p[0]['channel_hash'];
- $legacy_hash = $p[0]['channel_portable_id'];
$profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob'];
@@ -393,10 +404,9 @@ class Libzotdir {
);
if(intval($r[0]['xchan_hidden']) != $hidden) {
- $r = q("update xchan set xchan_hidden = %d where xchan_hash in ('%s', '%s')",
+ $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'",
intval($hidden),
- dbesc($hash),
- dbesc($legacy_hash)
+ dbesc($hash)
);
}
@@ -410,13 +420,11 @@ class Libzotdir {
}
else {
// they may have made it private
- q("delete from xprof where xprof_hash in ('%s', '%s')",
- dbesc($hash),
- dbesc($legacy_hash)
+ q("delete from xprof where xprof_hash = '%s'",
+ dbesc($hash)
);
- q("delete from xtag where xtag_hash in ('%s', '%s')",
- dbesc($hash),
- dbesc($legacy_hash)
+ q("delete from xtag where xtag_hash = '%s'",
+ dbesc($hash)
);
}
@@ -635,8 +643,13 @@ class Libzotdir {
$dirmode = intval(get_config('system', 'directory_mode'));
- if($dirmode == DIRECTORY_MODE_NORMAL)
+ if($dirmode == DIRECTORY_MODE_NORMAL) {
return;
+ }
+
+ if (empty($hash) || empty($guid) || empty($addr)) {
+ return;
+ }
if($flags) {
q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )",
@@ -656,9 +669,4 @@ class Libzotdir {
}
}
-
-
-
-
-
}
diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php
index 750d6d424..21e6ca26a 100644
--- a/Zotlabs/Lib/MessageFilter.php
+++ b/Zotlabs/Lib/MessageFilter.php
@@ -11,8 +11,6 @@ class MessageFilter {
require_once('include/html2plain.php');
- unobscure($item);
-
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text);
diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php
index 373a7d304..35eb1e264 100644
--- a/Zotlabs/Lib/Queue.php
+++ b/Zotlabs/Lib/Queue.php
@@ -2,6 +2,9 @@
namespace Zotlabs\Lib;
+use Zotlabs\Zot6\Receiver;
+use Zotlabs\Zot6\Zot6Handler;
+
class Queue {
static function update($id, $add_priority = 0) {
@@ -28,19 +31,19 @@ class Queue {
$might_be_down = ((datetime_convert('UTC','UTC',$y[0]['earliest']) < datetime_convert('UTC','UTC','now - 2 days')) ? true : false);
- // Set all other records for this destination way into the future.
+ // Set all other records for this destination way into the future.
// The queue delivers by destination. We'll keep one queue item for
// this destination (this one) with a shorter delivery. If we succeed
// once, we'll try to deliver everything for that destination.
- // The delivery will be set to at most once per hour, and if the
+ // The delivery will be set to at most once per hour, and if the
// queue item is less than 12 hours old, we'll schedule for fifteen
- // minutes.
+ // minutes.
q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'",
dbesc(datetime_convert('UTC','UTC','now + 5 days')),
dbesc($x[0]['outq_posturl'])
);
-
+
$since = datetime_convert('UTC','UTC',$x[0]['outq_created']);
if(($might_be_down) || ($since < datetime_convert('UTC','UTC','now - 12 hour'))) {
@@ -50,9 +53,9 @@ class Queue {
$next = datetime_convert('UTC','UTC','now + ' . intval($add_priority) . ' minutes');
}
- q("UPDATE outq SET outq_updated = '%s',
- outq_priority = outq_priority + %d,
- outq_scheduled = '%s'
+ q("UPDATE outq SET outq_updated = '%s',
+ outq_priority = outq_priority + %d,
+ outq_scheduled = '%s'
WHERE outq_hash = '%s'",
dbesc(datetime_convert()),
@@ -66,7 +69,7 @@ class Queue {
static function remove($id,$channel_id = 0) {
logger('queue: remove queue item ' . $id,LOGGER_DEBUG);
$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : '');
-
+
q("DELETE FROM outq WHERE outq_hash = '%s' $sql_extra",
dbesc($id)
);
@@ -75,7 +78,7 @@ class Queue {
static function remove_by_posturl($posturl) {
logger('queue: remove queue posturl ' . $posturl,LOGGER_DEBUG);
-
+
q("DELETE FROM outq WHERE outq_posturl = '%s' ",
dbesc($posturl)
);
@@ -88,7 +91,7 @@ class Queue {
$sql_extra = (($channel['channel_id']) ? " and outq_channel = " . intval($channel['channel_id']) . " " : '');
// Set the next scheduled run date so far in the future that it will be expired
- // long before it ever makes it back into the delivery chain.
+ // long before it ever makes it back into the delivery chain.
q("update outq set outq_delivered = 1, outq_updated = '%s', outq_scheduled = '%s' where outq_hash = '%s' $sql_extra ",
dbesc(datetime_convert()),
@@ -108,7 +111,7 @@ class Queue {
}
$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority,
- outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )
+ outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )
values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )",
dbesc($arr['hash']),
intval($arr['account_id']),
@@ -133,7 +136,7 @@ class Queue {
$base = null;
$h = parse_url($outq['outq_posturl']);
- if($h !== false)
+ if($h !== false)
$base = $h['scheme'] . '://' . $h['host'] . (isset($h['port']) ? ':' . $h['port'] : '');
if(($base) && ($base !== z_root()) && ($immediate)) {
@@ -147,7 +150,7 @@ class Queue {
return;
}
if($y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) {
- self::update($outq['outq_hash'],10);
+ self::update($outq['outq_hash'], 10);
logger('immediate delivery deferred for site ' . $base);
return;
}
@@ -158,12 +161,12 @@ class Queue {
// your site has existed. Since we don't know for sure what these sites are,
// call them unknown
- site_store_lowlevel(
+ site_store_lowlevel(
[
'site_url' => $base,
'site_update' => datetime_convert(),
'site_dead' => 0,
- 'site_type' => intval(($outq['outq_driver'] === 'post') ? SITE_TYPE_NOTZOT : SITE_TYPE_UNKNOWN),
+ 'site_type' => SITE_TYPE_UNKNOWN,
'site_crypto' => ''
]
);
@@ -171,65 +174,17 @@ class Queue {
}
$arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate);
- call_hooks('queue_deliver',$arr);
+ call_hooks('queue_deliver', $arr);
if($arr['handled'])
return;
- // "post" queue driver - used for diaspora and friendica-over-diaspora communications.
-
- if($outq['outq_driver'] === 'post') {
- $result = z_post_url($outq['outq_posturl'],$outq['outq_msg']);
- if($result['success'] && $result['return_code'] < 300) {
- logger('deliver: queue post success to ' . $outq['outq_posturl'], LOGGER_DEBUG);
- if($base) {
- q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ",
- dbesc(datetime_convert()),
- dbesc($base)
- );
- }
- q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s'",
- dbesc('accepted for delivery'),
- dbesc(datetime_convert()),
- dbesc($outq['outq_hash'])
- );
- self::remove($outq['outq_hash']);
-
- // server is responding - see if anything else is going to this destination and is piled up
- // and try to send some more. We're relying on the fact that do_delivery() results in an
- // immediate delivery otherwise we could get into a queue loop.
-
- if(! $immediate) {
- $x = q("select outq_hash from outq where outq_posturl = '%s' and outq_delivered = 0",
- dbesc($outq['outq_posturl'])
- );
-
- $piled_up = array();
- if($x) {
- foreach($x as $xx) {
- $piled_up[] = $xx['outq_hash'];
- }
- }
- if($piled_up) {
- // call do_delivery() with the force flag
- do_delivery($piled_up, true);
- }
- }
- }
- else {
- logger('deliver: queue post returned ' . $result['return_code']
- . ' from ' . $outq['outq_posturl'],LOGGER_DEBUG);
- self::update($outq['outq_hash'],10);
- }
- return;
- }
-
// normal zot delivery
logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG);
if($outq['outq_posturl'] === z_root() . '/zot') {
// local delivery
- $zot = new \Zotlabs\Zot6\Receiver(new \Zotlabs\Zot6\Zot6Handler(),$outq['outq_notify']);
+ $zot = new Receiver(new Zot6Handler(), $outq['outq_notify']);
$result = $zot->run();
logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']);
@@ -246,7 +201,8 @@ class Queue {
$host_crypto = null;
if($channel && $base) {
- $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_sitekey != '' order by hubloc_id desc limit 1",
+ $h = q("SELECT hubloc_sitekey, site_crypto FROM hubloc LEFT JOIN site ON hubloc_url = site_url
+ WHERE site_url = '%s' AND hubloc_network = 'zot6' ORDER BY hubloc_id DESC LIMIT 1",
dbesc($base)
);
if($h) {
@@ -256,7 +212,7 @@ class Queue {
$msg = $outq['outq_notify'];
- $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto);
+ $result = Libzot::zot($outq['outq_posturl'], $msg, $channel, $host_crypto);
if($result['success']) {
logger('deliver: remote zot delivery succeeded to ' . $outq['outq_posturl']);
@@ -265,7 +221,7 @@ class Queue {
else {
logger('deliver: remote zot delivery failed to ' . $outq['outq_posturl']);
logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA);
- self::update($outq['outq_hash'],10);
+ self::update($outq['outq_hash'], 10);
}
}
return;
diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php
index b4cd5a194..81f378d0d 100644
--- a/Zotlabs/Lib/Share.php
+++ b/Zotlabs/Lib/Share.php
@@ -8,13 +8,13 @@ class Share {
public function __construct($post_id) {
-
+
if(! $post_id)
return;
-
+
if(! (local_channel() || remote_channel()))
return;
-
+
$r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1",
intval($post_id)
);
@@ -23,26 +23,26 @@ class Share {
if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss'))
return;
-
+
$sql_extra = item_permissions_sql($r[0]['uid']);
-
+
$r = q("select * from item where id = %d $sql_extra",
intval($post_id)
);
if(! $r)
return;
-
+
if($r[0]['mimetype'] !== 'text/bbcode')
return;
-
+
/** @FIXME eventually we want to post remotely via rpost on your home site */
// When that works remove this next bit:
-
+
if(! local_channel())
return;
xchan_query($r);
-
+
$this->item = $r[0];
return;
}
@@ -66,14 +66,14 @@ class Share {
'address' => $this->item['author']['xchan_addr'],
'network' => $this->item['author']['xchan_network'],
'link' => [
- [
- 'rel' => 'alternate',
- 'type' => 'text/html',
+ [
+ 'rel' => 'alternate',
+ 'type' => 'text/html',
'href' => $this->item['author']['xchan_url']
],
[
- 'rel' => 'photo',
- 'type' => $this->item['author']['xchan_photo_mimetype'],
+ 'rel' => 'photo',
+ 'type' => $this->item['author']['xchan_photo_mimetype'],
'href' => $this->item['author']['xchan_photo_m']
]
]
@@ -84,14 +84,14 @@ class Share {
'address' => $this->item['owner']['xchan_addr'],
'network' => $this->item['owner']['xchan_network'],
'link' => [
- [
- 'rel' => 'alternate',
- 'type' => 'text/html',
+ [
+ 'rel' => 'alternate',
+ 'type' => 'text/html',
'href' => $this->item['owner']['xchan_url']
],
[
- 'rel' => 'photo',
- 'type' => $this->item['owner']['xchan_photo_mimetype'],
+ 'rel' => 'photo',
+ 'type' => $this->item['owner']['xchan_photo_mimetype'],
'href' => $this->item['owner']['xchan_photo_m']
]
]
@@ -117,7 +117,7 @@ class Share {
$object = json_decode($this->item['obj'],true);
$photo_bb = $object['body'];
}
-
+
if (strpos($this->item['body'], "[/share]") !== false) {
$pos = strpos($this->item['body'], "[share");
$bb = substr($this->item['body'], $pos);
@@ -126,7 +126,7 @@ class Share {
"' profile='" . $this->item['author']['xchan_url'] .
"' avatar='" . $this->item['author']['xchan_photo_s'] .
"' link='" . $this->item['plink'] .
- "' auth='" . ((in_array($this->item['author']['xchan_network'], ['zot6', 'zot'])) ? 'true' : 'false') .
+ "' auth='" . (($this->item['author']['xchan_network'] === 'zot6') ? 'true' : 'false') .
"' posted='" . $this->item['created'] .
"' message_id='" . $this->item['mid'] .
"']";
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index c0d5c001b..c9048cd4f 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -299,7 +299,7 @@ class ThreadItem {
);
*/
- $settings = t('Conversation Tools');
+ $settings = t('Conversation Features');
}
$has_bookmarks = false;
@@ -367,7 +367,7 @@ class ThreadItem {
call_hooks('dropdown_extras',$dropdown_extras_arr);
$dropdown_extras = $dropdown_extras_arr['dropdown_extras'];
- $midb64 = 'b64.' . base64url_encode($item['mid']);
+ $midb64 = gen_link_id($item['mid']);
$mids = [ $midb64 ];
$response_mids = [];
foreach($response_verbs as $v) {
diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php
index 68b2c70dd..7fe8fcc2e 100644
--- a/Zotlabs/Lib/ThreadStream.php
+++ b/Zotlabs/Lib/ThreadStream.php
@@ -77,7 +77,7 @@ class ThreadStream {
$this->reload = $_SESSION['return_url'];
break;
case 'display':
- // in this mode we set profile_owner after initialisation (from conversation()) and then
+ // in this mode we set profile_owner after initialisation (from conversation()) and then
// pull some trickery which allows us to re-invoke this function afterward
// it's an ugly hack so @FIXME
$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
@@ -170,14 +170,14 @@ class ThreadStream {
* Only add things that will be displayed
*/
-
+
if(($item->get_data_value('id') != $item->get_data_value('parent')) && (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE))) {
return false;
}
$item->set_commentable(false);
$ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : '');
-
+
if(! comments_are_now_closed($item->get_data())) {
if(($item->get_data_value('author_xchan') === $ob_hash) || ($item->get_data_value('owner_xchan') === $ob_hash))
$item->set_commentable(true);
@@ -194,7 +194,7 @@ class ThreadStream {
}
if($this->mode === 'pubstream' && (! local_channel())) {
$item->set_commentable(false);
- }
+ }
$item->set_conversation($this);