forked from friendica/friendica-addons
Compare commits
5 commits
2025.07-rc
...
stable-plu
Author | SHA1 | Date | |
---|---|---|---|
86ab22530a | |||
2c62a6aae5 | |||
a37f313990 | |||
99f26dc3cc | |||
a844eb0cad |
6 changed files with 55 additions and 16 deletions
|
@ -209,7 +209,7 @@ function blockbot_log_activitypub(string $url, string $agent)
|
|||
blockbot_save('activitypub-inbox-agents', $agent);
|
||||
}
|
||||
|
||||
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) {
|
||||
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER, false))) {
|
||||
blockbot_save('activitypub-signature-agents', $agent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -671,6 +671,8 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
|
|||
}
|
||||
}
|
||||
|
||||
$item['body'] = bluesky_set_mentions($item['body']);
|
||||
|
||||
$urls = bluesky_get_urls($item['body']);
|
||||
$item['body'] = $urls['body'];
|
||||
|
||||
|
@ -732,14 +734,38 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
|
|||
}
|
||||
}
|
||||
|
||||
function bluesky_set_mentions(string $body): string
|
||||
{
|
||||
if (!preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
return $body;
|
||||
}
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$contact = Contact::selectFirst(['addr'], ['nurl' => $match[1]]);
|
||||
if (!empty($contact['addr'])) {
|
||||
$body = str_replace($match[0], '@[url=' . $match[1] . ']' . $contact['addr'] . '[/url]', $body);
|
||||
} else {
|
||||
$body = str_replace($match[0], '@' . $match[2], $body);
|
||||
}
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
function bluesky_get_urls(string $body): array
|
||||
{
|
||||
// Remove all hashtag and mention links
|
||||
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
|
||||
|
||||
$body = BBCode::expandVideoLinks($body);
|
||||
$urls = [];
|
||||
|
||||
// Search for Mentions
|
||||
if (preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$text = '@' . $match[2];
|
||||
$urls[strpos($body, $match[0])] = ['mention' => $match[1], 'text' => $text, 'hash' => $text];
|
||||
$body = str_replace($match[0], $text, $body);
|
||||
}
|
||||
}
|
||||
|
||||
// Search for hash tags
|
||||
if (preg_match_all("/#\[url\=(https?:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
|
@ -824,6 +850,9 @@ function bluesky_get_facets(string $body, array $urls): array
|
|||
} elseif (!empty($url['url'])) {
|
||||
$feature->uri = $url['url'];
|
||||
$feature->$type = 'app.bsky.richtext.facet#link';
|
||||
} elseif (!empty($url['mention'])) {
|
||||
$feature->did = $url['mention'];
|
||||
$feature->$type = 'app.bsky.richtext.facet#mention';
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -1004,6 +1033,10 @@ function bluesky_process_reason(stdClass $reason, string $uri, int $uid)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Post::exists(['uid' => $item['uid'], 'thr-parent' => $item['thr-parent'], 'verb' => $item['verb'], 'contact-id' => $item['contact-id']])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item['guid'] = Item::guidFromUri($item['uri'], $contact['alias']);
|
||||
$item['owner-name'] = $item['author-name'];
|
||||
$item['owner-link'] = $item['author-link'];
|
||||
|
@ -1137,8 +1170,14 @@ function bluesky_get_feeds(int $uid): array
|
|||
return [];
|
||||
}
|
||||
foreach ($preferences->preferences as $preference) {
|
||||
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPref') {
|
||||
return $preference->pinned ?? [];
|
||||
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPrefV2') {
|
||||
$pinned = [];
|
||||
foreach ($preference->items as $item) {
|
||||
if (($item->type == 'feed') && $item->pinned) {
|
||||
$pinned[] = $item->value;
|
||||
}
|
||||
}
|
||||
return $pinned;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
|
|
|
@ -54,8 +54,8 @@ function invidious_settings(array &$data)
|
|||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$enabled' => ['enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
|
||||
'$server' => ['server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
|
||||
'$enabled' => ['invidious-enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
|
||||
'$server' => ['invidious-server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
|
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['enabled']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['invidious-enabled']);
|
||||
|
||||
$server = trim($_POST['server'], " \n\r\t\v\x00/");
|
||||
$server = trim($_POST['invidious-server'], " \n\r\t\v\x00/");
|
||||
if ($server != DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT) && !empty($server)) {
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ function markdown_addon_settings(array &$data)
|
|||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
|
||||
'$enabled' => ['markdown-enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
|
@ -43,7 +43,7 @@ function markdown_addon_settings_post(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['markdown-enabled']));
|
||||
}
|
||||
|
||||
function markdown_post_local_start(&$request) {
|
||||
|
|
|
@ -60,7 +60,7 @@ function rendertime_page_end(string &$o)
|
|||
|
||||
if (DI::userSession()->isSiteAdmin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) {
|
||||
|
||||
$o = $o . '<div class="renderinfo">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
|
||||
$o = $o . '<div class="renderinfo" aria-hidden="true">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
|
||||
round($profiler->get('database') - $profiler->get('database_write'), 3),
|
||||
round($profiler->get('database_write'), 3),
|
||||
round($profiler->get('network'), 2),
|
||||
|
@ -77,7 +77,7 @@ function rendertime_page_end(string &$o)
|
|||
|
||||
$total = microtime(true) - $profiler->get('start');
|
||||
$rest = $total - ($profiler->get('ready') - $profiler->get('start')) - $profiler->get('init') - $profiler->get('content');
|
||||
$o = $o . '<div class="renderinfo">' . DI::l10n()->t("Class-Init: %s, Boot: %s, Init: %s, Content: %s, Other: %s, Total: %s",
|
||||
$o = $o . '<div class="renderinfo" aria-hidden="true">' . DI::l10n()->t("Class-Init: %s, Boot: %s, Init: %s, Content: %s, Other: %s, Total: %s",
|
||||
round($profiler->get('classinit') - $profiler->get('start'), 3),
|
||||
round($profiler->get('ready') - $profiler->get('classinit'), 3),
|
||||
round($profiler->get('init'), 3),
|
||||
|
@ -87,7 +87,7 @@ function rendertime_page_end(string &$o)
|
|||
) . '</div>';
|
||||
|
||||
if ($profiler->isRendertime()) {
|
||||
$o .= '<pre>';
|
||||
$o .= '<pre aria-hidden="true">';
|
||||
$o .= $profiler->getRendertimeString(floatval(DI::config()->get('rendertime', 'minimal_time', 0)));
|
||||
$o .= '</pre>';
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ function addHeightToggleHandler($item) {
|
|||
$item.data("item-id", itemId);
|
||||
var toggleId = "wall-item-body-toggle-" + itemId;
|
||||
|
||||
$item.append('<div class="wall-item-body-toggle" data-item-id="' + itemId + '" id="' + toggleId + '" ><button type="button" class="wall-item-body-toggle-text">' + showmore_dyn_showmore_linktext + '</button></div>');
|
||||
$item.append('<div class="wall-item-body-toggle" data-item-id="' + itemId + '" id="' + toggleId + '" ><button type="button" class="wall-item-body-toggle-text" aria-hidden="true">' + showmore_dyn_showmore_linktext + '</button></div>');
|
||||
$item.addClass("limitable limit-height");
|
||||
|
||||
var $toggle = $("#" + toggleId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue