mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:35:19 +00:00
Merge branch 'dev' into nomadic
This commit is contained in:
commit
dae31497ef
16 changed files with 162 additions and 27 deletions
|
@ -1304,13 +1304,13 @@ function embedfolder_widget($args)
|
|||
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
|
||||
*/
|
||||
if ($album) {
|
||||
$x = q(
|
||||
"select hash from attach where display_path= '%s' and uid = %d limit 1",
|
||||
$albumEntity = q(
|
||||
"select * from attach where display_path= '%s' and uid = %d limit 1",
|
||||
dbesc($album),
|
||||
intval($owner_uid)
|
||||
);
|
||||
if ($x) {
|
||||
$y = attach_can_view_folder($owner_uid, get_observer_hash(), $x[0]['hash']);
|
||||
if ($albumEntity) {
|
||||
$y = attach_can_view_folder($owner_uid, get_observer_hash(), $albumEntity[0]['hash']);
|
||||
if (!$y) {
|
||||
return '';
|
||||
}
|
||||
|
@ -1324,7 +1324,7 @@ function embedfolder_widget($args)
|
|||
$sql_extra
|
||||
ORDER BY filename ASC",
|
||||
intval($owner_uid),
|
||||
dbesc($x[0]['hash'])
|
||||
dbesc($albumEntity[0]['hash'])
|
||||
);
|
||||
|
||||
if ($r) {
|
||||
|
@ -1367,6 +1367,19 @@ function embedfolder_widget($args)
|
|||
|
||||
$photos = [];
|
||||
if ($r) {
|
||||
$photos[] = [
|
||||
'id' => $albumEntity[0]['id'],
|
||||
'link' => z_root() . '/embedphotos/filelink/' . $albumEntity[0]['hash'],
|
||||
'filename' => t('Attach photo album'),
|
||||
'title' => t('Attach photos as album'),
|
||||
'src' => '',
|
||||
'icon' => getIconFromType('multipart/mixed'),
|
||||
'alt' => t('Attach photos as album'),
|
||||
'ext' => '',
|
||||
'hash' => $albumEntity[0]['hash'],
|
||||
'unknown' => t('Unknown')
|
||||
];
|
||||
|
||||
foreach ($r as $rr) {
|
||||
|
||||
$filetype = $rr['filetype'];
|
||||
|
|
|
@ -678,6 +678,8 @@ function bb_ShareAttributes($match)
|
|||
|
||||
if (strpos($link, '/cards/')) {
|
||||
$type = t('card');
|
||||
} elseif (strpos($link, '/album/')) {
|
||||
$type = t('album');
|
||||
} elseif (strpos($link, '/articles/')) {
|
||||
$type = t('article');
|
||||
} else {
|
||||
|
|
|
@ -493,7 +493,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
|
|||
|
||||
localize_item($item);
|
||||
if ($mode === 'stream-new') {
|
||||
$dropping = true;
|
||||
$dropping = (bool)local_channel() === (int)$item['uid'];
|
||||
} else {
|
||||
$dropping = false;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ function format_event_obj($jobject)
|
|||
else {
|
||||
$object = json_decode($jobject, true);
|
||||
}
|
||||
|
||||
|
||||
/*******
|
||||
This is our encoded format
|
||||
|
||||
|
|
|
@ -248,8 +248,8 @@ function html2bbcode($message)
|
|||
|
||||
node2bbcode($doc, 'a', array('href' => '/(.+)/'), '[url=$1]', '[/url]');
|
||||
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/', 'width' => '/(\d+)/', 'height' => '/(\d+)/', 'alt' => '/(.+)/'), '[img width=\'$2\' height=\'$3\' src=\'$1\' alt=\'$4\']', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/', 'alt' => '/(.+)/'), '[img src=\'$1\' alt=\'$2\']', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/', 'width' => '/(\d+)/', 'height' => '/(\d+)/', 'alt' => '/(.+)/'), '[img width=\'$2\' height=\'$3\' alt=\'$4\']$1', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/', 'alt' => '/(.+)/'), '[img alt=\'$2\']$1', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/', 'width' => '/(\d+)/', 'height' => '/(\d+)/'), '[img=$2x$3]$1', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/'), '[img]$1', '[/img]');
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ function authenticate_success($user_record, $channel = false, $login_initial = f
|
|||
// might want to log success here
|
||||
}
|
||||
|
||||
if ($_SESSION['2FA_REQUIRED'] && !$_SESSION['2FA_VERIFIED'] && App::$module !== 'totp_check') {
|
||||
if ($_SESSION['2FA_REQUIRED'] && !$_SESSION['2FA_VERIFIED']
|
||||
&& !in_array(App::$module, ['totp_check', 'dav', 'cdav', 'api', 'addressbook', 'calendar'], true)) {
|
||||
goaway(z_root() . '/totp_check');
|
||||
}
|
||||
|
||||
|
|
|
@ -398,6 +398,69 @@ class Activity
|
|||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function encode_photo_collection($items, $id, $type, $activitypub = false, $attributedTo = '', $total = 0): array
|
||||
{
|
||||
|
||||
$ret = [
|
||||
'id' => z_root() . '/' . $id,
|
||||
'type' => $type,
|
||||
'totalItems' => $total,
|
||||
];
|
||||
if ($attributedTo) {
|
||||
$ret['attributedTo'] = $attributedTo;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
if ($items) {
|
||||
$x = [];
|
||||
foreach ($items as $i) {
|
||||
$m = ObjCache::Get($i['mid']);
|
||||
if ($m) {
|
||||
$t = json_decode($m, true);
|
||||
} else {
|
||||
$t = self::encode_activity($i, $activitypub);
|
||||
// These activities are unlikely to have a context or signature, which are
|
||||
// usually added during 'delivery'. Add them now.
|
||||
if (!$t['@context']) {
|
||||
$ldContext = ['@context' => Activity::ap_schema()];
|
||||
$t = array_merge($ldContext, $t);
|
||||
}
|
||||
if (!$t['proof']) {
|
||||
$channel = Channel::from_hash($i['author_xchan']);
|
||||
if ($channel) {
|
||||
$t['proof'] = (new JcsEddsa2022())->sign($t, $channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($t) {
|
||||
$x[] = $t;
|
||||
$image = $t['object']['url'][1];
|
||||
if ($image) {
|
||||
$alt = 'alt="' . $image['summary'] . '"' ;
|
||||
$width = $image['width'];
|
||||
$height = $image['height'];
|
||||
$tag = '[zmg width="' . $width . '" height="' . $height . '" ' . "\n\n" . $alt . "\n\n" . ']';
|
||||
$content .= '[zmg width="' . $width . '" height="' . $height . '" ' . "\n\n" . $alt . "\n\n" . ']'
|
||||
. $image['href'] . '[/zmg]' . "\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($type === 'OrderedCollection') {
|
||||
$ret['orderedItems'] = $x;
|
||||
} else {
|
||||
$ret['items'] = $x;
|
||||
}
|
||||
$ret['content'] = $content;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function encode_follow_collection($items, $id, $type, $total = 0, $extra = null): array
|
||||
{
|
||||
|
||||
|
@ -1376,9 +1439,17 @@ class Activity
|
|||
$img[] = ['type' => 'Image', 'url' => substr($match[1], 1), 'name' => $match[2]];
|
||||
} // preferred mechanism for adding alt text
|
||||
elseif (str_contains($match[1], 'alt=')) {
|
||||
$txt = str_replace('"', '"', $match[1]);
|
||||
$txt = substr($txt, strpos($txt, 'alt="') + 5, -1);
|
||||
$img[] = ['type' => 'Image', 'url' => $match[2], 'name' => $txt];
|
||||
$submatch = null;
|
||||
$x = preg_match("/alt=\"\;(.*?)\"\;/ism", $match[1], $submatch);
|
||||
if ($x) {
|
||||
$alt = $submatch[1];
|
||||
}
|
||||
$submatch = null;
|
||||
$x = preg_match('/alt="([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"/ism', $match[1], $submatch);
|
||||
if ($x) {
|
||||
$alt = $submatch[1];
|
||||
}
|
||||
$img[] = ['type' => 'Image', 'url' => $match[2], 'name' => $alt];
|
||||
} else {
|
||||
$img[] = ['type' => 'Image', 'url' => $match[2]];
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ class Album extends Controller
|
|||
intval($channel['channel_id'])
|
||||
);
|
||||
|
||||
$contents = [];
|
||||
$collection = [];
|
||||
$content = '';
|
||||
$item_normal_not_hidden = item_normal_not_hidden();
|
||||
if ($x) {
|
||||
foreach ($x as $xv) {
|
||||
|
@ -93,17 +94,19 @@ class Album extends Controller
|
|||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($query) {
|
||||
$contents[] = array_shift($query);
|
||||
$collection[] = array_shift($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($contents) {
|
||||
xchan_query($contents);
|
||||
$contents = fetch_post_tags($contents);
|
||||
if ($collection) {
|
||||
xchan_query($collection);
|
||||
$collection = fetch_post_tags($collection);
|
||||
}
|
||||
|
||||
$obj = Activity::encode_item_collection($contents, App::$query_string, 'OrderedCollection', true, Channel::getDidResolver($channel, true), count($contents));
|
||||
$obj = Activity::encode_photo_collection($collection, App::$query_string, 'Collection', true, Channel::getDidResolver($channel, true), count($collection));
|
||||
$obj['content'] = bbcode($obj['content'], ['export' => true]);
|
||||
|
||||
as_return_and_die($obj, $channel);
|
||||
}
|
||||
goaway(z_root() . '/photos/' . argv(1) . '/album/' . argv(2));
|
||||
|
|
|
@ -132,6 +132,40 @@ class Embedphotos extends Controller
|
|||
return '';
|
||||
}
|
||||
|
||||
protected static function insertAlbum($folder, $channel)
|
||||
{
|
||||
|
||||
$output = '';
|
||||
$x = q(
|
||||
"select * from attach where is_photo = 1 and folder = '%s' and uid = %d ",
|
||||
dbesc($folder['hash']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($x) {
|
||||
foreach ($x as $attach) {
|
||||
$images = q("select * from photo where resource_id = '%s' and uid = %d and imgscale = 1",
|
||||
dbesc($attach['hash']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($images) {
|
||||
$image = array_shift($images);
|
||||
$alt = 'alt="' . (($image['description']) ?: $image['filename']) . '"';
|
||||
$ext = pathinfo($image['filename'], PATHINFO_EXTENSION);
|
||||
$url = z_root() . '/photo/' . $image['resource_id'] . '-1' . (($ext) ? '.' . $ext : '');
|
||||
if ($image['allow_cid'] && strpos($image['allow_cid'],'<token:')) {
|
||||
$token = substr($image['allow_cid'], strpos($image['allow_cid'], '<token:'));
|
||||
$token = substr($token, 0, strpos($token, '>'));
|
||||
$url = $url . '?token=' . $token;
|
||||
}
|
||||
|
||||
$output .= '[zmg width="' . $image['width'] . '" height="' . $image['height'] . '" ' . "\n\n" . $alt . "\n\n" . ']'
|
||||
. $url . '[/zmg]' . "\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= '[attachment]' . z_root() . '/album/' . $channel['channel_address'] . '/' . $folder['hash'] . '[/attachment]';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
protected static function filelink($resource, $channel_id = 0)
|
||||
|
@ -143,7 +177,9 @@ class Embedphotos extends Controller
|
|||
}
|
||||
|
||||
$r = attach_by_hash($resource,get_observer_hash());
|
||||
|
||||
if ($r['success'] && $r['data']['is_dir']) {
|
||||
return self::insertAlbum($r['data'], $channel);
|
||||
}
|
||||
$url = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path'];
|
||||
|
||||
if (str_starts_with($r['data']['filetype'], 'video')) {
|
||||
|
|
|
@ -84,7 +84,7 @@ class Followers extends Controller
|
|||
left join abook on abook_xchan = xchan_hash
|
||||
where abook_channel = %d and abconfig.chan = %d and abconfig.cat = 'system'
|
||||
and abconfig.k = 'their_perms' and abconfig.v like '%%send_stream%%' and xchan_hash != '%s'
|
||||
and xchan_orphan = 0 and xchan_deleted = 0 and abook_hidden = 0 and abook_pending = 0
|
||||
and xchan_orphan = 0 and xchan_deleted = 0 and abook_pending = 0
|
||||
and abook_self = 0 $sqlExtra $pager_sql",
|
||||
intval($channel['channel_id']),
|
||||
intval($channel['channel_id']),
|
||||
|
|
|
@ -85,7 +85,7 @@ class Following extends Controller
|
|||
left join abook on abook_xchan = xchan_hash
|
||||
where abook_channel = %d and abconfig.chan = %d and abconfig.cat = 'system' and abconfig.k = 'my_perms'
|
||||
and abconfig.v like '%%send_stream%%' and xchan_hash != '%s' and xchan_orphan = 0
|
||||
and xchan_deleted = 0 and abook_hidden = 0 and abook_pending = 0 and abook_self = 0 $sqlExtra $pager_sql",
|
||||
and abook_hidden = 0 and abook_pending = 0 and abook_self = 0 $sqlExtra $pager_sql",
|
||||
intval($channel['channel_id']),
|
||||
intval($channel['channel_id']),
|
||||
dbesc($channel['channel_hash'])
|
||||
|
|
|
@ -513,4 +513,9 @@ class Inbox extends Controller
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get()
|
||||
{
|
||||
http_status_exit(403, 'Permission denied');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1182,8 +1182,10 @@ class Item extends Controller
|
|||
$attach_link = '';
|
||||
$hash = substr($mtch, 0, strpos($mtch, ','));
|
||||
$rev = intval(substr($mtch, strpos($mtch, ',')));
|
||||
if (str_starts_with($mtch, 'https://')) {
|
||||
$attachments[] = [ 'href' => $mtch, 'type' => 'application/activity+json', 'title' => $mtch ];
|
||||
if (str_starts_with($mtch, 'http')) {
|
||||
$attachments[] = [ 'href' => $mtch, 'type' => 'text/html', 'title' => $mtch ];
|
||||
} elseif (str_starts_with($mtch, 'jsonld://')) {
|
||||
$attachments[] = [ 'href' => str_replace('jsonld://', 'https://', $mtch), 'type' => 'application/activity+json', 'title' => $mtch ];
|
||||
}
|
||||
else {
|
||||
$r = attach_by_hash_nodata($hash, $observer['xchan_hash'], $rev);
|
||||
|
|
|
@ -229,7 +229,7 @@ class Linkinfo extends Controller
|
|||
$y = new ActivityStreams($x);
|
||||
if (
|
||||
$y->is_valid() && $y->type === 'Announce' && is_array($y->obj)
|
||||
&& (array_key_exists('object', $AS->obj) || array_key_exists('target', $AS->obj)) && array_key_exists('actor', $y->obj)
|
||||
&& (array_key_exists('object', $y->obj) || array_key_exists('target', $y->obj)) && array_key_exists('actor', $y->obj)
|
||||
) {
|
||||
// This is a relayed/forwarded Activity (as opposed to a shared/boosted object)
|
||||
// Reparse the encapsulated Activity and use that instead
|
||||
|
@ -258,13 +258,15 @@ class Linkinfo extends Controller
|
|||
if (check_siteallowed($r['hubloc_id_url']) && check_channelallowed($z['author_xchan'])) {
|
||||
$s = new Zlib\Share($z);
|
||||
echo $s->bbcode();
|
||||
echo "\n" . '[attachment]' . $z['mid'] . '[/attachment]' . "\n";
|
||||
echo "\n" . '[attachment]' . str_replace('https://', 'jsonld://', $z['mid']) . '[/attachment]' . "\n";
|
||||
killme();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($process_oembed) {
|
||||
$x = Oembed::process($url);
|
||||
if ($x) {
|
||||
|
|
|
@ -465,7 +465,7 @@ class Photos extends Controller
|
|||
intval($item_id)
|
||||
);
|
||||
|
||||
// make sure the attach has the same permissions as the photo regardless of any other changes
|
||||
// make sure the "attach" table has the same permissions as the photo regardless of any other changes
|
||||
$x = q(
|
||||
"update attach set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where hash = '%s' and uid = %d and is_photo = 1",
|
||||
dbesc($perm['allow_cid']),
|
||||
|
|
0
util/fhublocs
Normal file → Executable file
0
util/fhublocs
Normal file → Executable file
Loading…
Reference in a new issue