2.0.1 update: Merge branch 'dev'

This commit is contained in:
zotlabs 2018-12-12 16:30:57 -08:00
commit 9984f3bdcf
12 changed files with 172 additions and 59 deletions

View file

@ -806,7 +806,7 @@ class Activity {
$ret['type'] = 'Person';
if($c) {
$role = get_pconfig($c['channel_id'],'system','permissions_role');
$role = PConfig::Get($c['channel_id'],'system','permissions_role');
if(strpos($role,'forum') !== false) {
$ret['type'] = 'Group';
}
@ -1105,7 +1105,7 @@ class Activity {
$my_perms = Permissions::serialise($p['perms']);
$automatic = $p['automatic'];
$closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness',80);
$closeness = PConfig::Get($channel['channel_id'],'system','new_abook_closeness',80);
$r = abook_store_lowlevel(
[
@ -1123,10 +1123,10 @@ class Activity {
);
if($my_perms)
set_abconfig($channel['channel_id'],$ret['xchan_hash'],'system','my_perms',$my_perms);
AbConfig:Set($channel['channel_id'],$ret['xchan_hash'],'system','my_perms',$my_perms);
if($their_perms)
set_abconfig($channel['channel_id'],$ret['xchan_hash'],'system','their_perms',$their_perms);
AbConfig::Set($channel['channel_id'],$ret['xchan_hash'],'system','their_perms',$their_perms);
if($r) {
@ -1603,11 +1603,9 @@ class Activity {
}
if($abook) {
if(! post_is_importable($s,$abook[0])) {
logger('post is filtered');
return;
}
if(! post_is_importable($channel['channel_id'],$s,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {
@ -1822,7 +1820,7 @@ class Activity {
if(! $s['edited'])
$s['edited'] = $s['created'];
$s['title'] = self::bb_content($content,'name');
$s['title'] = (($response_activity) ? EMPTY_STR : self::bb_content($content,'name'));
$s['summary'] = self::bb_content($content,'summary');
$s['body'] = ((self::bb_content($content,'bbcode') && (! $response_activity)) ? self::bb_content($content,'bbcode') : self::bb_content($content,'content'));
@ -2122,11 +2120,21 @@ class Activity {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
// Some authors may be zot6 authors in which case we want to store their nomadic identity
// instead of their ActivityPub identity
$item['author_xchan'] = self::find_best_identity($item['author_xchan']);
$item['owner_xchan'] = self::find_best_identity($item['owner_xchan']);
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');
@ -2139,13 +2147,11 @@ class Activity {
intval($channel['channel_id'])
);
if($abook) {
if(! post_is_importable($item,$abook[0])) {
logger('post is filtered');
return;
}
}
if(! post_is_importable($channel['channel_id'],$item,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {
set_iconfig($item,'ostatus','conversation',$act->obj['conversation'],1);
@ -2179,7 +2185,10 @@ class Activity {
intval($item['uid'])
);
if(! $p) {
$a = (($fetch_parents) ? self::fetch_and_store_parents($channel,$observer_hash,$act,$item) : false);
$a = false;
if(PConfig::Get($channel['channel_id'],'system','hyperdrive',true)) {
$a = (($fetch_parents) ? self::fetch_and_store_parents($channel,$observer_hash,$act,$item) : false);
}
if($a) {
$p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1",
dbesc($item['parent_mid']),
@ -2246,6 +2255,18 @@ class Activity {
}
static public function find_best_identity($xchan) {
$r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
dbesc($xchan)
);
if($r) {
return $r[0]['hubloc_hash'];
}
return $xchan;
}
static public function fetch_and_store_parents($channel,$observer_hash,$act,$item) {
logger('fetching parents');
@ -2371,11 +2392,9 @@ class Activity {
intval($channel['channel_id'])
);
if($abook) {
if(! post_is_importable($s,$abook[0])) {
logger('post is filtered');
return;
}
if(! post_is_importable($channel['channel_id'],$s,$abook[0])) {
logger('post is filtered');
return;
}
if($act->obj['conversation']) {

View file

@ -1412,6 +1412,12 @@ class Libzot {
$result = [];
// If an upstream hop used ActivityPub, set the identities to zot6 nomadic identities where applicable
// else things could easily get confused
$arr['author_xchan'] = Activity::find_best_identity($arr['author_xchan']);
$arr['owner_xchan'] = Activity::find_best_identity($arr['owner_xchan']);
// We've validated the sender. Now make sure that the sender is the owner or author
if(! $public) {
@ -1551,6 +1557,10 @@ class Libzot {
// the top level post is unlikely to be imported and
// this is just an exercise in futility.
if(! get_pconfig($channel['channel_id'],'system','hyperdrive',true)) {
continue;
}
if((! $relay) && (! $request) && (! $local_public)
&& perm_is_allowed($channel['channel_id'],$sender,'send_stream')) {
$f = self::fetch_conversation($channel,$arr['parent_mid']);
@ -1662,7 +1672,7 @@ class Libzot {
elseif($arr['edited'] > $r[0]['edited']) {
$arr['id'] = $r[0]['id'];
$arr['uid'] = $channel['channel_id'];
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($channel['channel_id'],$arr,$abook))) {
$DR->update('update ignored');
$result[] = $DR->get();
}
@ -1702,7 +1712,7 @@ class Libzot {
$item_id = 0;
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr['uid'],$arr,$abook))) {
$DR->update('post ignored');
$result[] = $DR->get();
}
@ -3028,4 +3038,24 @@ class Libzot {
return(($x) ? true : false);
}
static public function zot_record_preferred($arr, $check = 'hubloc_network') {
if(! $arr) {
return $arr;
}
foreach($arr as $v) {
if($v[$check] === 'zot6') {
return $v;
}
}
return $arr[0];
}
}

View file

@ -16,10 +16,9 @@ class MessageFilter {
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text);
$lang = null;
if((strpos($incl,'lang=') !== false) || (strpos($excl,'lang=') !== false)) {
if((strpos($incl,'lang=') !== false) || (strpos($excl,'lang=') !== false) || (strpos($incl,'lang!=') !== false) || (strpos($excl,'lang!=') !== false)) {
$lang = detect_language($text);
}
@ -43,6 +42,8 @@ class MessageFilter {
return false;
elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0))
return false;
elseif((strpos($word,'lang!=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,6))) != 0))
return false;
elseif(stristr($text,$word) !== false)
return false;
}
@ -64,6 +65,8 @@ class MessageFilter {
return true;
elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0))
return true;
elseif((strpos($word,'lang!=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,6))) != 0))
return true;
elseif(stristr($text,$word) !== false)
return true;
}

View file

@ -147,6 +147,7 @@ class Channel {
$suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
$autoperms = ((x($_POST,'autoperms')) ? intval($_POST['autoperms']) : 0);
$anymention = ((x($_POST,'anymention')) ? intval($_POST['anymention']) : 0);
$hyperdrive = ((x($_POST,'hyperdrive')) ? intval($_POST['hyperdrive']) : 0);
$public_uploads = ((isset($_POST['public_uploads'])) ? intval($_POST['public_uploads']) : 0);
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
@ -257,6 +258,7 @@ class Channel {
set_pconfig(local_channel(),'system','profile_assign',$profile_assign);
set_pconfig(local_channel(),'system','autoperms',$autoperms);
set_pconfig(local_channel(),'system','anymention',$anymention);
set_pconfig(local_channel(),'system','hyperdrive',$hyperdrive);
set_pconfig(local_channel(),'system','force_public_uploads',$public_uploads);
$r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d",
@ -495,6 +497,8 @@ class Channel {
$anymention = '<input type="hidden" name="anymention" value="' . intval(get_pconfig(local_channel(),'system','anymention')) . '" />';
}
$hyperdrive = [ 'hyperdrive', t('Enable hyperdrive'), ((get_pconfig(local_channel(),'system','hyperdrive',true)) ? 1 : 0), t('Dramatically increases the content available in your stream.'), $yes_no ];
$permissions_set = (($permissions_role != 'custom') ? true : false);
$perm_roles = \Zotlabs\Access\PermissionRoles::roles();
@ -575,6 +579,7 @@ class Channel {
'$autoperms' => $autoperms,
'$anymention' => $anymention,
'$hyperdrive' => $hyperdrive,
'$h_not' => t('Notification Settings'),
'$activity_options' => t('By default post a status message when:'),
'$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no),

View file

@ -4,6 +4,8 @@ namespace Zotlabs\Web;
use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\Webfinger;
use Zotlabs\Lib\Zotfinger;
use Zotlabs\Lib\Libzot;
/**
* @brief Implements HTTP Signatures per draft-cavage-http-signatures-10.
@ -240,13 +242,17 @@ class HTTPSig {
$url = ((strpos($id,'#')) ? substr($id,0,strpos($id,'#')) : $id);
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1",
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' ",
dbesc(str_replace('acct:','',$url)),
dbesc($url)
);
if($x && $x[0]['xchan_pubkey']) {
return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ];
if($x) {
$best = Libzot::zot_record_preferred($x);
}
if($best && $best['xchan_pubkey']) {
return [ 'portable_id' => $best['xchan_hash'], 'public_key' => $best['xchan_pubkey'] , 'hubloc' => $best ];
}
$r = ActivityStreams::fetch($id);
@ -265,13 +271,17 @@ class HTTPSig {
function get_webfinger_key($id) {
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1",
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' ",
dbesc(str_replace('acct:','',$id)),
dbesc($id)
);
if($x && $x[0]['xchan_pubkey']) {
return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ];
if($x) {
$best = Libzot::zot_record_preferred($x);
}
if($best && $best['xchan_pubkey']) {
return [ 'portable_id' => $best['xchan_hash'], 'public_key' => $best['xchan_pubkey'] , 'hubloc' => $best ];
}
$wf = Webfinger::exec($id);
@ -299,14 +309,20 @@ class HTTPSig {
function get_zotfinger_key($id) {
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1",
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' ",
dbesc(str_replace('acct:','',$id)),
dbesc($id)
);
if($x && $x[0]['xchan_pubkey']) {
return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ];
if($x) {
$best = Libzot::zot_record_preferred($x);
}
if($best && $best['xchan_pubkey']) {
return [ 'portable_id' => $best['xchan_hash'], 'public_key' => $best['xchan_pubkey'] , 'hubloc' => $best ];
}
$wf = Webfinger::exec($id);
$key = [ 'portable_id' => '', 'public_key' => '', 'hubloc' => [] ];
@ -320,9 +336,9 @@ class HTTPSig {
continue;
}
if($l['rel'] === 'http://purl.org/zot/protocol/6.0' && array_key_exists('href',$l) && $l['href'] !== EMPTY_STR) {
$z = \Zotlabs\Lib\Zotfinger::exec($l['href']);
$z = Zotfinger::exec($l['href']);
if($z) {
$i = Zotlabs\Lib\Libzot::import_xchan($z['data']);
$i = Libzot::import_xchan($z['data']);
if($i['success']) {
$key['portable_id'] = $i['hash'];

View file

@ -32,7 +32,8 @@ require_once('include/bbcode.php');
require_once('include/items.php');
define ( 'STD_VERSION', '2.0' );
define ( 'STD_VERSION', '2.0.1' );
define ( 'ZOT_REVISION', '6.0' );
define ( 'DB_UPDATE_VERSION', 1223 );

View file

@ -1338,7 +1338,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
}
if(! post_is_importable($datarray, $contact))
if(! post_is_importable($importer['channel_id'],$datarray, $contact))
continue;
$datarray['parent_mid'] = $datarray['mid'];
@ -1494,7 +1494,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
}
if(! post_is_importable($datarray, $contact))
if(! post_is_importable($importer['channel_id'],$datarray, $contact))
continue;
logger('author: ' . print_r($author, true), LOGGER_DEBUG);

View file

@ -60,12 +60,20 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$xchan_hash = '';
$sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : '');
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' $sql_options limit 1",
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' $sql_options ",
dbesc($url),
dbesc($url),
dbesc($url)
);
if($r) {
// reset results to the best record or the first if we don't have the best
$r = Libzot::zot_record_preferred($r,'xchan_network');
}
$singleton = false;
$d = false;
@ -99,8 +107,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
// if discovery was a success we should have an xchan record in $r
if($r) {
$xchan = $r[0];
$xchan_hash = $r[0]['xchan_hash'];
$xchan = $r;
$xchan_hash = $r['xchan_hash'];
$their_perms = EMPTY_STR;
}

View file

@ -15,6 +15,7 @@ use Zotlabs\Lib\Enotify;
use Zotlabs\Lib\MarkdownSoap;
use Zotlabs\Lib\MessageFilter;
use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\PConfig;
use Zotlabs\Lib\ThreadListener;
use Zotlabs\Access\PermissionLimits;
use Zotlabs\Access\AccessList;
@ -833,32 +834,48 @@ function import_author_activitypub($x) {
if(! $x['url'])
return false;
// let somebody upgrade from an 'unknown' connection which has no xchan_addr
$r = q("select xchan_hash, xchan_url, xchan_name, xchan_photo_s from xchan where xchan_url = '%s' limit 1",
// let somebody upgrade from an 'unknown' connection which has no xchan_addr and resolve issues with identities from multiple protocols using the same url
$r = q("select xchan_hash, xchan_url, xchan_network, xchan_name, xchan_photo_s from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s'",
dbesc($x['url'])
);
if(! $r) {
$r = q("select xchan_hash, xchan_url, xchan_name, xchan_photo_s from xchan where xchan_hash = '%s' limit 1",
$r = q("select xchan_hash, xchan_url, xchan_network, xchan_name, xchan_photo_s from xchan where xchan_hash = '%s' ",
dbesc($x['url'])
);
}
if($r) {
logger('in_cache: ' . $r[0]['xchan_name'], LOGGER_DATA);
return $r[0]['xchan_hash'];
$ptr = null;
foreach($r as $rv) {
if (strpos($rv['xchan_network'],'zot') !== false) {
$ptr = $rv;
}
}
if(! $ptr) {
$ptr = $r[0];
}
logger('in_cache: ' . $ptr['xchan_name'], LOGGER_DATA);
return $ptr['xchan_hash'];
}
$z = discover_by_webbie($x['url']);
if($z) {
$r = q("select xchan_hash, xchan_url, xchan_name, xchan_photo_s from xchan where xchan_url = '%s' limit 1",
$r = q("select xchan_hash, xchan_url, xchan_network, xchan_name, xchan_photo_s from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s'",
dbesc($x['url'])
);
if(! $r) {
$r = q("select xchan_hash, xchan_url, xchan_name, xchan_photo_s from xchan where xchan_hash = '%s' limit 1",
$r = q("select xchan_hash, xchan_url, xchan_name, xchan_photo_s from xchan where xchan_hash = '%s' ",
dbesc($x['url'])
);
}
if($r) {
foreach($r as $rv) {
if (strpos($rv['xchan_network'],'zot') !== false) {
return $rv['xchan_hash'];
}
}
return $r[0]['xchan_hash'];
}
}
@ -3260,17 +3277,27 @@ function check_item_source($uid, $item) {
return false;
}
function post_is_importable($item,$abook) {
if(! $abook)
return true;
if(($abook['abook_channel']) && (! feature_enabled($abook['abook_channel'],'connfilter')))
return true;
function post_is_importable($channel_id,$item,$abook) {
if(! $item)
return false;
$incl = PConfig::get($channel_id,'system','message_filter_incl',EMPTY_STR);
$excl = PConfig::get($channel_id,'system','message_filter_excl',EMPTY_STR);
if($incl || $excl) {
$x = MessageFilter::evaluate($item,$incl,$excl);
if(! $x) {
logger('MessageFilter: channel blocked content',LOGGER_DEBUG,LOG_INFO);
return false;
}
}
if(($channel_id) && (! feature_enabled($channel_id,'connfilter')))
return true;
if(! $abook)
return true;
if(! ($abook['abook_incl'] || $abook['abook_excl']))
return true;

View file

@ -1807,3 +1807,7 @@ dl.bb-dl > dd > li {
.hover-fx-show:hover .hover-fx-hide {
opacity: 1;
}
.threadlevel.even {
color: #888;
}

View file

@ -9,7 +9,7 @@
<a name="item_{{$item.id}}" ></a>
<div class="wall-item-outside-wrapper{{if $item.is_comment}} comment{{/if}}{{if $item.previewing}} preview{{/if}}" id="wall-item-outside-wrapper-{{$item.id}}" >
<div class="clearfix wall-item-content-wrapper{{if $item.is_comment}} comment{{/if}}" id="wall-item-content-wrapper-{{$item.id}}">
{{for $x=3 to $item.thread_level}}<i class="fa fa-caret-right threadlevel"></i>{{/for}}
{{for $x=3 to $item.thread_level}}<i class="fa fa-caret-right threadlevel {{if $x is odd}}odd{{else}}even{{/if}}"></i>{{/for}}
{{if $item.photo}}
<div class="wall-photo-item" id="wall-photo-item-{{$item.id}}">
{{$item.photo}}

View file

@ -189,7 +189,7 @@
</div>
{{/if}}
{{include file="field_checkbox.tpl" field=$cal_first_day}}
{{include file="field_checkbox.tpl" field=$hyperdrive}}
{{if $misc_addon}}
{{$misc_addon}}
{{/if}}