mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
upstream/downstream comment work
This commit is contained in:
parent
b7e0115447
commit
b3b6b813f2
8 changed files with 65 additions and 22 deletions
|
@ -339,11 +339,18 @@ class Notifier {
|
|||
return;
|
||||
|
||||
|
||||
$m = get_iconfig($target_item,'activitystreams','signed_data');
|
||||
if($m)
|
||||
self::$encoded_item = json_decode($m,true);
|
||||
else
|
||||
self::$encoded_item = \Zotlabs\Lib\Activity::encode_activity($target_item);
|
||||
|
||||
logger('target_item: ' . print_r($target_item,true));
|
||||
|
||||
// self::$encoded_item = encode_item($target_item);
|
||||
|
||||
self::$encoded_item = \Zotlabs\Lib\Activity::encode_activity($target_item);
|
||||
|
||||
logger('encoded: ' . print_r(self::$encoded_item,true));
|
||||
logger('encoded: ' . print_r(self::$encoded_item,true));
|
||||
|
||||
// Send comments to the owner to re-deliver to everybody in the conversation
|
||||
// We only do this if the item in question originated on this site. This prevents looping.
|
||||
|
|
|
@ -20,11 +20,9 @@ class Activity {
|
|||
if($x['type'] === ACTIVITY_OBJ_PROFILE) {
|
||||
return self::fetch_profile($x);
|
||||
}
|
||||
|
||||
if($x['type'] === ACTIVITY_OBJ_NOTE) {
|
||||
if(in_array($x['type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE ] )) {
|
||||
return self::fetch_item($x);
|
||||
}
|
||||
|
||||
if($x['type'] === ACTIVITY_OBJ_THING) {
|
||||
return self::fetch_thing($x);
|
||||
}
|
||||
|
@ -401,6 +399,9 @@ class Activity {
|
|||
return [];
|
||||
|
||||
if($i['obj']) {
|
||||
if(! is_array($i['obj'])) {
|
||||
$i['obj'] = json_decode($i['obj'],true);
|
||||
}
|
||||
$obj = self::encode_object($i['obj']);
|
||||
if($obj)
|
||||
$ret['object'] = $obj;
|
||||
|
@ -416,6 +417,9 @@ class Activity {
|
|||
}
|
||||
|
||||
if($i['target']) {
|
||||
if(! is_array($i['target'])) {
|
||||
$i['target'] = json_decode($i['target'],true);
|
||||
}
|
||||
$tgt = self::encode_object($i['target']);
|
||||
if($tgt)
|
||||
$ret['target'] = $tgt;
|
||||
|
@ -423,10 +427,6 @@ class Activity {
|
|||
return [];
|
||||
}
|
||||
|
||||
if(! $i['item_private']) {
|
||||
$ret['to'] = [ ACTIVITY_PUBLIC_INBOX ];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class ActivityStreams {
|
|||
if($this->is_valid()) {
|
||||
$this->id = $this->get_property_obj('id');
|
||||
$this->type = $this->get_primary_type();
|
||||
$this->actor = $this->get_compound_property('actor','','',true);
|
||||
$this->actor = $this->get_actor('actor','','');
|
||||
$this->obj = $this->get_compound_property('object');
|
||||
$this->tgt = $this->get_compound_property('target');
|
||||
$this->origin = $this->get_compound_property('origin');
|
||||
|
@ -87,10 +87,9 @@ class ActivityStreams {
|
|||
}
|
||||
|
||||
if($this->obj && $this->obj['actor'])
|
||||
$this->obj['actor'] = $this->get_compound_property('actor',$this->obj,'',true);
|
||||
$this->obj['actor'] = $this->get_actor('actor',$this->obj);
|
||||
if($this->tgt && $this->tgt['actor'])
|
||||
$this->tgt['actor'] = $this->get_compound_property('actor',$this->tgt,'',true);
|
||||
|
||||
$this->tgt['actor'] = $this->get_actor('actor',$this->tgt);
|
||||
|
||||
|
||||
if(($this->type === 'Note') && (! $this->obj)) {
|
||||
|
@ -102,7 +101,6 @@ class ActivityStreams {
|
|||
if(! $this->parent_id) {
|
||||
$this->parent_id = $this->id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,6 +254,33 @@ class ActivityStreams {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param string $property
|
||||
* @param array $base
|
||||
* @param string $namespace (optional) default empty
|
||||
* @return NULL|mixed
|
||||
*/
|
||||
|
||||
function get_actor($property,$base='',$namespace = '') {
|
||||
$x = $this->get_property_obj($property, $base, $namespace);
|
||||
if($this->is_url($x)) {
|
||||
|
||||
// SECURITY: If we have already stored the actor profile, re-generate it
|
||||
// from cached data - don't refetch it from the network
|
||||
|
||||
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s' limit 1",
|
||||
dbesc($x)
|
||||
);
|
||||
if($r) {
|
||||
return Activity::encode_person($r[0]);
|
||||
}
|
||||
}
|
||||
return $this->get_compound_property($property,$base,$namespace,true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
|
|
@ -52,7 +52,7 @@ class JSalmon {
|
|||
. base64url_encode($x['alg'],true);
|
||||
|
||||
$key = HTTPSig::get_key(EMPTY_STR,base64url_decode($x['sigs']['key_id']));
|
||||
// logger('key: ' . print_r($key,true));
|
||||
logger('key: ' . print_r($key,true));
|
||||
if($key['portable_id'] && $key['public_key']) {
|
||||
if(rsa_verify($signed_data,base64url_decode($x['sigs']['value']),$key['public_key'])) {
|
||||
logger('verified');
|
||||
|
|
|
@ -1131,7 +1131,12 @@ class Libzot {
|
|||
logger('recips: no recipients on this site');
|
||||
return;
|
||||
}
|
||||
$private = true;
|
||||
|
||||
// Response messages will inherit the privacy of the parent
|
||||
|
||||
if($env['type'] !== 'response')
|
||||
$private = true;
|
||||
|
||||
$deliveries = ids_to_array($r,'hash');
|
||||
|
||||
// We found somebody on this site that's in the recipient list.
|
||||
|
@ -1147,10 +1152,6 @@ class Libzot {
|
|||
|
||||
$deliveries = self::public_recips($env);
|
||||
|
||||
if($has_data && $data['type'] === 'location') {
|
||||
$sys = get_sys_channel();
|
||||
$deliveries = [ $sys['xchan_hash'] ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1184,7 @@ class Libzot {
|
|||
}
|
||||
$arr = \Zotlabs\Lib\Activity::decode_note($AS);
|
||||
|
||||
// logger($AS->debug());
|
||||
logger($AS->debug());
|
||||
|
||||
$r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
|
||||
dbesc($AS->actor['id'])
|
||||
|
@ -1197,6 +1198,14 @@ class Libzot {
|
|||
if($private) {
|
||||
$arr['item_private'] = true;
|
||||
}
|
||||
// @fixme - spoofable
|
||||
if($AS->data['hubloc']) {
|
||||
$arr['item_verified'] = true;
|
||||
}
|
||||
if($AS->data['signed_data']) {
|
||||
IConfig::Set($arr,'activitystreams','signed_data',$AS->data['signed_data'],false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
logger('Activity received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG);
|
||||
|
|
1
boot.php
1
boot.php
|
@ -490,6 +490,7 @@ define ( 'ACTIVITY_UNFOLLOW', 'Unfollow');
|
|||
|
||||
define ( 'ACTIVITY_OBJ_COMMENT', 'Note' );
|
||||
define ( 'ACTIVITY_OBJ_NOTE', 'Note' );
|
||||
define ( 'ACTIVITY_OBJ_ARTICLE', 'Article' );
|
||||
define ( 'ACTIVITY_OBJ_PERSON', 'Person' );
|
||||
define ( 'ACTIVITY_OBJ_PHOTO', 'Image');
|
||||
define ( 'ACTIVITY_OBJ_P_PHOTO', 'Icon' );
|
||||
|
|
|
@ -1590,6 +1590,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
|||
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
|
||||
$arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
|
||||
$arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
|
||||
$arr['item_verified'] = ((x($arr,'item_verified')) ? intval($arr['item_verified']) : 0 );
|
||||
|
||||
// obsolete, but needed so as not to throw not-null constraints on some database driveres
|
||||
$arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 );
|
||||
|
|
|
@ -370,7 +370,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
|
|||
|
||||
function json_return_and_die($x, $content_type = 'application/json') {
|
||||
header("Content-type: $content_type");
|
||||
logger('returned_json: ' . json_encode($x,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
|
||||
btlogger('returned_json: ' . json_encode($x,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
|
||||
echo json_encode($x);
|
||||
killme();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue