Compare commits

..

No commits in common. "develop" and "develop" have entirely different histories.

13 changed files with 60 additions and 75 deletions

View file

@ -208,7 +208,7 @@ function blockbot_log_activitypub(string $url, string $agent)
blockbot_save('activitypub-inbox-agents', $agent);
}
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER, false))) {
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) {
blockbot_save('activitypub-signature-agents', $agent);
}
}

View file

@ -1005,10 +1005,6 @@ 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'];

View file

@ -54,8 +54,8 @@ function invidious_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
$html = Renderer::replaceMacros($t, [
'$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>')],
'$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>')],
]);
$data = [
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['invidious-enabled']);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['enabled']);
$server = trim($_POST['invidious-server'], " \n\r\t\v\x00/");
$server = trim($_POST['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 {

View file

@ -26,7 +26,7 @@ function markdown_addon_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['markdown-enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
]);
$data = [
@ -42,7 +42,7 @@ function markdown_addon_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['markdown-enabled']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled']));
}
function markdown_post_local_start(&$request) {

View file

@ -1,4 +0,0 @@
# Monolog Addon
A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)).
There are just Friendica additions inside the src directory.

View file

@ -1,7 +1,7 @@
<?php
/*
* Name: Monolog
* Description: A Logging framework with lots of additions, customized for Friendica.
* Version: 1.1
* Description: A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the src directory
* Version: 1.0
* Author: Philipp Holzer
*/

View file

@ -4,8 +4,7 @@ namespace Friendica\Addon\monolog\src\Factory;
use Friendica\Addon\monolog\src\Monolog\IntrospectionProcessor;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Factory\LoggerFactory;
use Friendica\Core\Logger\Factory\AbstractLoggerTypeFactory;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
@ -17,49 +16,32 @@ use Psr\Log\LogLevel;
require_once __DIR__ . '/../../vendor/autoload.php';
final class MonologFactory implements LoggerFactory
class Monolog extends AbstractLoggerTypeFactory
{
private IHaveCallIntrospections $introspection;
private IManageConfigValues $config;
public function __construct(IHaveCallIntrospections $introspection, IManageConfigValues $config)
{
$this->introspection = $introspection;
$this->config = $config;
}
/**
* Creates and returns a PSR-3 Logger instance.
*
* Calling this method multiple times with the same parameters SHOULD return the same object.
*
* @param \Psr\Log\LogLevel::* $logLevel The log level
* @param \Friendica\Core\Logger\Capability\LogChannel::* $logChannel The log channel
*/
public function createLogger(string $logLevel, string $logChannel): LoggerInterface
public function create(IManageConfigValues $config, string $loglevel = null): LoggerInterface
{
$loggerTimeZone = new \DateTimeZone('UTC');
$logger = new Logger($logChannel);
$logger = new Logger($this->channel);
$logger->setTimezone($loggerTimeZone);
$logger->pushProcessor(new PsrLogMessageProcessor());
$logger->pushProcessor(new ProcessIdProcessor());
$logger->pushProcessor(new UidProcessor());
$logger->pushProcessor(new IntrospectionProcessor($this->introspection, LogLevel::DEBUG));
$logfile = $this->config->get('system', 'logfile');
$logfile = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (is_writable($logfile)) {
$logLevel = Logger::toMonologLevel($logLevel);
$loglevel = $loglevel ?? static::mapLegacyConfigDebugLevel($config->get('system', 'loglevel'));
$loglevel = Logger::toMonologLevel($loglevel);
// fallback to notice if an invalid loglevel is set
if (!is_int($logLevel)) {
$logLevel = LogLevel::NOTICE;
if (!is_int($loglevel)) {
$loglevel = LogLevel::NOTICE;
}
$fileHandler = new StreamHandler($logfile, $logLevel);
$fileHandler = new StreamHandler($logfile, $loglevel);
$formatter = new LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
$fileHandler->setFormatter($formatter);

View file

@ -20,7 +20,10 @@
*/
return [
\Friendica\Core\Logger\Factory\LoggerFactory::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\MonologFactory::class,
\Monolog\Logger::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\Monolog::class,
'call' => [
['create', [], \Dice\Dice::CHAIN_CALL],
],
],
];

View file

@ -0,0 +1,26 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
return [
\Psr\Log\LoggerInterface::class => [
\Monolog\Logger::class => ['monolog'],
],
];

View file

@ -59,7 +59,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" aria-hidden="true">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
$o = $o . '<div class="renderinfo">' . 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),

View file

@ -82,13 +82,11 @@ function saml_footer(string &$body)
<script>
var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); }
document.getElementById('id_email').setAttribute('readonly', 'readonly');
var saml_hint = document.createElement("span");
var saml_hint_text = document.createTextNode('$samlhint');
saml_hint.appendChild(saml_hint_text);
if ( document.getElementById('id_email') != null ) {
document.getElementById('id_email').setAttribute('readonly', 'readonly');
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
}
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
// Frio theme
if ( document.getElementById('password-settings-collapse') != null ) {
document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));

View file

@ -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" aria-hidden="true">' + 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">' + showmore_dyn_showmore_linktext + '</button></div>');
$item.addClass("limitable limit-height");
var $toggle = $("#" + toggleId);

View file

@ -391,17 +391,12 @@ function tumblr_settings_post(array &$b)
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
$tags = array_slice(
array_filter(
array_map(
function($tag) { return trim($tag, ' #');},
explode(',', $_POST['tags']) ?: []
)
),
0,
$max_tags,
);
$tags = [];
foreach (explode(',', $_POST['tags']) as $tag) {
if (count($tags) < $max_tags) {
$tags[] = trim($tag, ' #');
}
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'tags', $tags);
}
@ -747,18 +742,7 @@ function tumblr_fetch_tags(int $uid, int $last_poll)
}
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags') ?? [] as $tag) {
// Tumblr will return an error for queries on empty tag
if (!$tag) {
continue;
}
$data = tumblr_get($uid, 'tagged', ['tag' => $tag]);
if (!is_array($data->response)) {
DI::logger()->warning('Unexpected Tumblr response format', ['uid' => $uid, 'url' => 'tagged', 'parameters' => ['tag' => $tag], 'data' => $data]);
continue;
}
foreach (array_reverse($data->response) as $post) {
$id = tumblr_process_post($post, $uid, Item::PR_TAG, $last_poll);
if (!empty($id)) {