Merge branch 'dev' into release

This commit is contained in:
Mike Macgirvin 2022-06-23 17:20:45 -07:00
commit df7a3a80c4
3 changed files with 2221 additions and 2219 deletions

View file

@ -578,6 +578,9 @@ class Activity
return $url;
}
/**
* Convert an item attach list to an ActivityStreams attachment array
*/
public static function encode_attachment($item)
{
@ -588,10 +591,18 @@ class Activity
$atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'], true));
if ($atts) {
foreach ($atts as $att) {
if (isset($att['type']) && strpos($att['type'], 'image')) {
$ret[] = ['type' => 'Image', 'url' => $att['href']];
if (isset($att['type']) && strpos($att['type'], 'image') !== false) {
$ret[] = [
'type' => 'Image',
'url' => $arr['href'],
'name' => ($arr['name']) ? $arr['name'] : '',
];
} else {
$ret[] = ['type' => 'Link', 'mediaType' => isset($att['type']) ? $att['type'] : 'application/octet-stream', 'href' => isset($att['href']) ? $att['href'] : ''];
$ret[] = [
'type' => 'Link',
'mediaType' => isset($att['type']) ? $att['type'] : 'application/octet-stream',
'href' => isset($att['href']) ? $att['href'] : ''
];
}
}
}
@ -599,7 +610,7 @@ class Activity
if (array_key_exists('iconfig', $item) && is_array($item['iconfig'])) {
foreach ($item['iconfig'] as $att) {
if ($att['sharing']) {
$ret[] = ['type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => unserialise($att['v'])];
$ret[] = ['type' => 'PropertyValue', 'name' => 'nomad.' . $att['cat'] . '.' . $att['k'], 'value' => unserialise($att['v'])];
}
}
}
@ -623,7 +634,7 @@ class Activity
if ($att['type'] === 'PropertyValue') {
if (array_key_exists('name', $att) && $att['name']) {
$key = explode('.', $att['name']);
if (count($key) === 3 && $key[0] === 'zot') {
if (count($key) === 3 && in_array($key[0], ['nomad', 'zot'])) {
$entry['cat'] = $key[1];
$entry['k'] = $key[2];
$entry['v'] = $att['value'];
@ -637,14 +648,17 @@ class Activity
return $ret;
}
public static function decode_attachment($item)
/**
* Decodes and Activity object attachment structure to store in an item.
*/
public static function decode_attachment($obj)
{
$ret = [];
if (array_key_exists('attachment', $item) && is_array($item['attachment'])) {
$ptr = $item['attachment'];
if (array_key_exists('attachment', $obj) && is_array($obj['attachment'])) {
$ptr = $obj['attachment'];
if (!array_key_exists(0, $ptr)) {
$ptr = [$ptr];
}
@ -667,8 +681,8 @@ class Activity
$ret[] = $entry;
}
}
} elseif (isset($item['attachment']) && is_string($item['attachment'])) {
btlogger('not an array: ' . $item['attachment']);
} elseif (isset($obj['attachment']) && is_string($obj['attachment'])) {
btlogger('not an array: ' . $obj['attachment']);
}
return $ret;
@ -3346,7 +3360,7 @@ class Activity
}
set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1);
set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 0);
// Restrict html caching to ActivityPub senders.
// Zot has dynamic content and this library is used by both.
@ -3655,8 +3669,8 @@ class Activity
}
if (tgroup_check($channel['channel_id'], $item) && (!$is_child_node)) {
// for forum deliveries, make sure we keep a copy of the signed original
set_iconfig($item, 'activitypub', 'rawmsg', $act->raw, 1);
// for relayed deliveries, make sure we keep a copy of the signed original
set_iconfig($item, 'activitypub', 'rawmsg', $act->raw, 0);
logger('allowed: tgroup');
$allowed = true;
}
@ -4071,7 +4085,7 @@ class Activity
}
}
if (array_key_exists('type', $a) && stripos($a['type'], 'activity') !== false) {
if (self::media_not_in_body($a['href'], $item['body'])) {
if (self::share_not_in_body($item['body'])) {
$item = self::get_quote($a['href'], $item);
}
}
@ -4107,6 +4121,16 @@ class Activity
return false;
}
// check for the existence of existing media link in body
public static function share_not_in_body($body)
{
if (strpos($body, '[/share]') === false) {
return true;
}
return false;
}
public static function bb_content($content, $field)
{

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,2 @@
<?php
define ( 'STD_VERSION', '22.06.23' );
define ( 'STD_VERSION', '22.06.24' );