Compare commits

..

117 commits

Author SHA1 Message Date
Matthew Exon
7e8526c16f use post-content table instead of item-content 2025-01-19 16:54:10 +01:00
Matthew Exon
63bc3cc85a Retriever: use new logging convention 2025-01-19 15:24:45 +01:00
Matthew Exon
a46c4ef9f3 Mailstream: use new logging convention 2025-01-19 15:24:34 +01:00
Matthew Exon
c6bd06d3d7 restore retriever configuration 2025-01-19 14:43:24 +01:00
Matthew Exon
380dab7e95 Retriever: use new HTTP client API 2025-01-19 14:43:24 +01:00
Matthew Exon
daacd19f68 improved logging 2025-01-19 14:43:24 +01:00
Matthew Exon
bc9ca2eae8 Mailstream: respect blocked/ignored/collapsed contact settings 2025-01-19 14:43:24 +01:00
Matthew Exon
1311fe1e76 Revert "log uid but ignore results"
This reverts commit 0f5ba218f6.
2025-01-19 14:43:24 +01:00
Matthew Exon
7417ce0ad1 Another attempt to resolve local urls 2025-01-19 14:43:24 +01:00
Matthew Exon
59de855d0f a bit more defensiveness about add_retriever_item 2025-01-19 14:43:24 +01:00
Matthew Exon
be09d37331 globalise urls now handles relative urls 2025-01-19 14:43:24 +01:00
Matthew Exon
e5ada18f8e globalise_urls works better when retrospectively applying 2025-01-19 14:43:24 +01:00
Matthew Exon
57ad3c7f46 fix whitespace 2025-01-19 14:43:24 +01:00
Matthew Exon
79af1bbfa8 Fix broken images that have been broken for ages 2025-01-19 14:43:24 +01:00
Matthew Exon
dba114c799 adaptation for 2024.03 2025-01-19 14:43:24 +01:00
Matthew Exon
e08b5b2224 adaptation for 2024.03 2025-01-19 14:43:24 +01:00
Matthew Exon
d140eb43c3 trying to get phototrack to work 2025-01-19 14:43:24 +01:00
Matthew Exon
49e836c443 some more robust mailstream stuff 2025-01-19 14:43:24 +01:00
Matthew Exon
234d2173d3 debugging some issues 2025-01-19 14:43:24 +01:00
Matthew Exon
de2aa5fe7a more overdue adaptations 2025-01-19 14:43:24 +01:00
Matthew Exon
74742be6cb some changes that were long overdue 2025-01-19 14:43:24 +01:00
Matthew Exon
338c9a00ab more adaption to latest release 2025-01-19 14:43:24 +01:00
Matthew Exon
10844a8060 adapt to latest release 2025-01-19 14:43:24 +01:00
Matthew Exon
3960142cda log uid but ignore results 2025-01-19 14:43:24 +01:00
Matthew Exon
48bb777e80 remove duplicate use directive 2025-01-19 14:43:24 +01:00
Matthew Exon
cda356b7f8 fix contact photo menu callback really 2025-01-19 14:43:24 +01:00
Matthew Exon
7feb9aadb6 fix contact photo menu callback 2025-01-19 14:43:24 +01:00
Matthew Exon
8afd627f5b replace local_user 2025-01-19 14:43:24 +01:00
b321ded5ed The priority is now a class constant 2025-01-19 14:43:24 +01:00
Matthew Exon
de0a3576ba Add missing use statement 2025-01-19 14:43:24 +01:00
Matthew Exon
274212f349 add types to parameters 2025-01-19 14:43:24 +01:00
Matthew Exon
b47de35a9f fix order of upgrade commands 2025-01-19 14:43:24 +01:00
Matthew Exon
67d041db69 add log lines to install 2025-01-19 14:43:24 +01:00
Matthew Exon
ae091cce33 Fix length of keys 2025-01-19 14:43:24 +01:00
Matthew Exon
f7fde7d04e Use new hook registration calls 2025-01-19 14:43:24 +01:00
Matthew Exon
59974a7221 Update to correct collation mode 2025-01-19 14:43:24 +01:00
Matthew Exon
988189df22 Use separate album and repair dox for ces 2025-01-19 14:43:24 +01:00
Matthew Exon
cdc9bd52da fix comment 2025-01-19 14:43:24 +01:00
Matthew Exon
df77e2b82b correct use of fetchFull 2025-01-19 14:43:24 +01:00
Matthew Exon
eefda6e9dc fix argv stuff 2025-01-19 14:43:24 +01:00
Matthew Exon
f6bbb6245b fix argv stuff 2025-01-19 14:43:24 +01:00
Matthew Exon
62fc0bc368 use new temppath function 2025-01-19 14:43:24 +01:00
Matthew Exon
0a95de2fb1 fix sql syntax 2025-01-19 14:43:24 +01:00
Matthew Exon
8cf0a0ecf2 improvements 2025-01-19 14:43:24 +01:00
Matthew Exon
5361a75583 syntax errors 2025-01-19 14:43:24 +01:00
Matthew Exon
3e6fba1b76 syntax errors 2025-01-19 14:43:24 +01:00
Matthew Exon
b79b46715c syntax errors 2025-01-19 14:43:24 +01:00
Matthew Exon
f36ea9cbf4 syntax errors 2025-01-19 14:43:24 +01:00
Matthew Exon
e898c70de6 this is more correcter 2025-01-19 14:43:24 +01:00
Matthew Exon
5a8ca7f04c this is more correct 2025-01-19 14:43:24 +01:00
Matthew Exon
2e2706c9df another migrated function 2025-01-19 14:43:24 +01:00
Matthew Exon
8befd934c7 add anotehr check 2025-01-19 14:43:24 +01:00
Matthew Exon
51711d6721 also update these queries 2025-01-19 14:43:24 +01:00
Matthew Exon
1e0f16099b stray line 2025-01-19 14:43:24 +01:00
Matthew Exon
aa318adc64 perhaps it should be this style 2025-01-19 14:43:24 +01:00
Matthew Exon
0fbaf02089 attempt to handle one error 2025-01-19 14:43:24 +01:00
Matthew Exon
9fcb33d47a new style of http request 2025-01-19 14:43:24 +01:00
Matthew Exon
cdb20202e8 switch to new way of executing SQL 2025-01-19 14:43:24 +01:00
Matthew Exon
827898936c switch to new way of executing SQL 2025-01-19 14:43:24 +01:00
Matthew Exon
79696f4b9b switch to new way of executing SQL 2025-01-19 14:43:24 +01:00
Matthew Exon
8633e77a99 sync with submitted 2025-01-19 14:43:24 +01:00
Matthew Exon
6785e95309 error checking in retriever 2025-01-19 14:43:24 +01:00
Matthew Exon
a556e01a9f fix another stupid mistake 2025-01-19 14:43:24 +01:00
Matthew Exon
e67ed65a50 fix another stupid mistake 2025-01-19 14:43:24 +01:00
Matthew Exon
cc2351f0d6 Detect an error in mailstream 2025-01-19 14:43:24 +01:00
Matthew Exon
0321ee13d7 fixed another obvious mistake 2025-01-19 14:43:24 +01:00
Matthew Exon
a426e19b43 Fix a typo 2025-01-19 14:43:24 +01:00
Matthew Exon
355c93dae1 another check for empty results 2025-01-19 14:43:24 +01:00
Matthew Exon
efab4a9187 Adapt Item methods to Post methods 2025-01-19 14:43:24 +01:00
Matthew Exon
40ff029401 Remove binary field from httpRequest 2025-01-19 14:43:23 +01:00
Matthew Exon
90f41301e8 Replace fetchUrlFull with HTTPRequest version 2025-01-19 14:43:23 +01:00
Matthew Exon
be8764db94 Remove unneeded get_app 2025-01-19 14:43:23 +01:00
Matthew Exon
c50afbce65 Fix page assembly 2025-01-19 14:43:23 +01:00
Matthew Exon
8b8fd4e0ef Update with base url changes and strict key requirements 2025-01-19 14:43:23 +01:00
Matthew Exon
8b15ab92ed Further updates to 2020.03 2025-01-19 14:43:23 +01:00
Matthew Exon
ecf896fb9d Use new L10n thing 2025-01-19 14:43:23 +01:00
Matthew Exon
dd2d200709 Update to new module structure 2025-01-19 14:43:23 +01:00
Matthew Exon
c4ae276ce0 maybe this way works better 2025-01-19 14:43:23 +01:00
Matthew Exon
e1a566d9d7 New way of doing baseurl 2025-01-19 14:43:23 +01:00
Matthew Exon
0920a7eb11 Missing class 2025-01-19 14:43:23 +01:00
Matthew Exon
aa817af86c Update for new version 2025-01-19 14:43:23 +01:00
Matthew Exon
0baf5a1e89 Fix bug in phototrack 2025-01-19 14:43:23 +01:00
Matthew Exon
6f08073524 remove help section if images not allowed 2025-01-19 14:43:23 +01:00
Matthew Exon
0e9da65051 Almost finished, maybe not working 2025-01-19 14:43:23 +01:00
Matthew Exon
537e23f9eb working much better 2025-01-19 14:43:23 +01:00
Matthew Exon
dabe13043d I think this works 2025-01-19 14:43:23 +01:00
Matthew Exon
90d7f2e2da small addition 2025-01-19 14:43:23 +01:00
Matthew Exon
2e4dc1c866 small cleanup 2025-01-19 14:43:23 +01:00
Matthew Exon
8412a28507 working much better 2025-01-19 14:43:23 +01:00
Matthew Exon
439bd19990 maybe broken again 2025-01-19 14:43:23 +01:00
Matthew Exon
835f9b8c45 Now retriever works again 2025-01-19 14:43:23 +01:00
Matthew Exon
926dd59644 extensive refactoring 2025-01-19 14:43:23 +01:00
Matthew Exon
4713ceaa86 retriever tweaks 2025-01-19 14:43:23 +01:00
Matthew Exon
db8c26ac95 Add phototrack and publicise 2025-01-19 14:43:23 +01:00
Matthew Exon
cceb046833 configurable number of requests 2025-01-19 14:43:23 +01:00
Matthew Exon
fbc8f024a0 update version number 2025-01-19 14:43:23 +01:00
Matthew Exon
f353d21b5c Stuff in retriever 2025-01-19 14:43:23 +01:00
Matthew Exon
8e6ba6f3a5 fixed image regex 2025-01-19 14:43:23 +01:00
Matthew Exon
df1894944a more dba stuff 2025-01-19 14:43:23 +01:00
Matthew Exon
506f473830 fakerei2 2025-01-19 14:43:23 +01:00
Matthew Exon
b591521596 Fix bugs in retriever retrospective stuff 2025-01-19 14:43:23 +01:00
Matthew Exon
4f5b01636a more retriever stuff 2025-01-19 14:43:23 +01:00
Administrator
e33afbaa94 Fix retriever database problems 2025-01-19 14:43:23 +01:00
Matthew Exon
f549a220de retriever stuff 2025-01-19 14:43:23 +01:00
Matthew Exon
7fe4623f48 Change logging functions 2025-01-19 14:43:23 +01:00
Matthew Exon
550ee5455e Improvement 2025-01-19 14:43:23 +01:00
Administrator
d045672008 this is working OK 2025-01-19 14:43:23 +01:00
Matthew Exon
580b6c0145 fixed a bug and commented on another 2025-01-19 14:43:23 +01:00
Matthew Exon
e77834e0f4 fix 2025-01-19 14:43:23 +01:00
Matthew Exon
2b5fb2ed2a tentative database work 2025-01-19 14:43:23 +01:00
Matthew Exon
06f0a4a10d More preparation for persistent cookies 2025-01-19 14:43:23 +01:00
Matthew Exon
44e3115ea2 beginnings of persistent cookiejar support 2025-01-19 14:43:23 +01:00
Matthew Exon
d37b2ea415 now working retriever 2025-01-19 14:43:23 +01:00
Matthew Exon
dccb312810 more fixes 2025-01-19 14:43:23 +01:00
Matthew Exon
5486f774af more fixes 2025-01-19 14:43:23 +01:00
Matthew Exon
e57fe63446 Fixes for retriever 2025-01-19 14:43:23 +01:00
Matthew Exon
e381239de6 Latest version of retriever 2025-01-19 14:43:23 +01:00
89 changed files with 4745 additions and 809 deletions

View file

@ -56,10 +56,6 @@ steps:
- /tmp/drone-cache:/tmp/cache
when:
event: pull_request
phpstan:
image: friendicaci/php8.3:php8.3.3
commands:
- ./bin/composer.phar run phpstan;
check:
image: friendicaci/php-cs
commands:

View file

@ -48,7 +48,7 @@ steps:
branch: [ develop, '*-rc' ]
event: push
composer_install:
image: friendicaci/php8.2:php8.2.28
image: friendicaci/php8.2:php8.2.16
commands:
- export COMPOSER_HOME=.composer
- composer validate

View file

@ -5,13 +5,11 @@ matrix:
- PHP_MAJOR_VERSION: 8.0
PHP_VERSION: 8.0.30
- PHP_MAJOR_VERSION: 8.1
PHP_VERSION: 8.1.31
PHP_VERSION: 8.1.27
- PHP_MAJOR_VERSION: 8.2
PHP_VERSION: 8.2.28
PHP_VERSION: 8.2.16
- PHP_MAJOR_VERSION: 8.3
PHP_VERSION: 8.3.17
- PHP_MAJOR_VERSION: 8.4
PHP_VERSION: 8.4.5
PHP_VERSION: 8.3.3
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
labels:

View file

@ -45,7 +45,7 @@ steps:
repo: friendica/friendica-addons
event: tag
composer_install:
image: friendicaci/php8.2:php8.2.28
image: friendicaci/php8.2:php8.2.16
commands:
- export COMPOSER_HOME=.composer
- composer validate

View file

@ -36,6 +36,7 @@
use Friendica\BaseModule;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
@ -61,7 +62,7 @@ function advancedcontentfilter_install()
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
DBStructure::performUpdate();
DI::logger()->notice('installed advancedcontentfilter');
Logger::notice('installed advancedcontentfilter');
}
/*

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -26,7 +27,7 @@ function birdavatar_install()
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
DI::logger()->info('registered birdavatar');
Logger::info('registered birdavatar');
}
/**

View file

@ -45,6 +45,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
@ -76,7 +77,7 @@ function blackout_redirect ($b)
}
if (( $date1 <= $now ) && ( $now <= $date2 )) {
DI::logger()->notice('redirecting user to blackout page');
Logger::notice('redirecting user to blackout page');
System::externalRedirect($myurl);
}
}

View file

@ -11,6 +11,7 @@
use Friendica\Core\Hook;
use Friendica\DI;
use Jaybizzle\CrawlerDetect\CrawlerDetect;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Network\HTTPException\ForbiddenException;
@ -69,7 +70,7 @@ function blockbot_init_1()
}
if (empty($parts)) {
DI::logger()->debug('Known frontend found - accept', $logdata);
Logger::debug('Known frontend found - accept', $logdata);
if ($isCrawler) {
blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']);
}
@ -79,66 +80,66 @@ function blockbot_init_1()
blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']);
if (blockbot_is_crawler($parts)) {
DI::logger()->debug('Crawler found - reject', $logdata);
Logger::debug('Crawler found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_searchbot($parts)) {
DI::logger()->debug('Search bot found - reject', $logdata);
Logger::debug('Search bot found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_unwanted($parts)) {
DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata);
Logger::debug('Uncategorized unwanted agent found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_security_checker($parts)) {
if (!DI::config()->get('blockbot', 'security_checker')) {
DI::logger()->debug('Security checker found - reject', $logdata);
Logger::debug('Security checker found - reject', $logdata);
blockbot_reject();
}
DI::logger()->debug('Security checker found - accept', $logdata);
Logger::debug('Security checker found - accept', $logdata);
return;
}
if (blockbot_is_social_media($parts)) {
DI::logger()->debug('Social media service found - accept', $logdata);
Logger::debug('Social media service found - accept', $logdata);
return;
}
if (blockbot_is_fediverse_client($parts)) {
DI::logger()->debug('Fediverse client found - accept', $logdata);
Logger::debug('Fediverse client found - accept', $logdata);
return;
}
if (blockbot_is_feed_reader($parts)) {
DI::logger()->debug('Feed reader found - accept', $logdata);
Logger::debug('Feed reader found - accept', $logdata);
return;
}
if (blockbot_is_fediverse_tool($parts)) {
DI::logger()->debug('Fediverse tool found - accept', $logdata);
Logger::debug('Fediverse tool found - accept', $logdata);
return;
}
if (blockbot_is_service_agent($parts)) {
DI::logger()->debug('Service agent found - accept', $logdata);
Logger::debug('Service agent found - accept', $logdata);
return;
}
if (blockbot_is_monitor($parts)) {
DI::logger()->debug('Monitoring service found - accept', $logdata);
Logger::debug('Monitoring service found - accept', $logdata);
return;
}
if (blockbot_is_validator($parts)) {
DI::logger()->debug('Validation service found - accept', $logdata);
Logger::debug('Validation service found - accept', $logdata);
return;
}
if (blockbot_is_good_tool($parts)) {
DI::logger()->debug('Uncategorized helpful service found - accept', $logdata);
Logger::debug('Uncategorized helpful service found - accept', $logdata);
return;
}
@ -146,10 +147,10 @@ function blockbot_init_1()
if (blockbot_is_http_library($parts)) {
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
if (!DI::config()->get('blockbot', 'http_libraries')) {
DI::logger()->debug('HTTP Library found - reject', $logdata);
Logger::debug('HTTP Library found - reject', $logdata);
blockbot_reject();
}
DI::logger()->debug('HTTP Library found - accept', $logdata);
Logger::debug('HTTP Library found - accept', $logdata);
return;
}
@ -160,12 +161,12 @@ function blockbot_init_1()
if (!$isCrawler) {
blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']);
DI::logger()->debug('Non-bot user agent detected', $logdata);
Logger::debug('Non-bot user agent detected', $logdata);
return;
}
blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']);
DI::logger()->notice('Possible bot found - reject', $logdata);
Logger::notice('Possible bot found - reject', $logdata);
blockbot_reject();
}
@ -208,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, false))) {
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) {
blockbot_save('activitypub-signature-agents', $agent);
}
}
@ -216,7 +217,7 @@ function blockbot_log_activitypub(string $url, string $agent)
function blockbot_check_login_attempt(string $url, array $logdata)
{
if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) {
DI::logger()->debug('Login attempt detected - reject', $logdata);
Logger::debug('Login attempt detected - reject', $logdata);
blockbot_reject();
}
}
@ -442,7 +443,7 @@ function blockbot_is_monitor(array $parts): bool
}
/**
* Services in the centralized and decentralized social media environment
* Services in the centralized and decentralized social media environment
*
* @param array $parts
* @return boolean

View file

@ -30,6 +30,7 @@ use Friendica\Content\Text\Plaintext;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
@ -105,16 +106,16 @@ function bluesky_item_by_link(array &$hookData)
if (empty($did)) {
return;
}
DI::logger()->debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
Logger::debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
} else {
$uri = $hookData['uri'];
}
$uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0);
DI::logger()->debug('Got post', ['uri' => $uri]);
Logger::debug('Got post', ['uri' => $uri]);
if (!empty($uri)) {
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
if (!empty($item['id'])) {
@ -137,7 +138,7 @@ function bluesky_follow(array &$hook_data)
return;
}
DI::logger()->debug('Check if contact is bluesky', ['data' => $hook_data]);
Logger::debug('Check if contact is bluesky', ['data' => $hook_data]);
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
if (empty($contact)) {
return;
@ -158,7 +159,7 @@ function bluesky_follow(array &$hook_data)
$activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post);
if (!empty($activity->uri)) {
$hook_data['contact'] = $contact;
DI::logger()->debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
Logger::debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
}
}
@ -212,7 +213,7 @@ function bluesky_block(array &$hook_data)
if ($ucid) {
Contact::remove($ucid);
}
DI::logger()->debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
Logger::debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
}
}
@ -420,11 +421,11 @@ function bluesky_cron()
if ($last) {
$next = $last + ($poll_interval * 60);
if ($next > time()) {
DI::logger()->notice('poll interval not reached');
Logger::notice('poll interval not reached');
return;
}
}
DI::logger()->notice('cron_start');
Logger::notice('cron_start');
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
@ -436,19 +437,19 @@ function bluesky_cron()
$pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']);
foreach ($pconfigs as $pconfig) {
if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) {
DI::logger()->debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
Logger::debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
continue;
}
if ($abandon_days != 0) {
if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) {
DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
continue;
}
}
// Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers
DI::logger()->debug('Refresh the token', ['uid' => $pconfig['uid']]);
Logger::debug('Refresh the token', ['uid' => $pconfig['uid']]);
DI::atProtocol()->getUserToken($pconfig['uid']);
$last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync');
@ -462,32 +463,32 @@ function bluesky_cron()
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']);
}
if (DI::pConfig()->get($pconfig['uid'], 'bluesky', 'import_feeds')) {
DI::logger()->debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
Logger::debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
$feeds = bluesky_get_feeds($pconfig['uid']);
foreach ($feeds as $feed) {
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed);
}
}
DI::logger()->debug('Polling done for user', ['uid' => $pconfig['uid']]);
Logger::debug('Polling done for user', ['uid' => $pconfig['uid']]);
}
DI::logger()->notice('Polling done for all users');
Logger::notice('Polling done for all users');
DI::keyValue()->set('bluesky_last_poll', time());
$last_clean = DI::keyValue()->get('bluesky_last_clean');
if (empty($last_clean) || ($last_clean + 86400 < time())) {
DI::logger()->notice('Start contact cleanup');
Logger::notice('Start contact cleanup');
$contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]);
while ($contact = DBA::fetch($contacts)) {
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
}
DBA::close($contacts);
DI::keyValue()->set('bluesky_last_clean', time());
DI::logger()->notice('Contact cleanup done');
Logger::notice('Contact cleanup done');
}
DI::logger()->notice('cron_end');
Logger::notice('cron_end');
}
function bluesky_hook_fork(array &$b)
@ -507,7 +508,7 @@ function bluesky_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
// Don't post if it isn't a reply to a bluesky post
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
DI::logger()->notice('No bluesky parent found', ['item' => $post['id']]);
Logger::notice('No bluesky parent found', ['item' => $post['id']]);
$b['execute'] = false;
return;
}
@ -554,12 +555,12 @@ function bluesky_send(array &$b)
}
if ($b['gravity'] != Item::GRAVITY_PARENT) {
DI::logger()->debug('Got comment', ['item' => $b]);
Logger::debug('Got comment', ['item' => $b]);
if ($b['deleted']) {
$uri = DI::atpProcessor()->getUriClass($b['uri']);
if (empty($uri)) {
DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]);
Logger::debug('Not a bluesky post', ['uri' => $b['uri']]);
return;
}
bluesky_delete_post($b['uri'], $b['uid']);
@ -570,12 +571,12 @@ function bluesky_send(array &$b)
$parent = DI::atpProcessor()->getUriClass($b['thr-parent']);
if (empty($root) || empty($parent)) {
DI::logger()->debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
Logger::debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
return;
}
if ($b['gravity'] == Item::GRAVITY_COMMENT) {
DI::logger()->debug('Posting comment', ['root' => $root, 'parent' => $parent]);
Logger::debug('Posting comment', ['root' => $root, 'parent' => $parent]);
bluesky_create_post($b, $root, $parent);
return;
} elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) {
@ -634,10 +635,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
if (empty($activity->uri)) {
return;
}
DI::logger()->debug('Activity done', ['return' => $activity]);
Logger::debug('Activity done', ['return' => $activity]);
$uri = DI::atpProcessor()->getUri($activity);
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
}
function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null)
@ -672,8 +673,6 @@ 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'];
@ -723,53 +722,26 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
}
return;
}
DI::logger()->debug('Posting done', ['return' => $parent]);
Logger::debug('Posting done', ['return' => $parent]);
if (empty($root)) {
$root = $parent;
}
if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
$uri = DI::atpProcessor()->getUri($parent);
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
}
}
}
function bluesky_set_mentions(string $body): string
{
// Remove all url based mention links
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
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) {
@ -854,9 +826,6 @@ 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;
}
@ -930,20 +899,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass
$new_size = strlen($content);
if (($size != 0) && ($new_size == 0) && ($retrial == 0)) {
DI::logger()->warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
$content = Photo::getImageForPhoto($photo);
} else {
DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
}
$data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]);
if (empty($data) || empty($data->blob)) {
DI::logger()->info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
Logger::info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
return null;
}
Item::incrementOutbound(Protocol::BLUESKY);
DI::logger()->debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
Logger::debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
return $data->blob;
}
@ -951,11 +920,11 @@ function bluesky_delete_post(string $uri, int $uid)
{
$parts = DI::atpProcessor()->getUriParts($uri);
if (empty($parts)) {
DI::logger()->debug('No uri delected', ['uri' => $uri]);
Logger::debug('No uri delected', ['uri' => $uri]);
return;
}
DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts);
DI::logger()->debug('Deleted', ['parts' => $parts]);
Logger::debug('Deleted', ['parts' => $parts]);
}
function bluesky_fetch_timeline(int $uid)
@ -1037,10 +1006,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'];
@ -1061,10 +1026,10 @@ function bluesky_fetch_notifications(int $uid)
foreach ($data->notifications as $notification) {
$uri = DI::atpProcessor()->getUri($notification);
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) {
DI::logger()->debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
Logger::debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
continue;
}
DI::logger()->debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
switch ($notification->reason) {
case 'like':
$item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR);
@ -1074,9 +1039,9 @@ function bluesky_fetch_notifications(int $uid)
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
if (!empty($item['thr-parent'])) {
$data = Item::insert($item);
DI::logger()->debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else {
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
}
break;
@ -1088,37 +1053,37 @@ function bluesky_fetch_notifications(int $uid)
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
if (!empty($item['thr-parent'])) {
$data = Item::insert($item);
DI::logger()->debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else {
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
}
break;
case 'follow':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid);
DI::logger()->debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
Logger::debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
break;
case 'mention':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 0);
DI::logger()->debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
case 'reply':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 0);
DI::logger()->debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
case 'quote':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 0);
DI::logger()->debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
default:
DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
break;
}
}
@ -1149,16 +1114,16 @@ function bluesky_fetch_feed(int $uid, string $feed)
$languages = $entry->post->record->langs ?? [];
if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) {
DI::logger()->debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
Logger::debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
continue;
}
$causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0);
$uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR);
if (!empty($uri_id)) {
$stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
} else {
DI::logger()->notice('Post not found', ['entry' => $entry]);
Logger::notice('Post not found', ['entry' => $entry]);
}
if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid);
@ -1174,14 +1139,8 @@ function bluesky_get_feeds(int $uid): array
return [];
}
foreach ($preferences->preferences as $preference) {
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;
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPref') {
return $preference->pinned ?? [];
}
}
return [];

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_feed_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_feed_run($argv, $argc)
return;
}
DI::logger()->debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
Logger::debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
bluesky_fetch_feed($argv[1], $argv[2]);
DI::logger()->debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
Logger::debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
}

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_notifications_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_notifications_run($argv, $argc)
return;
}
DI::logger()->notice('importing notifications - start', ['user' => $argv[1]]);
Logger::notice('importing notifications - start', ['user' => $argv[1]]);
bluesky_fetch_notifications($argv[1]);
DI::logger()->notice('importing notifications - done', ['user' => $argv[1]]);
Logger::notice('importing notifications - done', ['user' => $argv[1]]);
}

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_timeline_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_timeline_run($argv, $argc)
return;
}
DI::logger()->notice('importing timeline - start', ['user' => $argv[1]]);
Logger::notice('importing timeline - start', ['user' => $argv[1]]);
bluesky_fetch_timeline($argv[1]);
DI::logger()->notice('importing timeline - done', ['user' => $argv[1]]);
Logger::notice('importing timeline - done', ['user' => $argv[1]]);
}

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -26,7 +27,7 @@ function catavatar_install()
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
DI::logger()->notice('registered catavatar');
Logger::notice('registered catavatar');
}
/**

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
function cld_install()
@ -17,17 +18,17 @@ function cld_install()
function cld_detect_languages(array &$data)
{
if (!in_array('cld2', get_loaded_extensions())) {
DI::logger()->warning('CLD2 is not installed.');
Logger::warning('CLD2 is not installed.');
return;
}
if (!class_exists('CLD2Detector')) {
DI::logger()->warning('CLD2Detector class does not exist.');
Logger::warning('CLD2Detector class does not exist.');
return;
}
if (!class_exists('CLD2Encoding')) {
DI::logger()->warning('CLD2Encoding class does not exist.');
Logger::warning('CLD2Encoding class does not exist.');
return;
}
@ -52,7 +53,7 @@ function cld_detect_languages(array &$data)
}
if (!$result['is_reliable']) {
DI::logger()->debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
Logger::debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) {
$data['detected'][$original] = $result['language_probability'] / 100;
}
@ -62,12 +63,12 @@ function cld_detect_languages(array &$data)
$available = array_keys(DI::l10n()->getLanguageCodes());
if (!in_array($detected, $available)) {
DI::logger()->debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
Logger::debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
return;
}
if ($original != $detected) {
DI::logger()->debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
Logger::debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
}
$length = count($data['detected']);

View file

@ -33,6 +33,7 @@ class Diaspora_Connection {
}
$this->cookiejar = tempnam(System::getTempPath(), 'cookies');
return $this;
}
public function __destruct() {

View file

@ -11,6 +11,7 @@ require_once 'addon/diaspora/Diaspora_Connection.php';
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Core\Worker;
@ -185,7 +186,7 @@ function diaspora_send(array &$b)
{
$hostname = DI::baseUrl()->getHost();
DI::logger()->notice('diaspora_send: invoked');
Logger::notice('diaspora_send: invoked');
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return;
@ -209,14 +210,14 @@ function diaspora_send(array &$b)
return;
}
DI::logger()->info('diaspora_send: prepare posting');
Logger::info('diaspora_send: prepare posting');
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
if ($handle && $password) {
DI::logger()->info('diaspora_send: all values seem to be okay');
Logger::info('diaspora_send: all values seem to be okay');
$title = $b['title'];
$body = $b['body'];
@ -247,20 +248,20 @@ function diaspora_send(array &$b)
require_once "addon/diaspora/diasphp.php";
try {
DI::logger()->info('diaspora_send: prepare');
Logger::info('diaspora_send: prepare');
$conn = new Diaspora_Connection($handle, $password);
DI::logger()->info('diaspora_send: try to log in ' . $handle);
Logger::info('diaspora_send: try to log in ' . $handle);
$conn->logIn();
DI::logger()->info('diaspora_send: try to send ' . $body);
Logger::info('diaspora_send: try to send ' . $body);
$conn->provider = $hostname;
$conn->postStatusMessage($body, $aspect);
DI::logger()->notice('diaspora_send: success');
Logger::notice('diaspora_send: success');
} catch (Exception $e) {
DI::logger()->notice("diaspora_send: Error submitting the post: " . $e->getMessage());
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
DI::logger()->info('diaspora_send: requeueing ' . $b['uid']);
Logger::info('diaspora_send: requeueing ' . $b['uid']);
Worker::defer();
}

View file

@ -10,6 +10,7 @@
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
@ -78,13 +79,13 @@ function discourse_email_getmessage(&$message)
// We do assume that all Discourse servers are running with SSL
if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
discourse_fetch_post_from_api($message, $matches[2], $matches[3])) {
DI::logger()->info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
Logger::info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
return;
}
if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
discourse_fetch_topic_from_api($message, 'https://' . $matches[2], $matches[1], 1)) {
DI::logger()->info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
Logger::info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
return;
}
@ -94,16 +95,16 @@ function discourse_email_getmessage(&$message)
}
if (empty($message['item']['plink']) || !preg_match('=(http.*)/t/.*/(.*\d)/(.*\d)=', $message['item']['plink'], $matches)) {
DI::logger()->info('This is no Discourse post');
Logger::info('This is no Discourse post');
return;
}
if (discourse_fetch_topic_from_api($message, $matches[1], $matches[2], $matches[3])) {
DI::logger()->info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
Logger::info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
return;
}
DI::logger()->info('Fallback mode', ['plink' => $message['item']['plink']]);
Logger::info('Fallback mode', ['plink' => $message['item']['plink']]);
// Search in the HTML part for the discourse entry and the author profile
if (!empty($message['html'])) {
$message = discourse_get_html($message);
@ -120,7 +121,7 @@ function discourse_fetch_post($host, $topic, $pid)
$url = $host . '/t/' . $topic . '/' . $pid . '.json';
$curlResult = DI::httpClient()->get($url);
if (!$curlResult->isSuccess()) {
DI::logger()->info('No success', ['url' => $url]);
Logger::info('No success', ['url' => $url]);
return false;
}
@ -132,11 +133,11 @@ function discourse_fetch_post($host, $topic, $pid)
/// @todo Possibly fetch missing posts here
continue;
}
DI::logger()->info('Got post data from topic', $post);
Logger::info('Got post data from topic', $post);
return $post;
}
DI::logger()->info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
Logger::info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
return false;
}
@ -168,7 +169,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
$message = discourse_process_post($message, $data, $hostaddr);
DI::logger()->info('Got API data', $message);
Logger::info('Got API data', $message);
return true;
}
@ -201,7 +202,7 @@ function discourse_get_user($post, $hostaddr)
$contact['url'] = $hostaddr . '/u/' . $contact['nick'];
$contact['nurl'] = Strings::normaliseLink($contact['url']);
$contact['baseurl'] = $hostaddr;
DI::logger()->info('Contact', $contact);
Logger::info('Contact', $contact);
$contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact);
if (!empty($contact['id'])) {
$avatar = $contact['photo'];
@ -267,11 +268,11 @@ function discourse_get_html($message)
$div = $doc2->importNode($result->item(0), true);
$doc2->appendChild($div);
$message['html'] = $doc2->saveHTML();
DI::logger()->info('Found html body', ['html' => $message['html']]);
Logger::info('Found html body', ['html' => $message['html']]);
$profile = discourse_get_profile($xpath);
if (!empty($profile['url'])) {
DI::logger()->info('Found profile', $profile);
Logger::info('Found profile', $profile);
$message['item']['author-id'] = Contact::getIdForURL($profile['url'], 0, false, $profile);
$message['item']['author-link'] = $profile['url'];
$message['item']['author-name'] = $profile['name'];
@ -287,21 +288,21 @@ function discourse_get_text($message)
$text = str_replace("\r", '', $text);
$pos = strpos($text, "\n---\n");
if ($pos == 0) {
DI::logger()->info('No separator found', ['text' => $text]);
Logger::info('No separator found', ['text' => $text]);
return $message;
}
$message['text'] = trim(substr($text, 0, $pos));
DI::logger()->info('Found text body', ['text' => $message['text']]);
Logger::info('Found text body', ['text' => $message['text']]);
$message['text'] = Markdown::toBBCode($message['text']);
$text = substr($text, $pos);
DI::logger()->info('Found footer', ['text' => $text]);
Logger::info('Found footer', ['text' => $text]);
if (preg_match('=\((http.*/t/.*/.*\d/.*\d)\)=', $text, $link)) {
$message['item']['plink'] = $link[1];
DI::logger()->info('Found plink', ['plink' => $message['item']['plink']]);
Logger::info('Found plink', ['plink' => $message['item']['plink']]);
}
return $message;
}

View file

@ -10,6 +10,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -184,12 +185,12 @@ function dwpost_send(array &$b)
EOT;
DI::logger()->debug('dwpost: data: ' . $xml);
Logger::debug('dwpost: data: ' . $xml);
if ($dw_blog !== 'test') {
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to dreamwidth: ' . ($x) ? $x : '');
Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');
}
}

View file

@ -8,6 +8,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -16,7 +17,7 @@ function fromapp_install()
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
DI::logger()->notice("installed fromapp");
Logger::notice("installed fromapp");
}
function fromapp_settings_post($post)

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -50,25 +51,25 @@ function geocoordinates_resolve_item(array &$item)
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
if (!$s) {
DI::logger()->info('API could not be queried');
Logger::info('API could not be queried');
return;
}
$data = json_decode($s);
if ($data->status->code != '200') {
DI::logger()->info('API returned error ' . $data->status->code . ' ' . $data->status->message);
Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
return;
}
if (($data->total_results == 0) || (count($data->results) == 0)) {
DI::logger()->info('No results found for coordinates ' . $item['coord']);
Logger::info('No results found for coordinates ' . $item['coord']);
return;
}
$item['location'] = $data->results[0]->formatted;
DI::logger()->info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
if ($item['location'] != '') {
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -44,7 +45,7 @@ function geonames_post_hook(array &$item)
* - The profile owner must have allowed our addon
*/
DI::logger()->notice('geonames invoked');
Logger::notice('geonames invoked');
if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */
return;

View file

@ -9,6 +9,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Notification;
@ -19,7 +20,7 @@ function gnot_install()
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
DI::logger()->notice("installed gnot");
Logger::notice("installed gnot");
}
/**

View file

@ -8,13 +8,13 @@
*/
use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Core\Logger;
function googlemaps_install()
{
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
DI::logger()->notice('installed googlemaps');
Logger::notice('installed googlemaps');
}
function googlemaps_location(&$item)

View file

@ -8,6 +8,7 @@
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -19,7 +20,7 @@ function gravatar_install() {
Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config');
Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup');
DI::logger()->notice("registered gravatar in avatar_lookup hook");
Logger::notice("registered gravatar in avatar_lookup hook");
}
function gravatar_load_config(ConfigFileManager $loader)

View file

@ -8,6 +8,7 @@
*/
use Friendica\Content\PageInfo;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -85,16 +86,16 @@ function ifttt_post()
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBA::isResult($user)) {
DI::logger()->info('User ' . $nickname . ' not found.');
Logger::info('User ' . $nickname . ' not found.');
return;
}
$uid = $user['uid'];
DI::logger()->info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
Logger::info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
if (!isset($_REQUEST['key'])) {
DI::logger()->notice('No key found.');
Logger::notice('No key found.');
return;
}
@ -102,7 +103,7 @@ function ifttt_post()
// Check the key
if ($key != DI::pConfig()->get($uid, 'ifttt', 'key')) {
DI::logger()->info('Invalid key for user ' . $uid);
Logger::info('Invalid key for user ' . $uid);
return;
}
@ -113,7 +114,7 @@ function ifttt_post()
}
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
DI::logger()->info('Unknown item type ' . $item['type']);
Logger::info('Unknown item type ' . $item['type']);
return;
}
@ -178,5 +179,5 @@ function ifttt_message($uid, $item)
$link = hash('ripemd128', $item['msg']);
}
Post\Delayed::add($link, $post, Worker::PRIORITY_MEDIUM, Post\Delayed::PREPARED);
Post\Delayed::add($link, $post, Worker::PRIORITY_MEDIUM, Post\Delayed::UNPREPARED);
}

View file

@ -10,6 +10,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -177,11 +178,11 @@ function ijpost_send(array &$b)
EOT;
DI::logger()->debug('ijpost: data: ' . $xml);
Logger::debug('ijpost: data: ' . $xml);
if ($ij_blog !== 'test') {
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to insanejournal: ' . $x ? $x : '');
Logger::info('posted to insanejournal: ' . $x ? $x : '');
}
}

View file

@ -9,6 +9,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -19,7 +20,7 @@ function impressum_install()
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
DI::logger()->notice("installed impressum Addon");
Logger::notice("installed impressum Addon");
}
/**

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

@ -8,6 +8,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Images;
@ -67,7 +68,7 @@ function js_upload_post_init(array &$b)
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
if (isset($result['error'])) {
DI::logger()->info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
Logger::info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
echo json_encode($result);
exit();
}
@ -90,7 +91,7 @@ function js_upload_post_end(int &$b)
{
global $js_upload_jsonresponse;
DI::logger()->notice('upload_post_end');
Logger::notice('upload_post_end');
if (!empty($js_upload_jsonresponse)) {
echo $js_upload_jsonresponse;
exit();
@ -186,10 +187,6 @@ class js_upload_qqFileUploader
{
private $allowedExtensions;
private $sizeLimit;
/**
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm|false
*/
private $file;
function __construct(array $allowedExtensions = [], $sizeLimit)
@ -237,7 +234,7 @@ class js_upload_qqFileUploader
$filename = $pathinfo['filename'];
if (!isset($pathinfo['extension'])) {
DI::logger()->warning('extension isn\'t set.', ['filename' => $filename]);
Logger::warning('extension isn\'t set.', ['filename' => $filename]);
}
$ext = $pathinfo['extension'] ?? '';

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -36,7 +37,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
$res = curl_exec($ch);
if (curl_errno($ch)) {
DI::logger()->error(curl_error($ch));
Logger::error(curl_error($ch));
}
curl_close($ch);

View file

@ -11,6 +11,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -30,7 +31,7 @@ function krynn_install()
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
DI::logger()->notice("installed krynn");
Logger::notice("installed krynn");
}
function krynn_post_hook(&$item)

View file

@ -30,6 +30,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
@ -68,54 +69,54 @@ function ldapauth_authenticate($username, $password)
$ldap_autocreateaccount_nameattribute = DI::config()->get('ldapauth', 'ldap_autocreateaccount_nameattribute');
if (!extension_loaded('ldap') || !strlen($ldap_server)) {
DI::logger()->error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
Logger::error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
return false;
}
if (!strlen($password)) {
DI::logger()->error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
Logger::error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
return false;
}
$connect = @ldap_connect($ldap_server);
if ($connect === false) {
DI::logger()->warning('Could not connect to LDAP server', ['server' => $ldap_server]);
Logger::warning('Could not connect to LDAP server', ['server' => $ldap_server]);
return false;
}
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) {
DI::logger()->warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
if (!$res) {
DI::logger()->notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$id = @ldap_first_entry($connect, $res);
if (!$id) {
DI::logger()->notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$dn = @ldap_get_dn($connect, $id);
if (!@ldap_bind($connect, $dn, $password)) {
DI::logger()->notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) {
$errno = @ldap_errno($connect);
if ($errno === 32) {
DI::logger()->notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
Logger::notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
} elseif ($errno === 16) {
DI::logger()->notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
Logger::notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
} else {
DI::logger()->notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
Logger::notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
}
@ldap_close($connect);
@ -139,7 +140,7 @@ function ldapauth_authenticate($username, $password)
$authentication = User::getAuthenticationInfo($username);
return User::getById($authentication['uid']);
} catch (Exception $e) {
DI::logger()->notice('LDAP authentication error: ' . $e->getMessage());
Logger::notice('LDAP authentication error: ' . $e->getMessage());
return false;
}
}
@ -147,7 +148,7 @@ function ldapauth_authenticate($username, $password)
function ldap_createaccount($username, $password, $email, $name)
{
if (!strlen($email) || !strlen($name)) {
DI::logger()->notice('Could not create local user from LDAP data, no email or nickname provided');
Logger::notice('Could not create local user from LDAP data, no email or nickname provided');
return false;
}
@ -159,10 +160,10 @@ function ldap_createaccount($username, $password, $email, $name)
'password' => $password,
'verified' => 1
]);
DI::logger()->info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
Logger::info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
return $user;
} catch (Exception $ex) {
DI::logger()->error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
Logger::error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
}
return false;

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
function leistungsschutzrecht_install()
@ -167,7 +168,7 @@ function leistungsschutzrecht_cron($b)
if ($last) {
$next = $last + 86400;
if ($next > time()) {
DI::logger()->notice('poll intervall not reached');
Logger::notice('poll intervall not reached');
return;
}
}

View file

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -129,7 +130,7 @@ function libertree_post_local(array &$b)
function libertree_send(array &$b)
{
DI::logger()->notice('libertree_send: invoked');
Logger::notice('libertree_send: invoked');
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return;
@ -195,6 +196,6 @@ function libertree_send(array &$b)
];
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
DI::logger()->notice('libertree: ' . $result);
Logger::notice('libertree: ' . $result);
}
}

View file

@ -361,7 +361,7 @@ class Services_Libravatar
protected function domainGet($identifier)
{
if ($identifier === null) {
return '';
return null;
}
// What are we, email or openid? Split ourself up and get the

View file

@ -6,7 +6,9 @@
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -18,7 +20,7 @@ function libravatar_install()
{
Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config');
Hook::register('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
DI::logger()->notice("registered libravatar in avatar_lookup hook");
Logger::notice("registered libravatar in avatar_lookup hook");
}
function libravatar_load_config(ConfigFileManager $loader)
@ -70,9 +72,7 @@ function libravatar_addon_admin(string &$o)
'pagan' => DI::l10n()->t('retro adventure game character'),
];
$addonHelper = DI::addonHelper();
if ($addonHelper->isAddonEnabled('gravatar')) {
if (Addon::isEnabled('gravatar')) {
$o = '<h5>' .DI::l10n()->t('Information') .'</h5><p>' .DI::l10n()->t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
}

View file

@ -10,6 +10,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -199,7 +200,7 @@ function ljpost_send(array &$b)
</methodCall>
EOT;
DI::logger()->debug('ljpost: data: ' . $xml);
Logger::debug('ljpost: data: ' . $xml);
$x = '';
@ -207,6 +208,6 @@ EOT;
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to livejournal: ' . $x);
Logger::info('posted to livejournal: ' . $x);
}
}

View file

@ -98,14 +98,47 @@ function mailstream_send_hook(array $data)
return;
}
$user = User::getById($item['uid']);
if (empty($user)) {
DI::logger()->error('could not find user', ['uid' => $item['uid']]);
if ($item['deleted']) {
DI::logger()->debug('mailstream_send_hook skipping deleted item', ['guid' => $item['guid']]);
return;
}
if (!mailstream_send($data['message_id'], $item, $user)) {
DI::logger()->debug('send failed, will retry', $data);
$user = User::getById($item['uid']);
if (empty($user)) {
DI::logger()->error('mailstream_send_hook could not find user', ['uid' => $item['uid']]);
return;
}
$author = DBA::selectFirst('contact', ['nick', 'blocked', 'uri-id'], ['id' => $data['author-id'], 'self' => false]);
if (!DBA::isResult($author)) {
DI::logger()->error('mailstream_send_hook could not find author', ['guid' => $item['guid'], 'author-id' => $data['author-id']]);
return;
}
if ($author['blocked']) {
DI::logger()->info('mailstream_send_hook author is blocked', ['guid' => $item['guid'], 'author-id' => $data['author-id']]);
return;
}
$collapsed = false;
$user_contact = DBA::selectFirst('user-contact', ['cid', 'blocked', 'ignored', 'collapsed'], ['uid' => $item['uid'], 'uri-id' => $item['author-uri-id']]);
if (!DBA::isResult($user_contact)) {
$user_contact = DBA::selectFirst('user-contact', ['cid', 'blocked', 'ignored', 'collapsed'], ['uid' => $item['uid'], 'cid' => $item['author-id']]);
}
if (DBA::isResult($user_contact)) {
if ($user_contact['blocked']) {
DI::logger()->info('mailstream_send_hook author is blocked', ['guid' => $item['guid'], 'cid' => $user_contact['cid']]);
return;
}
if ($user_contact['ignored']) {
DI::logger()->info('mailstream_send_hook author is ignored', ['guid' => $item['guid'], 'cid' => $user_contact['cid']]);
return;
}
if ($user_contact['collapsed']) {
$collapsed = true;
}
}
if (!mailstream_send($data['message_id'], $item, $user, $collapsed)) {
DI::logger()->debug('mailstream_send_hook send failed, will retry', $data);
if (!Worker::defer()) {
DI::logger()->error('failed and could not defer', $data);
}
@ -158,6 +191,7 @@ function mailstream_post_hook(array &$item)
$send_hook_data = [
'uid' => $item['uid'],
'contact-id' => $item['contact-id'],
'author-id' => $item['author-id'],
'uri' => $item['uri'],
'message_id' => $message_id,
'tries' => 0,
@ -179,7 +213,7 @@ function mailstream_post_hook(array &$item)
function mailstream_do_images(array &$item, array &$attachments)
{
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return $attachments;
return;
}
$attachments = [];
@ -344,10 +378,11 @@ function mailstream_subject(array $item): string
* @param string $message_id ID of the message (RFC 1036)
* @param array $item content of the item
* @param array $user results from the user table
* @param bool $collapsed true if the content should be hidden
*
* @return bool True if this message has been completed. False if it should be retried.
*/
function mailstream_send(string $message_id, array $item, array $user): bool
function mailstream_send(string $message_id, array $item, array $user, bool $collapsed): bool
{
if (!is_array($item)) {
DI::logger()->error('item is empty', ['message_id' => $message_id]);
@ -365,10 +400,16 @@ function mailstream_send(string $message_id, array $item, array $user): bool
require_once(dirname(__file__) . '/phpmailer/class.phpmailer.php');
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
if ($collapsed) {
$item['body'] = DI::l10n()->t('Content from %s is collapsed', $item['author-name']);
} else {
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
}
$attachments = [];
mailstream_do_images($item, $attachments);
if (!$collapsed) {
mailstream_do_images($item, $attachments);
}
$frommail = DI::config()->get('mailstream', 'frommail');
if ($frommail == '') {
$frommail = 'friendica@localhost.local';
@ -423,9 +464,9 @@ function mailstream_send(string $message_id, array $item, array $user): bool
'address' => $address
]);
} catch (phpmailerException $e) {
DI::logger()->debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]);
DI::logger()->debug('mailstream_send PHPMailer exception sending message', ['item uri' => $item['uri'], 'message_id' => $message_id, 'error' => $e->errorMessage()]);
} catch (Exception $e) {
DI::logger()->debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]);
DI::logger()->debug('mailstream_send exception sending message', ['item uri' => $item['uri'], 'message_id' => $message_id, 'error' => $e->errorMessage()]);
}
return true;

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

@ -17,11 +17,7 @@ function membersince_install()
Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
}
/**
* @param array|string|null $b
* @return void
*/
function membersince_display(&$b)
function membersince_display(array &$b)
{
$uid = DI::userSession()->getLocalUserId();
@ -63,7 +59,7 @@ function membersince_display(&$b)
$div->appendChild($entry);
$elm->parentNode->insertBefore($div, $elm->nextSibling);
$b = (string) $doc->saveHTML();
$b = $doc->saveHTML();
} else {
// Works in Vier.
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($user['register_date']) . "</dd>\n</dl>", $b, 1);

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

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\User;
@ -15,7 +16,7 @@ use Friendica\Model\User;
function newmemberwidget_install()
{
Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
DI::logger()->notice('newmemberwidget installed');
Logger::notice('newmemberwidget installed');
}
function newmemberwidget_network_mod_init ($b)

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -44,19 +45,19 @@ function nominatim_resolve_item(array &$item)
$s = DI::httpClient()->fetch('https://nominatim.openstreetmap.org/reverse?lat=' . $coords[0] . '&lon=' . $coords[1] . '&format=json&addressdetails=0&accept-language=' . $language);
if (empty($s)) {
DI::logger()->info('API could not be queried');
Logger::info('API could not be queried');
return;
}
$data = json_decode($s, true);
if (empty($data['display_name'])) {
DI::logger()->info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
Logger::info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
return;
}
$item['location'] = $data['display_name'];
DI::logger()->info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
Logger::info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
if (!empty($item['location'])) {
DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']);

View file

@ -57,7 +57,7 @@ function notifyall_post()
$notifyEmail = new NotifyAllEmail(DI::l10n(), DI::config(), DI::baseUrl(), $text);
foreach (DBA::toArray($recipients) as $recipient) {
foreach ($recipients as $recipient) {
DI::emailer()->send($notifyEmail->withRecipient($recipient['email']));
}

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -15,7 +16,7 @@ function numfriends_install() {
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
DI::logger()->notice("installed numfriends");
Logger::notice("installed numfriends");
}
/**

View file

@ -11,6 +11,7 @@
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -30,7 +31,7 @@ function openstreetmap_install()
Hook::register('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
DI::logger()->notice("installed openstreetmap");
Logger::notice("installed openstreetmap");
}
function openstreetmap_load_config(ConfigFileManager $loader)
@ -153,8 +154,8 @@ function openstreetmap_generate_map(array &$b)
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
DI::logger()->debug('lat: ' . $lat);
DI::logger()->debug('lon: ' . $lon);
Logger::debug('lat: ' . $lat);
Logger::debug('lon: ' . $lon);
$cardlink = '<a href="' . $tmsserver;
@ -172,7 +173,7 @@ function openstreetmap_generate_map(array &$b)
$b['html'] .= '<br/>' . $cardlink;
}
DI::logger()->debug('generate_map: ' . $b['html']);
Logger::debug('generate_map: ' . $b['html']);
}
function openstreetmap_addon_admin(string &$o)

View file

@ -9,6 +9,7 @@
use Friendica\DI;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Model\Contact;
use Friendica\Model\User;
@ -17,7 +18,7 @@ function opmlexport_install()
{
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
DI::logger()->notice('installed opmlexport Addon');
Logger::notice('installed opmlexport Addon');
}

23
phototrack/database.sql Normal file
View file

@ -0,0 +1,23 @@
CREATE TABLE IF NOT EXISTS `phototrack_photo_use` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`resource-id` char(64) NOT NULL,
`table` char(64) NOT NULL,
`field` char(64) NOT NULL,
`row-id` int(11) NOT NULL,
`checked` timestamp NOT NULL DEFAULT now(),
PRIMARY KEY (`id`),
INDEX `resource-id` (`resource-id`),
INDEX `row` (`table`,`field`,`row-id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `phototrack_row_check` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`table` char(64) NOT NULL,
`row-id` int(11) NOT NULL,
`checked` timestamp NOT NULL DEFAULT now(),
PRIMARY KEY (`id`),
INDEX `row` (`table`,`row-id`),
INDEX `checked` (`checked`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
SELECT TRUE

272
phototrack/phototrack.php Normal file
View file

@ -0,0 +1,272 @@
<?php
/**
* Name: Photo Track
* Description: Track which photos are actually being used and delete any others
* Version: 1.0
* Author: Matthew Exon <http://mat.exon.name>
*/
/*
* List of tables and the fields that are checked:
*
* contact: photo thumb micro about
* fcontact: photo
* fsuggest: photo
* gcontact: photo about
* item: body
* item-content: body
* mail: from-photo
* notify: photo
* profile: photo thumb about
*/
use Friendica\Core\Addon;
use Friendica\Core\Logger;
use Friendica\Object\Image;
use Friendica\Database\DBA;
use Friendica\Util\Images;
use Friendica\Util\DateTimeFormat;
use Friendica\DI;
if (!defined('PHOTOTRACK_DEFAULT_BATCH_SIZE')) {
define('PHOTOTRACK_DEFAULT_BATCH_SIZE', 1000);
}
// Time in *minutes* between searching for photo uses
if (!defined('PHOTOTRACK_DEFAULT_SEARCH_INTERVAL')) {
define('PHOTOTRACK_DEFAULT_SEARCH_INTERVAL', 10);
}
function phototrack_install() {
global $db;
Addon::registerHook('post_local_end', 'addon/phototrack/phototrack.php', 'phototrack_post_local_end');
Addon::registerHook('post_remote_end', 'addon/phototrack/phototrack.php', 'phototrack_post_remote_end');
Addon::registerHook('notifier_end', 'addon/phototrack/phototrack.php', 'phototrack_notifier_end');
Addon::registerHook('cron', 'addon/phototrack/phototrack.php', 'phototrack_cron');
if (DI::config()->get('phototrack', 'dbversion') != '0.1') {
$schema = file_get_contents(dirname(__file__).'/database.sql');
$arr = explode(';', $schema);
foreach ($arr as $a) {
if (!DBA::e($a)) {
Logger::warning('Unable to create database table: ' . DBA::errorMessage());
return;
}
}
DI::config()->set('phototrack', 'dbversion', '0.1');
}
}
function phototrack_uninstall() {
Addon::unregisterHook('post_local_end', 'addon/phototrack/phototrack.php', 'phototrack_post_local_end');
Addon::unregisterHook('post_remote_end', 'addon/phototrack/phototrack.php', 'phototrack_post_remote_end');
Addon::unregisterHook('notifier_end', 'addon/phototrack/phototrack.php', 'phototrack_notifier_end');
Addon::unregisterHook('cron', 'addon/phototrack/phototrack.php', 'phototrack_cron');
}
function phototrack_module() {}
function phototrack_finished_row($table, $id) {
$existing = DBA::selectFirst('phototrack_row_check', ['id'], ['table' => $table, 'row-id' => $id]);
if (!is_bool($existing)) {
DBA::update('phototrack_row_check', ['checked' => DateTimeFormat::utcNow()], ['table' => $table, 'row-id' => $id]);
}
else {
DBA::insert('phototrack_row_check', ['table' => $table, 'row-id' => $id, 'checked' => DateTimeFormat::utcNow()]);
}
}
function phototrack_photo_use($photo, $table, $field, $id) {
Logger::debug('@@@ phototrack_photo_use ' . $photo);
foreach (Images::supportedTypes() as $m => $e) {
$photo = str_replace(".$e", '', $photo);
}
if (substr($photo, -2, 1) == '-') {
$resolution = intval(substr($photo,-1,1));
$photo = substr($photo,0,-2);
}
if (strlen($photo) != 32) {
return;
}
$r = DBA::selectFirst('photo', ['resource-id'], ['resource-id' => $photo]);
if (!DBA::isResult($r)) {
return;
}
$rid = $r['resource-id'];
$existing = DBA::selectFirst('phototrack_photo_use', ['id'], ['resource-id' => $rid, 'table' => $table, 'field' => $field, 'row-id' => $id]);
if (DBA::isResult($existing)) {
DBA::update('phototrack_photo_use', ['checked' => DateTimeFormat::utcNow()], ['resource-id' => $rid, 'table' => $table, 'field' => $field, 'row-id' => $id]);
}
else {
DBA::insert('phototrack_photo_use', ['resource-id' => $rid, 'table' => $table, 'field' => $field, 'row-id' => $id, 'checked' => DateTimeFormat::utcNow()]);
}
}
function phototrack_check_field_url($a, $table, $id_field, $field, $id, $url) {
Logger::info('@@@ phototrack_check_field_url table ' . $table . ' id_field ' . $id_field . ' field ' . $field . ' id ' . $id . ' url ' . $url);
$baseurl = DI::baseUrl()->get(true);
if (strpos($url, $baseurl) === FALSE) {
return;
}
else {
$url = substr($url, strlen($baseurl));
Logger::info('@@@ phototrack_check_field_url funny url stuff ' . $url . ' base ' . $baseurl);
}
if (strpos($url, '/photo/') === FALSE) {
return;
}
else {
$url = substr($url, strlen('/photo/'));
Logger::info('@@@ phototrack_check_field_url more url stuff ' . $url);
}
if (preg_match('/([0-9a-z]{32})/', $url, $matches)) {
$rid = $matches[0];
Logger::info('@@@ phototrack_check_field_url rid ' . $rid);
phototrack_photo_use($rid, $table, $field, $id);
}
}
function phototrack_check_field_bbcode($a, $table, $id_field, $field, $id, $value) {
Logger::info('@@@ phototrack_check_field_url table ' . $table . ' id_field ' . $id_field . ' field ' . $field . ' id ' . $id . ' value ' . $value);
$baseurl = DI::baseUrl()->get(true);
$matches = array();
preg_match_all("/\[img(\=([0-9]*)x([0-9]*))?\](.*?)\[\/img\]/ism", $value, $matches);
foreach ($matches[4] as $url) {
phototrack_check_field_url($a, $table, $id_field, $field, $id, $url);
}
}
function phototrack_post_local_end(&$a, &$item) {
phototrack_check_row($a, 'item', 'id', $item);
phototrack_check_row($a, 'item-content', 'id', $item);
}
function phototrack_post_remote_end(&$a, &$item) {
phototrack_check_row($a, 'item', 'id', $item);
phototrack_check_row($a, 'item-content', 'id', $item);
}
function phototrack_notifier_end($item) {
}
function phototrack_check_row($a, $table, $id_field, $row) {
switch ($table) {
case 'post-content':
$fields = array(
'body' => 'bbcode');
break;
case 'contact':
$fields = array(
'photo' => 'url',
'thumb' => 'url',
'micro' => 'url',
'about' => 'bbcode');
break;
case 'fcontact':
$fields = array(
'photo' => 'url');
break;
case 'fsuggest':
$fields = array(
'photo' => 'url');
break;
case 'gcontact':
$fields = array(
'photo' => 'url',
'about' => 'bbcode');
break;
default: $fields = array(); break;
}
foreach ($fields as $field => $type) {
switch ($type) {
case 'bbcode': phototrack_check_field_bbcode($a, $table, $id_field, $field, $row['id'], $row[$field]); break;
case 'url': phototrack_check_field_url($a, $table, $id_field, $field, $row['id'], $row[$field]); break;
}
}
phototrack_finished_row($table, $row['id']);
}
function phototrack_batch_size() {
$batch_size = DI::config()->get('phototrack', 'batch_size');
if ($batch_size > 0) {
return $batch_size;
}
return PHOTOTRACK_DEFAULT_BATCH_SIZE;
}
function phototrack_search_table($a, $table, $id_field) {
$batch_size = phototrack_batch_size();
$rows = DBA::p("SELECT `$table`.* FROM `$table` LEFT OUTER JOIN phototrack_row_check ON ( phototrack_row_check.`table` = '$table' AND phototrack_row_check.`row-id` = `$table`.$id_field ) WHERE ( ( phototrack_row_check.checked IS NULL ) OR ( phototrack_row_check.checked < DATE_SUB(NOW(), INTERVAL 1 MONTH) ) ) ORDER BY phototrack_row_check.checked LIMIT $batch_size");
if (DBA::isResult($rows)) {
while ($row = DBA::fetch($rows)) {
phototrack_check_row($a, $table, $id_field, $row);
}
}
$r = DBA::p("SELECT COUNT(*) FROM `$table` LEFT OUTER JOIN phototrack_row_check ON ( phototrack_row_check.`table` = '$table' AND phototrack_row_check.`row-id` = `$table`.$id_field ) WHERE ( ( phototrack_row_check.checked IS NULL ) OR ( phototrack_row_check.checked < DATE_SUB(NOW(), INTERVAL 1 MONTH) ) )");
Logger::info("@@@ phototrack_search_table " . print_r(DBA::fetch($r)));
$remaining = DBA::fetch($r)['count'];
Logger::info('phototrack: searched ' . DBA::numRows($rows) . ' rows in table ' . $table . ', ' . $remaining . ' still remaining to search');
return $remaining;
}
function phototrack_cron_time() {
$prev_remaining = DI::config()->get('phototrack', 'remaining_items');
if ($prev_remaining > 10 * phototrack_batch_size()) {
Logger::debug('phototrack: more than ' . (10 * phototrack_batch_size()) . ' items remaining');
return true;
}
$last = DI::config()->get('phototrack', 'last_search');
$search_interval = intval(DI::config()->get('phototrack', 'search_interval'));
if (!$search_interval) {
$search_interval = PHOTOTRACK_DEFAULT_SEARCH_INTERVAL;
}
if ($last) {
$next = $last + ($search_interval * 60);
if ($next > time()) {
Logger::debug('phototrack: search interval not reached');
return false;
}
}
Logger::debug('@@@ phototrack: search interval reached last ' . $last . ' search interval ' . $search_interval);
return true;
}
function phototrack_cron($a, $b) {
return; // @@@ something is broken
if (!phototrack_cron_time()) {
return;
}
DI::config()->set('phototrack', 'last_search', time());
$remaining = 0;
$remaining += phototrack_search_table($a, 'post-content', 'uri-id');
$remaining += phototrack_search_table($a, 'contact', 'id');
$remaining += phototrack_search_table($a, 'fcontact', 'id');
$remaining += phototrack_search_table($a, 'fsuggest', 'id');
$remaining += phototrack_search_table($a, 'gcontact', 'id');
DI::config()->set('phototrack', 'remaining_items', $remaining);
if ($remaining === 0) {
phototrack_tidy();
}
}
function phototrack_tidy() {
$batch_size = phototrack_batch_size();
DBA::e('CREATE TABLE IF NOT EXISTS `phototrack-temp` (`resource-id` char(255) not null)');
DBA::e('INSERT INTO `phototrack-temp` SELECT DISTINCT(`resource-id`) FROM photo WHERE photo.`created` < DATE_SUB(NOW(), INTERVAL 2 MONTH)');
$rows = DBA::p('SELECT `phototrack-temp`.`resource-id` FROM `phototrack-temp` LEFT OUTER JOIN phototrack_photo_use ON (`phototrack-temp`.`resource-id` = phototrack_photo_use.`resource-id`) WHERE phototrack_photo_use.id IS NULL limit ' . /*$batch_size*/1000);
if (DBA::isResult($rows)) {
foreach ($rows as $row) {
Logger::debug('phototrack: remove photo ' . $row['resource-id']);
DBA::e('DELETE FROM photo WHERE `resource-id` = "' . $row['resource-id'] . '"');
}
Logger::info('phototrack_tidy: deleted ' . DBA::numRows($rows) . ' photos');
}
DBA::e('DROP TABLE `phototrack-temp`');
$rows = DBA::p('SELECT id FROM phototrack_photo_use WHERE checked < DATE_SUB(NOW(), INTERVAL 2 MONTH)');
foreach ($rows as $row) {
DBA::e( 'DELETE FROM phototrack_photo_use WHERE id = ' . $row['id']);
}
Logger::info('phototrack_tidy: deleted ' . DBA::numRows($rows) . ' phototrack_photo_use rows');
}

View file

@ -28,14 +28,10 @@ function phpmailer_load_config(ConfigFileManager $loader)
}
/**
* @param null|IEmail $email
* @param IEmail $email
*/
function phpmailer_emailer_send_prepare(?IEmail &$email)
function phpmailer_emailer_send_prepare(IEmail &$email)
{
if ($email === null) {
return;
}
// Passing `true` enables exceptions
$mailer = new PHPMailer(true);
try {

View file

@ -36,6 +36,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -44,7 +45,7 @@ function piwik_install() {
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
DI::logger()->notice("installed piwik addon");
Logger::notice("installed piwik addon");
}
function piwik_load_config(ConfigFileManager $loader)

View file

@ -8,6 +8,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -27,7 +28,7 @@ function planets_install()
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
DI::logger()->notice("installed planets");
Logger::notice("installed planets");
}
/**
@ -38,7 +39,7 @@ function planets_install()
*/
function planets_post_hook(&$item)
{
DI::logger()->notice('planets invoked');
Logger::notice('planets invoked');
if (!DI::userSession()->getLocalUserId()) {
/* non-zero if this is a logged in user of this system */

View file

@ -1025,7 +1025,7 @@ class phpnut
* see: https://docs.pnut.io/resources/posts/search
* @param string $query The search query. Supports
* normal search terms. Searches post text.
* @return string|array|false An array of associative arrays, each representing one post.
* @return array An array of associative arrays, each representing one post.
* or false on error
*/
public function searchPosts(array $params=[], string $query='', string $order='default')
@ -1769,7 +1769,7 @@ class phpnut
* see: https://docs.pnut.io/resources/messages/search
* @param string $query The search query. Supports
* normal search terms. Searches common channel raw.
* @return string|array|false An array of associative arrays, each representing one channel.
* @return array An array of associative arrays, each representing one channel.
* or false on error
*/
public function searchMessages(array $params=[], string $query='', string $order='default')

View file

@ -14,6 +14,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
@ -75,7 +76,7 @@ function pnut_connect()
try {
$token = $nut->getAccessToken($callback_url);
DI::logger()->debug('Got Token', [$token]);
Logger::debug('Got Token', [$token]);
$o = DI::l10n()->t('You are now authenticated with pnut.io.');
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token);
} catch (phpnutException $e) {
@ -265,8 +266,8 @@ function pnut_post_hook(array &$b)
return;
}
DI::logger()->notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
DI::logger()->debug('PNUT array', $b);
Logger::notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
Logger::debug('PNUT array', $b);
$token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token');
$nut = new phpnut\phpnut($token);
@ -275,7 +276,7 @@ function pnut_post_hook(array &$b)
$text = $msgarr['text'];
$raw = [];
DI::logger()->debug('PNUT msgarr', $msgarr);
Logger::debug('PNUT msgarr', $msgarr);
if (count($msgarr['parts']) > 1) {
$tstamp = time();
@ -291,23 +292,23 @@ function pnut_post_hook(array &$b)
if ($msgarr['type'] == 'photo') {
$fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true];
foreach ($msgarr['images'] as $image) {
DI::logger()->debug('PNUT image', $image);
Logger::debug('PNUT image', $image);
if (!empty($image['id'])) {
$photo = Photo::selectFirst([], ['id' => $image['id']]);
DI::logger()->debug('PNUT selectFirst');
Logger::debug('PNUT selectFirst');
} else {
$photo = Photo::createPhotoForExternalResource($image['url']);
DI::logger()->debug('PNUT createPhotoForExternalResource');
Logger::debug('PNUT createPhotoForExternalResource');
}
$picturedata = Photo::getImageForPhoto($photo);
DI::logger()->debug('PNUT photo', $photo);
Logger::debug('PNUT photo', $photo);
$picurefile = tempnam(System::getTempPath(), 'pnut');
file_put_contents($picurefile, $picturedata);
DI::logger()->debug('PNUT got file?', ['filename' => $picurefile]);
Logger::debug('PNUT got file?', ['filename' => $picurefile]);
$imagefile = $nut->createFile($picurefile, $fileraw);
DI::logger()->debug('PNUT file', ['pnutimagefile' => $imagefile]);
Logger::debug('PNUT file', ['pnutimagefile' => $imagefile]);
unlink($picurefile);
$raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']];
@ -317,5 +318,5 @@ function pnut_post_hook(array &$b)
$raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']];
$nut->createPost($text, ['raw' => $raw]);
DI::logger()->debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
Logger::debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
}

View file

@ -8,6 +8,7 @@
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -46,7 +47,7 @@ function public_server_register_account($b)
function public_server_cron($b)
{
DI::logger()->notice("public_server: cron start");
Logger::notice("public_server: cron start");
$users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
@ -95,7 +96,7 @@ function public_server_cron($b)
}
}
DI::logger()->notice("public_server: cron end");
Logger::notice("public_server: cron end");
}
function public_server_enotify(array &$b)

11
publicise/publicise.php Normal file
View file

@ -0,0 +1,11 @@
"SELECT `uid` FROM `contact` WHERE `id` = %d AND `reason` = 'publicise'", intval($item['contact-id']));
if (!$r1) {
return;
}
Logger::debug('Publicise: moving to wall: ' . $item['uid'] . ' ' . $item['contact-id'] . ' ' . $item['uri']);
$item['type'] = 'wall';
$item['wall'] = 1;
$item['private'] = 0;
}

View file

@ -0,0 +1,39 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<form method="post">
<table>
<thead>
<tr>
<th>{{$feed_t}}</th>
<th>{{$publicised_t}}</th>
<th>{{$comments_t}}</th>
<th>{{$expire_t}}</th>
</tr>
</thead>
<tbody>
{{foreach $feeds as $f}}
<tr>
<td>
<a href="{{$f.url}}">
<img style="vertical-align:middle" src='{{$f.micro}}'>
<span style="margin-left:1em">{{$f.name}}</span>
</a>
</td>
<td>
{{include file="field_yesno.tpl" field=$f.enabled}}
</td>
<td>
{{include file="field_yesno.tpl" field=$f.comments}}
</td>
<td>
<input name="publicise-expire-{{$f.id}}" value="{{$f.expire}}">
</td>
</tr>
{{/foreach}}
</tbody>
</table>
<input type="submit" size="70" value="{{$submit_t}}">
</form>

View file

@ -8,7 +8,9 @@
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
@ -105,7 +107,7 @@ function pumpio_registerclient($host)
$params['logo_url'] = DI::baseUrl() . '/images/friendica-256.png';
$params['redirect_uris'] = DI::baseUrl() . '/pumpio/connect';
DI::logger()->info('pumpio_registerclient: ' . $url . ' parameters', $params);
Logger::info('pumpio_registerclient: ' . $url . ' parameters', $params);
// @TODO Rewrite this to our own HTTP client
$ch = curl_init($url);
@ -120,10 +122,10 @@ function pumpio_registerclient($host)
if ($curl_info['http_code'] == '200') {
$values = json_decode($s);
DI::logger()->info('pumpio_registerclient: success ', (array)$values);
Logger::info('pumpio_registerclient: success ', (array)$values);
return $values;
}
DI::logger()->info('pumpio_registerclient: failed: ', $curl_info);
Logger::info('pumpio_registerclient: failed: ', $curl_info);
return false;
}
@ -136,7 +138,7 @@ function pumpio_connect()
$hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host');
if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) {
DI::logger()->notice('pumpio_connect: register client');
Logger::notice('pumpio_connect: register client');
$clientdata = pumpio_registerclient($hostname);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
@ -144,11 +146,11 @@ function pumpio_connect()
$consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key');
$consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret');
DI::logger()->info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
}
if (($consumer_key == '') || ($consumer_secret == '')) {
DI::logger()->notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
Logger::notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname);
}
@ -177,7 +179,7 @@ function pumpio_connect()
if (($success = $client->Initialize())) {
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
DI::logger()->info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
Logger::info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token', $client->access_token);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', $client->access_token_secret);
}
@ -189,11 +191,11 @@ function pumpio_connect()
}
if ($success) {
DI::logger()->notice('pumpio_connect: authenticated');
Logger::notice('pumpio_connect: authenticated');
$o = DI::l10n()->t('You are now authenticated to pumpio.');
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t('return to the connector page') . '</a>';
} else {
DI::logger()->notice('pumpio_connect: could not connect');
Logger::notice('pumpio_connect: could not connect');
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
}
@ -343,7 +345,7 @@ function pumpio_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
// Don't fork if it isn't a reply to a pump.io post
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
DI::logger()->notice('No pump.io parent found for item ' . $post['id']);
Logger::notice('No pump.io parent found for item ' . $post['id']);
$b['execute'] = false;
return;
}
@ -387,7 +389,7 @@ function pumpio_send(array &$b)
return;
}
DI::logger()->debug('pumpio_send: parameter ', $b);
Logger::debug('pumpio_send: parameter ', $b);
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
@ -397,7 +399,7 @@ function pumpio_send(array &$b)
$orig_post = Post::selectFirst([], $condition);
if (!DBA::isResult($orig_post)) {
DI::logger()->notice('pumpio_send: no pumpio post ' . $b['parent']);
Logger::notice('pumpio_send: no pumpio post ' . $b['parent']);
return;
} else {
$iscomment = true;
@ -407,7 +409,7 @@ function pumpio_send(array &$b)
$receiver = pumpio_getreceiver($b);
DI::logger()->notice('pumpio_send: receiver ', $receiver);
Logger::notice('pumpio_send: receiver ', $receiver);
if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
return;
@ -541,13 +543,13 @@ function pumpio_send(array &$b)
}
$post_id = $user->object->id;
DI::logger()->notice('pumpio_send ' . $username . ': success ' . $post_id);
Logger::notice('pumpio_send ' . $username . ': success ' . $post_id);
if ($post_id && $iscomment) {
DI::logger()->notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
Logger::notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
Item::update(['extid' => $post_id], ['id' => $b['id']]);
}
} else {
DI::logger()->notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
Logger::notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
Worker::defer();
}
}
@ -617,18 +619,16 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
}
if ($success) {
DI::logger()->notice('pumpio_action '.$username.' '.$action.': success '.$uri);
Logger::notice('pumpio_action '.$username.' '.$action.': success '.$uri);
} else {
DI::logger()->notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
Logger::notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
Worker::defer();
}
}
function pumpio_sync()
{
$addonHelper = DI::addonHelper();
if (!$addonHelper->isAddonEnabled('pumpio')) {
if (!Addon::isEnabled('pumpio')) {
return;
}
@ -639,15 +639,15 @@ function pumpio_sync()
if ($last) {
$next = $last + ($poll_interval * 60);
if ($next > time()) {
DI::logger()->notice('pumpio: poll intervall not reached');
Logger::notice('pumpio: poll intervall not reached');
return;
}
}
DI::logger()->notice('pumpio: cron_start');
Logger::notice('pumpio: cron_start');
$pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']);
foreach ($pconfigs as $rr) {
DI::logger()->notice('pumpio: mirroring user '.$rr['uid']);
Logger::notice('pumpio: mirroring user '.$rr['uid']);
pumpio_fetchtimeline($rr['uid']);
}
@ -662,12 +662,12 @@ function pumpio_sync()
foreach ($pconfigs as $rr) {
if ($abandon_days != 0) {
if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) {
DI::logger()->notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
Logger::notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
continue;
}
}
DI::logger()->notice('pumpio: importing timeline from user '.$rr['uid']);
Logger::notice('pumpio: importing timeline from user '.$rr['uid']);
pumpio_fetchinbox($rr['uid']);
// check for new contacts once a day
@ -684,7 +684,7 @@ function pumpio_sync()
}
}
DI::logger()->notice('pumpio: cron_end');
Logger::notice('pumpio: cron_end');
DI::keyValue()->set('pumpio_last_poll', time());
}
@ -729,7 +729,7 @@ function pumpio_fetchtimeline(int $uid)
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major';
DI::logger()->notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret);
Logger::notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret);
$useraddr = $username.'@'.$hostname;
@ -741,7 +741,7 @@ function pumpio_fetchtimeline(int $uid)
}
if (!$success) {
DI::logger()->notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
Logger::notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
return;
}
@ -801,11 +801,11 @@ function pumpio_fetchtimeline(int $uid)
}
}
DI::logger()->notice('pumpio: posting for user ' . $uid);
Logger::notice('pumpio: posting for user ' . $uid);
Item::insert($postarray, true);
DI::logger()->notice('pumpio: posting done - user ' . $uid);
Logger::notice('pumpio: posting done - user ' . $uid);
}
}
}
@ -846,16 +846,16 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
if (DBA::isResult($contact)) {
DI::logger()->notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
} else {
DI::logger()->notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
Logger::notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
}
}
function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcompletion = true)
{
if (empty($post->object->id)) {
DI::logger()->info('Got empty like: '.print_r($post, true));
Logger::info('Got empty like: '.print_r($post, true));
return;
}
@ -900,7 +900,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
];
if (Post::exists($condition)) {
DI::logger()->notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
return;
}
@ -934,7 +934,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
$ret = Item::insert($likedata);
DI::logger()->notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
}
function pumpio_get_contact($uid, $contact, $no_insert = false)
@ -1405,7 +1405,7 @@ function pumpio_fetchallcomments($uid, $id)
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
DI::logger()->notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
Logger::notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
$own_id = 'https://' . $hostname . '/' . $username;
@ -1430,7 +1430,7 @@ function pumpio_fetchallcomments($uid, $id)
$client->access_token = $otoken;
$client->access_token_secret = $osecret;
DI::logger()->notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
$item = new \stdClass();
@ -1495,7 +1495,7 @@ function pumpio_fetchallcomments($uid, $id)
$post->object = $item;
DI::logger()->notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
pumpio_dopost($client, $uid, $self, $post, $own_id, false);
}
}

View file

@ -1,5 +1,5 @@
<?php
use Friendica\Core\Logger;
use Friendica\DI;
function pumpio_sync_run(array $argv, int $argc) {
@ -8,7 +8,7 @@ function pumpio_sync_run(array $argv, int $argc) {
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > DI::config()->get('system', 'maxloadavg', 50)) {
DI::logger()->notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
Logger::notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
return;
}
}

View file

@ -20,6 +20,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -39,7 +40,7 @@ function randplace_install()
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
DI::logger()->notice("installed randplace");
Logger::notice("installed randplace");
}
function randplace_uninstall()
@ -49,7 +50,7 @@ function randplace_uninstall()
*
* Except hooks, they are all unregistered automatically and don't need to be unregistered manually.
*/
DI::logger()->notice("removed randplace");
Logger::notice("removed randplace");
}
function randplace_post_hook(&$item)
@ -60,7 +61,7 @@ function randplace_post_hook(&$item)
* - A status post by a profile owner
* - The profile owner must have allowed our addon
*/
DI::logger()->notice('randplace invoked');
Logger::notice('randplace invoked');
if (!DI::userSession()->getLocalUserId()) {
/* non-zero if this is a logged in user of this system */

View file

@ -3,6 +3,7 @@
namespace Friendica\Addon\ratioed;
use Friendica\Content\Pager;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -162,47 +163,47 @@ SELECT
SUM(original_like_point) AS original_like_total
FROM (
SELECT
reply_id,
like_date,
like_date IS NOT NULL AS like_point,
like_author = target_author AS target_like_point,
like_author = original_author AS original_like_point
reply_id,
like_date,
like_date IS NOT NULL AS like_point,
like_author = target_author AS target_like_point,
like_author = original_author AS original_like_point
FROM (
SELECT
original_post.`uri-id` AS original_id,
original_post.`author-id` AS original_author,
original_post.created AS original_date,
target_post.`uri-id` AS target_id,
target_post.`author-id` AS target_author,
target_post.created AS target_date,
reply_post.`uri-id` AS reply_id,
reply_post.`author-id` AS reply_author,
reply_post.created AS reply_date,
like_post.`uri-id` AS like_id,
like_post.`author-id` AS like_author,
like_post.created AS like_date
FROM
post AS original_post
JOIN
post AS target_post
ON
original_post.`uri-id` = target_post.`parent-uri-id`
JOIN
post AS reply_post
ON
target_post.`uri-id` = reply_post.`thr-parent-id` AND
reply_post.`author-id` = ? AND
reply_post.`author-id` != target_post.`author-id` AND
reply_post.`author-id` != original_post.`author-id` AND
reply_post.`uri-id` != reply_post.`thr-parent-id` AND
reply_post.vid = ? AND
reply_post.created > CURDATE() - INTERVAL 1 MONTH
LEFT OUTER JOIN
post AS like_post
ON
reply_post.`uri-id` = like_post.`thr-parent-id` AND
like_post.vid = ? AND
like_post.`author-id` != reply_post.`author-id`
SELECT
original_post.`uri-id` AS original_id,
original_post.`author-id` AS original_author,
original_post.created AS original_date,
target_post.`uri-id` AS target_id,
target_post.`author-id` AS target_author,
target_post.created AS target_date,
reply_post.`uri-id` AS reply_id,
reply_post.`author-id` AS reply_author,
reply_post.created AS reply_date,
like_post.`uri-id` AS like_id,
like_post.`author-id` AS like_author,
like_post.created AS like_date
FROM
post AS original_post
JOIN
post AS target_post
ON
original_post.`uri-id` = target_post.`parent-uri-id`
JOIN
post AS reply_post
ON
target_post.`uri-id` = reply_post.`thr-parent-id` AND
reply_post.`author-id` = ? AND
reply_post.`author-id` != target_post.`author-id` AND
reply_post.`author-id` != original_post.`author-id` AND
reply_post.`uri-id` != reply_post.`thr-parent-id` AND
reply_post.vid = ? AND
reply_post.created > CURDATE() - INTERVAL 1 MONTH
LEFT OUTER JOIN
post AS like_post
ON
reply_post.`uri-id` = like_post.`thr-parent-id` AND
like_post.vid = ? AND
like_post.`author-id` != reply_post.`author-id`
) AS post_meta
) AS reply_counts
', $contact_uid, $post_vid, $like_vid);
@ -225,29 +226,31 @@ FROM (
return $answer;
}
protected function fillReplyGuyData(&$user)
{
protected function fillReplyGuyData(&$user) {
$reply_guy_result = $this->getReplyGuyRow($user['user_contact_uid']);
if (DBA::isResult($reply_guy_result)) {
$reply_guy_result_row = DBA::fetch($reply_guy_result);
$user['reply_count'] = (int) $reply_guy_result_row['replies_total'] ?? 0;
$user['reply_likes'] = (int) $reply_guy_result_row['like_total'] ?? 0;
$user['reply_respondee_likes'] = (int) $reply_guy_result_row['target_like_total'] ?? 0;
$user['reply_op_likes'] = (int) $reply_guy_result_row['original_like_total'] ?? 0;
$user['reply_count'] = $reply_guy_result_row['replies_total'] ?? 0;
$user['reply_likes'] = $reply_guy_result_row['like_total'] ?? 0;
$user['reply_respondee_likes'] = $reply_guy_result_row['target_like_total'] ?? 0;
$user['reply_op_likes'] = $reply_guy_result_row['original_like_total'] ?? 0;
$denominator = $user['reply_likes'] + $user['reply_respondee_likes'] + $user['reply_op_likes'];
if ($user['reply_count'] === 0) {
if ($user['reply_count'] == 0) {
$user['reply_guy'] = false;
$user['reply_guy_score'] = 0;
} elseif ($denominator == 0) {
}
elseif ($denominator == 0) {
$user['reply_guy'] = true;
$user['reply_guy_score'] = '∞';
} else {
}
else {
$reply_guy_score = $user['reply_count'] / $denominator;
$user['reply_guy'] = $reply_guy_score >= 1.0;
$user['reply_guy_score'] = $this->sigFig($reply_guy_score, 2);
}
} else {
}
else {
$user['reply_count'] = "error";
$user['reply_likes'] = "error";
$user['reply_respondee_likes'] = "error";
@ -259,7 +262,7 @@ FROM (
protected function setupUserCallback(): \Closure
{
DI::logger()->debug("ratioed: setupUserCallback");
Logger::debug("ratioed: setupUserCallback");
$parentCallback = parent::setupUserCallback();
return function ($user) use ($parentCallback) {
$blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]);
@ -269,8 +272,9 @@ FROM (
if (DBA::isResult($self_contact_result)) {
$self_contact_result_row = DBA::fetch($self_contact_result);
$user['user_contact_uid'] = $self_contact_result_row['user_contact_uid'];
} else {
$user['user_contact_uid'] = null;
}
else {
$user['user_contact_uid'] = NULL;
}
if ($user['user_contact_uid']) {
@ -282,24 +286,28 @@ FROM (
if ($user['reactions'] > 0) {
$user['ratio'] = number_format($user['comments'] / $user['reactions'], 1, '.', '');
$user['ratioed'] = (float)($user['ratio']) >= 2.0;
} else {
}
else {
$user['reactions'] = 0;
if ($user['comments'] == 0) {
$user['comments'] = 0;
$user['ratio'] = 0;
$user['ratioed'] = false;
} else {
}
else {
$user['ratio'] = '∞';
$user['ratioed'] = false;
}
}
} else {
}
else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
$user['ratioed'] = false;
}
} else {
}
else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
@ -309,7 +317,7 @@ FROM (
$this->fillReplyGuyData($user);
$user = $parentCallback($user);
DI::logger()->debug("ratioed: setupUserCallback", [
Logger::debug("ratioed: setupUserCallback", [
'uid' => $user['uid'],
'blocked_by' => $user['blocked_by'],
'comments' => $user['comments'],

View file

@ -8,6 +8,7 @@
use Friendica\Addon\ratioed\RatioedPanel;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
/**
@ -17,7 +18,7 @@ function ratioed_install()
{
Hook::register('moderation_users_tabs', 'addon/ratioed/ratioed.php', 'ratioed_users_tabs');
DI::logger()->info("ratioed: installed");
Logger::info("ratioed: installed");
}
/**
@ -33,7 +34,7 @@ function ratioed_module() {}
* @param array $arr Parameters, including "tabs" which is the list to modify, and "selectedTab", which is the currently selected tab ID
*/
function ratioed_users_tabs(array &$arr) {
DI::logger()->debug("ratioed: users tabs");
Logger::debug("ratioed: users tabs");
array_push($arr['tabs'], [
'label' => DI::l10n()->t('Behaviour'),
@ -49,7 +50,7 @@ function ratioed_users_tabs(array &$arr) {
* @brief Displays the ratioed tab in the moderation panel
*/
function ratioed_content() {
DI::logger()->debug("ratioed: content");
Logger::debug("ratioed: content");
$ratioed = DI::getDice()->create(RatioedPanel::class, [$_SERVER]);
$httpException = DI::getDice()->create(Friendica\Module\Special\HTTPException::class);

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),

42
retriever/database.sql Normal file
View file

@ -0,0 +1,42 @@
CREATE TABLE IF NOT EXISTS `retriever_rule` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL,
`contact-id` int(11) NOT NULL,
`data` mediumtext NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `contact-id` (`contact-id`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE IF NOT EXISTS `retriever_item` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`item-uri` varbinary(255) NOT NULL,
`item-uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(10) unsigned NOT NULL DEFAULT '0',
`resource` int(11) NOT NULL,
`finished` tinyint(1) unsigned NOT NULL DEFAULT '0',
KEY `resource` (`resource`),
KEY `finished` (`finished`),
KEY `item-uid` (`item-uid`),
KEY `all` (`item-uri`, `item-uid`, `contact-id`),
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE IF NOT EXISTS `retriever_resource` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`item-uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(10) unsigned NOT NULL DEFAULT '0',
`type` char(255) NULL DEFAULT NULL,
`binary` int(1) NOT NULL DEFAULT 0,
`url` varbinary(700) NOT NULL,
`created` timestamp NOT NULL DEFAULT now(),
`completed` timestamp NULL DEFAULT NULL,
`last-try` timestamp NULL DEFAULT NULL,
`num-tries` int(11) NOT NULL DEFAULT 0,
`data` mediumblob NULL DEFAULT NULL,
`http-code` smallint(1) unsigned NULL DEFAULT NULL,
`redirect-url` varbinary(700) NOT NULL,
KEY `url` (`url`),
KEY `completed` (`completed`),
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

1074
retriever/retriever.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
{{include file="field_input.tpl" field=$downloads_per_cron}}
{{include file="field_checkbox.tpl" field=$allow_images}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}"></div>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" version="4.0"/>
<xsl:template match="text()"/>
{{function clause_xpath}}{{if !$clause.attribute}}{{$clause.element}}{{elseif $clause.attribute == 'class'}}{{$clause.element}}[contains(concat(' ', normalize-space(@class), ' '), '{{$clause.value}}')]{{else}}{{$clause.element}}[@{{$clause.attribute}}='{{$clause.value}}']{{/if}}{{/function}}
{{foreach $spec.include as $clause}}
<xsl:template match="{{clause_xpath clause=$clause}}">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="remove"/>
</xsl:copy>
</xsl:template>{{/foreach}}
{{foreach $spec.exclude as $clause}}
<xsl:template match="{{clause_xpath clause=$clause}}" mode="remove"/>{{/foreach}}
<xsl:template match="node()|@*" mode="remove">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="remove"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- attempt to replace relative URLs with absolute URLs -->
<!-- http://stackoverflow.com/questions/3824631/replace-href-value-in-anchor-tags-of-html-using-xslt -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" version="4.0"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*/@src[starts-with(.,'.')]">
<xsl:attribute name="src">
<xsl:value-of select="concat('{{$dirurl}}/',.)"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="*/@src[starts-with(.,'/')]">
<xsl:attribute name="src">
<xsl:value-of select="concat('{{$rooturl}}',.)"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="*/@src[not(starts-with(.,'/')) and not(contains(.,':'))]">
<xsl:attribute name="src">
<xsl:value-of select="concat('{{$dirurl}}',.)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,163 @@
<h2>Retriever Plugin Help</h2>
<p>
This plugin replaces the short excerpts you normally get in RSS feeds
with the full content of the article from the source website. You
specify which part of the page you're interested in with a set of
rules. When each item arrives, the plugin downloads the full page
from the website, extracts content using the rules, and replaces the
original article.
</p>
<p>
There's a few reasons you may want to do this. The source website
might be slow or overloaded. The source website might be
untrustworthy, in which case using Friendica to scrub the HTML is a
good idea. You might be on a LAN that blacklists certain websites.
It also works neatly with the mailstream plugin, allowing you to read
a news stream comfortably without needing continuous Internet
connectivity.
</p>
<p>
However, setting up retriever can be quite tricky since it depends on
the internal design of the website. That was designed to make life
easy for the website's developers, not for you. You'll need to have
some familiarity with HTML, and be willing to adapt when the website
suddenly changes everything without notice.
</p>
<h3>Configuring Retriever for a feed</h3>
<p>
To set up retriever for an RSS feed, go to the "Contacts" page and
find your feed. Then click on the drop-down menu on the contact.
Select "Retriever" to get to the retriever configuration.
</p>
<p>
The "Include" configuration section specifies parts of the page to
include in the article. Each row has three components:
</p>
<ul>
<li>An HTML tag (e.g. "div", "span", "p")</li>
<li>An attribute (usually "class" or "id")</li>
<li>A value for the attribute</li>
</ul>
<p>
A simple case is when the article is wrapped in a "div" element:
</p>
<pre>
...
&lt;div class="ArticleWrapper"&gt;
&lt;h2&gt;Man Bites Dog&lt;/h2&gt;
&lt;img src="mbd.jpg"&gt;
&lt;p&gt;
Residents of the sleepy community of Nowheresville were
shocked yesterday by the sight of creepy local weirdo Jim
McOddman assaulting innocent local dog Snufflekins with his
false teeth.
&lt;/p&gt;
...
&lt;/div&gt;
...
</pre>
<p>
You then specify the tag "div", attribute "class", and value
"ArticleWrapper". Everything else in the page, such as navigation
panels and menus and footers and so on, will be discarded. If there
is more than one section of the page you want to include, specify each
one on a separate row. If the matching section contains some sections
you want to remove, specify those in the "Exclude" section in the same
way.
</p>
<p>
Once you've got a configuration that you think will work, you can try
it out on some existing articles. Type a number into the
"Retrospectively Apply" box and click "Submit". After a while
(exactly how long depends on your system's cron configuration) the new
articles should be available.
</p>
<h3>Techniques</h3>
<p>
You can leave the attribute and value blank to include all the
corresponding elements with the specified tag name. You can also use
a tag name of just an asterisk ("*"), which will match any element type with the
specified attribute regardless of the tag.
</p>
<p>
Note that the "class" attribute is a special case. Many web page
templates will put multiple different classes in the same element,
separated by spaces. If you specify an attribute of "class" it will
match an element if any of its classes matches the specified value.
For example:
</p>
<pre>
&lt;div class="article breaking-news"&gt;
</pre>
<p>
In this case you can specify a value of "article", or "breaking-news".
You can also specify "article breaking-news", but that won't match if
the website suddenly changes to "breaking-news article", so that's not
recommended.
</p>
<p>
One useful trick you can try is using the website's "print" pages.
Many news sites have print versions of all their articles. These are
usually drastically simplified compared to the live website page.
Sometimes this is a good way to get the whole article when it's
normally split across multiple pages.
</p>
<p>
Hopefully the URL for the print page is a predictable variant of the
normal article URL. For example, an article URL like:
</p>
<pre>
http://www.newssite.com/article-8636.html
</pre>
<p>
...might have a print version at:
</p>
<pre>
http://www.newssite.com/print/article-8636.html
</pre>
<p>
To change the URL used to retrieve the page, use the "URL Pattern" and
"URL Replace" fields. The pattern is a regular expression matching
part of the URL to replace. In this case, you might use a pattern of
"/article" and a replace string of "/print/article". A common pattern
is simply a dollar sign ("$"), used to add the replace string to the end of the URL.
</p>
<h3>Background Processing</h3>
<p>
Note that retrieving and processing the articles can take some time,
so it's done in the background. Incoming articles will be marked as
invisible while they're in the process of being downloaded. If a URL
fails, the plugin will keep trying at progressively longer intervals
for up to a month, in case the website is temporarily overloaded or
the network is down.
</p>
{{if $allow_images}}
<h3>Retrieving Images</h3>
<p>
Retriever can also optionally download images and store them in the
local Friendica instance. Just check the "Download Images" box. You
can also download images in every item from your network, whether it's
an RSS feed or not. Go to the "Settings" page and
click <a href="$config">"Plugin settings"</a>. Then check the "All
Photos" box in the "Retriever Settings" section and click "Submit".
</p>
{{/if}}
<h2>Configure Feeds:</h2>
<div>
{{foreach $feeds as $feed}}
<div class="contact-entry-wrapper" id="contact-entry-wrapper-{{$feed.id}}">
<a href="{{$feed.url}} title="{{$feed.img_hover}}">
<div class="contact-entry-photo-wrapper">
<div class="contact-entry-photo mframe" id="contact-entry-photo-{{$feed.id}}">
<img src="{{$feed.thumb}}" {{$feed.sparkle}} alt="{{$feed.name}}"/>
</div>
</div>
<div class="contact-entry-desc">
<div class="contact-entry-name" id="contact-entry-name-{{$feed.id}}">
{{$feed.name}}
</div>
</div>
</a>
</div>
{{/foreach}}
</div>

View file

@ -0,0 +1,154 @@
<div class="settings-block">
<script language="javascript">
function retriever_add_row(id)
{
var tbody = document.getElementById(id);
var last = tbody.rows[tbody.childElementCount - 1];
var count = +last.id.replace(id + '-', '');
count++;
var row = document.createElement('tr');
row.id = id + '-' + count;
var cell1 = document.createElement('td');
var inptag = document.createElement('input');
inptag.name = row.id + '-element';
cell1.appendChild(inptag);
row.appendChild(cell1);
var cell2 = document.createElement('td');
var inpatt = document.createElement('input');
inpatt.name = row.id + '-attribute';
cell2.appendChild(inpatt);
row.appendChild(cell2);
var cell3 = document.createElement('td');
var inpval = document.createElement('input');
inpval.name = row.id + '-value';
cell3.appendChild(inpval);
row.appendChild(cell3);
var cell4 = document.createElement('td');
var butrem = document.createElement('input');
butrem.id = row.id + '-rem';
butrem.type = 'button';
butrem.onclick = function(){retriever_remove_row(id, count)};
butrem.value = '{{$remove_t}}';
cell4.appendChild(butrem);
row.appendChild(cell4);
tbody.appendChild(row);
}
function retriever_remove_row(id, number)
{
var tbody = document.getElementById(id);
var row = document.getElementById(id + '-' + number);
tbody.removeChild(row);
}
function retriever_toggle_url_block()
{
var pattern = document.querySelector("#id_retriever_pattern").parentNode;
if (document.querySelector("#id_retriever_modurl").checked) {
pattern.style.display = "block";
}
else {
pattern.style.display = "none";
}
var replace = document.querySelector("#id_retriever_replace").parentNode;
if (document.querySelector("#id_retriever_modurl").checked) {
replace.style.display = "block";
}
else {
replace.style.display = "none";
}
}
function retriever_toggle_cookiedata_block()
{
var div = document.querySelector("#id_retriever_cookiedata").parentNode;
if (document.querySelector("#id_retriever_storecookies").checked) {
div.style.display = "block";
}
else {
div.style.display = "none";
}
}
document.addEventListener('DOMContentLoaded', function() {
retriever_toggle_url_block();
document.querySelector("#id_retriever_modurl").addEventListener('change', retriever_toggle_url_block, false);
retriever_toggle_cookiedata_block();
document.querySelector("#id_retriever_storecookies").addEventListener('change', retriever_toggle_cookiedata_block, false);
}, false);
</script>
<h2>{{$title}}</h2>
<p><a href="{{$help}}">{{$help_t}}</a></p>
<form method="post">
<input type="hidden" name="id" value="{{$id}}">
{{include file="field_checkbox.tpl" field=$enable}}
<h3>{{$include_t}}:</h3>
<div>
<table>
<thead>
<tr><th>{{$tag_t}}</th><th>{{$attribute_t}}</th><th>{{$value_t}}</th></tr>
</thead>
<tbody id="retriever-include">
{{if $include}}
{{foreach $include as $k=>$m}}
<tr id="retriever-include-{{$k}}">
<td><input name="retriever-include-{{$k}}-element" value="{{$m.element}}"></td>
<td><input name="retriever-include-{{$k}}-attribute" value="{{$m.attribute}}"></td>
<td><input name="retriever-include-{{$k}}-value" value="{{$m.value}}"></td>
<td><input id="retrieve-include-{{$k}}-rem" type="button" onclick="retriever_remove_row('retriever-include', {{$k}})" value="{{$remove_t}}"></td>
</tr>
{{/foreach}}
{{else}}
<tr id="retriever-include-0">
<td><input name="retriever-include-0-element"></td>
<td><input name="retriever-include-0-attribute"></td>
<td><input name="retriever-include-0-value"></td>
<td><input id="retrieve-include-0-rem" type="button" onclick="retriever_remove_row('retriever-include', 0)" value="{{$remove_t}}"></td>
</tr>
{{/if}}
</tbody>
</table>
<input type="button" onclick="retriever_add_row('retriever-include')" value="{{$add_t}}">
</div>
<h3>{{$exclude_t}}:</h3>
<div>
<table>
<thead>
<tr><th>{{$tag_t}}</th><th>{{$attribute_t}}</th><th>{{$value_t}}</th></tr>
</thead>
<tbody id="retriever-exclude">
{{if $exclude}}
{{foreach $exclude as $k=>$r}}
<tr id="retriever-exclude-{{$k}}">
<td><input name="retriever-exclude-{{$k}}-element" value="{{$r.element}}"></td>
<td><input name="retriever-exclude-{{$k}}-attribute" value="{{$r.attribute}}"></td>
<td><input name="retriever-exclude-{{$k}}-value" value="{{$r.value}}"></td>
<td><input id="retrieve-exclude-{{$k}}-rem" type="button" onclick="retriever_remove_row('retriever-exclude', {{$k}})" value="{{$remove_t}}"></td>
</tr>
{{/foreach}}
{{else}}
<tr id="retriever-exclude-0">
<td><input name="retriever-exclude-0-element"></td>
<td><input name="retriever-exclude-0-attribute"></td>
<td><input name="retriever-exclude-0-value"></td>
<td><input id="retrieve-exclude-0-rem" type="button" onclick="retriever_remove_row('retriever-exclude', 0)" value="{{$remove_t}}"></td>
</tr>
{{/if}}
</tbody>
</table>
<input type="button" onclick="retriever_add_row('retriever-exclude')" value="{{$add_t}}">
</div>
{{include file="field_checkbox.tpl" field=$modurl}}
{{include file="field_input.tpl" field=$pattern}}
{{include file="field_input.tpl" field=$replace}}
{{if $allow_images}}
{{include file="field_checkbox.tpl" field=$images}}
{{/if}}
{{include file="field_textarea.tpl" field=$customxslt}}
{{include file="field_checkbox.tpl" field=$storecookies}}
{{include file="field_textarea.tpl" field=$cookiedata}}
{{include file="field_input.tpl" field=$retrospective}}
<input type="submit" size="70" value="{{$submit_t}}">
</form>
</div>

View file

@ -0,0 +1,5 @@
<p><a href="{{$help}}">Get Help</a></p>
{{if $allow_images}}
{{include file="field_checkbox.tpl" field=$allphotos}}
{{/if}}
{{include file="field_checkbox.tpl" field=$oembed}}

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-17 03:23+0100\n"
"POT-Creation-Date: 2021-05-18 07:23+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,82 +17,82 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: saml.php:81
msgid "managed via SAML authentication"
msgstr ""
#: saml.php:246
#: saml.php:231
msgid "Settings statement"
msgstr ""
#: saml.php:247
msgid "A statement on the settings page explaining where the user should go to change their e-mail and password. BBCode allowed."
#: saml.php:232
msgid ""
"A statement on the settings page explaining where the user should go to "
"change their e-mail and password. BBCode allowed."
msgstr ""
#: saml.php:252
#: saml.php:237
msgid "IdP ID"
msgstr ""
#: saml.php:253
msgid "Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/user)."
#: saml.php:238
msgid ""
"Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/"
"user)."
msgstr ""
#: saml.php:257
#: saml.php:242
msgid "Client ID"
msgstr ""
#: saml.php:258
#: saml.php:243
msgid "Identifier assigned to client by the identity provider (IdP)."
msgstr ""
#: saml.php:262
#: saml.php:247
msgid "IdP SSO URL"
msgstr ""
#: saml.php:263
#: saml.php:248
msgid "The URL for your identity provider's SSO endpoint."
msgstr ""
#: saml.php:267
#: saml.php:252
msgid "IdP SLO request URL"
msgstr ""
#: saml.php:268
#: saml.php:253
msgid "The URL for your identity provider's SLO request endpoint."
msgstr ""
#: saml.php:272
#: saml.php:257
msgid "IdP SLO response URL"
msgstr ""
#: saml.php:273
#: saml.php:258
msgid "The URL for your identity provider's SLO response endpoint."
msgstr ""
#: saml.php:277
#: saml.php:262
msgid "SP private key"
msgstr ""
#: saml.php:278
#: saml.php:263
msgid "The private key the addon should use to authenticate."
msgstr ""
#: saml.php:282
#: saml.php:267
msgid "SP certificate"
msgstr ""
#: saml.php:283
#: saml.php:268
msgid "The certficate for the addon's private key."
msgstr ""
#: saml.php:287
#: saml.php:272
msgid "IdP certificate"
msgstr ""
#: saml.php:288
#: saml.php:273
msgid "The x509 certficate for your identity provider."
msgstr ""
#: saml.php:291
#: saml.php:276
msgid "Save Settings"
msgstr ""

1
saml/saml.css Normal file
View file

@ -0,0 +1 @@
#settings-form > div:first-of-type, #settings-form > h2:first-of-type, #wrapper_mpassword, #wrapper_email { display: none !important; }

View file

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -62,7 +63,7 @@ function saml_metadata()
);
}
} catch (Exception $e) {
DI::logger()->error($e->getMessage());
Logger::error($e->getMessage());
}
}
@ -74,38 +75,18 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer');
}
function saml_head(string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}
function saml_footer(string &$body)
{
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
$samlhint = DI::l10n()->t('managed via SAML authentication');
$body .= <<<EOL
<script>
var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); }
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);
}
// Frio theme
if ( document.getElementById('password-settings-collapse') != null ) {
document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));
}
if ( document.getElementById('id_mpassword_wrapper') != null ) {
document.getElementById('id_mpassword_wrapper').parentNode.appendChild(saml_hint.cloneNode(true));
document.getElementById('id_mpassword_wrapper').remove();
document.getElementById('id_email').nextElementSibling.classList.add('help-block');
}
// Vier theme
if ( document.getElementById('wrapper_mpassword') != null ) {
document.getElementById('wrapper_mpassword').remove();
document.getElementById('id_email').nextElementSibling.classList.add('field_help');
}
if ( document.getElementById('wrapper_password') != null ) {
document.getElementById('wrapper_password').parentNode.replaceChildren(saml_hint.cloneNode(true));
}
</script>
EOL;
}
@ -126,7 +107,7 @@ function saml_is_configured()
function saml_sso_initiate(string &$body)
{
if (!saml_is_configured()) {
DI::logger()->warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
return;
}
@ -155,7 +136,7 @@ function saml_sso_reply()
if (!empty($errors)) {
echo 'Errors encountered.';
DI::logger()->error(implode(', ', $errors));
Logger::error(implode(', ', $errors));
exit();
}
@ -191,7 +172,7 @@ function saml_sso_reply()
function saml_slo_initiate()
{
if (!saml_is_configured()) {
DI::logger()->warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
return;
}
@ -222,7 +203,7 @@ function saml_slo_reply()
if (empty($errors)) {
$auth->redirectTo(DI::baseUrl());
} else {
DI::logger()->error(implode(', ', $errors));
Logger::error(implode(', ', $errors));
}
}
@ -315,7 +296,7 @@ function saml_addon_admin_post()
function saml_create_user($username, $email, $name)
{
if (!strlen($email) || !strlen($name)) {
DI::logger()->error('Could not create user: no email or username given.');
Logger::error('Could not create user: no email or username given.');
return false;
}
@ -337,7 +318,7 @@ function saml_create_user($username, $email, $name)
return $user;
} catch (Exception $e) {
DI::logger()->error(
Logger::error(
'Exception while creating user',
[
'username' => $username,

View file

@ -8,6 +8,7 @@
use Friendica\Addon\securemail\SecureTestEmail;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Object\EMail\IEmail;
@ -21,7 +22,7 @@ function securemail_install()
Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10);
DI::logger()->notice('installed securemail');
Logger::notice('installed securemail');
}
/**

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

@ -976,7 +976,7 @@ class CodebirdSN
* @param string $method The method that has been called
* @param string $reply The actual reply, JSON-encoded or URL-encoded
*
* @return string|array|object The parsed reply
* @return array|object The parsed reply
*/
protected function _parseApiReply($method, $reply)
{

View file

@ -12,7 +12,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitteroauth.php';
*/
class StatusNetOAuth extends TwitterOAuth
{
public function get_maxlength()
function get_maxlength()
{
$config = $this->get($this->host . 'statusnet/config.json');
if (empty($config)) {
@ -21,27 +21,27 @@ class StatusNetOAuth extends TwitterOAuth
return $config->site->textlimit;
}
public function accessTokenURL()
function accessTokenURL()
{
return $this->host . 'oauth/access_token';
}
public function authenticateURL()
function authenticateURL()
{
return $this->host . 'oauth/authenticate';
}
public function authorizeURL()
function authorizeURL()
{
return $this->host . 'oauth/authorize';
}
public function requestTokenURL()
function requestTokenURL()
{
return $this->host . 'oauth/request_token';
}
public function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
{
parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$this->host = $apipath;
@ -52,9 +52,9 @@ class StatusNetOAuth extends TwitterOAuth
*
* Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
*
* @return array|object|mixed API results
* @return array|object API results
*/
public function http($url, $method, $postfields = NULL)
function http($url, $method, $postfields = NULL)
{
$this->http_info = [];
$ci = curl_init();

View file

@ -45,11 +45,11 @@ class TwitterOAuth
public $http_header;
/**
* Contains the last HTTP request info
* @var array
* @var string
*/
public $http_info;
/** @var OAuthToken|null */
/** @var OAuthToken */
private $token;
/** @var OAuthConsumer */
private $consumer;
@ -59,27 +59,27 @@ class TwitterOAuth
/**
* Set API URLS
*/
public function accessTokenURL()
function accessTokenURL()
{
return 'https://api.twitter.com/oauth/access_token';
}
public function authenticateURL()
function authenticateURL()
{
return 'https://twitter.com/oauth/authenticate';
}
public function authorizeURL()
function authorizeURL()
{
return 'https://twitter.com/oauth/authorize';
}
public function requestTokenURL()
function requestTokenURL()
{
return 'https://api.twitter.com/oauth/request_token';
}
public function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
{
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
@ -96,7 +96,7 @@ class TwitterOAuth
* @param callable $oauth_callback
* @return array
*/
public function getRequestToken($oauth_callback = null)
function getRequestToken($oauth_callback = null)
{
$parameters = [];
if (!empty($oauth_callback)) {
@ -114,7 +114,7 @@ class TwitterOAuth
*
* @return string
*/
public function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE)
{
if (is_array($token)) {
$token = $token['oauth_token'];
@ -137,7 +137,7 @@ class TwitterOAuth
* "user_id" => "9436992",
* "screen_name" => "abraham")
*/
public function getAccessToken($oauth_verifier = FALSE)
function getAccessToken($oauth_verifier = FALSE)
{
$parameters = [];
if (!empty($oauth_verifier)) {
@ -162,7 +162,7 @@ class TwitterOAuth
* "screen_name" => "abraham",
* "x_auth_expires" => "0")
*/
public function getXAuthToken($username, $password)
function getXAuthToken($username, $password)
{
$parameters = [];
$parameters['x_auth_username'] = $username;
@ -182,7 +182,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function get($url, $parameters = [])
function get($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -199,7 +199,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function post($url, $parameters = [])
function post($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -216,7 +216,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function delete($url, $parameters = [])
function delete($url, $parameters = [])
{
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
@ -234,7 +234,7 @@ class TwitterOAuth
* @param array $parameters
* @return mixed|string
*/
public function oAuthRequest($url, $method, $parameters)
function oAuthRequest($url, $method, $parameters)
{
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
@ -258,9 +258,9 @@ class TwitterOAuth
* @param string $url
* @param string $method
* @param mixed $postfields
* @return string|bool|mixed API results
* @return string API results
*/
public function http($url, $method, $postfields = null)
function http($url, $method, $postfields = null)
{
$this->http_info = [];
$ci = curl_init();
@ -305,7 +305,7 @@ class TwitterOAuth
* @param string $header
* @return int
*/
public function getHeader($ch, $header)
function getHeader($ch, $header)
{
$i = strpos($header, ':');
if (!empty($i)) {

View file

@ -40,6 +40,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . '
use CodebirdSN\CodebirdSN;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
@ -57,7 +58,7 @@ function statusnet_install()
Hook::register('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
Hook::register('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
Hook::register('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
DI::logger()->notice('installed GNU Social');
Logger::notice('installed GNU Social');
}
function statusnet_jot_nets(array &$jotnets_fields)
@ -354,7 +355,7 @@ function statusnet_post_hook(array &$b)
return;
}
DI::logger()->notice('GNU Socialpost invoked');
Logger::notice('GNU Socialpost invoked');
DI::pConfig()->load($b['uid'], 'statusnet');
@ -406,7 +407,7 @@ function statusnet_post_hook(array &$b)
$cb->setToken($otoken, $osecret);
$result = $cb->statuses_update($postdata);
//$result = $dent->post('statuses/update', $postdata);
DI::logger()->info('statusnet_post send, result: ' . print_r($result, true) .
Logger::info('statusnet_post send, result: ' . print_r($result, true) .
"\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true));
if (!empty($result->source)) {
@ -414,9 +415,9 @@ function statusnet_post_hook(array &$b)
}
if (!empty($result->error)) {
DI::logger()->notice('Send to GNU Social failed: "' . $result->error . '"');
Logger::notice('Send to GNU Social failed: "' . $result->error . '"');
} elseif ($iscomment) {
DI::logger()->notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']);
Logger::notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']);
Item::update(['extid' => $hostname . '::' . $result->id, 'body' => $result->text], ['id' => $b['id']]);
}
}

View file

@ -7,8 +7,8 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
use thiagoalessio\TesseractOCR\TesseractOCR;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
@ -17,7 +17,7 @@ function tesseract_install()
{
Hook::register('ocr-detection', __FILE__, 'tesseract_ocr_detection');
DI::logger()->notice('installed tesseract');
Logger::notice('installed tesseract');
}
function tesseract_ocr_detection(&$media)
@ -33,6 +33,6 @@ function tesseract_ocr_detection(&$media)
$ocr->imageData($media['img_str'], strlen($media['img_str']));
$media['description'] = $ocr->run();
} catch (\Throwable $th) {
DI::logger()->info('Error calling TesseractOCR', ['message' => $th->getMessage()]);
Logger::info('Error calling TesseractOCR', ['message' => $th->getMessage()]);
}
}

View file

@ -14,6 +14,7 @@ use Friendica\Content\Text\NPF;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
@ -59,7 +60,7 @@ function tumblr_install()
Hook::register('check_item_notification', __FILE__, 'tumblr_check_item_notification');
Hook::register('probe_detect', __FILE__, 'tumblr_probe_detect');
Hook::register('item_by_link', __FILE__, 'tumblr_item_by_link');
DI::logger()->info('installed tumblr');
Logger::info('installed tumblr');
}
function tumblr_load_config(ConfigFileManager $loader)
@ -120,16 +121,16 @@ function tumblr_item_by_link(array &$hookData)
return;
}
DI::logger()->debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]);
Logger::debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]);
$parameters = ['id' => $matches[2], 'reblog_info' => false, 'notes_info' => false, 'npf' => false];
$result = tumblr_get($hookData['uid'], 'blog/' . $matches[1] . '/posts', $parameters);
if ($result->meta->status > 399) {
DI::logger()->notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]);
Logger::notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]);
return [];
}
DI::logger()->debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]);
Logger::debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]);
if (!empty($result->response->posts)) {
$hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid'], Item::PR_FETCHED);
Item::incrementInbound(Protocol::TUMBLR);
@ -158,20 +159,20 @@ function tumblr_follow(array &$hook_data)
return;
}
DI::logger()->debug('Check if contact is Tumblr', ['url' => $hook_data['url']]);
Logger::debug('Check if contact is Tumblr', ['url' => $hook_data['url']]);
$fields = tumblr_get_contact_by_url($hook_data['url'], $uid);
if (empty($fields)) {
DI::logger()->debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]);
Logger::debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]);
return;
}
$result = tumblr_post($uid, 'user/follow', ['url' => $fields['url']]);
if ($result->meta->status <= 399) {
$hook_data['contact'] = $fields;
DI::logger()->debug('Successfully start following', ['url' => $fields['url']]);
Logger::debug('Successfully start following', ['url' => $fields['url']]);
} else {
DI::logger()->notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]);
Logger::notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]);
}
}
@ -391,17 +392,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);
}
@ -419,11 +415,11 @@ function tumblr_cron()
if ($last) {
$next = $last + ($poll_interval * 60);
if ($next > time()) {
DI::logger()->notice('poll interval not reached');
Logger::notice('poll interval not reached');
return;
}
}
DI::logger()->notice('cron_start');
Logger::notice('cron_start');
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
@ -436,30 +432,30 @@ function tumblr_cron()
foreach ($pconfigs as $pconfig) {
if ($abandon_days != 0) {
if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) {
DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
continue;
}
}
DI::logger()->notice('importing timeline - start', ['user' => $pconfig['uid']]);
Logger::notice('importing timeline - start', ['user' => $pconfig['uid']]);
tumblr_fetch_dashboard($pconfig['uid'], $last);
tumblr_fetch_tags($pconfig['uid'], $last);
DI::logger()->notice('importing timeline - done', ['user' => $pconfig['uid']]);
Logger::notice('importing timeline - done', ['user' => $pconfig['uid']]);
}
$last_clean = DI::keyValue()->get('tumblr_last_clean');
if (empty($last_clean) || ($last_clean + 86400 < time())) {
DI::logger()->notice('Start contact cleanup');
Logger::notice('Start contact cleanup');
$contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::TUMBLR, 0, Contact::NOTHING]);
while ($contact = DBA::fetch($contacts)) {
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
}
DBA::close($contacts);
DI::keyValue()->set('tumblr_last_clean', time());
DI::logger()->notice('Contact cleanup done');
Logger::notice('Contact cleanup done');
}
DI::logger()->notice('cron_end');
Logger::notice('cron_end');
DI::keyValue()->set('tumblr_last_poll', time());
}
@ -482,7 +478,7 @@ function tumblr_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) {
// Don't post if it isn't a reply to a tumblr post
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) {
DI::logger()->notice('No tumblr parent found', ['item' => $post['id']]);
Logger::notice('No tumblr parent found', ['item' => $post['id']]);
$b['execute'] = false;
return;
}
@ -529,20 +525,20 @@ function tumblr_send(array &$b)
}
if ($b['gravity'] != Item::GRAVITY_PARENT) {
DI::logger()->debug('Got comment', ['item' => $b]);
Logger::debug('Got comment', ['item' => $b]);
$parent = tumblr_get_post_from_uri($b['thr-parent']);
if (empty($parent)) {
DI::logger()->notice('No tumblr post', ['thr-parent' => $b['thr-parent']]);
Logger::notice('No tumblr post', ['thr-parent' => $b['thr-parent']]);
return;
}
DI::logger()->debug('Parent found', ['parent' => $parent]);
Logger::debug('Parent found', ['parent' => $parent]);
$page = tumblr_get_page($b['uid']);
if ($b['gravity'] == Item::GRAVITY_COMMENT) {
DI::logger()->notice('Commenting is not supported (yet)');
Logger::notice('Commenting is not supported (yet)');
} else {
if (($b['verb'] == Activity::LIKE) && !$b['deleted']) {
$params = ['id' => $parent['id'], 'reblog_key' => $parent['reblog_key']];
@ -566,12 +562,12 @@ function tumblr_send(array &$b)
}
if ($result->meta->status < 400) {
DI::logger()->info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]);
Logger::info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]);
if (!$b['deleted'] && !empty($result->response->id_string)) {
Item::update(['extid' => 'tumblr::' . $result->response->id_string], ['guid' => $b['guid']]);
}
} else {
DI::logger()->notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
Logger::notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
}
}
return;
@ -669,9 +665,9 @@ function tumblr_send_legacy(array $b)
$result = tumblr_post($b['uid'], 'blog/' . $page . '/post', $params);
if ($result->meta->status < 400) {
DI::logger()->info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]);
Logger::info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]);
} else {
DI::logger()->notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
Logger::notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
}
}
@ -680,7 +676,7 @@ function tumblr_send_npf(array $post): bool
$page = tumblr_get_page($post['uid']);
if (empty($page)) {
DI::logger()->notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]);
Logger::notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]);
// "true" is returned, since the legacy function will fail as well.
return true;
}
@ -711,10 +707,10 @@ function tumblr_send_npf(array $post): bool
$result = tumblr_post($post['uid'], 'blog/' . $page . '/posts', $params);
if ($result->meta->status < 400) {
DI::logger()->info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]);
Logger::info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]);
return true;
} else {
DI::logger()->notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
Logger::notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]);
return false;
}
}
@ -747,25 +743,14 @@ 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)) {
DI::logger()->debug('Tag post imported', ['tag' => $tag, 'id' => $id]);
Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]);
$post = Post::selectFirst(['uri-id'], ['id' => $id]);
$stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $tag);
DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]);
Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]);
Item::incrementInbound(Protocol::TUMBLR);
}
}
@ -790,8 +775,8 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll)
$dashboard = tumblr_get($uid, 'user/dashboard', $parameters);
if ($dashboard->meta->status > 399) {
DI::logger()->notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]);
return;
Logger::notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]);
return [];
}
if (empty($dashboard->response->posts)) {
@ -803,7 +788,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll)
$last = $post->id;
}
DI::logger()->debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]);
Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]);
tumblr_process_post($post, $uid, Item::PR_NONE, $last_poll);
Item::incrementInbound(Protocol::TUMBLR);
@ -1078,7 +1063,7 @@ function tumblr_get_type_replacement(array $data, string $plink): string
}
default:
DI::logger()->notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]);
Logger::notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]);
$body = '';
}
@ -1133,9 +1118,9 @@ function tumblr_get_contact(stdClass $blog, int $uid): array
$cid = $contact['id'];
Contact::update($fields, ['id' => $cid], true);
}
DI::logger()->debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]);
Logger::debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]);
} else {
DI::logger()->debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]);
Logger::debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]);
}
if (!empty($avatar)) {
@ -1171,13 +1156,13 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra
];
if (!$update) {
DI::logger()->debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]);
Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]);
return $fields;
}
$info = tumblr_get($uid, 'blog/' . $blog->uuid . '/info');
if ($info->meta->status > 399) {
DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]);
Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]);
return $fields;
}
Item::incrementInbound(Protocol::TUMBLR);
@ -1199,7 +1184,7 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra
$fields['header'] = $info->response->blog->theme->header_image_focused;
DI::logger()->debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]);
Logger::debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]);
return $fields;
}
@ -1241,7 +1226,7 @@ function tumblr_get_blogs(int $uid): array
{
$userinfo = tumblr_get($uid, 'user/info');
if ($userinfo->meta->status > 399) {
DI::logger()->notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]);
Logger::notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]);
return [];
}
@ -1297,15 +1282,15 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array
return null;
}
DI::logger()->debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]);
Logger::debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]);
$info = tumblr_get($uid, 'blog/' . $blog . '/info');
if ($info->meta->status > 399) {
DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]);
Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]);
return null;
}
DI::logger()->debug('Got data', ['blog' => $blog, 'meta' => $info->meta]);
Logger::debug('Got data', ['blog' => $blog, 'meta' => $info->meta]);
Item::incrementInbound(Protocol::TUMBLR);
$baseurl = 'https://tumblr.com';
@ -1434,7 +1419,7 @@ function tumblr_get_token(int $uid, string $code = ''): string
$refresh_token = DI::pConfig()->get($uid, 'tumblr', 'refresh_token');
if (empty($code) && !empty($access_token) && ($expires_at > (time()))) {
DI::logger()->debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
Logger::debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
return $access_token;
}
@ -1446,11 +1431,11 @@ function tumblr_get_token(int $uid, string $code = ''): string
if (empty($refresh_token) && empty($code)) {
$result = tumblr_exchange_token($uid);
if (empty($result->refresh_token)) {
DI::logger()->info('Invalid result while exchanging token', ['uid' => $uid]);
Logger::info('Invalid result while exchanging token', ['uid' => $uid]);
return '';
}
$expires_at = time() + $result->expires_in;
DI::logger()->debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
Logger::debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
} else {
if (!empty($code)) {
$parameters['code'] = $code;
@ -1462,18 +1447,18 @@ function tumblr_get_token(int $uid, string $code = ''): string
$curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters);
if (!$curlResult->isSuccess()) {
DI::logger()->info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]);
Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]);
return '';
}
$result = json_decode($curlResult->getBodyString());
if (empty($result)) {
DI::logger()->info('Invalid result when updating token', ['uid' => $uid]);
Logger::info('Invalid result when updating token', ['uid' => $uid]);
return '';
}
$expires_at = time() + $result->expires_in;
DI::logger()->debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
Logger::debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]);
}
DI::pConfig()->set($uid, 'tumblr', 'access_token', $result->access_token);
@ -1517,7 +1502,7 @@ function tumblr_exchange_token(int $uid): stdClass
$response = $client->post('oauth2/exchange', ['auth' => 'oauth']);
return json_decode($response->getBody()->getContents());
} catch (RequestException $exception) {
DI::logger()->notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
return new stdClass;
}
}

File diff suppressed because it is too large Load diff

View file

@ -52,7 +52,7 @@ class WebDavConfig implements ICanConfigureStorage
$this->config = $config;
$this->client = $client;
$this->authOptions = [];
$this->authOptions = null;
if (!empty($this->config->get('webdav', 'username'))) {
$this->authOptions = [

View file

@ -9,6 +9,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -256,13 +257,13 @@ function wppost_send(array &$b)
EOT;
DI::logger()->debug('wppost: data: ' . $xml);
Logger::debug('wppost: data: ' . $xml);
$x = '';
if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBodyString();
}
DI::logger()->info('posted to wordpress: ' . $x);
Logger::info('posted to wordpress: ' . $x);
}
}