AS2 Update and implement a first draft of AS2 Profile activities

This commit is contained in:
Mario
2024-02-29 17:05:48 +00:00
parent 291e12574a
commit 46f67eaa1e
11 changed files with 82 additions and 180 deletions

View File

@@ -172,10 +172,6 @@ class Activity {
}
static function fetch_person($x) {
return self::fetch_profile($x);
}
static function fetch_profile($x) {
$r = q("select * from xchan where xchan_url = '%s' limit 1",
dbesc($x['id'])
);
@@ -189,7 +185,14 @@ class Activity {
return [];
return self::encode_person($r[0]);
}
static function fetch_profile($x) {
if (isset($x['describes'])) {
return $x;
}
return [];
}
static function fetch_thing($x) {
@@ -978,6 +981,7 @@ class Activity {
$ret['to'] = [ACTIVITY_PUBLIC_INBOX];
}
$hookinfo = [
'item' => $i,
'encoded' => $ret
@@ -2049,6 +2053,10 @@ class Activity {
$s['mid'] = $act->obj['data']['id'];
}
if ($act->objprop('type') === 'Profile') {
$s['mid'] = $act->id;
}
if (!$s['mid']) {
return false;
}
@@ -2293,6 +2301,14 @@ class Activity {
if (!$response_activity) {
if ($act->objprop('type') === 'Profile') {
$s['parent_mid'] = $s['mid'];
$s['item_thread_top'] = 1;
$s['summary'] = '';
$s['body'] = self::bb_content($content, 'summary');
}
// we will need a hook here to extract magnet links e.g. peertube
// right now just link to the largest mp4 we find that will fit in our
// standard content region
@@ -2438,7 +2454,6 @@ class Activity {
}
}
if ($act->objprop('type') === 'Page' && !$s['body']) {
$ptr = null;
@@ -2479,7 +2494,7 @@ class Activity {
}
}
if (in_array($act->objprop('type', ''), ['Note', 'Article', 'Page'])) {
if (in_array($act->objprop('type'), ['Note', 'Article', 'Page'])) {
$ptr = null;
if (array_key_exists('url', $act->obj)) {

View File

@@ -1143,7 +1143,6 @@ class Libzot {
if ($env['encoding'] === 'activitystreams') {
$AS = new ActivityStreams($data);
if (!$AS->is_valid()) {
logger('Activity rejected: ' . print_r($data, true));
return;

View File

@@ -93,8 +93,6 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$image_id = substr($image_id,0,-2);
}
$srcX = intval($_POST['xstart']);
$srcY = intval($_POST['ystart']);
$srcW = intval($_POST['xfinal']) - $srcX;
@@ -228,7 +226,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
return;
}
$this->send_cover_photo_activity($channel,$base_image,$profile);
profile_activity([t('Cover Photo')], $base_image['resource_id']);
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
@@ -245,7 +243,6 @@ class Cover_photo extends \Zotlabs\Web\Controller {
}
$hash = photo_new_resource();
$smallest = 0;
@@ -287,45 +284,6 @@ class Cover_photo extends \Zotlabs\Web\Controller {
}
function send_cover_photo_activity($channel,$photo,$profile) {
$arr = array();
$arr['item_thread_top'] = 1;
$arr['item_origin'] = 1;
$arr['item_wall'] = 1;
if($profile && stripos($profile['gender'],t('female')) !== false)
$t = t('%1$s updated her %2$s');
elseif($profile && stripos($profile['gender'],t('male')) !== false)
$t = t('%1$s updated his %2$s');
else
$t = t('%1$s updated their %2$s');
$ptext = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . t('cover photo') . '[/zrl]';
$ltext = '[zrl=' . z_root() . '/profile/' . $channel['channel_address'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-8[/zmg][/zrl]';
$arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext;
$acl = new \Zotlabs\Access\AccessList($channel);
$x = $acl->get();
$arr['allow_cid'] = $x['allow_cid'];
$arr['allow_gid'] = $x['allow_gid'];
$arr['deny_cid'] = $x['deny_cid'];
$arr['deny_gid'] = $x['deny_gid'];
$arr['uid'] = $channel['channel_id'];
$arr['aid'] = $channel['channel_account_id'];
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['author_xchan'] = $channel['channel_hash'];
post_activity_item($arr);
}
/**
* @brief Generate content of profile-photo view
@@ -334,7 +292,6 @@ class Cover_photo extends \Zotlabs\Web\Controller {
*
*/
function get() {
if(! local_channel()) {

View File

@@ -223,7 +223,7 @@ class Profile_photo extends Controller {
intval(local_channel())
);
send_profile_photo_activity($channel, $base_image, $profile);
profile_activity([t('Profile Photo')], $base_image['resource_id']);
}
else {
q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",

View File

@@ -3,10 +3,6 @@ namespace Zotlabs\Module;
use Zotlabs\Lib\Libsync;
require_once('include/channel.php');
require_once('include/selectors.php');
class Profiles extends \Zotlabs\Web\Controller {
function init() {
@@ -492,7 +488,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$publish = ((x($_POST, 'profile_in_directory') && (intval($_POST['profile_in_directory']) == 1)) ? 1 : 0);
profile_activity($changes,$value);
profile_activity($changes, $value);
}