mirror of
https://github.com/friendica/friendica
synced 2025-02-08 17:38:51 +00:00
Merge branch 'develop' into xundeenergy/dropzone-upload-improvement
This commit is contained in:
commit
3980de94a4
181 changed files with 5714 additions and 5383 deletions
|
@ -52,4 +52,4 @@ $container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
|||
|
||||
$app = \Friendica\App::fromContainer($container);
|
||||
|
||||
$app->processEjabberd();
|
||||
$app->processEjabberd($_SERVER);
|
||||
|
|
|
@ -19,4 +19,4 @@ $container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
|||
|
||||
$app = \Friendica\App::fromContainer($container);
|
||||
|
||||
$app->processConsole($_SERVER['argv'] ?? []);
|
||||
$app->processConsole($_SERVER);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php daemon instead
|
||||
* @deprecated 2025.02 use `bin/console.php daemon` instead
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -24,11 +24,15 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "daemon");
|
||||
$_SERVER['argv'] = $argv;
|
||||
|
||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||
|
||||
$app = \Friendica\App::fromContainer($container);
|
||||
|
||||
$app->processConsole($argv);
|
||||
$app->processConsole($_SERVER);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php jetstream instead
|
||||
* @deprecated 2025.02 use `bin/console.php jetstream` instead
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
|
@ -19,11 +19,15 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "jetstream");
|
||||
$_SERVER['argv'] = $argv;
|
||||
|
||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||
|
||||
$app = \Friendica\App::fromContainer($container);
|
||||
|
||||
$app->processConsole($argv);
|
||||
$app->processConsole($_SERVER);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
* Starts the background processing
|
||||
*
|
||||
* @deprecated 2025.02 use bin/console.php worker instead
|
||||
* @deprecated 2025.02 use `bin/console.php worker` instead
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
|
@ -21,11 +21,15 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/worker.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
array_splice($argv, 1, 0, "worker");
|
||||
$_SERVER['argv'] = $argv;
|
||||
|
||||
$container = \Friendica\Core\DiceContainer::fromBasePath(dirname(__DIR__));
|
||||
|
||||
$app = \Friendica\App::fromContainer($container);
|
||||
|
||||
$app->processConsole($argv);
|
||||
$app->processConsole($_SERVER);
|
||||
|
|
|
@ -171,6 +171,7 @@
|
|||
"cs:fix": [
|
||||
"@cs:install",
|
||||
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
|
||||
]
|
||||
],
|
||||
"cs:fix-develop": "TARGET_BRANCH=develop COMMAND=fix bin/dev/fix-codestyle.sh"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,3 +156,97 @@ If you are interested in improving those clients, please contact the developers
|
|||
* iOS: *currently no client*
|
||||
* SailfishOS: **Friendiy** [src](https://kirgroup.com/projects/fabrixxm/harbour-friendly) - developed by [Fabio](https://kirgroup.com/profile/fabrixxm/profile)
|
||||
* Windows: **Friendica Mobile** for Windows versions [before 8.1](http://windowsphone.com/s?appid=e3257730-c9cf-4935-9620-5261e3505c67) and [Windows 10](https://www.microsoft.com/store/apps/9nblggh0fhmn) - developed by [Gerhard Seeber](http://mozartweg.dyndns.org/friendica/profile/gerhard/profile)
|
||||
|
||||
## Backward compatibility
|
||||
|
||||
### Backward Compatibility Promise
|
||||
|
||||
Friendica can be extended by addons.
|
||||
These addons relies on many classes and conventions from Friendica.
|
||||
As developers our work on Friendica should not break things in the addons without giving the addon maintainers a chance to fix their addons.
|
||||
Our goal is to build trust for the addon maintainers but also allow Friendica developers to move on.
|
||||
This is called the Backward Compatibility Promise.
|
||||
|
||||
Inspired by the [Symonfy BC promise](https://symfony.com/doc/current/contributing/code/bc.html) we promise BC for every class, interface, trait, enum, function, constant, etc., but with the exception of:
|
||||
|
||||
- Classes, interfaces, traits, enums, functions, methods, properties and constants marked as `@internal` or `@private`
|
||||
- Extending or modifying a `final` class or method in any way
|
||||
- Calling `private` methods (via Reflection)
|
||||
- Accessing `private` properties (via Reflection)
|
||||
- Accessing `private` methods (via Reflection)
|
||||
- Accessing `private` constants (via Reflection)
|
||||
- New properties on overridden `protected` methods
|
||||
- Possible name collisions with new methods in an extended class (addon developers should prefix their custom methods in the extending classes in an appropriate way)
|
||||
- Dropping support for every PHP version that has reached end of life
|
||||
|
||||
### Deprecation and removing features
|
||||
|
||||
As the development goes by Friendica needs to get rid of old code and concepts.
|
||||
This will be done in 3 steps to give addon maintainers a chance to adjust their addons.
|
||||
|
||||
**1. Label deprecation**
|
||||
|
||||
If we as the Friendica maintainers decide to remove some functions, classes, interface, etc. we start this by adding a `@deprecated` PHPDoc note on the code.
|
||||
For instance the class `Friendica\Core\Logger` should be removed, so we add the following note with a possible replacement:
|
||||
|
||||
```php
|
||||
/**
|
||||
* Logger functions
|
||||
*
|
||||
* @deprecated 2025.02 Use constructor injection or `DI::logger()` instead
|
||||
*/
|
||||
class Logger {/* ... */}
|
||||
```
|
||||
|
||||
This way addon developers might be notified early by their IDE or other tools that the usage of the class is deprecated.
|
||||
In Friendica we can now start to replace all occurrences and usage of this class with the alternative.
|
||||
|
||||
The deprecation label COULD be remain over multiple releases.
|
||||
As long as the code that is labeled with `@deprecated` is used inside Friendica or the official addon repository, it SHOULD NOT be hard deprecated.
|
||||
|
||||
**2. Hard deprecation**
|
||||
|
||||
If the deprecated code is no longer used inside Friendica or the official addons it MUST be hard deprecated.
|
||||
The code MUST NOT be deleted.
|
||||
Starting from the next release, it MUST be stay for at least 5 months.
|
||||
Hard deprecated code COULD remain longer than 5 months, depending on when a release appears.
|
||||
Addon developer MUST NOT consider that they have more than 5 months to adjust their code.
|
||||
|
||||
Hard deprecation code means that the code triggers an `E_USER_DEPRECATION` error if it is called.
|
||||
For instance with the deprecated class `Friendica\Core\Logger` the call of every method should trigger an error:
|
||||
|
||||
```php
|
||||
/**
|
||||
* Logger functions
|
||||
*
|
||||
* @deprecated 2025.02 Use constructor injection or `DI::logger()` instead
|
||||
*/
|
||||
class Logger {
|
||||
public static function info(string $message, array $context = [])
|
||||
{
|
||||
trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->info($message, $context);
|
||||
}
|
||||
|
||||
/* ... */
|
||||
}
|
||||
```
|
||||
|
||||
This way the maintainer or users of addons will be notified that the addon will stop working in one of the next releases.
|
||||
The addon maintainer now has at least 5 months or at least one release to fix the deprecations.
|
||||
|
||||
Please note that the deprecation message contains the release that will be released next.
|
||||
In the example the code was hard deprecated with release `2025.05`, so it COULD be removed earliest with the `2025.11` release.
|
||||
|
||||
**3. Code Removing**
|
||||
|
||||
We promise BC for deprecated code for at least 5 months, starting from the release the deprecation was announced.
|
||||
After this time the deprecated code COULD be remove within the next release.
|
||||
|
||||
Breaking changes MUST be happen only in a new release but MUST be hard deprecated first.
|
||||
The BC promise refers only to releases, respective the `stable` branch.
|
||||
Deprecated code on other branches like `develop` or RC branches could be removed earlier.
|
||||
This is not a BC break as long as the release will be published 5 months after the hard deprecation.
|
||||
|
||||
If a release breaks BC without deprecation or earlier than 5 months, this SHOULD considered as a bug and BC SHOULD be restored in a bugfix release.
|
||||
|
|
37
mod/item.php
37
mod/item.php
|
@ -19,7 +19,6 @@
|
|||
use Friendica\Content\Conversation;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -56,7 +55,7 @@ function item_post()
|
|||
*/
|
||||
if (!$preview && !empty($_REQUEST['post_id_random'])) {
|
||||
if (DI::session()->get('post-random') == $_REQUEST['post_id_random']) {
|
||||
Logger::warning('duplicate post');
|
||||
DI::logger()->warning('duplicate post');
|
||||
item_post_return(DI::baseUrl(), $return_path);
|
||||
} else {
|
||||
DI::session()->set('post-random', $_REQUEST['post_id_random']);
|
||||
|
@ -132,10 +131,10 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
|
|||
$post = DI::contentItem()->initializePost($post);
|
||||
|
||||
$post['edit'] = null;
|
||||
$post['post-type'] = $request['post_type'] ?? '';
|
||||
$post['wall'] = $request['wall'] ?? true;
|
||||
$post['post-type'] = $request['post_type'] ?? '';
|
||||
$post['wall'] = $request['wall'] ?? true;
|
||||
$post['pubmail'] = $request['pubmail_enable'] ?? false;
|
||||
$post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
|
||||
$post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
|
||||
$post['edited'] = $post['changed'] = $post['commented'] = $post['created'];
|
||||
$post['app'] = '';
|
||||
$post['inform'] = '';
|
||||
|
@ -165,18 +164,18 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
|
|||
// This enables interaction like starring and saving into folders
|
||||
if ($toplevel_item['uid'] == 0) {
|
||||
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], $post['uid'], ['post-reason' => Item::PR_ACTIVITY]);
|
||||
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]);
|
||||
DI::logger()->info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]);
|
||||
}
|
||||
|
||||
$post['parent'] = $toplevel_item['id'];
|
||||
$post['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$post['thr-parent'] = $parent_item['uri'];
|
||||
$post['wall'] = $toplevel_item['wall'];
|
||||
$post['parent'] = $toplevel_item['id'];
|
||||
$post['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$post['thr-parent'] = $parent_item['uri'];
|
||||
$post['wall'] = $toplevel_item['wall'];
|
||||
} else {
|
||||
$parent_item = [];
|
||||
$post['parent'] = 0;
|
||||
$post['gravity'] = Item::GRAVITY_PARENT;
|
||||
$post['thr-parent'] = $post['uri'];
|
||||
$parent_item = [];
|
||||
$post['parent'] = 0;
|
||||
$post['gravity'] = Item::GRAVITY_PARENT;
|
||||
$post['thr-parent'] = $post['uri'];
|
||||
}
|
||||
|
||||
$post = DI::contentItem()->getACL($post, $parent_item, $request);
|
||||
|
@ -197,7 +196,7 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
|
|||
|
||||
$post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
|
||||
if (!$post) {
|
||||
Logger::error('Item couldn\'t be fetched.', ['post_id' => $post_id]);
|
||||
DI::logger()->error('Item couldn\'t be fetched.', ['post_id' => $post_id]);
|
||||
if ($return_path) {
|
||||
DI::baseUrl()->redirect($return_path);
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
|
|||
DI::contentItem()->copyPermissions($post['thr-parent-id'], $post['uri-id'], $post['parent-uri-id']);
|
||||
}
|
||||
|
||||
Logger::debug('post_complete');
|
||||
DI::logger()->debug('post_complete');
|
||||
|
||||
item_post_return(DI::baseUrl(), $return_path);
|
||||
// NOTREACHED
|
||||
|
@ -297,7 +296,7 @@ function item_process(array $post, array $request, bool $preview, string $return
|
|||
}
|
||||
|
||||
if (!empty($post['cancel'])) {
|
||||
Logger::info('mod_item: post cancelled by addon.');
|
||||
DI::logger()->info('mod_item: post cancelled by addon.');
|
||||
if ($return_path) {
|
||||
DI::baseUrl()->redirect($return_path);
|
||||
}
|
||||
|
@ -324,7 +323,7 @@ function item_post_return($baseurl, $return_path)
|
|||
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
|
||||
}
|
||||
|
||||
Logger::debug('post_json', ['json' => $json]);
|
||||
DI::logger()->debug('post_json', ['json' => $json]);
|
||||
|
||||
System::jsonExit($json);
|
||||
}
|
||||
|
@ -444,7 +443,7 @@ function drop_item(int $id, string $return = ''): string
|
|||
item_redirect_after_action($item, $return);
|
||||
//NOTREACHED
|
||||
} else {
|
||||
Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'uid' => $item['uid'], 'cid' => $contact_id]);
|
||||
DI::logger()->warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'uid' => $item['uid'], 'cid' => $contact_id]);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
DI::baseUrl()->redirect('display/' . $item['guid']);
|
||||
//NOTREACHED
|
||||
|
|
293
mod/photos.php
293
mod/photos.php
|
@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -115,8 +114,8 @@ function photos_post()
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
$can_post = false;
|
||||
$visitor = 0;
|
||||
$can_post = false;
|
||||
$visitor = 0;
|
||||
|
||||
$page_owner_uid = intval($user['uid']);
|
||||
$community_page = in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_COMM_MAN]);
|
||||
|
@ -125,8 +124,8 @@ function photos_post()
|
|||
$can_post = true;
|
||||
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
|
||||
$can_post = true;
|
||||
$visitor = $contact_id;
|
||||
$can_post = true;
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
|
||||
if (!$can_post) {
|
||||
|
@ -142,7 +141,7 @@ function photos_post()
|
|||
System::exit();
|
||||
}
|
||||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
$str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
|
||||
$str_circle_allow = isset($_REQUEST['circle_allow']) ? $aclFormatter->toString($_REQUEST['circle_allow']) : $owner_record['allow_gid'] ?? '';
|
||||
$str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $owner_record['deny_cid'] ?? '';
|
||||
|
@ -152,7 +151,7 @@ function photos_post()
|
|||
if ($visibility === 'public') {
|
||||
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
|
||||
$str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_deny = '';
|
||||
} else if ($visibility === 'custom') {
|
||||
} elseif ($visibility === 'custom') {
|
||||
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
|
||||
// case that would make it public. So we always append the author's contact id to the allowed contacts.
|
||||
// See https://github.com/friendica/friendica/issues/9672
|
||||
|
@ -277,7 +276,7 @@ function photos_post()
|
|||
}
|
||||
|
||||
if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) {
|
||||
Logger::debug('rotate');
|
||||
DI::logger()->debug('rotate');
|
||||
|
||||
$photo = Photo::getPhotoForUser($page_owner_uid, $resource_id);
|
||||
|
||||
|
@ -318,7 +317,7 @@ function photos_post()
|
|||
|
||||
if (DBA::isResult($photos)) {
|
||||
$photo = $photos[0];
|
||||
$ext = Images::getExtensionByMimeType($photo['type']);
|
||||
$ext = Images::getExtensionByMimeType($photo['type']);
|
||||
Photo::update(
|
||||
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny],
|
||||
['resource-id' => $resource_id, 'uid' => $page_owner_uid]
|
||||
|
@ -333,9 +332,9 @@ function photos_post()
|
|||
if (DBA::isResult($photos) && !$item_id) {
|
||||
// Create item container
|
||||
$title = '';
|
||||
$uri = Item::newURI();
|
||||
$uri = Item::newURI();
|
||||
|
||||
$arr = [];
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $page_owner_uid;
|
||||
$arr['uri'] = $uri;
|
||||
|
@ -357,7 +356,7 @@ function photos_post()
|
|||
$arr['visible'] = 0;
|
||||
$arr['origin'] = 1;
|
||||
|
||||
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
|
||||
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
|
||||
|
||||
$item_id = Item::insert($arr);
|
||||
}
|
||||
|
@ -371,7 +370,7 @@ function photos_post()
|
|||
}
|
||||
|
||||
if (strlen($rawtags)) {
|
||||
$inform = '';
|
||||
$inform = '';
|
||||
|
||||
// if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
|
||||
$x = substr($rawtags, 0, 1);
|
||||
|
@ -380,13 +379,13 @@ function photos_post()
|
|||
}
|
||||
|
||||
$taginfo = [];
|
||||
$tags = BBCode::getTags($rawtags);
|
||||
$tags = BBCode::getTags($rawtags);
|
||||
|
||||
if (count($tags)) {
|
||||
foreach ($tags as $tag) {
|
||||
if (strpos($tag, '@') === 0) {
|
||||
$profile = '';
|
||||
$name = substr($tag, 1);
|
||||
$name = substr($tag, 1);
|
||||
$contact = Contact::getByURL($name);
|
||||
if (empty($contact)) {
|
||||
$newname = $name;
|
||||
|
@ -454,7 +453,7 @@ function photos_post()
|
|||
}
|
||||
$newinform .= $inform;
|
||||
|
||||
$fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||
$fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||
$condition = ['id' => $item_id];
|
||||
Item::update($fields, $condition);
|
||||
|
||||
|
@ -553,7 +552,7 @@ function photos_content()
|
|||
$datum = null;
|
||||
if (DI::args()->getArgc() > 3) {
|
||||
$datatype = DI::args()->getArgv()[2];
|
||||
$datum = DI::args()->getArgv()[3];
|
||||
$datum = DI::args()->getArgv()[3];
|
||||
} elseif ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
|
||||
$datatype = 'upload';
|
||||
} else {
|
||||
|
@ -583,12 +582,12 @@ function photos_content()
|
|||
$can_post = true;
|
||||
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
|
||||
if (DBA::isResult($contact)) {
|
||||
$can_post = true;
|
||||
$can_post = true;
|
||||
$remote_contact = true;
|
||||
$visitor = $contact_id;
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,14 +643,14 @@ function photos_content()
|
|||
$uploader = '';
|
||||
|
||||
$ret = [
|
||||
'post_url' => 'profile/' . $user['nickname'] . '/photos',
|
||||
'addon_text' => $uploader,
|
||||
'post_url' => 'profile/' . $user['nickname'] . '/photos',
|
||||
'addon_text' => $uploader,
|
||||
'default_upload' => true
|
||||
];
|
||||
|
||||
Hook::callAll('photo_upload_form', $ret);
|
||||
|
||||
$default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
|
||||
$default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
|
||||
$default_upload_submit = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_submit.tpl'), [
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
]);
|
||||
|
@ -676,22 +675,22 @@ function photos_content()
|
|||
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId()));
|
||||
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$pagename' => DI::l10n()->t('Upload Photos'),
|
||||
'$sessid' => session_id(),
|
||||
'$usage' => $usage_message,
|
||||
'$nickname' => $user['nickname'],
|
||||
'$newalbum' => DI::l10n()->t('New album name: '),
|
||||
'$existalbumtext' => DI::l10n()->t('or select existing album:'),
|
||||
'$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
|
||||
'$albumselect' => $albumselect,
|
||||
'$selname' => $selname,
|
||||
'$permissions' => DI::l10n()->t('Permissions'),
|
||||
'$aclselect' => $aclselect_e,
|
||||
'$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
|
||||
'$alt_uploader' => $ret['addon_text'],
|
||||
'$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
|
||||
'$pagename' => DI::l10n()->t('Upload Photos'),
|
||||
'$sessid' => session_id(),
|
||||
'$usage' => $usage_message,
|
||||
'$nickname' => $user['nickname'],
|
||||
'$newalbum' => DI::l10n()->t('New album name: '),
|
||||
'$existalbumtext' => DI::l10n()->t('or select existing album:'),
|
||||
'$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
|
||||
'$albumselect' => $albumselect,
|
||||
'$selname' => $selname,
|
||||
'$permissions' => DI::l10n()->t('Permissions'),
|
||||
'$aclselect' => $aclselect_e,
|
||||
'$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
|
||||
'$alt_uploader' => $ret['addon_text'],
|
||||
'$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
|
||||
'$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
|
||||
'$uploadurl' => $ret['post_url'],
|
||||
'$uploadurl' => $ret['post_url'],
|
||||
|
||||
// ACL permissions box
|
||||
'$return_path' => DI::args()->getQueryString(),
|
||||
|
@ -713,7 +712,7 @@ function photos_content()
|
|||
}
|
||||
|
||||
$total = 0;
|
||||
$r = DBA::toArray(DBA::p(
|
||||
$r = DBA::toArray(DBA::p(
|
||||
"SELECT `resource-id`, MAX(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
|
||||
AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
|
||||
$owner_uid,
|
||||
|
@ -749,7 +748,7 @@ function photos_content()
|
|||
$drop_url = DI::args()->getQueryString();
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$l10n' => [
|
||||
'$l10n' => [
|
||||
'message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
|
||||
'confirm' => DI::l10n()->t('Delete Album'),
|
||||
'cancel' => DI::l10n()->t('Cancel'),
|
||||
|
@ -769,11 +768,11 @@ function photos_content()
|
|||
$album_e = $album;
|
||||
|
||||
$o .= Renderer::replaceMacros($edit_tpl, [
|
||||
'$nametext' => DI::l10n()->t('New album name: '),
|
||||
'$nickname' => $user['nickname'],
|
||||
'$album' => $album_e,
|
||||
'$hexalbum' => bin2hex($album),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$nametext' => DI::l10n()->t('New album name: '),
|
||||
'$nickname' => $user['nickname'],
|
||||
'$album' => $album_e,
|
||||
'$hexalbum' => bin2hex($album),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$dropsubmit' => DI::l10n()->t('Delete Album')
|
||||
]);
|
||||
}
|
||||
|
@ -783,7 +782,7 @@ function photos_content()
|
|||
}
|
||||
|
||||
if ($order_field === 'created') {
|
||||
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
|
||||
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
|
||||
} else {
|
||||
$order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=created', 'newest'];
|
||||
}
|
||||
|
@ -799,7 +798,7 @@ function photos_content()
|
|||
$ext = Images::getExtensionByMimeType($rr['type']);
|
||||
|
||||
$imgalt_e = $rr['filename'];
|
||||
$desc_e = $rr['desc'];
|
||||
$desc_e = $rr['desc'];
|
||||
|
||||
$photos[] = [
|
||||
'id' => $rr['id'],
|
||||
|
@ -818,13 +817,13 @@ function photos_content()
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('photo_album.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$photos' => $photos,
|
||||
'$album' => $album,
|
||||
'$photos' => $photos,
|
||||
'$album' => $album,
|
||||
'$can_post' => $can_post,
|
||||
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$drop' => $drop,
|
||||
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$drop' => $drop,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
|
@ -849,7 +848,7 @@ function photos_content()
|
|||
$drop_url = DI::args()->getQueryString();
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$l10n' => [
|
||||
'$l10n' => [
|
||||
'message' => DI::l10n()->t('Do you really want to delete this photo?'),
|
||||
'confirm' => DI::l10n()->t('Delete Photo'),
|
||||
'cancel' => DI::l10n()->t('Cancel'),
|
||||
|
@ -951,8 +950,8 @@ function photos_content()
|
|||
if ($cmd === 'edit') {
|
||||
$tools['view'] = ['photos/' . $user['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')];
|
||||
} else {
|
||||
$tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
|
||||
$tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
|
||||
$tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
|
||||
$tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
|
||||
$tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
|
||||
}
|
||||
|
||||
|
@ -974,9 +973,9 @@ function photos_content()
|
|||
'filename' => $hires['filename'],
|
||||
];
|
||||
|
||||
$map = null;
|
||||
$map = null;
|
||||
$link_item = [];
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
|
||||
// Do we have an item for this photo?
|
||||
|
||||
|
@ -990,12 +989,12 @@ function photos_content()
|
|||
|
||||
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
|
||||
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
|
||||
$total = Post::count($condition);
|
||||
$total = Post::count($condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
|
||||
$items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
|
||||
|
||||
if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
|
||||
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
|
||||
|
@ -1022,51 +1021,51 @@ function photos_content()
|
|||
$tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr];
|
||||
if ($cmd === 'edit') {
|
||||
$tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand());
|
||||
$tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
|
||||
$tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$edit = Null;
|
||||
$edit = null;
|
||||
if ($cmd === 'edit' && $can_post) {
|
||||
$edit_tpl = Renderer::getMarkupTemplate('photo_edit.tpl');
|
||||
|
||||
$album_e = $ph[0]['album'];
|
||||
$caption_e = $ph[0]['desc'];
|
||||
$album_e = $ph[0]['album'];
|
||||
$caption_e = $ph[0]['desc'];
|
||||
$aclselect_e = ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
|
||||
|
||||
$edit = Renderer::replaceMacros($edit_tpl, [
|
||||
'$id' => $ph[0]['id'],
|
||||
'$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
|
||||
'$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
|
||||
'$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
|
||||
'$id' => $ph[0]['id'],
|
||||
'$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
|
||||
'$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
|
||||
'$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
|
||||
'$rotate_none' => ['rotate', DI::l10n()->t('Do not rotate'), 0, '', true],
|
||||
'$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
|
||||
'$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
|
||||
'$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
|
||||
'$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
|
||||
|
||||
'$nickname' => $user['nickname'],
|
||||
'$nickname' => $user['nickname'],
|
||||
'$resource_id' => $ph[0]['resource-id'],
|
||||
'$permissions' => DI::l10n()->t('Permissions'),
|
||||
'$aclselect' => $aclselect_e,
|
||||
'$aclselect' => $aclselect_e,
|
||||
|
||||
'$item_id' => $link_item['id'] ?? 0,
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$delete' => DI::l10n()->t('Delete Photo'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$delete' => DI::l10n()->t('Delete Photo'),
|
||||
|
||||
// ACL permissions box
|
||||
'$return_path' => DI::args()->getQueryString(),
|
||||
]);
|
||||
}
|
||||
|
||||
$like = '';
|
||||
$dislike = '';
|
||||
$like = '';
|
||||
$dislike = '';
|
||||
$likebuttons = '';
|
||||
$comments = '';
|
||||
$paginate = '';
|
||||
$comments = '';
|
||||
$paginate = '';
|
||||
|
||||
if (!empty($link_item['id']) && !empty($link_item['uri'])) {
|
||||
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
|
||||
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
|
||||
$return_path = DI::args()->getCommand();
|
||||
|
||||
if (!DBA::isResult($items)) {
|
||||
|
@ -1077,25 +1076,25 @@ function photos_content()
|
|||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
||||
$comments .= Renderer::replaceMacros($cmnt_tpl, [
|
||||
'$return_path' => '',
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $link_item['id'],
|
||||
'$parent' => $link_item['id'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$loading' => DI::l10n()->t('Loading...'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $link_item['id'],
|
||||
'$parent' => $link_item['id'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$loading' => DI::l10n()->t('Loading...'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1133,29 +1132,29 @@ function photos_content()
|
|||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
||||
$comments .= Renderer::replaceMacros($cmnt_tpl, [
|
||||
'$return_path' => '',
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $link_item['id'],
|
||||
'$parent' => $link_item['id'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $link_item['id'],
|
||||
'$parent' => $link_item['id'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$comment = '';
|
||||
$comment = '';
|
||||
$template = $tpl;
|
||||
|
||||
$activity = DI::activity();
|
||||
|
@ -1182,7 +1181,7 @@ function photos_content()
|
|||
}
|
||||
|
||||
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
|
||||
$drop = [
|
||||
$drop = [
|
||||
'dropping' => $dropping,
|
||||
'pagedrop' => false,
|
||||
'select' => DI::l10n()->t('Select'),
|
||||
|
@ -1190,7 +1189,7 @@ function photos_content()
|
|||
];
|
||||
|
||||
$title_e = $item['title'];
|
||||
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
|
||||
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
|
||||
|
||||
$comments .= Renderer::replaceMacros($template, [
|
||||
'$id' => $item['id'],
|
||||
|
@ -1213,24 +1212,24 @@ function photos_content()
|
|||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
||||
$comments .= Renderer::replaceMacros($cmnt_tpl, [
|
||||
'$return_path' => '',
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $item['id'],
|
||||
'$parent' => $item['parent'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $item['id'],
|
||||
'$parent' => $item['parent'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => $contact['thumb'],
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$preview' => DI::l10n()->t('Preview'),
|
||||
'$qcomment' => $qcomment,
|
||||
'$rand_num' => Crypto::randomDigits(12),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1244,17 +1243,17 @@ function photos_content()
|
|||
}
|
||||
|
||||
if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
|
||||
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
|
||||
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
|
||||
$likebuttons = Renderer::replaceMacros($like_tpl, [
|
||||
'$id' => $link_item['id'],
|
||||
'$like' => DI::l10n()->t('Like'),
|
||||
'$like_title' => DI::l10n()->t('I like this (toggle)'),
|
||||
'$dislike' => DI::l10n()->t('Dislike'),
|
||||
'$wait' => DI::l10n()->t('Please wait'),
|
||||
'$id' => $link_item['id'],
|
||||
'$like' => DI::l10n()->t('Like'),
|
||||
'$like_title' => DI::l10n()->t('I like this (toggle)'),
|
||||
'$dislike' => DI::l10n()->t('Dislike'),
|
||||
'$wait' => DI::l10n()->t('Please wait'),
|
||||
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
|
||||
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
|
||||
'$responses' => $responses,
|
||||
'$return_path' => DI::args()->getQueryString(),
|
||||
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
|
||||
'$responses' => $responses,
|
||||
'$return_path' => DI::args()->getQueryString(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -1263,22 +1262,22 @@ function photos_content()
|
|||
|
||||
$photo_tpl = Renderer::getMarkupTemplate('photo_view.tpl');
|
||||
$o .= Renderer::replaceMacros($photo_tpl, [
|
||||
'$id' => $ph[0]['id'],
|
||||
'$album' => [$album_link, $ph[0]['album']],
|
||||
'$tools' => $tools,
|
||||
'$photo' => $photo,
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink,
|
||||
'$desc' => $ph[0]['desc'],
|
||||
'$tags' => $tags,
|
||||
'$edit' => $edit,
|
||||
'$map' => $map,
|
||||
'$map_text' => DI::l10n()->t('Map'),
|
||||
'$id' => $ph[0]['id'],
|
||||
'$album' => [$album_link, $ph[0]['album']],
|
||||
'$tools' => $tools,
|
||||
'$photo' => $photo,
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink,
|
||||
'$desc' => $ph[0]['desc'],
|
||||
'$tags' => $tags,
|
||||
'$edit' => $edit,
|
||||
'$map' => $map,
|
||||
'$map_text' => DI::l10n()->t('Map'),
|
||||
'$likebuttons' => $likebuttons,
|
||||
'$like' => $like,
|
||||
'$dislike' => $dislike,
|
||||
'$comments' => $comments,
|
||||
'$paginate' => $paginate,
|
||||
'$like' => $like,
|
||||
'$dislike' => $dislike,
|
||||
'$comments' => $comments,
|
||||
'$paginate' => $paginate,
|
||||
]);
|
||||
|
||||
DI::page()['htmlhead'] .= "\n" . '<meta name="twitter:card" content="summary_large_image" />' . "\n";
|
||||
|
|
86
src/App.php
86
src/App.php
|
@ -57,6 +57,7 @@ use Psr\Log\LoggerInterface;
|
|||
* and anything else that might need to be passed around
|
||||
* before we spit the page out.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class App
|
||||
{
|
||||
|
@ -64,6 +65,9 @@ class App
|
|||
const CODENAME = 'Interrupted Fern';
|
||||
const VERSION = '2025.02-dev';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function fromContainer(Container $container): self
|
||||
{
|
||||
return new self($container);
|
||||
|
@ -130,6 +134,9 @@ class App
|
|||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
||||
{
|
||||
$this->container->addRule(Mode::class, [
|
||||
|
@ -158,16 +165,18 @@ class App
|
|||
$this->session = $this->container->create(IHandleUserSessions::class);
|
||||
$this->appHelper = $this->container->create(AppHelper::class);
|
||||
|
||||
$this->loadSetupForFrontend(
|
||||
$request,
|
||||
$this->load(
|
||||
$request->getServerParams(),
|
||||
$this->container->create(DbaDefinition::class),
|
||||
$this->container->create(ViewDefinition::class),
|
||||
$this->mode,
|
||||
$this->config,
|
||||
$this->profiler,
|
||||
$this->appHelper,
|
||||
);
|
||||
|
||||
$this->registerTemplateEngine();
|
||||
|
||||
$this->mode->setExecutor(Mode::INDEX);
|
||||
|
||||
$this->runFrontend(
|
||||
$this->container->create(IManagePersonalConfigValues::class),
|
||||
$this->container->create(Page::class),
|
||||
|
@ -178,8 +187,13 @@ class App
|
|||
);
|
||||
}
|
||||
|
||||
public function processConsole(array $argv): void
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processConsole(array $serverParams): void
|
||||
{
|
||||
$argv = $serverParams['argv'] ?? [];
|
||||
|
||||
$this->setupContainerForAddons();
|
||||
|
||||
$this->setupLogChannel($this->determineLogChannel($argv));
|
||||
|
@ -188,12 +202,25 @@ class App
|
|||
|
||||
$this->registerErrorHandler();
|
||||
|
||||
$this->load(
|
||||
$serverParams,
|
||||
$this->container->create(DbaDefinition::class),
|
||||
$this->container->create(ViewDefinition::class),
|
||||
$this->container->create(Mode::class),
|
||||
$this->container->create(IManageConfigValues::class),
|
||||
$this->container->create(Profiler::class),
|
||||
$this->container->create(AppHelper::class),
|
||||
);
|
||||
|
||||
$this->registerTemplateEngine();
|
||||
|
||||
(\Friendica\Core\Console::create($this->container, $argv))->execute();
|
||||
}
|
||||
|
||||
public function processEjabberd(): void
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function processEjabberd(array $serverParams): void
|
||||
{
|
||||
$this->setupContainerForAddons();
|
||||
|
||||
|
@ -203,6 +230,16 @@ class App
|
|||
|
||||
$this->registerErrorHandler();
|
||||
|
||||
$this->load(
|
||||
$serverParams,
|
||||
$this->container->create(DbaDefinition::class),
|
||||
$this->container->create(ViewDefinition::class),
|
||||
$this->container->create(Mode::class),
|
||||
$this->container->create(IManageConfigValues::class),
|
||||
$this->container->create(Profiler::class),
|
||||
$this->container->create(AppHelper::class),
|
||||
);
|
||||
|
||||
/** @var BasePath */
|
||||
$basePath = $this->container->create(BasePath::class);
|
||||
|
||||
|
@ -272,14 +309,21 @@ class App
|
|||
/**
|
||||
* Load the whole app instance
|
||||
*/
|
||||
private function loadSetupForFrontend(ServerRequestInterface $request, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition)
|
||||
{
|
||||
if ($this->config->get('system', 'ini_max_execution_time') !== false) {
|
||||
set_time_limit((int)$this->config->get('system', 'ini_max_execution_time'));
|
||||
private function load(
|
||||
array $serverParams,
|
||||
DbaDefinition $dbaDefinition,
|
||||
ViewDefinition $viewDefinition,
|
||||
Mode $mode,
|
||||
IManageConfigValues $config,
|
||||
Profiler $profiler,
|
||||
AppHelper $appHelper
|
||||
): void {
|
||||
if ($config->get('system', 'ini_max_execution_time') !== false) {
|
||||
set_time_limit((int) $config->get('system', 'ini_max_execution_time'));
|
||||
}
|
||||
|
||||
if ($this->config->get('system', 'ini_pcre_backtrack_limit') !== false) {
|
||||
ini_set('pcre.backtrack_limit', (int)$this->config->get('system', 'ini_pcre_backtrack_limit'));
|
||||
if ($config->get('system', 'ini_pcre_backtrack_limit') !== false) {
|
||||
ini_set('pcre.backtrack_limit', (int) $config->get('system', 'ini_pcre_backtrack_limit'));
|
||||
}
|
||||
|
||||
// Normally this constant is defined - but not if "pcntl" isn't installed
|
||||
|
@ -290,11 +334,11 @@ class App
|
|||
// Ensure that all "strtotime" operations do run timezone independent
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
$this->profiler->reset();
|
||||
$profiler->reset();
|
||||
|
||||
if ($this->mode->has(Mode::DBAVAILABLE)) {
|
||||
if ($mode->has(Mode::DBAVAILABLE)) {
|
||||
Core\Hook::loadHooks();
|
||||
$loader = (new Config())->createConfigFileManager($this->appHelper->getBasePath(), $request->getServerParams());
|
||||
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $serverParams);
|
||||
Core\Hook::callAll('load_config', $loader);
|
||||
|
||||
// Hooks are now working, reload the whole definitions with hook enabled
|
||||
|
@ -302,7 +346,7 @@ class App
|
|||
$viewDefinition->load(true);
|
||||
}
|
||||
|
||||
$this->loadDefaultTimezone();
|
||||
$this->loadDefaultTimezone($config, $appHelper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,16 +356,16 @@ class App
|
|||
*
|
||||
* @global string $default_timezone
|
||||
*/
|
||||
private function loadDefaultTimezone()
|
||||
private function loadDefaultTimezone(IManageConfigValues $config, AppHelper $appHelper)
|
||||
{
|
||||
if ($this->config->get('system', 'default_timezone')) {
|
||||
$timezone = $this->config->get('system', 'default_timezone', 'UTC');
|
||||
if ($config->get('system', 'default_timezone')) {
|
||||
$timezone = $config->get('system', 'default_timezone', 'UTC');
|
||||
} else {
|
||||
global $default_timezone;
|
||||
$timezone = $default_timezone ?? '' ?: 'UTC';
|
||||
}
|
||||
|
||||
$this->appHelper->setTimeZone($timezone);
|
||||
$appHelper->setTimeZone($timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,6 +392,8 @@ class App
|
|||
float $start_time,
|
||||
ServerRequestInterface $request
|
||||
) {
|
||||
$this->mode->setExecutor(Mode::INDEX);
|
||||
|
||||
$httpInput = new HTTPInputData($request->getServerParams());
|
||||
$serverVars = $request->getServerParams();
|
||||
$queryVars = $request->getQueryParams();
|
||||
|
|
|
@ -16,12 +16,12 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Model\UserSession;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -81,7 +81,7 @@ class Page implements ArrayAccess
|
|||
public function __construct(string $basepath)
|
||||
{
|
||||
$this->timestamp = microtime(true);
|
||||
$this->basePath = $basepath;
|
||||
$this->basePath = $basepath;
|
||||
}
|
||||
|
||||
public function setLogging(string $method, string $module, string $command)
|
||||
|
@ -102,7 +102,7 @@ class Page implements ArrayAccess
|
|||
$load = number_format(System::currentLoad(), 2);
|
||||
$runtime = number_format(microtime(true) - $this->timestamp, 3);
|
||||
if ($runtime > $config->get('system', 'runtime_loglimit')) {
|
||||
Logger::debug('Runtime', ['method' => $this->method, 'module' => $this->module, 'runtime' => $runtime, 'load' => $load, 'origin' => $origin, 'signature' => $signature, 'request' => $_SERVER['REQUEST_URI'] ?? '']);
|
||||
DI::logger()->debug('Runtime', ['method' => $this->method, 'module' => $this->module, 'runtime' => $runtime, 'load' => $load, 'origin' => $origin, 'signature' => $signature, 'request' => $_SERVER['REQUEST_URI'] ?? '']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ class Page implements ArrayAccess
|
|||
$this->initContent($response, $mode);
|
||||
|
||||
// Load current theme info after module has been initialized as theme could have been set in module
|
||||
$currentTheme = $appHelper->getCurrentTheme();
|
||||
$currentTheme = $appHelper->getCurrentTheme();
|
||||
$theme_info_file = 'view/theme/' . $currentTheme . '/theme.php';
|
||||
if (file_exists($theme_info_file)) {
|
||||
require_once $theme_info_file;
|
||||
|
@ -479,7 +479,7 @@ class Page implements ArrayAccess
|
|||
// Add the navigation (menu) template
|
||||
if ($moduleName != 'install' && $moduleName != 'maintenance') {
|
||||
$this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('nav_head.tpl'), []);
|
||||
$this->page['nav'] = $nav->getHtml();
|
||||
$this->page['nav'] = $nav->getHtml();
|
||||
}
|
||||
|
||||
// Build the page - now that we have all the components
|
||||
|
@ -512,7 +512,7 @@ class Page implements ArrayAccess
|
|||
}
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$page = $this->page;
|
||||
|
||||
// add and escape some common but crucial content for direct "echo" in HTML (security)
|
||||
$page['title'] = htmlspecialchars($page['title'] ?? '');
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Util\Strings;
|
|||
* and anything else that might need to be passed around
|
||||
* before we spit the page out.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AppLegacy implements AppHelper
|
||||
{
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Capabilities\ICanHandleRequests;
|
|||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Response;
|
||||
|
@ -412,8 +411,8 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
Logger::notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
|
||||
Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
|
||||
DI::logger()->notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
|
||||
DI::logger()->debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
|
||||
DI::sysmsg()->addNotice(self::getFormSecurityStandardErrorMessage());
|
||||
DI::baseUrl()->redirect($err_redirect);
|
||||
}
|
||||
|
@ -422,8 +421,8 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
public static function checkFormSecurityTokenForbiddenOnError(string $typename = '', string $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
Logger::notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
|
||||
Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
|
||||
DI::logger()->notice('checkFormSecurityToken failed: user ' . DI::userSession()->getLocalUserNickname() . ' - form element ' . $typename);
|
||||
DI::logger()->debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
|
||||
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\Core\Console as CoreConsole;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
|
||||
/**
|
||||
* Abstract Console class for common settings
|
||||
*/
|
||||
abstract class AbstractConsole extends Console
|
||||
{
|
||||
/**
|
||||
* Overwrite this const in case you want to switch the LogChannel for this console command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const LOG_CHANNEL = LogChannel::CONSOLE;
|
||||
|
||||
/**
|
||||
* Checks, if the Console command was executed outside `bin/console.php` and prints the correct execution
|
||||
*
|
||||
* @param string $command the current command
|
||||
*/
|
||||
protected function checkDeprecated(string $command): void
|
||||
{
|
||||
if (substr($this->executable, -strlen(CoreConsole::getDefaultExecutable())) !== CoreConsole::getDefaultExecutable()) {
|
||||
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php %s' instead", $this->executable, $command));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@ declare(strict_types=1);
|
|||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -27,10 +27,8 @@ use RuntimeException;
|
|||
/**
|
||||
* Console command for interacting with the daemon
|
||||
*/
|
||||
final class Daemon extends AbstractConsole
|
||||
final class Daemon extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::DAEMON;
|
||||
|
||||
private Mode $mode;
|
||||
private IManageConfigValues $config;
|
||||
private IManageKeyValuePairs $keyValue;
|
||||
|
@ -93,8 +91,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('daemon');
|
||||
|
||||
if ($this->mode->isInstall()) {
|
||||
throw new RuntimeException("Friendica isn't properly installed yet");
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Protocol\ATProtocol\Jetstream;
|
||||
use Friendica\System\Daemon as SysDaemon;
|
||||
use RuntimeException;
|
||||
|
@ -22,10 +22,8 @@ use RuntimeException;
|
|||
/**
|
||||
* Console command for interacting with the daemon
|
||||
*/
|
||||
final class JetstreamDaemon extends AbstractConsole
|
||||
final class JetstreamDaemon extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::DAEMON;
|
||||
|
||||
private Mode $mode;
|
||||
private IManageConfigValues $config;
|
||||
private IManageKeyValuePairs $keyValue;
|
||||
|
@ -79,8 +77,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('jetstream');
|
||||
|
||||
if ($this->mode->isInstall()) {
|
||||
throw new RuntimeException("Friendica isn't properly installed yet");
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Logger\Capability\LogChannel;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Core\Worker as CoreWorker;
|
||||
use Friendica\Core\Worker\Repository\Process as ProcessRepository;
|
||||
|
@ -19,10 +19,8 @@ use Friendica\Util\BasePath;
|
|||
/**
|
||||
* Console command for starting worker
|
||||
*/
|
||||
final class Worker extends AbstractConsole
|
||||
final class Worker extends Console
|
||||
{
|
||||
public const LOG_CHANNEL = LogChannel::WORKER;
|
||||
|
||||
private Mode $mode;
|
||||
private BasePath $basePath;
|
||||
private ProcessRepository $processRepo;
|
||||
|
@ -69,8 +67,6 @@ HELP;
|
|||
|
||||
protected function doExecute()
|
||||
{
|
||||
$this->checkDeprecated('worker');
|
||||
|
||||
$this->mode->setExecutor(Mode::WORKER);
|
||||
|
||||
// Check the database structure and possibly fixes it
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Contact;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
|
@ -47,36 +46,36 @@ class Avatar
|
|||
|
||||
if (($avatar != $contact['avatar']) || $force) {
|
||||
self::deleteCache($contact);
|
||||
Logger::debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
|
||||
DI::logger()->debug('Avatar file name changed', ['new' => $avatar, 'old' => $contact['avatar']]);
|
||||
} elseif (self::isCacheFile($contact['photo']) && self::isCacheFile($contact['thumb']) && self::isCacheFile($contact['micro'])) {
|
||||
$fields['photo'] = $contact['photo'];
|
||||
$fields['thumb'] = $contact['thumb'];
|
||||
$fields['micro'] = $contact['micro'];
|
||||
Logger::debug('Using existing cache files', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
|
||||
DI::logger()->debug('Using existing cache files', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
try {
|
||||
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]);
|
||||
DI::logger()->notice('Avatar is invalid', ['avatar' => $avatar, 'exception' => $exception]);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
if (!$fetchResult->isSuccess()) {
|
||||
Logger::debug('Fetching was unsuccessful', ['avatar' => $avatar]);
|
||||
DI::logger()->debug('Fetching was unsuccessful', ['avatar' => $avatar]);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
$img_str = $fetchResult->getBodyString();
|
||||
if (empty($img_str)) {
|
||||
Logger::debug('Avatar is invalid', ['avatar' => $avatar]);
|
||||
DI::logger()->debug('Avatar is invalid', ['avatar' => $avatar]);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
$image = new Image($img_str, $fetchResult->getContentType(), $avatar);
|
||||
if (!$image->isValid()) {
|
||||
Logger::debug('Avatar picture is invalid', ['avatar' => $avatar]);
|
||||
DI::logger()->debug('Avatar picture is invalid', ['avatar' => $avatar]);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ class Avatar
|
|||
$fields['thumb'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_THUMB, $timestamp);
|
||||
$fields['micro'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_MICRO, $timestamp);
|
||||
|
||||
Logger::debug('Storing new avatar cache', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
|
||||
DI::logger()->debug('Storing new avatar cache', ['uri-id' => $contact['uri-id'], 'fields' => $fields]);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
@ -155,36 +154,36 @@ class Avatar
|
|||
|
||||
if (!file_exists($dirpath)) {
|
||||
if (!@mkdir($dirpath, $dir_perm) && !file_exists($dirpath)) {
|
||||
Logger::warning('Directory could not be created', ['directory' => $dirpath]);
|
||||
DI::logger()->warning('Directory could not be created', ['directory' => $dirpath]);
|
||||
}
|
||||
} elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) {
|
||||
Logger::warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]);
|
||||
DI::logger()->warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]);
|
||||
}
|
||||
|
||||
if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) {
|
||||
Logger::warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
|
||||
DI::logger()->warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_put_contents($filepath, $image->asString())) {
|
||||
Logger::warning('File could not be created', ['file' => $filepath]);
|
||||
DI::logger()->warning('File could not be created', ['file' => $filepath]);
|
||||
}
|
||||
|
||||
$old_perm = fileperms($filepath) & 0666;
|
||||
$old_group = filegroup($filepath);
|
||||
|
||||
if (($old_perm != $file_perm) && !chmod($filepath, $file_perm)) {
|
||||
Logger::warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
|
||||
DI::logger()->warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
|
||||
}
|
||||
|
||||
if (($old_group != $group) && !chgrp($filepath, $group)) {
|
||||
Logger::warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
|
||||
DI::logger()->warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
|
||||
}
|
||||
|
||||
DI::profiler()->stopRecording();
|
||||
|
||||
if (!file_exists($filepath)) {
|
||||
Logger::warning('Avatar cache file could not be stored', ['file' => $filepath]);
|
||||
DI::logger()->warning('Avatar cache file could not be stored', ['file' => $filepath]);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -216,7 +215,7 @@ class Avatar
|
|||
}
|
||||
|
||||
$avatarpath = parse_url(self::baseUrl(), PHP_URL_PATH);
|
||||
$pos = strpos($parts['path'], $avatarpath);
|
||||
$pos = strpos($parts['path'], $avatarpath);
|
||||
if ($pos !== 0) {
|
||||
return '';
|
||||
}
|
||||
|
@ -257,7 +256,7 @@ class Avatar
|
|||
$localFile = self::getCacheFile($avatar);
|
||||
if (!empty($localFile)) {
|
||||
@unlink($localFile);
|
||||
Logger::debug('Unlink avatar', ['avatar' => $avatar, 'local' => $localFile]);
|
||||
DI::logger()->debug('Unlink avatar', ['avatar' => $avatar, 'local' => $localFile]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,11 +276,11 @@ class Avatar
|
|||
if (!file_exists($basepath)) {
|
||||
// We only automatically create the folder when it is in the web root
|
||||
if (strpos($basepath, DI::basePath()) !== 0) {
|
||||
Logger::warning('Base directory does not exist', ['directory' => $basepath]);
|
||||
DI::logger()->warning('Base directory does not exist', ['directory' => $basepath]);
|
||||
return '';
|
||||
}
|
||||
if (!mkdir($basepath, 0775)) {
|
||||
Logger::warning('Base directory could not be created', ['directory' => $basepath]);
|
||||
DI::logger()->warning('Base directory could not be created', ['directory' => $basepath]);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode\Video;
|
|||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
|
@ -117,8 +116,8 @@ class Item
|
|||
public function determineCategoriesTerms(array $item, int $uid = 0): array
|
||||
{
|
||||
$categories = [];
|
||||
$folders = [];
|
||||
$first = true;
|
||||
$folders = [];
|
||||
$first = true;
|
||||
|
||||
$uid = $item['uid'] ?: $uid;
|
||||
|
||||
|
@ -133,11 +132,11 @@ class Item
|
|||
$url = '#';
|
||||
}
|
||||
$categories[] = [
|
||||
'name' => $savedFolderName,
|
||||
'url' => $url,
|
||||
'name' => $savedFolderName,
|
||||
'url' => $url,
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
|
@ -149,11 +148,11 @@ class Item
|
|||
if ($this->userSession->getLocalUserId() == $uid) {
|
||||
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
|
||||
$folders[] = [
|
||||
'name' => $savedFolderName,
|
||||
'url' => "#",
|
||||
'name' => $savedFolderName,
|
||||
'url' => "#",
|
||||
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
|
@ -198,55 +197,55 @@ class Item
|
|||
// Sometimes the tag detection doesn't seem to work right
|
||||
// This is some workaround
|
||||
$nameparts = explode(' ', $name);
|
||||
$name = $nameparts[0];
|
||||
$name = $nameparts[0];
|
||||
|
||||
// Try to detect the contact in various ways
|
||||
if (strpos($name, 'http://') || strpos($name, '@')) {
|
||||
$contact = Contact::getByURLForUser($name, $profile_uid);
|
||||
} else {
|
||||
$contact = false;
|
||||
$fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
|
||||
$fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
|
||||
|
||||
if (strrpos($name, '+')) {
|
||||
// Is it in format @nick+number?
|
||||
$tagcid = intval(substr($name, strrpos($name, '+') + 1));
|
||||
$tagcid = intval(substr($name, strrpos($name, '+') + 1));
|
||||
$contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
|
||||
}
|
||||
|
||||
// select someone by nick in the current network
|
||||
if (!DBA::isResult($contact) && ($network != '')) {
|
||||
$condition = ['nick' => $name, 'network' => $network, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
// select someone by attag in the current network
|
||||
if (!DBA::isResult($contact) && ($network != '')) {
|
||||
$condition = ['attag' => $name, 'network' => $network, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
//select someone by name in the current network
|
||||
if (!DBA::isResult($contact) && ($network != '')) {
|
||||
$condition = ['name' => $name, 'network' => $network, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
// select someone by nick in any network
|
||||
if (!DBA::isResult($contact)) {
|
||||
$condition = ['nick' => $name, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
// select someone by attag in any network
|
||||
if (!DBA::isResult($contact)) {
|
||||
$condition = ['attag' => $name, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
|
||||
// select someone by name in any network
|
||||
if (!DBA::isResult($contact)) {
|
||||
$condition = ['name' => $name, 'uid' => $profile_uid];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,8 +262,8 @@ class Item
|
|||
$replaced = true;
|
||||
// create profile link
|
||||
$profile = str_replace(',', '%2c', $profile);
|
||||
$newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
|
||||
$body = str_replace($tag_type . $name, $newtag, $body);
|
||||
$newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
|
||||
$body = str_replace($tag_type . $name, $newtag, $body);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +303,7 @@ class Item
|
|||
'url' => $item['author-link'],
|
||||
'alias' => $item['author-alias'],
|
||||
];
|
||||
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
|
||||
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
|
||||
|
||||
$author_arr = [
|
||||
'uid' => 0,
|
||||
|
@ -313,7 +312,7 @@ class Item
|
|||
'url' => $obj['author-link'],
|
||||
'alias' => $obj['author-alias'],
|
||||
];
|
||||
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
|
||||
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
|
||||
|
||||
switch ($obj['verb']) {
|
||||
case Activity::POST:
|
||||
|
@ -341,7 +340,7 @@ class Item
|
|||
|
||||
$parsedobj = XML::parseString($xmlhead . $item['object']);
|
||||
|
||||
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
|
||||
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
|
||||
$item['body'] = $this->l10n->t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +358,7 @@ class Item
|
|||
public function photoMenu(array $item, string $formSecurityToken): string
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
$sub_link = $contact_url = $pm_url = $status_link = '';
|
||||
$sub_link = $contact_url = $pm_url = $status_link = '';
|
||||
$photos_link = $posts_link = $block_link = $ignore_link = $collapse_link = $ignoreserver_link = '';
|
||||
|
||||
if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||
|
@ -380,16 +379,16 @@ class Item
|
|||
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
|
||||
}
|
||||
|
||||
$cid = 0;
|
||||
$pcid = $item['author-id'];
|
||||
$network = '';
|
||||
$rel = 0;
|
||||
$cid = 0;
|
||||
$pcid = $item['author-id'];
|
||||
$network = '';
|
||||
$rel = 0;
|
||||
$condition = ['uid' => $this->userSession->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
|
||||
if (DBA::isResult($contact)) {
|
||||
$cid = $contact['id'];
|
||||
$cid = $contact['id'];
|
||||
$network = $contact['network'];
|
||||
$rel = $contact['rel'];
|
||||
$rel = $contact['rel'];
|
||||
}
|
||||
|
||||
if (!empty($pcid)) {
|
||||
|
@ -416,16 +415,16 @@ class Item
|
|||
|
||||
if ($this->userSession->getLocalUserId()) {
|
||||
$menu = [
|
||||
$this->l10n->t('Follow Thread') => $sub_link,
|
||||
$this->l10n->t('View Status') => $status_link,
|
||||
$this->l10n->t('View Profile') => $profile_link,
|
||||
$this->l10n->t('View Photos') => $photos_link,
|
||||
$this->l10n->t('Network Posts') => $posts_link,
|
||||
$this->l10n->t('View Contact') => $contact_url,
|
||||
$this->l10n->t('Send PM') => $pm_url,
|
||||
$this->l10n->t('Block') => $block_link,
|
||||
$this->l10n->t('Ignore') => $ignore_link,
|
||||
$this->l10n->t('Collapse') => $collapse_link,
|
||||
$this->l10n->t('Follow Thread') => $sub_link,
|
||||
$this->l10n->t('View Status') => $status_link,
|
||||
$this->l10n->t('View Profile') => $profile_link,
|
||||
$this->l10n->t('View Photos') => $photos_link,
|
||||
$this->l10n->t('Network Posts') => $posts_link,
|
||||
$this->l10n->t('View Contact') => $contact_url,
|
||||
$this->l10n->t('Send PM') => $pm_url,
|
||||
$this->l10n->t('Block') => $block_link,
|
||||
$this->l10n->t('Ignore') => $ignore_link,
|
||||
$this->l10n->t('Collapse') => $collapse_link,
|
||||
$this->l10n->t("Ignore %s server", $authorBaseUri->getHost()) => $ignoreserver_link,
|
||||
];
|
||||
|
||||
|
@ -518,20 +517,20 @@ class Item
|
|||
if (!empty($contact['prv']) || ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION])) {
|
||||
$private_group = $contact['prv'];
|
||||
$only_to_group = ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
|
||||
$private_id = $contact['id'];
|
||||
$private_id = $contact['id'];
|
||||
$group_contact = $contact;
|
||||
Logger::info('Private group or exclusive mention', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
DI::logger()->info('Private group or exclusive mention', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
} elseif ($item['allow_cid'] == '<' . $contact['id'] . '>') {
|
||||
$private_group = false;
|
||||
$only_to_group = true;
|
||||
$private_id = $contact['id'];
|
||||
$private_id = $contact['id'];
|
||||
$group_contact = $contact;
|
||||
Logger::info('Public group', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
DI::logger()->info('Public group', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
} else {
|
||||
Logger::info('Post with group mention will not be converted to a group post', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
DI::logger()->info('Post with group mention will not be converted to a group post', ['url' => $tag[2], 'mention' => $tag[1]]);
|
||||
}
|
||||
}
|
||||
Logger::info('Got inform', ['inform' => $item['inform']]);
|
||||
DI::logger()->info('Got inform', ['inform' => $item['inform']]);
|
||||
|
||||
if (($item['gravity'] == ItemModel::GRAVITY_PARENT) && !empty($group_contact) && ($private_group || $only_to_group)) {
|
||||
// we tagged a group in a top level post. Now we change the post
|
||||
|
@ -562,7 +561,7 @@ class Item
|
|||
} elseif ($setPermissions) {
|
||||
if (empty($receivers)) {
|
||||
// For security reasons direct posts without any receiver will be posts to yourself
|
||||
$self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
|
||||
$self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
|
||||
$receivers[] = $self['id'];
|
||||
}
|
||||
|
||||
|
@ -606,9 +605,9 @@ class Item
|
|||
$owner_updated = '';
|
||||
$owner_thumb = $item['contact-avatar'];
|
||||
} else {
|
||||
$owner_avatar = $item['owner-id'];
|
||||
$owner_updated = $item['owner-updated'];
|
||||
$owner_thumb = $item['owner-avatar'];
|
||||
$owner_avatar = $item['owner-id'];
|
||||
$owner_updated = $item['owner-updated'];
|
||||
$owner_thumb = $item['owner-avatar'];
|
||||
}
|
||||
|
||||
if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
|
||||
|
@ -635,10 +634,10 @@ class Item
|
|||
return $body;
|
||||
}
|
||||
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
|
||||
$shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id'], 'uid' => [$item['uid'], 0], 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
|
||||
if (!DBA::isResult($shared_item)) {
|
||||
Logger::notice('Post does not exist.', ['uri-id' => $item['quote-uri-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->notice('Post does not exist.', ['uri-id' => $item['quote-uri-id'], 'uid' => $item['uid']]);
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
@ -650,11 +649,11 @@ class Item
|
|||
*/
|
||||
private function createSharedPostByGuid(string $guid, bool $add_media): string
|
||||
{
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
|
||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
|
||||
$shared_item = Post::selectFirst($fields, ['guid' => $guid, 'uid' => 0, 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
|
||||
|
||||
if (!DBA::isResult($shared_item)) {
|
||||
Logger::notice('Post does not exist.', ['guid' => $guid]);
|
||||
DI::logger()->notice('Post does not exist.', ['guid' => $guid]);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -801,14 +800,14 @@ class Item
|
|||
|
||||
public function storeAttachmentFromRequest(array $request): string
|
||||
{
|
||||
$attachment_type = $request['attachment_type'] ?? '';
|
||||
$attachment_type = $request['attachment_type'] ?? '';
|
||||
$attachment_title = $request['attachment_title'] ?? '';
|
||||
$attachment_text = $request['attachment_text'] ?? '';
|
||||
$attachment_text = $request['attachment_text'] ?? '';
|
||||
|
||||
$attachment_url = hex2bin($request['attachment_url'] ?? '');
|
||||
$attachment_url = hex2bin($request['attachment_url'] ?? '');
|
||||
$attachment_img_src = hex2bin($request['attachment_img_src'] ?? '');
|
||||
|
||||
$attachment_img_width = $request['attachment_img_width'] ?? 0;
|
||||
$attachment_img_width = $request['attachment_img_width'] ?? 0;
|
||||
$attachment_img_height = $request['attachment_img_height'] ?? 0;
|
||||
|
||||
// Fetch the basic attachment data
|
||||
|
@ -816,10 +815,10 @@ class Item
|
|||
unset($attachment['keywords']);
|
||||
|
||||
// Overwrite the basic data with possible changes from the frontend
|
||||
$attachment['type'] = $attachment_type;
|
||||
$attachment['type'] = $attachment_type;
|
||||
$attachment['title'] = $attachment_title;
|
||||
$attachment['text'] = $attachment_text;
|
||||
$attachment['url'] = $attachment_url;
|
||||
$attachment['text'] = $attachment_text;
|
||||
$attachment['url'] = $attachment_url;
|
||||
|
||||
if (!empty($attachment_img_src)) {
|
||||
$attachment['images'] = [
|
||||
|
@ -843,7 +842,7 @@ class Item
|
|||
$filedas = FileTag::fileToArray($post['file']);
|
||||
}
|
||||
|
||||
$list_array = explode(',', trim($category));
|
||||
$list_array = explode(',', trim($category));
|
||||
$post['file'] = FileTag::arrayToFile($list_array, 'category');
|
||||
|
||||
if (!empty($filedas) && is_array($filedas)) {
|
||||
|
@ -859,8 +858,8 @@ class Item
|
|||
if ($toplevel_item) {
|
||||
$post['allow_cid'] = $toplevel_item['allow_cid'] ?? '';
|
||||
$post['allow_gid'] = $toplevel_item['allow_gid'] ?? '';
|
||||
$post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
|
||||
$post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
|
||||
$post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
|
||||
$post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
|
||||
$post['private'] = $toplevel_item['private'];
|
||||
return $post;
|
||||
}
|
||||
|
@ -879,7 +878,7 @@ class Item
|
|||
if ($visibility === 'public') {
|
||||
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
|
||||
$post['allow_cid'] = $post['allow_gid'] = $post['deny_cid'] = $post['deny_gid'] = '';
|
||||
} else if ($visibility === 'custom') {
|
||||
} elseif ($visibility === 'custom') {
|
||||
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
|
||||
// case that would make it public. So we always append the author's contact id to the allowed contacts.
|
||||
// See https://github.com/friendica/friendica/issues/9672
|
||||
|
@ -908,7 +907,7 @@ class Item
|
|||
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || !empty($data['type']))
|
||||
&& ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)
|
||||
) {
|
||||
$post['post-type'] = ItemModel::PT_PAGE;
|
||||
$post['post-type'] = ItemModel::PT_PAGE;
|
||||
$post['object-type'] = Activity\ObjectType::BOOKMARK;
|
||||
}
|
||||
|
||||
|
@ -926,10 +925,10 @@ class Item
|
|||
$post['direction'] = Conversation::PUSH;
|
||||
$post['received'] = DateTimeFormat::utcNow();
|
||||
$post['origin'] = true;
|
||||
$post['wall'] = $post['wall'] ?? true;
|
||||
$post['guid'] = $post['guid'] ?? System::createUUID();
|
||||
$post['verb'] = $post['verb'] ?? Activity::POST;
|
||||
$post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
|
||||
$post['wall'] = $post['wall'] ?? true;
|
||||
$post['guid'] = $post['guid'] ?? System::createUUID();
|
||||
$post['verb'] = $post['verb'] ?? Activity::POST;
|
||||
$post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
|
||||
$post['thr-parent'] = $post['thr-parent'] ?? $post['uri'];
|
||||
|
||||
if (empty($post['gravity'])) {
|
||||
|
@ -990,7 +989,7 @@ class Item
|
|||
// Convert links with empty descriptions to links without an explicit description
|
||||
$post['body'] = trim(preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $post['body']));
|
||||
$post['body'] = $this->bbCodeVideo->transform($post['body']);
|
||||
$post = $this->setObjectType($post);
|
||||
$post = $this->setObjectType($post);
|
||||
|
||||
// Personal notes must never be altered to a group post.
|
||||
if ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE) {
|
||||
|
@ -1084,10 +1083,10 @@ class Item
|
|||
}
|
||||
|
||||
if (($expire_interval > 0) && !empty($created)) {
|
||||
$expire_date = time() - ($expire_interval * 86400);
|
||||
$expire_date = time() - ($expire_interval * 86400);
|
||||
$created_date = strtotime($created);
|
||||
if ($created_date < $expire_date) {
|
||||
Logger::notice('Item created before expiration interval.', ['created' => date('c', $created_date), 'expired' => date('c', $expire_date)]);
|
||||
DI::logger()->notice('Item created before expiration interval.', ['created' => date('c', $created_date), 'expired' => date('c', $expire_date)]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\ParseUrl;
|
||||
|
@ -28,7 +27,7 @@ class PageInfo
|
|||
*/
|
||||
public static function searchAndAppendToBody(string $body, bool $searchNakedUrls = false, bool $no_photos = false)
|
||||
{
|
||||
Logger::debug('add_page_info_to_body: fetch page info for body', ['body' => $body]);
|
||||
DI::logger()->debug('add_page_info_to_body: fetch page info for body', ['body' => $body]);
|
||||
|
||||
$url = self::getRelevantUrlFromBody($body, $searchNakedUrls);
|
||||
if (!$url) {
|
||||
|
@ -60,7 +59,7 @@ class PageInfo
|
|||
$body = substr_replace($body, "\n[bookmark=" . $data['url'] . ']' . $linkTitle . "[/bookmark]\n", $existingAttachmentPos, 0);
|
||||
} else {
|
||||
$footer = self::getFooterFromData($data, $no_photos);
|
||||
$body = self::stripTrailingUrlFromBody($body, $data['url']);
|
||||
$body = self::stripTrailingUrlFromBody($body, $data['url']);
|
||||
$body .= "\n" . $footer;
|
||||
}
|
||||
|
||||
|
@ -194,7 +193,7 @@ class PageInfo
|
|||
}
|
||||
}
|
||||
|
||||
Logger::debug('fetch page info for URL', ['url' => $url, 'data' => $data]);
|
||||
DI::logger()->debug('fetch page info for URL', ['url' => $url, 'data' => $data]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -216,8 +215,11 @@ class PageInfo
|
|||
|
||||
$taglist = [];
|
||||
foreach ($data['keywords'] as $keyword) {
|
||||
$hashtag = str_replace([' ', '+', '/', '.', '#', "'"],
|
||||
['', '', '', '', '', ''], $keyword);
|
||||
$hashtag = str_replace(
|
||||
[' ', '+', '/', '.', '#', "'"],
|
||||
['', '', '', '', '', ''],
|
||||
$keyword
|
||||
);
|
||||
|
||||
$taglist[] = $hashtag;
|
||||
}
|
||||
|
@ -271,7 +273,7 @@ class PageInfo
|
|||
protected static function stripTrailingUrlFromBody(string $body, string $url): string
|
||||
{
|
||||
$quotedUrl = preg_quote($url, '#');
|
||||
$body = preg_replace_callback("#(?:
|
||||
$body = preg_replace_callback("#(?:
|
||||
\[url]$quotedUrl\[/url]|
|
||||
\[url=$quotedUrl]$quotedUrl\[/url]|
|
||||
\[url=$quotedUrl]([^[]*?)\[/url]|
|
||||
|
|
|
@ -16,7 +16,6 @@ use Friendica\Content\OEmbed;
|
|||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Content\Smilies;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
@ -131,10 +130,11 @@ class BBCode
|
|||
break;
|
||||
|
||||
case 'title':
|
||||
$value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
|
||||
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
|
||||
$value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
|
||||
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
|
||||
$data['title'] = self::escapeContent($value);
|
||||
|
||||
// no break
|
||||
default:
|
||||
$data[$field] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
|
||||
break;
|
||||
|
@ -290,7 +290,7 @@ class BBCode
|
|||
// Remove all unneeded white space
|
||||
do {
|
||||
$oldtext = $text;
|
||||
$text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
|
||||
$text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
|
||||
} while ($oldtext != $text);
|
||||
|
||||
return trim($text);
|
||||
|
@ -328,15 +328,15 @@ class BBCode
|
|||
// than the maximum, then don't waste time looking for the images
|
||||
if ($maxlen && (strlen($body) > $maxlen)) {
|
||||
|
||||
Logger::info('the total body length exceeds the limit', ['maxlen' => $maxlen, 'body_len' => strlen($body)]);
|
||||
DI::logger()->info('the total body length exceeds the limit', ['maxlen' => $maxlen, 'body_len' => strlen($body)]);
|
||||
|
||||
$orig_body = $body;
|
||||
$new_body = '';
|
||||
$textlen = 0;
|
||||
$new_body = '';
|
||||
$textlen = 0;
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
while (($img_st_close !== false) && ($img_end !== false)) {
|
||||
|
||||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
|
@ -348,9 +348,9 @@ class BBCode
|
|||
|
||||
if (($textlen + $img_start) > $maxlen) {
|
||||
if ($textlen < $maxlen) {
|
||||
Logger::debug('the limit happens before an embedded image');
|
||||
DI::logger()->debug('the limit happens before an embedded image');
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
$textlen = $maxlen;
|
||||
$textlen = $maxlen;
|
||||
}
|
||||
} else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start);
|
||||
|
@ -362,9 +362,9 @@ class BBCode
|
|||
|
||||
if (($textlen + $img_end) > $maxlen) {
|
||||
if ($textlen < $maxlen) {
|
||||
Logger::debug('the limit happens before the end of a non-embedded image');
|
||||
DI::logger()->debug('the limit happens before the end of a non-embedded image');
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
$textlen = $maxlen;
|
||||
$textlen = $maxlen;
|
||||
}
|
||||
} else {
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_end);
|
||||
|
@ -378,18 +378,18 @@ class BBCode
|
|||
$orig_body = '';
|
||||
}
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
}
|
||||
|
||||
if (($textlen + strlen($orig_body)) > $maxlen) {
|
||||
if ($textlen < $maxlen) {
|
||||
Logger::debug('the limit happens after the end of the last image');
|
||||
DI::logger()->debug('the limit happens after the end of the last image');
|
||||
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
|
||||
}
|
||||
} else {
|
||||
Logger::debug('the text size with embedded images extracted did not violate the limit');
|
||||
DI::logger()->debug('the text size with embedded images extracted did not violate the limit');
|
||||
$new_body = $new_body . $orig_body;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ class BBCode
|
|||
|
||||
if (((strpos($data['text'], '[img=') !== false) || (strpos($data['text'], '[img]') !== false) || DI::config()->get('system', 'always_show_preview')) && !empty($data['image'])) {
|
||||
$data['preview'] = $data['image'];
|
||||
$data['image'] = '';
|
||||
$data['image'] = '';
|
||||
}
|
||||
|
||||
$return = '';
|
||||
|
@ -507,11 +507,11 @@ class BBCode
|
|||
}
|
||||
|
||||
$title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false);
|
||||
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
|
||||
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
|
||||
if ($plaintext || (($title != '') && strstr($text, $title))) {
|
||||
$data['title'] = $data['url'];
|
||||
} elseif (($text != '') && strstr($title, $text)) {
|
||||
$data['text'] = $data['title'];
|
||||
$data['text'] = $data['title'];
|
||||
$data['title'] = $data['url'];
|
||||
}
|
||||
|
||||
|
@ -585,11 +585,11 @@ class BBCode
|
|||
|
||||
$res = [
|
||||
'start' => [
|
||||
'open' => $start_open,
|
||||
'open' => $start_open,
|
||||
'close' => $start_close
|
||||
],
|
||||
'end' => [
|
||||
'open' => $end_open,
|
||||
'open' => $end_open,
|
||||
'close' => $end_open + strlen('[/' . $name . ']')
|
||||
],
|
||||
];
|
||||
|
@ -615,17 +615,17 @@ class BBCode
|
|||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
$occurrences = 0;
|
||||
$pos = self::getTagPosition($text, $name, $occurrences);
|
||||
$pos = self::getTagPosition($text, $name, $occurrences);
|
||||
while ($pos !== false && $occurrences++ < 1000) {
|
||||
$start = substr($text, 0, $pos['start']['open']);
|
||||
$start = substr($text, 0, $pos['start']['open']);
|
||||
$subject = substr($text, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
|
||||
$end = substr($text, $pos['end']['close']);
|
||||
$end = substr($text, $pos['end']['close']);
|
||||
if ($end === false) {
|
||||
$end = '';
|
||||
}
|
||||
|
||||
$subject = preg_replace($pattern, $replace, $subject);
|
||||
$text = $start . $subject . $end;
|
||||
$text = $start . $subject . $end;
|
||||
|
||||
$pos = self::getTagPosition($text, $name, $occurrences);
|
||||
}
|
||||
|
@ -637,13 +637,13 @@ class BBCode
|
|||
private static function extractImagesFromItemBody(string $body): array
|
||||
{
|
||||
$saved_image = [];
|
||||
$orig_body = $body;
|
||||
$new_body = '';
|
||||
$orig_body = $body;
|
||||
$new_body = '';
|
||||
|
||||
$cnt = 0;
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$cnt = 0;
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
while (($img_st_close !== false) && ($img_end !== false)) {
|
||||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
$img_end += $img_start;
|
||||
|
@ -651,7 +651,7 @@ class BBCode
|
|||
if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
|
||||
// This is an embedded image
|
||||
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]';
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]';
|
||||
|
||||
$cnt++;
|
||||
} else {
|
||||
|
@ -665,9 +665,9 @@ class BBCode
|
|||
$orig_body = '';
|
||||
}
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
}
|
||||
|
||||
$new_body = $new_body . $orig_body;
|
||||
|
@ -737,7 +737,7 @@ class BBCode
|
|||
$attributes = self::extractShareAttributes($matches[2]);
|
||||
|
||||
$attributes['comment'] = trim($matches[1]);
|
||||
$attributes['shared'] = trim($matches[3]);
|
||||
$attributes['shared'] = trim($matches[3]);
|
||||
|
||||
DI::profiler()->stopRecording();
|
||||
return $attributes;
|
||||
|
@ -797,13 +797,13 @@ class BBCode
|
|||
function ($match) use ($callback, $uriid) {
|
||||
$attributes = self::extractShareAttributes($match[2]);
|
||||
|
||||
$author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
|
||||
$author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
|
||||
$author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
|
||||
$author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
|
||||
$author_contact['addr'] = ($author_contact['addr'] ?? '');
|
||||
|
||||
$attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
|
||||
$attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
|
||||
$attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
|
||||
$attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
|
||||
$attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
|
||||
$attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
|
||||
|
||||
if (!empty($author_contact['id'])) {
|
||||
$attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], Proxy::SIZE_THUMB);
|
||||
|
@ -832,7 +832,7 @@ class BBCode
|
|||
"/\[[zi]mg(.*?)\]([^\[\]]*)\[\/[zi]mg\]/ism",
|
||||
function ($match) use ($simplehtml, $uriid) {
|
||||
$attribute_string = $match[1];
|
||||
$attributes = [];
|
||||
$attributes = [];
|
||||
foreach (['alt', 'width', 'height'] as $field) {
|
||||
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
|
||||
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
|
@ -908,7 +908,7 @@ class BBCode
|
|||
break;
|
||||
case self::ACTIVITYPUB:
|
||||
$author = '@<span class="vcard"><a href="' . $author_contact['url'] . '" class="url u-url mention" title="' . $author_contact['addr'] . '"><span class="fn nickname mention">' . $author_contact['addr'] . '</span></a>:</span>';
|
||||
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\n";
|
||||
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\n";
|
||||
break;
|
||||
default:
|
||||
$text = ($is_quote_share ? "\n" : '');
|
||||
|
@ -917,7 +917,7 @@ class BBCode
|
|||
$network = $contact['network'] ?? Protocol::PHANTOM;
|
||||
|
||||
$gsid = ContactSelector::getServerIdForProfile($attributes['profile']);
|
||||
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
|
||||
$text .= self::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [
|
||||
'$profile' => $attributes['profile'],
|
||||
'$avatar' => $attributes['avatar'],
|
||||
|
@ -939,7 +939,7 @@ class BBCode
|
|||
private static function removePictureLinksCallback(array $match): string
|
||||
{
|
||||
$cache_key = 'remove:' . $match[1];
|
||||
$text = DI::cache()->get($cache_key);
|
||||
$text = DI::cache()->get($cache_key);
|
||||
|
||||
if (is_null($text)) {
|
||||
$curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
|
||||
|
@ -964,7 +964,7 @@ class BBCode
|
|||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($body);
|
||||
$xpath = new DOMXPath($doc);
|
||||
$list = $xpath->query('//meta[@name]');
|
||||
$list = $xpath->query('//meta[@name]');
|
||||
foreach ($list as $node) {
|
||||
$attr = [];
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ class BBCode
|
|||
}
|
||||
|
||||
$cache_key = 'clean:' . $match[1];
|
||||
$text = DI::cache()->get($cache_key);
|
||||
$text = DI::cache()->get($cache_key);
|
||||
if (!is_null($text)) {
|
||||
return $text;
|
||||
}
|
||||
|
@ -1067,7 +1067,7 @@ class BBCode
|
|||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($body);
|
||||
$xpath = new DOMXPath($doc);
|
||||
$list = $xpath->query('//meta[@name]');
|
||||
$list = $xpath->query('//meta[@name]');
|
||||
foreach ($list as $node) {
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
|
@ -1135,7 +1135,7 @@ class BBCode
|
|||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
$regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
||||
$body = preg_replace_callback($regexp, [self::class, 'mentionCallback'], $body);
|
||||
$body = preg_replace_callback($regexp, [self::class, 'mentionCallback'], $body);
|
||||
DI::profiler()->stopRecording();
|
||||
return $body;
|
||||
}
|
||||
|
@ -1171,7 +1171,7 @@ class BBCode
|
|||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
$regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
||||
$body = preg_replace_callback($regexp, [self::class, 'mentionToAddrCallback'], $body);
|
||||
$body = preg_replace_callback($regexp, [self::class, 'mentionToAddrCallback'], $body);
|
||||
DI::profiler()->stopRecording();
|
||||
return $body;
|
||||
}
|
||||
|
@ -1311,7 +1311,7 @@ class BBCode
|
|||
* $match[2] = $title or absent
|
||||
*/
|
||||
$try_oembed_callback = function (array $match) use ($uriid) {
|
||||
$url = $match[1];
|
||||
$url = $match[1];
|
||||
$title = $match[2] ?? '';
|
||||
|
||||
try {
|
||||
|
@ -1326,7 +1326,7 @@ class BBCode
|
|||
// Extract the private images which use data urls since preg has issues with
|
||||
// large data sizes. Stash them away while we do bbcode conversion, and then put them back
|
||||
// in after we've done all the regex matching. We cannot use any preg functions to do this.
|
||||
$extracted = self::extractImagesFromItemBody($text);
|
||||
$extracted = self::extractImagesFromItemBody($text);
|
||||
$saved_image = $extracted['images'];
|
||||
|
||||
// General clean up of the content, for example unneeded blanks and new lines
|
||||
|
@ -1475,13 +1475,13 @@ class BBCode
|
|||
];
|
||||
do {
|
||||
$oldtext = $text;
|
||||
$text = str_replace($search, $replace, $text);
|
||||
$text = str_replace($search, $replace, $text);
|
||||
} while ($oldtext != $text);
|
||||
|
||||
// Replace these here only once
|
||||
$search = ["\n[table]", "[/table]\n"];
|
||||
$search = ["\n[table]", "[/table]\n"];
|
||||
$replace = ["[table]", "[/table]"];
|
||||
$text = str_replace($search, $replace, $text);
|
||||
$text = str_replace($search, $replace, $text);
|
||||
|
||||
// Trim new lines regardless of the system.remove_multiplicated_lines config value
|
||||
$text = trim($text, "\n");
|
||||
|
@ -1498,7 +1498,7 @@ class BBCode
|
|||
];
|
||||
do {
|
||||
$oldtext = $text;
|
||||
$text = str_replace($search, $replace, $text);
|
||||
$text = str_replace($search, $replace, $text);
|
||||
} while ($oldtext != $text);
|
||||
}
|
||||
|
||||
|
@ -1635,7 +1635,7 @@ class BBCode
|
|||
}
|
||||
|
||||
$elements = [
|
||||
'del' => 's', 'ins' => 'em', 'kbd' => 'code', 'mark' => 'strong',
|
||||
'del' => 's', 'ins' => 'em', 'kbd' => 'code', 'mark' => 'strong',
|
||||
'samp' => 'code', 'u' => 'em', 'var' => 'em'
|
||||
];
|
||||
foreach ($elements as $bbcode => $html) {
|
||||
|
@ -1750,7 +1750,7 @@ class BBCode
|
|||
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($text, "[/spoiler]") !== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
|
||||
while ((strpos($text, "[/spoiler]") !== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
|
||||
$text = preg_replace(
|
||||
"/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
|
||||
'<details class="spoiler"><summary>$1</summary>$2</details>',
|
||||
|
@ -1796,7 +1796,7 @@ class BBCode
|
|||
|
||||
// handle nested quotes
|
||||
$endlessloop = 0;
|
||||
while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
|
||||
while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
|
||||
$text = preg_replace(
|
||||
"/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
|
||||
"<p><strong class=" . '"author"' . ">" . $t_wrote . "</strong></p><blockquote>$2</blockquote>",
|
||||
|
@ -1830,7 +1830,7 @@ class BBCode
|
|||
"/\[[iz]mg\=(.*?)\](.*?)\[\/[iz]mg\]/ism",
|
||||
function ($matches) use ($simple_html, $uriid) {
|
||||
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
|
||||
$alt = htmlspecialchars($matches[2], ENT_COMPAT);
|
||||
$alt = htmlspecialchars($matches[2], ENT_COMPAT);
|
||||
// Fix for Markdown problems with Diaspora, see issue #12701
|
||||
if (($simple_html != self::DIASPORA) || strpos($matches[2], '"') === false) {
|
||||
return '<img src="' . $matches[1] . '" alt="' . $alt . '" title="' . $alt . '" class="' . (empty($alt) ? 'empty-description' : 'has-alt-description') . '">';
|
||||
|
@ -2044,7 +2044,7 @@ class BBCode
|
|||
// Server independent link to posts and comments
|
||||
// See issue: https://github.com/diaspora/diaspora_federation/issues/75
|
||||
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
|
||||
$text = preg_replace($expression, DI::baseUrl() . "/display/$1", $text);
|
||||
$text = preg_replace($expression, DI::baseUrl() . "/display/$1", $text);
|
||||
|
||||
/* Tag conversion
|
||||
* Supports:
|
||||
|
@ -2107,7 +2107,7 @@ class BBCode
|
|||
try {
|
||||
return (string)Uri::fromParts($parts);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Exception on unparsing url', ['url' => $url, 'parts' => $parts, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Exception on unparsing url', ['url' => $url, 'parts' => $parts, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
@ -2219,7 +2219,7 @@ class BBCode
|
|||
});
|
||||
|
||||
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
|
||||
$text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
|
||||
$text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
@ -2319,7 +2319,7 @@ class BBCode
|
|||
* Transform #tags, strip off the [url] and replace spaces with underscore
|
||||
*/
|
||||
$url_search_string = "^\[\]";
|
||||
$text = preg_replace_callback(
|
||||
$text = preg_replace_callback(
|
||||
"/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
|
||||
function ($matches) {
|
||||
return '#' . str_replace(' ', '_', $matches[2]);
|
||||
|
@ -2368,7 +2368,7 @@ class BBCode
|
|||
|
||||
if ($for_diaspora) {
|
||||
$url_search_string = "^\[\]";
|
||||
$text = preg_replace_callback(
|
||||
$text = preg_replace_callback(
|
||||
"/([@!])\[(.*?)\]\(([$url_search_string]*?)\)/ism",
|
||||
[self::class, 'bbCodeMention2DiasporaCallback'],
|
||||
$text
|
||||
|
@ -2572,7 +2572,7 @@ class BBCode
|
|||
$header .= "' message_id='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $uri);
|
||||
}
|
||||
|
||||
$header .= "']";
|
||||
$header .= "']";
|
||||
|
||||
DI::profiler()->stopRecording();
|
||||
return $header;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Content\Text;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
||||
|
@ -25,10 +24,11 @@ class Markdown
|
|||
* @param string $baseuri Optional. Prepend anchor links with this URL
|
||||
* @return string
|
||||
*/
|
||||
public static function convert($text, $hardwrap = true, $baseuri = null) {
|
||||
public static function convert($text, $hardwrap = true, $baseuri = null)
|
||||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
|
||||
$MarkdownParser = new MarkdownParser();
|
||||
$MarkdownParser = new MarkdownParser();
|
||||
$MarkdownParser->code_class_prefix = 'language-';
|
||||
$MarkdownParser->hard_wrap = $hardwrap;
|
||||
$MarkdownParser->hashtag_protection = true;
|
||||
|
@ -97,7 +97,7 @@ class Markdown
|
|||
{
|
||||
// @TODO Temporary until we find the source of the null value to finally set the correct type-hint
|
||||
if (is_null($s)) {
|
||||
Logger::warning('Received null value');
|
||||
DI::logger()->warning('Received null value');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -122,10 +122,10 @@ class Markdown
|
|||
|
||||
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/shorts\/(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism', '[youtube]$1[/youtube]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/shorts\/(.*?)\].*?\[\/url\]/ism', '[youtube]$1[/youtube]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism', '[vimeo]$2[/vimeo]', 'url', $s);
|
||||
$s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism', '[vimeo]$1[/vimeo]', 'url', $s);
|
||||
|
||||
// remove duplicate adjacent code tags
|
||||
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Content\Widget;
|
|||
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
@ -34,17 +33,17 @@ class VCard
|
|||
public static function getHTML(array $contact, bool $hide_mention = false, bool $hide_follow = false): string
|
||||
{
|
||||
if (!isset($contact['network']) || !isset($contact['id'])) {
|
||||
Logger::warning('Incomplete contact', ['contact' => $contact]);
|
||||
DI::logger()->warning('Incomplete contact', ['contact' => $contact]);
|
||||
}
|
||||
|
||||
$contact_url = Contact::getProfileLink($contact);
|
||||
|
||||
if ($contact['network'] != '') {
|
||||
$network_link = Strings::formatNetworkName($contact['network'], $contact_url);
|
||||
$network_svg = ContactSelector::networkToSVG($contact['network'], $contact['gsid'], '', DI::userSession()->getLocalUserId());
|
||||
$network_link = Strings::formatNetworkName($contact['network'], $contact_url);
|
||||
$network_svg = ContactSelector::networkToSVG($contact['network'], $contact['gsid'], '', DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
$network_link = '';
|
||||
$network_svg = '';
|
||||
$network_link = '';
|
||||
$network_svg = '';
|
||||
}
|
||||
|
||||
$follow_link = '';
|
||||
|
@ -54,7 +53,7 @@ class VCard
|
|||
$mention_link = '';
|
||||
$showgroup_link = '';
|
||||
|
||||
$photo = Contact::getPhoto($contact);
|
||||
$photo = Contact::getPhoto($contact);
|
||||
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
if (Contact\User::isIsBlocked($contact['id'], DI::userSession()->getLocalUserId())) {
|
||||
|
@ -69,8 +68,8 @@ class VCard
|
|||
} else {
|
||||
$pcontact = Contact::selectFirst([], ['uid' => DI::userSession()->getLocalUserId(), 'uri-id' => $contact['uri-id'], 'deleted' => false]);
|
||||
|
||||
$id = $pcontact['id'] ?? $contact['id'];
|
||||
$rel = $pcontact['rel'] ?? Contact::NOTHING;
|
||||
$id = $pcontact['id'] ?? $contact['id'];
|
||||
$rel = $pcontact['rel'] ?? Contact::NOTHING;
|
||||
$pending = $pcontact['pending'] ?? false;
|
||||
|
||||
if (!empty($pcontact) && in_array($pcontact['network'], [Protocol::MAIL, Protocol::FEED])) {
|
||||
|
@ -92,8 +91,8 @@ class VCard
|
|||
|
||||
if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
if (!$hide_mention) {
|
||||
$mention_label = DI::l10n()->t('Post to group');
|
||||
$mention_link = 'compose/0?body=!' . $contact['addr'];
|
||||
$mention_label = DI::l10n()->t('Post to group');
|
||||
$mention_link = 'compose/0?body=!' . $contact['addr'];
|
||||
}
|
||||
$showgroup_link = 'contact/' . $id . '/conversations';
|
||||
} elseif (!$hide_mention) {
|
||||
|
|
|
@ -40,12 +40,12 @@ class Addon
|
|||
public static function getAvailableList(): array
|
||||
{
|
||||
$addons = [];
|
||||
$files = glob('addon/*/');
|
||||
$files = glob('addon/*/');
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
list($tmp, $addon) = array_map('trim', explode('/', $file));
|
||||
$info = self::getInfo($addon);
|
||||
$info = self::getInfo($addon);
|
||||
|
||||
if (DI::config()->get('system', 'show_unsupported_addons')
|
||||
|| strtolower($info['status']) != 'unsupported'
|
||||
|
@ -70,7 +70,7 @@ class Addon
|
|||
public static function getAdminList(): array
|
||||
{
|
||||
$addons_admin = [];
|
||||
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||
|
||||
ksort($addons);
|
||||
foreach ($addons as $name => $data) {
|
||||
|
@ -79,8 +79,8 @@ class Addon
|
|||
}
|
||||
|
||||
$addons_admin[$name] = [
|
||||
'url' => 'admin/addons/' . $name,
|
||||
'name' => $name,
|
||||
'url' => 'admin/addons/' . $name,
|
||||
'name' => $name,
|
||||
'class' => 'addon'
|
||||
];
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class Addon
|
|||
{
|
||||
$addon = Strings::sanitizeFilePathItem($addon);
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]);
|
||||
DI::config()->delete('addons', $addon);
|
||||
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
|
@ -150,7 +150,7 @@ class Addon
|
|||
return false;
|
||||
}
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]);
|
||||
$t = @filemtime($addon_file_path);
|
||||
@include_once($addon_file_path);
|
||||
if (function_exists($addon . '_install')) {
|
||||
|
@ -160,7 +160,7 @@ class Addon
|
|||
|
||||
DI::config()->set('addons', $addon, [
|
||||
'last_update' => $t,
|
||||
'admin' => function_exists($addon . '_addon_admin'),
|
||||
'admin' => function_exists($addon . '_addon_admin'),
|
||||
]);
|
||||
|
||||
if (!self::isEnabled($addon)) {
|
||||
|
@ -182,14 +182,14 @@ class Addon
|
|||
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||
|
||||
foreach ($addons as $name => $data) {
|
||||
$addonname = Strings::sanitizeFilePathItem(trim($name));
|
||||
$addonname = Strings::sanitizeFilePathItem(trim($name));
|
||||
$addon_file_path = 'addon/' . $addonname . '/' . $addonname . '.php';
|
||||
if (file_exists($addon_file_path) && $data['last_update'] == filemtime($addon_file_path)) {
|
||||
// Addon unmodified, skipping
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger::debug("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $name]);
|
||||
DI::logger()->debug("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $name]);
|
||||
|
||||
self::uninstall($name);
|
||||
self::install($name);
|
||||
|
@ -218,12 +218,12 @@ class Addon
|
|||
$addon = Strings::sanitizeFilePathItem($addon);
|
||||
|
||||
$info = [
|
||||
'name' => $addon,
|
||||
'name' => $addon,
|
||||
'description' => "",
|
||||
'author' => [],
|
||||
'maintainer' => [],
|
||||
'version' => "",
|
||||
'status' => ""
|
||||
'author' => [],
|
||||
'maintainer' => [],
|
||||
'version' => "",
|
||||
'status' => ""
|
||||
];
|
||||
|
||||
if (!is_file("addon/$addon/$addon.php")) {
|
||||
|
@ -247,7 +247,7 @@ class Addon
|
|||
}
|
||||
|
||||
list($type, $v) = $addon_info;
|
||||
$type = strtolower($type);
|
||||
$type = strtolower($type);
|
||||
if ($type == "author" || $type == "maintainer") {
|
||||
$r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||
if ($r) {
|
||||
|
@ -302,7 +302,7 @@ class Addon
|
|||
public static function getVisibleList(): array
|
||||
{
|
||||
$visible_addons = [];
|
||||
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||
$addons = array_filter(DI::config()->get('addons') ?? []);
|
||||
|
||||
foreach ($addons as $name => $data) {
|
||||
$visible_addons[] = $name;
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Friendica\Core;
|
|||
|
||||
/**
|
||||
* Dependency Injection Container
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface Container
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@ use Dice\Dice;
|
|||
|
||||
/**
|
||||
* Wrapper for the Dice class to make some basic setups
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class DiceContainer implements Container
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@ use Psr\Log\LoggerInterface;
|
|||
*
|
||||
* @see \Friendica\Core\Logger\Factory\StreamLogger
|
||||
* @see \Friendica\Core\Logger\Factory\SyslogLogger
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class LegacyLoggerFactory implements LoggerFactory
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ use Psr\Log\NullLogger;
|
|||
|
||||
/**
|
||||
* Manager for the core logging instances
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class LoggerManager
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
@ -56,7 +57,7 @@ class Protocol
|
|||
const XMPP = 'xmpp'; // XMPP
|
||||
const ZOT = 'zot!'; // Zot!
|
||||
|
||||
const PHANTOM = 'unkn'; // Place holder
|
||||
const PHANTOM = 'unkn'; // Place holder
|
||||
|
||||
/**
|
||||
* Returns whether the provided protocol supports following
|
||||
|
@ -73,7 +74,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null
|
||||
];
|
||||
Hook::callAll('support_follow', $hook_data);
|
||||
|
||||
|
@ -95,7 +96,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null
|
||||
];
|
||||
Hook::callAll('support_revoke_follow', $hook_data);
|
||||
|
||||
|
@ -123,7 +124,7 @@ class Protocol
|
|||
|
||||
if ($protocol == self::DIASPORA) {
|
||||
$contact = Diaspora::sendShare($owner, $contact);
|
||||
Logger::notice('share returns: ' . $contact);
|
||||
DI::logger()->notice('share returns: ' . $contact);
|
||||
} elseif (in_array($protocol, [self::ACTIVITYPUB, self::DFRN])) {
|
||||
$activity_id = ActivityPub\Transmitter::activityIDFromContact($contact['id']);
|
||||
if (empty($activity_id)) {
|
||||
|
@ -132,7 +133,7 @@ class Protocol
|
|||
}
|
||||
|
||||
$success = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $owner['uid'], $activity_id);
|
||||
Logger::notice('Follow returns: ' . $success);
|
||||
DI::logger()->notice('Follow returns: ' . $success);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -150,7 +151,7 @@ class Protocol
|
|||
public static function unfollow(array $contact, array $owner): ?bool
|
||||
{
|
||||
if (empty($contact['network'])) {
|
||||
Logger::notice('Contact has got no network, we quit here', ['id' => $contact['id']]);
|
||||
DI::logger()->notice('Contact has got no network, we quit here', ['id' => $contact['id']]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -241,8 +242,8 @@ class Protocol
|
|||
// Catch-all hook for connector addons
|
||||
$hook_data = [
|
||||
'contact' => $contact,
|
||||
'uid' => $uid,
|
||||
'result' => null,
|
||||
'uid' => $uid,
|
||||
'result' => null,
|
||||
];
|
||||
Hook::callAll('block', $hook_data);
|
||||
|
||||
|
@ -280,8 +281,8 @@ class Protocol
|
|||
// Catch-all hook for connector addons
|
||||
$hook_data = [
|
||||
'contact' => $contact,
|
||||
'uid' => $uid,
|
||||
'result' => null,
|
||||
'uid' => $uid,
|
||||
'result' => null,
|
||||
];
|
||||
Hook::callAll('unblock', $hook_data);
|
||||
|
||||
|
@ -308,7 +309,7 @@ class Protocol
|
|||
|
||||
$hook_data = [
|
||||
'protocol' => $protocol,
|
||||
'result' => null
|
||||
'result' => null
|
||||
];
|
||||
Hook::callAll('support_probe', $hook_data);
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Object\Search\ContactResult;
|
||||
use Friendica\Object\Search\ResultList;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
/**
|
||||
|
@ -118,15 +117,15 @@ class Search
|
|||
$results = json_decode($resultJson, true);
|
||||
|
||||
$resultList = new ResultList(
|
||||
($results['page'] ?? 0) ?: 1,
|
||||
$results['count'] ?? 0,
|
||||
($results['page'] ?? 0) ?: 1,
|
||||
$results['count'] ?? 0,
|
||||
($results['itemsperpage'] ?? 0) ?: 30
|
||||
);
|
||||
|
||||
$profiles = $results['profiles'] ?? [];
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
$profile_url = $profile['profile_url'] ?? '';
|
||||
$profile_url = $profile['profile_url'] ?? '';
|
||||
$contactDetails = Contact::getByURLForUser($profile_url, DI::userSession()->getLocalUserId());
|
||||
|
||||
$result = new ContactResult(
|
||||
|
@ -138,7 +137,7 @@ class Search
|
|||
Protocol::DFRN,
|
||||
$contactDetails['cid'] ?? 0,
|
||||
$contactDetails['zid'] ?? 0,
|
||||
$profile['tags'] ?? ''
|
||||
$profile['tags'] ?? ''
|
||||
);
|
||||
|
||||
$resultList->addResult($result);
|
||||
|
@ -160,7 +159,7 @@ class Search
|
|||
*/
|
||||
public static function getContactsFromLocalDirectory(string $search, int $type = self::TYPE_ALL, int $start = 0, int $itemPage = 80): ResultList
|
||||
{
|
||||
Logger::info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
|
||||
DI::logger()->info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
|
||||
|
||||
$contacts = Contact::searchByName($search, $type == self::TYPE_GROUP ? 'community' : '', true);
|
||||
|
||||
|
@ -200,7 +199,7 @@ class Search
|
|||
*/
|
||||
public static function searchContact(string $search, string $mode, int $page = 1): array
|
||||
{
|
||||
Logger::info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
|
||||
DI::logger()->info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
return [];
|
||||
|
@ -223,7 +222,7 @@ class Search
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
if ($curlResult->isSuccess()) {
|
||||
|
@ -232,7 +231,7 @@ class Search
|
|||
// Converting Directory Search results into contact-looking records
|
||||
$return = array_map(function ($result) {
|
||||
static $contactType = [
|
||||
'People' => Contact::TYPE_PERSON,
|
||||
'People' => Contact::TYPE_PERSON,
|
||||
// Kept for backward compatibility
|
||||
'Forum' => Contact::TYPE_COMMUNITY,
|
||||
'Group' => Contact::TYPE_COMMUNITY,
|
||||
|
|
|
@ -322,7 +322,7 @@ class System
|
|||
}
|
||||
|
||||
if ($status) {
|
||||
Logger::notice('xml_status returning non_zero: ' . $status . " message=" . $message);
|
||||
DI::logger()->notice('xml_status returning non_zero: ' . $status . " message=" . $message);
|
||||
}
|
||||
|
||||
self::httpExit(XML::fromArray(['result' => $result]), Response::TYPE_XML);
|
||||
|
@ -340,7 +340,7 @@ class System
|
|||
public static function httpError($httpCode, $message = '', $content = '')
|
||||
{
|
||||
if ($httpCode >= 400) {
|
||||
Logger::debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
DI::logger()->debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
}
|
||||
DI::apiResponse()->setStatus($httpCode, $message);
|
||||
|
||||
|
@ -373,7 +373,7 @@ class System
|
|||
public static function jsonError($httpCode, $content, $content_type = 'application/json')
|
||||
{
|
||||
if ($httpCode >= 400) {
|
||||
Logger::debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
DI::logger()->debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
|
||||
}
|
||||
DI::apiResponse()->setStatus($httpCode);
|
||||
self::jsonExit($content, $content_type);
|
||||
|
@ -520,7 +520,7 @@ class System
|
|||
public static function externalRedirect($url, $code = 302)
|
||||
{
|
||||
if (empty(parse_url($url, PHP_URL_SCHEME))) {
|
||||
Logger::warning('No fully qualified URL provided', ['url' => $url]);
|
||||
DI::logger()->warning('No fully qualified URL provided', ['url' => $url]);
|
||||
DI::baseUrl()->redirect($url);
|
||||
}
|
||||
|
||||
|
@ -564,27 +564,27 @@ class System
|
|||
private static function isDirectoryUsable(string $directory): bool
|
||||
{
|
||||
if (empty($directory)) {
|
||||
Logger::warning('Directory is empty. This shouldn\'t happen.');
|
||||
DI::logger()->warning('Directory is empty. This shouldn\'t happen.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists($directory)) {
|
||||
Logger::info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_file($directory)) {
|
||||
Logger::warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
Logger::warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_writable($directory)) {
|
||||
Logger::warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
DI::logger()->warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class Theme
|
|||
{
|
||||
$allowed_themes_str = DI::config()->get('system', 'allowed_themes');
|
||||
$allowed_themes_raw = explode(',', str_replace(' ', '', $allowed_themes_str));
|
||||
$allowed_themes = [];
|
||||
$allowed_themes = [];
|
||||
if (count($allowed_themes_raw)) {
|
||||
foreach ($allowed_themes_raw as $theme) {
|
||||
$theme = Strings::sanitizeFilePathItem(trim($theme));
|
||||
|
@ -58,14 +58,14 @@ class Theme
|
|||
$theme = Strings::sanitizeFilePathItem($theme);
|
||||
|
||||
$info = [
|
||||
'name' => $theme,
|
||||
'description' => "",
|
||||
'author' => [],
|
||||
'maintainer' => [],
|
||||
'version' => "",
|
||||
'credits' => "",
|
||||
'name' => $theme,
|
||||
'description' => "",
|
||||
'author' => [],
|
||||
'maintainer' => [],
|
||||
'version' => "",
|
||||
'credits' => "",
|
||||
'experimental' => file_exists("view/theme/$theme/experimental"),
|
||||
'unsupported' => file_exists("view/theme/$theme/unsupported")
|
||||
'unsupported' => file_exists("view/theme/$theme/unsupported")
|
||||
];
|
||||
|
||||
if (!is_file("view/theme/$theme/theme.php")) {
|
||||
|
@ -84,7 +84,7 @@ class Theme
|
|||
$comment_line = trim($comment_line, "\t\n\r */");
|
||||
if (strpos($comment_line, ':') !== false) {
|
||||
list($key, $value) = array_map("trim", explode(":", $comment_line, 2));
|
||||
$key = strtolower($key);
|
||||
$key = strtolower($key);
|
||||
if ($key == "author") {
|
||||
$result = preg_match("|([^<]+)<([^>]+)>|", $value, $matches);
|
||||
if ($result) {
|
||||
|
@ -153,7 +153,7 @@ class Theme
|
|||
}
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
$key = array_search($theme, $allowed_themes);
|
||||
$key = array_search($theme, $allowed_themes);
|
||||
if ($key !== false) {
|
||||
unset($allowed_themes[$key]);
|
||||
Theme::setAllowedList($allowed_themes);
|
||||
|
@ -185,13 +185,13 @@ class Theme
|
|||
$func();
|
||||
}
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
$allowed_themes[] = $theme;
|
||||
Theme::setAllowedList($allowed_themes);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Logger::error('Theme installation failed', ['theme' => $theme, 'error' => $e->getMessage()]);
|
||||
DI::logger()->error('Theme installation failed', ['theme' => $theme, 'error' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class Theme
|
|||
{
|
||||
$theme = Strings::sanitizeFilePathItem($theme);
|
||||
|
||||
$appHelper = DI::appHelper();
|
||||
$appHelper = DI::appHelper();
|
||||
$base_theme = $appHelper->getThemeInfoValue('extends') ?? '';
|
||||
|
||||
if (file_exists("view/theme/$theme/config.php")) {
|
||||
|
|
|
@ -169,7 +169,7 @@ class Update
|
|||
if ($build != DB_UPDATE_VERSION || $force) {
|
||||
require_once 'update.php';
|
||||
|
||||
$stored = intval($build);
|
||||
$stored = intval($build);
|
||||
$current = intval(DB_UPDATE_VERSION);
|
||||
if ($stored < $current || $force) {
|
||||
DI::config()->reload();
|
||||
|
@ -178,7 +178,7 @@ class Update
|
|||
// If the Lock is acquired, never release it automatically to avoid double updates
|
||||
if (DI::lock()->acquire('dbupdate', 0, Cache\Enum\Duration::INFINITE)) {
|
||||
|
||||
Logger::notice('Update starting.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Update starting.', ['from' => $stored, 'to' => $current]);
|
||||
|
||||
// Checks if the build changed during Lock acquiring (so no double update occurs)
|
||||
$retryBuild = DI::config()->get('system', 'build');
|
||||
|
@ -192,7 +192,7 @@ class Update
|
|||
}
|
||||
|
||||
if ($retryBuild != $build) {
|
||||
Logger::notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
|
||||
DI::logger()->notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
|
||||
DI::lock()->release('dbupdate');
|
||||
return '';
|
||||
}
|
||||
|
@ -202,12 +202,15 @@ class Update
|
|||
|
||||
// run the pre_update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $version++) {
|
||||
Logger::notice('Execute pre update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing pre update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
|
||||
DI::logger()->notice('Execute pre update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t(
|
||||
'%s: executing pre update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'),
|
||||
$version
|
||||
));
|
||||
$r = self::runUpdateFunction($version, 'pre_update', $sendMail);
|
||||
if (!$r) {
|
||||
Logger::warning('Pre update failed', ['version' => $version]);
|
||||
DI::logger()->warning('Pre update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -216,12 +219,12 @@ class Update
|
|||
->commit();
|
||||
return $r;
|
||||
} else {
|
||||
Logger::notice('Pre update executed.', ['version' => $version]);
|
||||
DI::logger()->notice('Pre update executed.', ['version' => $version]);
|
||||
}
|
||||
}
|
||||
|
||||
// update the structure in one call
|
||||
Logger::notice('Execute structure update');
|
||||
DI::logger()->notice('Execute structure update');
|
||||
$retval = DBStructure::performUpdate(false, $verbose);
|
||||
if (!empty($retval)) {
|
||||
if ($sendMail) {
|
||||
|
@ -230,7 +233,7 @@ class Update
|
|||
$retval
|
||||
);
|
||||
}
|
||||
Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
DI::logger()->error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -239,17 +242,20 @@ class Update
|
|||
->commit();
|
||||
return $retval;
|
||||
} else {
|
||||
Logger::notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
|
||||
}
|
||||
|
||||
// run the update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $version++) {
|
||||
Logger::notice('Execute post update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing post update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
|
||||
DI::logger()->notice('Execute post update.', ['version' => $version]);
|
||||
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t(
|
||||
'%s: executing post update %d',
|
||||
DateTimeFormat::utcNow() . ' ' . date('e'),
|
||||
$version
|
||||
));
|
||||
$r = self::runUpdateFunction($version, 'update', $sendMail);
|
||||
if (!$r) {
|
||||
Logger::warning('Post update failed', ['version' => $version]);
|
||||
DI::logger()->warning('Post update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->beginTransaction()
|
||||
|
@ -259,7 +265,7 @@ class Update
|
|||
return $r;
|
||||
} else {
|
||||
DI::config()->set('system', 'build', $version);
|
||||
Logger::notice('Post update executed.', ['version' => $version]);
|
||||
DI::logger()->notice('Post update executed.', ['version' => $version]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,12 +277,12 @@ class Update
|
|||
->delete('system', 'maintenance_reason')
|
||||
->commit();
|
||||
|
||||
Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
|
||||
DI::logger()->notice('Update success.', ['from' => $stored, 'to' => $current]);
|
||||
if ($sendMail) {
|
||||
self::updateSuccessful($stored, $current);
|
||||
}
|
||||
} else {
|
||||
Logger::warning('Update lock could not be acquired');
|
||||
DI::logger()->warning('Update lock could not be acquired');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +303,7 @@ class Update
|
|||
{
|
||||
$funcname = $prefix . '_' . $version;
|
||||
|
||||
Logger::notice('Update function start.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function start.', ['function' => $funcname]);
|
||||
|
||||
if (function_exists($funcname)) {
|
||||
// There could be a lot of processes running or about to run.
|
||||
|
@ -310,9 +316,9 @@ class Update
|
|||
if (DI::lock()->acquire('dbupdate_function', 120, Cache\Enum\Duration::INFINITE)) {
|
||||
|
||||
// call the specific update
|
||||
Logger::notice('Pre update function start.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Pre update function start.', ['function' => $funcname]);
|
||||
$retval = $funcname();
|
||||
Logger::notice('Update function done.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function done.', ['function' => $funcname]);
|
||||
|
||||
if ($retval) {
|
||||
if ($sendMail) {
|
||||
|
@ -322,20 +328,20 @@ class Update
|
|||
DI::l10n()->t('Update %s failed. See error logs.', $version)
|
||||
);
|
||||
}
|
||||
Logger::error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
|
||||
DI::logger()->error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
|
||||
DI::lock()->release('dbupdate_function');
|
||||
return false;
|
||||
} else {
|
||||
DI::lock()->release('dbupdate_function');
|
||||
Logger::notice('Update function finished.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function finished.', ['function' => $funcname]);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Logger::error('Locking failed.', ['function' => $funcname]);
|
||||
DI::logger()->error('Locking failed.', ['function' => $funcname]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Logger::notice('Update function skipped.', ['function' => $funcname]);
|
||||
DI::logger()->notice('Update function skipped.', ['function' => $funcname]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -352,20 +358,22 @@ class Update
|
|||
{
|
||||
$adminEmails = User::getAdminListForEmailing(['uid', 'language', 'email']);
|
||||
if (!$adminEmails) {
|
||||
Logger::warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
|
||||
DI::logger()->warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($adminEmails as $admin) {
|
||||
$l10n = DI::l10n()->withLang($admin['language'] ?: 'en');
|
||||
|
||||
$preamble = Strings::deindent($l10n->t("
|
||||
$preamble = Strings::deindent($l10n->t(
|
||||
"
|
||||
The friendica developers released update %s recently,
|
||||
but when I tried to install it, something went terribly wrong.
|
||||
This needs to be fixed soon and I can't do it alone. Please contact a
|
||||
friendica developer if you can not help me on your own. My database might be invalid.",
|
||||
$update_id));
|
||||
$body = $l10n->t('The error message is\n[pre]%s[/pre]', $error_message);
|
||||
$update_id
|
||||
));
|
||||
$body = $l10n->t('The error message is\n[pre]%s[/pre]', $error_message);
|
||||
|
||||
$email = DI::emailer()
|
||||
->newSystemMail()
|
||||
|
@ -376,7 +384,7 @@ class Update
|
|||
DI::emailer()->send($email);
|
||||
}
|
||||
|
||||
Logger::alert('Database structure update failed.', ['error' => $error_message]);
|
||||
DI::logger()->alert('Database structure update failed.', ['error' => $error_message]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -391,9 +399,12 @@ class Update
|
|||
foreach(User::getAdminListForEmailing(['uid', 'language', 'email']) as $admin) {
|
||||
$l10n = DI::l10n()->withLang($admin['language'] ?: 'en');
|
||||
|
||||
$preamble = Strings::deindent($l10n->t('
|
||||
$preamble = Strings::deindent($l10n->t(
|
||||
'
|
||||
The friendica database was successfully updated from %s to %s.',
|
||||
$from_build, $to_build));
|
||||
$from_build,
|
||||
$to_build
|
||||
));
|
||||
|
||||
$email = DI::emailer()
|
||||
->newSystemMail()
|
||||
|
@ -404,6 +415,6 @@ class Update
|
|||
DI::emailer()->send($email);
|
||||
}
|
||||
|
||||
Logger::debug('Database structure update successful.');
|
||||
DI::logger()->debug('Database structure update successful.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class Worker
|
|||
|
||||
// At first check the maximum load. We shouldn't continue with a high load
|
||||
if (DI::system()->isMaxLoadReached()) {
|
||||
Logger::notice('Pre check: maximum load reached, quitting.');
|
||||
DI::logger()->notice('Pre check: maximum load reached, quitting.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class Worker
|
|||
foreach ($r as $entry) {
|
||||
// The work will be done
|
||||
if (!self::execute($entry)) {
|
||||
Logger::warning('Process execution failed, quitting.', ['entry' => $entry]);
|
||||
DI::logger()->warning('Process execution failed, quitting.', ['entry' => $entry]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -131,14 +131,14 @@ class Worker
|
|||
if (DI::lock()->acquire(self::LOCK_WORKER, 0)) {
|
||||
// Count active workers and compare them with a maximum value that depends on the load
|
||||
if (self::tooMuchWorkers()) {
|
||||
Logger::info('Active worker limit reached, quitting.');
|
||||
DI::logger()->info('Active worker limit reached, quitting.');
|
||||
DI::lock()->release(self::LOCK_WORKER);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check free memory
|
||||
if (DI::system()->isMinMemoryReached()) {
|
||||
Logger::warning('Memory limit reached, quitting.');
|
||||
DI::logger()->warning('Memory limit reached, quitting.');
|
||||
DI::lock()->release(self::LOCK_WORKER);
|
||||
return;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class Worker
|
|||
|
||||
// Quit the worker once every cron interval
|
||||
if (time() > ($starttime + (DI::config()->get('system', 'cron_interval') * 60)) && !self::systemLimitReached()) {
|
||||
Logger::info('Process lifetime reached, respawning.');
|
||||
DI::logger()->info('Process lifetime reached, respawning.');
|
||||
self::unclaimProcess($process);
|
||||
if (Worker\Daemon::isMode()) {
|
||||
Worker\IPC::SetJobState(true);
|
||||
|
@ -164,7 +164,7 @@ class Worker
|
|||
if (Worker\Daemon::isMode()) {
|
||||
Worker\IPC::SetJobState(false);
|
||||
}
|
||||
Logger::info("Couldn't select a workerqueue entry, quitting process", ['pid' => getmypid()]);
|
||||
DI::logger()->info("Couldn't select a workerqueue entry, quitting process", ['pid' => getmypid()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,25 +178,25 @@ class Worker
|
|||
{
|
||||
// Count active workers and compare them with a maximum value that depends on the load
|
||||
if (self::tooMuchWorkers()) {
|
||||
Logger::info('Active worker limit reached, quitting.');
|
||||
DI::logger()->info('Active worker limit reached, quitting.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do we have too few memory?
|
||||
if (DI::system()->isMinMemoryReached()) {
|
||||
Logger::warning('Memory limit reached, quitting.');
|
||||
DI::logger()->warning('Memory limit reached, quitting.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Possibly there are too much database connections
|
||||
if (self::maxConnectionsReached()) {
|
||||
Logger::warning('Maximum connections reached, quitting.');
|
||||
DI::logger()->warning('Maximum connections reached, quitting.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Possibly there are too much database processes that block the system
|
||||
if (DI::system()->isMaxProcessesReached()) {
|
||||
Logger::warning('Maximum processes reached, quitting.');
|
||||
DI::logger()->warning('Maximum processes reached, quitting.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -322,19 +322,19 @@ class Worker
|
|||
|
||||
// Quit when in maintenance
|
||||
if (DI::config()->get('system', 'maintenance', false)) {
|
||||
Logger::notice('Maintenance mode - quit process', ['pid' => $mypid]);
|
||||
DI::logger()->notice('Maintenance mode - quit process', ['pid' => $mypid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Constantly check the number of parallel database processes
|
||||
if (DI::system()->isMaxProcessesReached()) {
|
||||
Logger::warning('Max processes reached for process', ['pid' => $mypid]);
|
||||
DI::logger()->warning('Max processes reached for process', ['pid' => $mypid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Constantly check the number of available database connections to let the frontend be accessible at any time
|
||||
if (self::maxConnectionsReached()) {
|
||||
Logger::warning('Max connection reached for process', ['pid' => $mypid]);
|
||||
DI::logger()->warning('Max connection reached for process', ['pid' => $mypid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ class Worker
|
|||
}
|
||||
|
||||
if (empty($argv)) {
|
||||
Logger::warning('Parameter is empty', ['queue' => $queue]);
|
||||
DI::logger()->warning('Parameter is empty', ['queue' => $queue]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ class Worker
|
|||
}
|
||||
|
||||
if (!self::validateInclude($include)) {
|
||||
Logger::warning('Include file is not valid', ['file' => $argv[0]]);
|
||||
DI::logger()->warning('Include file is not valid', ['file' => $argv[0]]);
|
||||
$stamp = (float)microtime(true);
|
||||
DBA::delete('workerqueue', ['id' => $queue['id']]);
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
|
@ -424,7 +424,7 @@ class Worker
|
|||
self::$db_duration = (microtime(true) - $stamp);
|
||||
self::$db_duration_write += (microtime(true) - $stamp);
|
||||
} else {
|
||||
Logger::warning('Function does not exist', ['function' => $funcname]);
|
||||
DI::logger()->warning('Function does not exist', ['function' => $funcname]);
|
||||
$stamp = (float)microtime(true);
|
||||
DBA::delete('workerqueue', ['id' => $queue['id']]);
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
|
@ -477,7 +477,7 @@ class Worker
|
|||
{
|
||||
$cooldown = DI::config()->get('system', 'worker_cooldown', 0);
|
||||
if ($cooldown > 0) {
|
||||
Logger::debug('Wait for cooldown.', ['cooldown' => $cooldown]);
|
||||
DI::logger()->debug('Wait for cooldown.', ['cooldown' => $cooldown]);
|
||||
if ($cooldown < 1) {
|
||||
usleep($cooldown * 1000000);
|
||||
} else {
|
||||
|
@ -501,7 +501,7 @@ class Worker
|
|||
while ($load = System::getLoadAvg($processes_cooldown != 0)) {
|
||||
if (($load_cooldown > 0) && ($load['average1'] > $load_cooldown)) {
|
||||
if (!$sleeping) {
|
||||
Logger::info('Load induced pre execution cooldown.', ['max' => $load_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
DI::logger()->info('Load induced pre execution cooldown.', ['max' => $load_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
$sleeping = true;
|
||||
}
|
||||
sleep(1);
|
||||
|
@ -509,7 +509,7 @@ class Worker
|
|||
}
|
||||
if (($processes_cooldown > 0) && ($load['scheduled'] > $processes_cooldown)) {
|
||||
if (!$sleeping) {
|
||||
Logger::info('Process induced pre execution cooldown.', ['max' => $processes_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
DI::logger()->info('Process induced pre execution cooldown.', ['max' => $processes_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
$sleeping = true;
|
||||
}
|
||||
sleep(1);
|
||||
|
@ -519,7 +519,7 @@ class Worker
|
|||
}
|
||||
|
||||
if ($sleeping) {
|
||||
Logger::info('Cooldown ended.', ['max-load' => $load_cooldown, 'max-processes' => $processes_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
DI::logger()->info('Cooldown ended.', ['max-load' => $load_cooldown, 'max-processes' => $processes_cooldown, 'load' => $load, 'called-by' => System::callstack(1)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,12 +677,12 @@ class Worker
|
|||
// If $max is set we will use the processlist to determine the current number of connections
|
||||
// The processlist only shows entries of the current user
|
||||
if ($max != 0) {
|
||||
Logger::info('Connection usage (user values)', ['working' => $used, 'sleeping' => $sleep, 'max' => $max]);
|
||||
DI::logger()->info('Connection usage (user values)', ['working' => $used, 'sleeping' => $sleep, 'max' => $max]);
|
||||
|
||||
$level = ($used / $max) * 100;
|
||||
|
||||
if ($level >= $maxlevel) {
|
||||
Logger::warning('Maximum level (' . $maxlevel . '%) of user connections reached: ' . $used .'/' . $max);
|
||||
DI::logger()->warning('Maximum level (' . $maxlevel . '%) of user connections reached: ' . $used .'/' . $max);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -705,14 +705,14 @@ class Worker
|
|||
if ($used == 0) {
|
||||
return false;
|
||||
}
|
||||
Logger::info('Connection usage (system values)', ['working' => $used, 'sleeping' => $sleep, 'max' => $max]);
|
||||
DI::logger()->info('Connection usage (system values)', ['working' => $used, 'sleeping' => $sleep, 'max' => $max]);
|
||||
|
||||
$level = $used / $max * 100;
|
||||
|
||||
if ($level < $maxlevel) {
|
||||
return false;
|
||||
}
|
||||
Logger::warning('Maximum level (' . $level . '%) of system connections reached: ' . $used . '/' . $max);
|
||||
DI::logger()->warning('Maximum level (' . $level . '%) of system connections reached: ' . $used . '/' . $max);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -815,16 +815,16 @@ class Worker
|
|||
$high_running = self::processWithPriorityActive($top_priority);
|
||||
|
||||
if (!$high_running && ($top_priority > self::PRIORITY_UNDEFINED) && ($top_priority < self::PRIORITY_NEGLIGIBLE)) {
|
||||
Logger::info('Jobs with a higher priority are waiting but none is executed. Open a fastlane.', ['priority' => $top_priority]);
|
||||
DI::logger()->info('Jobs with a higher priority are waiting but none is executed. Open a fastlane.', ['priority' => $top_priority]);
|
||||
$queues = $active + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Logger::info('Load: ' . $load . '/' . $maxsysload . ' - processes: ' . $deferred . '/' . $active . '/' . $waiting_processes . $processlist . ' - maximum: ' . $queues . '/' . $maxqueues);
|
||||
DI::logger()->info('Load: ' . $load . '/' . $maxsysload . ' - processes: ' . $deferred . '/' . $active . '/' . $waiting_processes . $processlist . ' - maximum: ' . $queues . '/' . $maxqueues);
|
||||
|
||||
// Are there fewer workers running as possible? Then fork a new one.
|
||||
if (!DI::config()->get('system', 'worker_dont_fork', false) && ($queues > ($active + 1)) && self::entriesExists() && !self::systemLimitReached()) {
|
||||
Logger::info('There are fewer workers as possible, fork a new worker.', ['active' => $active, 'queues' => $queues]);
|
||||
DI::logger()->info('There are fewer workers as possible, fork a new worker.', ['active' => $active, 'queues' => $queues]);
|
||||
if (Worker\Daemon::isMode()) {
|
||||
Worker\IPC::SetJobState(true);
|
||||
} else {
|
||||
|
@ -840,10 +840,10 @@ class Worker
|
|||
&& !DBA::exists('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $max_idletime . ' second')])
|
||||
) {
|
||||
DI::cache()->set(self::LAST_CHECK, time(), Duration::HOUR);
|
||||
Logger::info('The last worker execution had been too long ago.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
|
||||
DI::logger()->info('The last worker execution had been too long ago.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
|
||||
return false;
|
||||
} elseif ($max_idletime > 0) {
|
||||
Logger::debug('Maximum idletime not reached.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
|
||||
DI::logger()->debug('Maximum idletime not reached.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ class Worker
|
|||
{
|
||||
$priority = self::nextPriority();
|
||||
if (empty($priority)) {
|
||||
Logger::info('No tasks found');
|
||||
DI::logger()->info('No tasks found');
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -948,7 +948,7 @@ class Worker
|
|||
}
|
||||
DBA::close($tasks);
|
||||
|
||||
Logger::info('Found:', ['priority' => $priority, 'id' => $ids]);
|
||||
DI::logger()->info('Found:', ['priority' => $priority, 'id' => $ids]);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
@ -987,7 +987,7 @@ class Worker
|
|||
|
||||
foreach ($priorities as $priority) {
|
||||
if (!empty($waiting[$priority]) && empty($running[$priority])) {
|
||||
Logger::info('No running worker found with priority {priority} - assigning it.', ['priority' => $priority]);
|
||||
DI::logger()->info('No running worker found with priority {priority} - assigning it.', ['priority' => $priority]);
|
||||
return $priority;
|
||||
}
|
||||
}
|
||||
|
@ -1009,14 +1009,14 @@ class Worker
|
|||
$i = 0;
|
||||
foreach ($running as $priority => $workers) {
|
||||
if ($workers < $limit[$i++]) {
|
||||
Logger::info('Priority {priority} has got {workers} workers out of a limit of {limit}', ['priority' => $priority, 'workers' => $workers, 'limit' => $limit[$i - 1]]);
|
||||
DI::logger()->info('Priority {priority} has got {workers} workers out of a limit of {limit}', ['priority' => $priority, 'workers' => $workers, 'limit' => $limit[$i - 1]]);
|
||||
return $priority;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($waiting)) {
|
||||
$priority = array_keys($waiting)[0];
|
||||
Logger::info('No underassigned priority found, now taking the highest priority.', ['priority' => $priority]);
|
||||
DI::logger()->info('No underassigned priority found, now taking the highest priority.', ['priority' => $priority]);
|
||||
return $priority;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ class Worker
|
|||
|
||||
$stamp = (float)microtime(true);
|
||||
foreach ($worker as $worker_pid => $worker_ids) {
|
||||
Logger::info('Set queue entry', ['pid' => $worker_pid, 'ids' => $worker_ids]);
|
||||
DI::logger()->info('Set queue entry', ['pid' => $worker_pid, 'ids' => $worker_ids]);
|
||||
DBA::update(
|
||||
'workerqueue',
|
||||
['executed' => DateTimeFormat::utcNow(), 'pid' => $worker_pid],
|
||||
|
@ -1155,7 +1155,7 @@ class Worker
|
|||
private static function forkProcess(bool $do_cron)
|
||||
{
|
||||
if (DI::system()->isMinMemoryReached()) {
|
||||
Logger::warning('Memory limit reached - quitting');
|
||||
DI::logger()->warning('Memory limit reached - quitting');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1165,21 +1165,21 @@ class Worker
|
|||
$pid = pcntl_fork();
|
||||
if ($pid == -1) {
|
||||
DBA::connect();
|
||||
Logger::warning('Could not spawn worker');
|
||||
DI::logger()->warning('Could not spawn worker');
|
||||
return;
|
||||
} elseif ($pid) {
|
||||
// The parent process continues here
|
||||
DBA::connect();
|
||||
|
||||
Worker\IPC::SetJobState(true, $pid);
|
||||
Logger::info('Spawned new worker', ['pid' => $pid]);
|
||||
DI::logger()->info('Spawned new worker', ['pid' => $pid]);
|
||||
|
||||
$cycles = 0;
|
||||
while (Worker\IPC::JobsExists($pid) && (++$cycles < 100)) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
Logger::info('Spawned worker is ready', ['pid' => $pid, 'wait_cycles' => $cycles]);
|
||||
DI::logger()->info('Spawned worker is ready', ['pid' => $pid, 'wait_cycles' => $cycles]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ class Worker
|
|||
usleep(10000);
|
||||
}
|
||||
|
||||
Logger::info('Worker spawned', ['pid' => $process->pid, 'wait_cycles' => $cycles]);
|
||||
DI::logger()->info('Worker spawned', ['pid' => $process->pid, 'wait_cycles' => $cycles]);
|
||||
|
||||
self::processQueue($do_cron, $process);
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ class Worker
|
|||
|
||||
Worker\IPC::SetJobState(false, $process->pid);
|
||||
DI::process()->delete($process);
|
||||
Logger::info('Worker ended', ['pid' => $process->pid]);
|
||||
DI::logger()->info('Worker ended', ['pid' => $process->pid]);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -1292,7 +1292,7 @@ class Worker
|
|||
$added = 0;
|
||||
|
||||
if (!is_int($priority) || !in_array($priority, self::PRIORITIES)) {
|
||||
Logger::warning('Invalid priority', ['priority' => $priority, 'command' => $command]);
|
||||
DI::logger()->warning('Invalid priority', ['priority' => $priority, 'command' => $command]);
|
||||
$priority = self::PRIORITY_MEDIUM;
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ class Worker
|
|||
$new_retrial = $retrial;
|
||||
}
|
||||
}
|
||||
Logger::notice('New retrial for task', ['id' => $queue['id'], 'created' => $queue['created'], 'old' => $queue['retrial'], 'new' => $new_retrial]);
|
||||
DI::logger()->notice('New retrial for task', ['id' => $queue['id'], 'created' => $queue['created'], 'old' => $queue['retrial'], 'new' => $new_retrial]);
|
||||
return $new_retrial;
|
||||
}
|
||||
|
||||
|
@ -1419,7 +1419,7 @@ class Worker
|
|||
$new_retrial = self::getNextRetrial($queue, $max_level);
|
||||
|
||||
if ($new_retrial > $max_level) {
|
||||
Logger::notice('The task exceeded the maximum retry count', ['id' => $id, 'created' => $queue['created'], 'old_prio' => $queue['priority'], 'old_retrial' => $queue['retrial'], 'max_level' => $max_level, 'retrial' => $new_retrial]);
|
||||
DI::logger()->notice('The task exceeded the maximum retry count', ['id' => $id, 'created' => $queue['created'], 'old_prio' => $queue['priority'], 'old_retrial' => $queue['retrial'], 'max_level' => $max_level, 'retrial' => $new_retrial]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1435,7 +1435,7 @@ class Worker
|
|||
$priority = self::PRIORITY_NEGLIGIBLE;
|
||||
}
|
||||
|
||||
Logger::info('Deferred task', ['id' => $id, 'retrial' => $new_retrial, 'created' => $queue['created'], 'next_execution' => $next, 'old_prio' => $queue['priority'], 'new_prio' => $priority]);
|
||||
DI::logger()->info('Deferred task', ['id' => $id, 'retrial' => $new_retrial, 'created' => $queue['created'], 'next_execution' => $next, 'old_prio' => $queue['priority'], 'new_prio' => $priority]);
|
||||
|
||||
$stamp = (float)microtime(true);
|
||||
$fields = ['retrial' => $new_retrial, 'next_try' => $next, 'executed' => DBA::NULL_DATETIME, 'pid' => 0, 'priority' => $priority];
|
||||
|
@ -1458,7 +1458,7 @@ class Worker
|
|||
$start = strtotime(DI::config()->get('system', 'maintenance_start')) % 86400;
|
||||
$end = strtotime(DI::config()->get('system', 'maintenance_end')) % 86400;
|
||||
|
||||
Logger::info('Maintenance window', ['start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
DI::logger()->info('Maintenance window', ['start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
|
||||
if ($check_last_execution) {
|
||||
// Calculate the window duration
|
||||
|
@ -1467,7 +1467,7 @@ class Worker
|
|||
// Quit when the last cron execution had been after the previous window
|
||||
$last_cron = DI::keyValue()->get('last_cron_daily');
|
||||
if ($last_cron + $duration > time()) {
|
||||
Logger::info('The Daily cron had been executed recently', ['last' => date(DateTimeFormat::MYSQL, $last_cron), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
DI::logger()->info('The Daily cron had been executed recently', ['last' => date(DateTimeFormat::MYSQL, $last_cron), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1483,9 +1483,9 @@ class Worker
|
|||
}
|
||||
|
||||
if ($execute) {
|
||||
Logger::info('We are inside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
DI::logger()->info('We are inside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
} else {
|
||||
Logger::info('We are outside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
DI::logger()->info('We are outside the maintenance window', ['current' => date('H:i:s', $current), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
|
||||
}
|
||||
|
||||
return $execute;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Core\Worker;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -32,7 +31,7 @@ class Cron
|
|||
*/
|
||||
public static function run()
|
||||
{
|
||||
Logger::info('Add cron entries');
|
||||
DI::logger()->info('Add cron entries');
|
||||
|
||||
// Check for spooled items
|
||||
Worker::add(['priority' => Worker::PRIORITY_HIGH, 'force_priority' => true], 'SpoolPost');
|
||||
|
@ -99,7 +98,7 @@ class Cron
|
|||
// How long is the process already running?
|
||||
$duration = (time() - strtotime($entry["executed"])) / 60;
|
||||
if ($duration > $max_duration) {
|
||||
Logger::warning('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
|
||||
DI::logger()->warning('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
|
||||
posix_kill($entry["pid"], SIGTERM);
|
||||
|
||||
// We killed the stale process.
|
||||
|
@ -113,10 +112,13 @@ class Cron
|
|||
} elseif ($entry['priority'] != Worker::PRIORITY_CRITICAL) {
|
||||
$new_priority = Worker::PRIORITY_NEGLIGIBLE;
|
||||
}
|
||||
DBA::update('workerqueue', ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['id' => $entry["id"]]
|
||||
DBA::update(
|
||||
'workerqueue',
|
||||
['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
|
||||
['id' => $entry["id"]]
|
||||
);
|
||||
} else {
|
||||
Logger::info('Process runtime is okay', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
|
||||
DI::logger()->info('Process runtime is okay', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +158,12 @@ class Cron
|
|||
$deliveries = DBA::p("SELECT `item-uri`.`uri` AS `inbox`, MAX(`gsid`) AS `gsid`, MAX(`shared`) AS `shared`, MAX(`failed`) AS `failed` FROM `post-delivery` INNER JOIN `item-uri` ON `item-uri`.`id` = `post-delivery`.`inbox-id` LEFT JOIN `inbox-status` ON `inbox-status`.`url` = `item-uri`.`uri` GROUP BY `inbox` ORDER BY RAND()");
|
||||
while ($delivery = DBA::fetch($deliveries)) {
|
||||
if ($delivery['failed'] > 0) {
|
||||
Logger::info('Removing failed deliveries', ['inbox' => $delivery['inbox'], 'failed' => $delivery['failed']]);
|
||||
DI::logger()->info('Removing failed deliveries', ['inbox' => $delivery['inbox'], 'failed' => $delivery['failed']]);
|
||||
Post\Delivery::removeFailed($delivery['inbox']);
|
||||
}
|
||||
if (($delivery['failed'] == 0) && $delivery['shared'] && !empty($delivery['gsid']) && GServer::isReachableById($delivery['gsid'])) {
|
||||
$result = ActivityPub\Delivery::deliver($delivery['inbox']);
|
||||
Logger::info('Directly deliver inbox', ['inbox' => $delivery['inbox'], 'result' => $result['success']]);
|
||||
DI::logger()->info('Directly deliver inbox', ['inbox' => $delivery['inbox'], 'result' => $result['success']]);
|
||||
continue;
|
||||
} elseif ($delivery['failed'] < 3) {
|
||||
$priority = Worker::PRIORITY_HIGH;
|
||||
|
@ -174,7 +176,7 @@ class Cron
|
|||
}
|
||||
|
||||
if (Worker::add(['priority' => $priority, 'force_priority' => true], 'APDelivery', '', 0, $delivery['inbox'], 0)) {
|
||||
Logger::info('Priority for APDelivery worker adjusted', ['inbox' => $delivery['inbox'], 'failed' => $delivery['failed'], 'priority' => $priority]);
|
||||
DI::logger()->info('Priority for APDelivery worker adjusted', ['inbox' => $delivery['inbox'], 'failed' => $delivery['failed'], 'priority' => $priority]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,9 +184,9 @@ class Cron
|
|||
|
||||
// Optimizing this table only last seconds
|
||||
if (DI::config()->get('system', 'optimize_tables')) {
|
||||
Logger::info('Optimize start');
|
||||
DI::logger()->info('Optimize start');
|
||||
DBA::optimizeTable('post-delivery');
|
||||
Logger::info('Optimize end');
|
||||
DI::logger()->info('Optimize end');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +197,7 @@ class Cron
|
|||
{
|
||||
foreach(DI::deliveryQueueItemRepo()->selectAggregateByServerId() as $delivery) {
|
||||
if ($delivery->failed > 0) {
|
||||
Logger::info('Removing failed deliveries', ['gsid' => $delivery->targetServerId, 'failed' => $delivery->failed]);
|
||||
DI::logger()->info('Removing failed deliveries', ['gsid' => $delivery->targetServerId, 'failed' => $delivery->failed]);
|
||||
DI::deliveryQueueItemRepo()->removeFailedByServerId($delivery->targetServerId, DI::config()->get('system', 'worker_defer_limit'));
|
||||
}
|
||||
|
||||
|
@ -210,15 +212,15 @@ class Cron
|
|||
}
|
||||
|
||||
if (Worker::add(['priority' => $priority, 'force_priority' => true], 'BulkDelivery', $delivery->targetServerId)) {
|
||||
Logger::info('Priority for BulkDelivery worker adjusted', ['gsid' => $delivery->targetServerId, 'failed' => $delivery->failed, 'priority' => $priority]);
|
||||
DI::logger()->info('Priority for BulkDelivery worker adjusted', ['gsid' => $delivery->targetServerId, 'failed' => $delivery->failed, 'priority' => $priority]);
|
||||
}
|
||||
}
|
||||
|
||||
// Optimizing this table only last seconds
|
||||
if (DI::config()->get('system', 'optimize_tables')) {
|
||||
Logger::info('Optimize start');
|
||||
DI::logger()->info('Optimize start');
|
||||
DI::deliveryQueueItemRepo()->optimizeStorage();
|
||||
Logger::info('Optimize end');
|
||||
DI::logger()->info('Optimize end');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +239,7 @@ class Cron
|
|||
'datetime' => $contact['created'],
|
||||
'hash' => Strings::getRandomHex()
|
||||
];
|
||||
Logger::notice('Adding missing intro', ['fields' => $fields]);
|
||||
DI::logger()->notice('Adding missing intro', ['fields' => $fields]);
|
||||
DBA::insert('intro', $fields);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Core\Worker;
|
||||
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
|
@ -98,11 +97,11 @@ class Daemon
|
|||
|
||||
$pid = intval(file_get_contents($pidfile));
|
||||
if (posix_kill($pid, 0)) {
|
||||
Logger::info('Daemon process is running', ['pid' => $pid]);
|
||||
DI::logger()->info('Daemon process is running', ['pid' => $pid]);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::warning('Daemon process is not running', ['pid' => $pid]);
|
||||
DI::logger()->warning('Daemon process is not running', ['pid' => $pid]);
|
||||
|
||||
self::spawn();
|
||||
}
|
||||
|
@ -114,8 +113,8 @@ class Daemon
|
|||
*/
|
||||
private static function spawn()
|
||||
{
|
||||
Logger::notice('Starting new daemon process');
|
||||
DI::logger()->notice('Starting new daemon process');
|
||||
DI::system()->run('bin/console.php', ['start']);
|
||||
Logger::notice('New daemon process started');
|
||||
DI::logger()->notice('New daemon process started');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ abstract class DI
|
|||
|
||||
/**
|
||||
* Returns a clone of the current dice instance
|
||||
* This useful for overloading the current instance with mocked methods during tests
|
||||
*
|
||||
* @internal This useful for overloading the current instance with mocked methods during tests
|
||||
*
|
||||
* @return Dice
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Database;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
|
@ -74,8 +73,11 @@ class DBStructure
|
|||
'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item', 'challenge',
|
||||
'auth_codes', 'tokens', 'clients', 'profile_check', 'host', 'conversation', 'fcontact', 'addon', 'push_subscriber'];
|
||||
|
||||
$tables = DBA::selectToArray('INFORMATION_SCHEMA.TABLES', ['TABLE_NAME'],
|
||||
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']);
|
||||
$tables = DBA::selectToArray(
|
||||
'INFORMATION_SCHEMA.TABLES',
|
||||
['TABLE_NAME'],
|
||||
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']
|
||||
);
|
||||
|
||||
if (empty($tables)) {
|
||||
echo DI::l10n()->t('No unused tables found.');
|
||||
|
@ -144,8 +146,11 @@ class DBStructure
|
|||
*/
|
||||
private static function printUpdateError(string $message): string
|
||||
{
|
||||
echo DI::l10n()->t("\nError %d occurred during database update:\n%s\n",
|
||||
DBA::errorNo(), DBA::errorMessage());
|
||||
echo DI::l10n()->t(
|
||||
"\nError %d occurred during database update:\n%s\n",
|
||||
DBA::errorNo(),
|
||||
DBA::errorMessage()
|
||||
);
|
||||
|
||||
return DI::l10n()->t('Errors encountered performing database changes: ') . $message . '<br />';
|
||||
}
|
||||
|
@ -238,7 +243,7 @@ class DBStructure
|
|||
|
||||
$errors = '';
|
||||
|
||||
Logger::info('updating structure');
|
||||
DI::logger()->info('updating structure');
|
||||
|
||||
// Get the current structure
|
||||
$database = [];
|
||||
|
@ -251,7 +256,7 @@ class DBStructure
|
|||
foreach ($tables as $table) {
|
||||
$table = current($table);
|
||||
|
||||
Logger::info('updating structure', ['table' => $table]);
|
||||
DI::logger()->info('updating structure', ['table' => $table]);
|
||||
$database[$table] = self::tableStructure($table);
|
||||
}
|
||||
}
|
||||
|
@ -523,30 +528,36 @@ class DBStructure
|
|||
// This query doesn't seem to be executable as a prepared statement
|
||||
$indexes = DBA::toArray(DBA::p("SHOW INDEX FROM " . DBA::quoteIdentifier($table)));
|
||||
|
||||
$fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS',
|
||||
$fields = DBA::selectToArray(
|
||||
'INFORMATION_SCHEMA.COLUMNS',
|
||||
['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA',
|
||||
'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
|
||||
'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
|
||||
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
|
||||
DBA::databaseName(), $table]);
|
||||
DBA::databaseName(), $table]
|
||||
);
|
||||
|
||||
$foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
|
||||
$foreign_keys = DBA::selectToArray(
|
||||
'INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
|
||||
['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'],
|
||||
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
|
||||
DBA::databaseName(), $table]);
|
||||
DBA::databaseName(), $table]
|
||||
);
|
||||
|
||||
$table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES',
|
||||
$table_status = DBA::selectFirst(
|
||||
'INFORMATION_SCHEMA.TABLES',
|
||||
['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'],
|
||||
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
|
||||
DBA::databaseName(), $table]);
|
||||
DBA::databaseName(), $table]
|
||||
);
|
||||
|
||||
$fielddata = [];
|
||||
$indexdata = [];
|
||||
$fielddata = [];
|
||||
$indexdata = [];
|
||||
$foreigndata = [];
|
||||
|
||||
if (DBA::isResult($foreign_keys)) {
|
||||
foreach ($foreign_keys as $foreign_key) {
|
||||
$parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]];
|
||||
$constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters);
|
||||
$parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]];
|
||||
$constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters);
|
||||
$foreigndata[$constraint] = $foreign_key;
|
||||
}
|
||||
}
|
||||
|
@ -574,8 +585,8 @@ class DBStructure
|
|||
$fielddata = [];
|
||||
if (DBA::isResult($fields)) {
|
||||
foreach ($fields as $field) {
|
||||
$search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
|
||||
$replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
|
||||
$search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
|
||||
$replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
|
||||
$field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']);
|
||||
|
||||
$fielddata[$field['COLUMN_NAME']]['type'] = $field['COLUMN_TYPE'];
|
||||
|
@ -597,13 +608,13 @@ class DBStructure
|
|||
}
|
||||
|
||||
$fielddata[$field['COLUMN_NAME']]['Collation'] = $field['COLLATION_NAME'];
|
||||
$fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT'];
|
||||
$fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT'];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'fields' => $fielddata,
|
||||
'indexes' => $indexdata,
|
||||
'fields' => $fielddata,
|
||||
'indexes' => $indexdata,
|
||||
'foreign_keys' => $foreigndata,
|
||||
'table_status' => $table_status
|
||||
];
|
||||
|
@ -732,9 +743,11 @@ class DBStructure
|
|||
*/
|
||||
public static function existsForeignKeyForField(string $table, string $field): bool
|
||||
{
|
||||
return DBA::exists('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
|
||||
return DBA::exists(
|
||||
'INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
|
||||
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
|
||||
DBA::databaseName(), $table, $field]);
|
||||
DBA::databaseName(), $table, $field]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -807,8 +820,8 @@ class DBStructure
|
|||
|
||||
if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) {
|
||||
$user = [
|
||||
'verified' => true,
|
||||
'page-flags' => User::PAGE_FLAGS_SOAPBOX,
|
||||
'verified' => true,
|
||||
'page-flags' => User::PAGE_FLAGS_SOAPBOX,
|
||||
'account-type' => User::ACCOUNT_TYPE_RELAY,
|
||||
];
|
||||
DBA::insert('user', $user);
|
||||
|
@ -884,7 +897,7 @@ class DBStructure
|
|||
$permission = '';
|
||||
}
|
||||
$fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission,
|
||||
'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
|
||||
'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
|
||||
DBA::insert('permissionset', $fields, Database::INSERT_IGNORE);
|
||||
}
|
||||
DBA::close($sets);
|
||||
|
@ -914,7 +927,7 @@ class DBStructure
|
|||
$isUpdate = false;
|
||||
|
||||
$processes = DBA::select('information_schema.processlist', ['info'], [
|
||||
'db' => DBA::databaseName(),
|
||||
'db' => DBA::databaseName(),
|
||||
'command' => ['Query', 'Execute']
|
||||
]);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Database;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -36,7 +35,7 @@ use GuzzleHttp\Psr7\Uri;
|
|||
class PostUpdate
|
||||
{
|
||||
// Needed for the helper function to read from the legacy term table
|
||||
const OBJECT_TYPE_POST = 1;
|
||||
const OBJECT_TYPE_POST = 1;
|
||||
|
||||
const VERSION = 1550;
|
||||
|
||||
|
@ -139,24 +138,24 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$max_item_delivery_data = DBA::selectFirst('item-delivery-data', ['iid'], ['queue_count > 0 OR queue_done > 0'], ['order' => ['iid']]);
|
||||
$max_iid = $max_item_delivery_data['iid'] ?? 0;
|
||||
$max_iid = $max_item_delivery_data['iid'] ?? 0;
|
||||
|
||||
Logger::info('Start update1297 with max iid: ' . $max_iid);
|
||||
DI::logger()->info('Start update1297 with max iid: ' . $max_iid);
|
||||
|
||||
$condition = ['`queue_count` = 0 AND `iid` < ?', $max_iid];
|
||||
|
||||
DBA::update('item-delivery-data', ['queue_count' => -1], $condition);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage());
|
||||
DI::logger()->error('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::info('Processed rows: ' . DBA::affectedRows());
|
||||
DI::logger()->info('Processed rows: ' . DBA::affectedRows());
|
||||
|
||||
DI::keyValue()->set('post_update_version', 1297);
|
||||
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -173,24 +172,31 @@ class PostUpdate
|
|||
return true;
|
||||
}
|
||||
|
||||
Logger::info('Start');
|
||||
DI::logger()->info('Start');
|
||||
|
||||
$contacts = DBA::p("SELECT `nurl`, `uid` FROM `contact`
|
||||
$contacts = DBA::p(
|
||||
"SELECT `nurl`, `uid` FROM `contact`
|
||||
WHERE EXISTS (SELECT `nurl` FROM `contact` AS `c2`
|
||||
WHERE `c2`.`nurl` = `contact`.`nurl` AND `c2`.`id` != `contact`.`id` AND `c2`.`uid` = `contact`.`uid` AND `c2`.`network` IN (?, ?, ?) AND NOT `deleted`)
|
||||
AND (`network` IN (?, ?, ?) OR (`uid` = ?)) AND NOT `deleted` GROUP BY `nurl`, `uid`",
|
||||
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB,
|
||||
Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB, 0);
|
||||
Protocol::DIASPORA,
|
||||
Protocol::OSTATUS,
|
||||
Protocol::ACTIVITYPUB,
|
||||
Protocol::DIASPORA,
|
||||
Protocol::OSTATUS,
|
||||
Protocol::ACTIVITYPUB,
|
||||
0
|
||||
);
|
||||
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Logger::info('Remove duplicates', ['nurl' => $contact['nurl'], 'uid' => $contact['uid']]);
|
||||
DI::logger()->info('Remove duplicates', ['nurl' => $contact['nurl'], 'uid' => $contact['uid']]);
|
||||
Contact::removeDuplicates($contact['nurl'], $contact['uid']);
|
||||
}
|
||||
|
||||
DBA::close($contact);
|
||||
DI::keyValue()->set('post_update_version', 1322);
|
||||
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -215,16 +221,16 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1329_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`id` > ?", $id];
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$items = DBA::select('item', ['id', 'uri-id', 'uid'], $condition, $params);
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$items = DBA::select('item', ['id', 'uri-id', 'uid'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -239,11 +245,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1329_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1329);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -270,7 +276,7 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1341_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
|
@ -279,7 +285,7 @@ class PostUpdate
|
|||
ORDER BY `uri-id` LIMIT 100000", '%#%', '%@%', '%!%', $id);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -295,13 +301,13 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1341_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
// When there are less than 1,000 items processed this means that we reached the end
|
||||
// The other entries will then be processed with the regular functionality
|
||||
if ($rows < 1000) {
|
||||
DI::keyValue()->set('post_update_version', 1341);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -328,35 +334,41 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1342_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
$terms = DBA::p("SELECT `term`.`tid`, `item`.`uri-id`, `term`.`type`, `term`.`term`, `term`.`url`, `item-content`.`body`
|
||||
$terms = DBA::p(
|
||||
"SELECT `term`.`tid`, `item`.`uri-id`, `term`.`type`, `term`.`term`, `term`.`url`, `item-content`.`body`
|
||||
FROM `term`
|
||||
INNER JOIN `item` ON `item`.`id` = `term`.`oid`
|
||||
INNER JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
|
||||
WHERE term.type IN (?, ?, ?, ?) AND `tid` >= ? ORDER BY `tid` LIMIT 100000",
|
||||
Tag::HASHTAG, Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION, $id);
|
||||
Tag::HASHTAG,
|
||||
Tag::MENTION,
|
||||
Tag::EXCLUSIVE_MENTION,
|
||||
Tag::IMPLICIT_MENTION,
|
||||
$id
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($term = DBA::fetch($terms)) {
|
||||
if (($term['type'] == Tag::MENTION) && !empty($term['url']) && !strstr($term['body'], $term['url'])) {
|
||||
$condition = ['nurl' => Strings::normaliseLink($term['url']), 'uid' => 0, 'deleted' => false];
|
||||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
$ssl_url = str_replace('http://', 'https://', $term['url']);
|
||||
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ? AND NOT `deleted`', $term['url'], Strings::normaliseLink($term['url']), $ssl_url, 0];
|
||||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
}
|
||||
$condition = ['nurl' => Strings::normaliseLink($term['url']), 'uid' => 0, 'deleted' => false];
|
||||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
$ssl_url = str_replace('http://', 'https://', $term['url']);
|
||||
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ? AND NOT `deleted`', $term['url'], Strings::normaliseLink($term['url']), $ssl_url, 0];
|
||||
$contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
|
||||
}
|
||||
|
||||
if (DBA::isResult($contact) && (!strstr($term['body'], $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], $contact['alias'])))) {
|
||||
$term['type'] = Tag::IMPLICIT_MENTION;
|
||||
}
|
||||
if (DBA::isResult($contact) && (!strstr($term['body'], $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], $contact['alias'])))) {
|
||||
$term['type'] = Tag::IMPLICIT_MENTION;
|
||||
}
|
||||
}
|
||||
|
||||
Tag::store($term['uri-id'], $term['type'], $term['term'], $term['url']);
|
||||
|
@ -371,13 +383,13 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1342_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
// When there are less than 1,000 items processed this means that we reached the end
|
||||
// The other entries will then be processed with the regular functionality
|
||||
if ($rows < 1000) {
|
||||
DI::keyValue()->set('post_update_version', 1342);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -404,7 +416,7 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1345_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
|
@ -415,7 +427,7 @@ class PostUpdate
|
|||
WHERE `iid` >= ? ORDER BY `iid` LIMIT 10000", $id);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -429,13 +441,13 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1345_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
// When there are less than 100 items processed this means that we reached the end
|
||||
// The other entries will then be processed with the regular functionality
|
||||
if ($rows < 100) {
|
||||
DI::keyValue()->set('post_update_version', 1345);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -455,7 +467,7 @@ class PostUpdate
|
|||
$file_text = '';
|
||||
|
||||
$condition = ['otype' => self::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => [Category::FILE, Category::CATEGORY]];
|
||||
$tags = DBA::selectToArray('term', ['type', 'term', 'url'], $condition);
|
||||
$tags = DBA::selectToArray('term', ['type', 'term', 'url'], $condition);
|
||||
foreach ($tags as $tag) {
|
||||
if ($tag['type'] == Category::CATEGORY) {
|
||||
$file_text .= '<' . $tag['term'] . '>';
|
||||
|
@ -487,16 +499,19 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1346_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
$terms = DBA::select('term', ['oid'],
|
||||
$terms = DBA::select(
|
||||
'term',
|
||||
['oid'],
|
||||
["`type` IN (?, ?) AND `oid` >= ?", Category::CATEGORY, Category::FILE, $id],
|
||||
['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]);
|
||||
['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -521,13 +536,13 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1346_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
// When there are less than 10 items processed this means that we reached the end
|
||||
// The other entries will then be processed with the regular functionality
|
||||
if ($rows < 10) {
|
||||
DI::keyValue()->set('post_update_version', 1346);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -555,10 +570,10 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1347_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
DI::logger()->info('Start', ['item' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
|
||||
$items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity`
|
||||
FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
|
||||
|
@ -566,12 +581,12 @@ class PostUpdate
|
|||
WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", Item::GRAVITY_ACTIVITY, $id);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($item = DBA::fetch($items)) {
|
||||
$id = $item['id'];
|
||||
$id = $item['id'];
|
||||
$verb = $item['item-verb'];
|
||||
if (empty($verb)) {
|
||||
$verb = $item['verb'];
|
||||
|
@ -590,11 +605,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1347_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1347);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -617,25 +632,27 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1348_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['contact' => $id]);
|
||||
DI::logger()->info('Start', ['contact' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`id` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$contacts = DBA::select('contact', ['id', 'baseurl'], $condition, $params);
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$contacts = DBA::select('contact', ['id', 'baseurl'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
$id = $contact['id'];
|
||||
|
||||
DBA::update('contact',
|
||||
DBA::update(
|
||||
'contact',
|
||||
['gsid' => GServer::getID($contact['baseurl'], true), 'baseurl' => GServer::cleanURL($contact['baseurl'])],
|
||||
['id' => $contact['id']]);
|
||||
['id' => $contact['id']]
|
||||
);
|
||||
|
||||
++$rows;
|
||||
}
|
||||
|
@ -643,11 +660,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1348_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1348);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -670,25 +687,27 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1349_id') ?? '';
|
||||
|
||||
Logger::info('Start', ['apcontact' => $id]);
|
||||
DI::logger()->info('Start', ['apcontact' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`url` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
|
||||
$params = ['order' => ['url'], 'limit' => 10000];
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`url` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
|
||||
$params = ['order' => ['url'], 'limit' => 10000];
|
||||
$apcontacts = DBA::select('apcontact', ['url', 'baseurl'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($apcontact = DBA::fetch($apcontacts)) {
|
||||
$id = $apcontact['url'];
|
||||
|
||||
DBA::update('apcontact',
|
||||
DBA::update(
|
||||
'apcontact',
|
||||
['gsid' => GServer::getID($apcontact['baseurl'], true), 'baseurl' => GServer::cleanURL($apcontact['baseurl'])],
|
||||
['url' => $apcontact['url']]);
|
||||
['url' => $apcontact['url']]
|
||||
);
|
||||
|
||||
++$rows;
|
||||
}
|
||||
|
@ -696,11 +715,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1349_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1349);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -721,10 +740,10 @@ class PostUpdate
|
|||
return true;
|
||||
}
|
||||
|
||||
Logger::info('Start');
|
||||
DI::logger()->info('Start');
|
||||
|
||||
$deleted = 0;
|
||||
$avatar = [4 => 'photo', 5 => 'thumb', 6 => 'micro'];
|
||||
$avatar = [4 => 'photo', 5 => 'thumb', 6 => 'micro'];
|
||||
|
||||
$photos = DBA::select('photo', ['id', 'contact-id', 'resource-id', 'scale'], ["`contact-id` != ? AND `album` = ?", 0, Photo::CONTACT_PHOTOS]);
|
||||
while ($photo = DBA::fetch($photos)) {
|
||||
|
@ -744,7 +763,7 @@ class PostUpdate
|
|||
DBA::close($photos);
|
||||
|
||||
DI::keyValue()->set('post_update_version', 1383);
|
||||
Logger::info('Done', ['deleted' => $deleted]);
|
||||
DI::logger()->info('Done', ['deleted' => $deleted]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -763,13 +782,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`hash` IS NULL"];
|
||||
Logger::info('Start', ['rest' => DBA::count('photo', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('photo', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$photos = DBA::select('photo', [], $condition, ['limit' => 100]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -782,11 +801,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($photos);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1384);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -813,13 +832,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`extid` != ? AND EXISTS(SELECT `id` FROM `post-user` WHERE `uri-id` = `item`.`uri-id` AND `uid` = `item`.`uid` AND `external-id` IS NULL)", ''];
|
||||
Logger::info('Start', ['rest' => DBA::count('item', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('item', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$items = DBA::select('item', ['uri-id', 'uid', 'extid'], $condition, ['order' => ['id'], 'limit' => 10000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -829,11 +848,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($items);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1400);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -855,13 +874,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`uri-id` IS NULL"];
|
||||
Logger::info('Start', ['rest' => DBA::count('contact', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('contact', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$contacts = DBA::select('contact', ['id', 'url'], $condition, ['limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -871,11 +890,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($contacts);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1424);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -902,13 +921,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`uri-id` IS NULL"];
|
||||
Logger::info('Start', ['rest' => DBA::count('fcontact', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('fcontact', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$fcontacts = DBA::select('fcontact', ['id', 'url', 'guid'], $condition, ['limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -923,11 +942,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($fcontacts);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1425);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -949,13 +968,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`uri-id` IS NULL"];
|
||||
Logger::info('Start', ['rest' => DBA::count('apcontact', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('apcontact', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$apcontacts = DBA::select('apcontact', ['url', 'uuid'], $condition, ['limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -970,11 +989,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($apcontacts);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1426);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -996,13 +1015,13 @@ class PostUpdate
|
|||
}
|
||||
|
||||
$condition = ["`uri-id` IS NULL"];
|
||||
Logger::info('Start', ['rest' => DBA::count('event', $condition)]);
|
||||
DI::logger()->info('Start', ['rest' => DBA::count('event', $condition)]);
|
||||
|
||||
$rows = 0;
|
||||
$rows = 0;
|
||||
$events = DBA::select('event', ['id', 'uri', 'guid'], $condition, ['limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1017,11 +1036,11 @@ class PostUpdate
|
|||
}
|
||||
DBA::close($events);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1427);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1049,18 +1068,22 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1452_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['uri-id' => $id]);
|
||||
DI::logger()->info('Start', ['uri-id' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
$received = '';
|
||||
|
||||
$conversations = DBA::p("SELECT `post-view`.`uri-id`, `conversation`.`source`, `conversation`.`received` FROM `conversation`
|
||||
$conversations = DBA::p(
|
||||
"SELECT `post-view`.`uri-id`, `conversation`.`source`, `conversation`.`received` FROM `conversation`
|
||||
INNER JOIN `post-view` ON `post-view`.`uri` = `conversation`.`item-uri`
|
||||
WHERE NOT `source` IS NULL AND `conversation`.`protocol` = ? AND `uri-id` > ? LIMIT ?",
|
||||
Conversation::PARCEL_ACTIVITYPUB, $id, 1000);
|
||||
Conversation::PARCEL_ACTIVITYPUB,
|
||||
$id,
|
||||
1000
|
||||
);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1088,11 +1111,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1452_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id, 'last-received' => $received]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id, 'last-received' => $received]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1452);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1137,7 @@ class PostUpdate
|
|||
return true;
|
||||
}
|
||||
|
||||
Logger::info('Start');
|
||||
DI::logger()->info('Start');
|
||||
|
||||
$posts = DBA::select('post-view', ['uri-id'], ['conversation' => './']);
|
||||
while ($post = DBA::fetch($posts)) {
|
||||
|
@ -1127,7 +1150,7 @@ class PostUpdate
|
|||
DBA::close($posts);
|
||||
|
||||
DI::keyValue()->set('post_update_version', 1483);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1147,14 +1170,14 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1484_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['id' => $id]);
|
||||
DI::logger()->info('Start', ['id' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
$contacts = DBA::select('contact', ['id', 'uid', 'uri-id', 'url'], ["`id` > ?", $id], ['order' => ['id'], 'limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1171,11 +1194,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1484_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1484);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1198,16 +1221,16 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1506_id') ?? 0;
|
||||
|
||||
Logger::info('Start', ['contact' => $id]);
|
||||
DI::logger()->info('Start', ['contact' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`id` > ? AND `gsid` IS NULL AND `network` = ?", $id, Protocol::DIASPORA];
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$contacts = DBA::select('contact', ['id', 'url'], $condition, $params);
|
||||
$params = ['order' => ['id'], 'limit' => 10000];
|
||||
$contacts = DBA::select('contact', ['id', 'url'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1218,9 +1241,11 @@ class PostUpdate
|
|||
unset($parts['path']);
|
||||
$server = (string)Uri::fromParts($parts);
|
||||
|
||||
DBA::update('contact',
|
||||
DBA::update(
|
||||
'contact',
|
||||
['gsid' => GServer::getID($server, true), 'baseurl' => GServer::cleanURL($server)],
|
||||
['id' => $contact['id']]);
|
||||
['id' => $contact['id']]
|
||||
);
|
||||
|
||||
++$rows;
|
||||
}
|
||||
|
@ -1228,11 +1253,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1506_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1506);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1255,16 +1280,16 @@ class PostUpdate
|
|||
|
||||
$id = DI::keyValue()->get('post_update_version_1507_id') ?? '';
|
||||
|
||||
Logger::info('Start', ['apcontact' => $id]);
|
||||
DI::logger()->info('Start', ['apcontact' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`url` > ? AND NOT `gsid` IS NULL", $id];
|
||||
$params = ['order' => ['url'], 'limit' => 10000];
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
$condition = ["`url` > ? AND NOT `gsid` IS NULL", $id];
|
||||
$params = ['order' => ['url'], 'limit' => 10000];
|
||||
$apcontacts = DBA::select('apcontact', ['url', 'gsid', 'sharedinbox', 'inbox'], $condition, $params);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1283,11 +1308,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1507_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($start_id == $id) {
|
||||
DI::keyValue()->set('post_update_version', 1507);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1311,17 +1336,17 @@ class PostUpdate
|
|||
$id = (int)(DI::keyValue()->get('post_update_version_1544_id') ?? 0);
|
||||
if ($id == 0) {
|
||||
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
}
|
||||
|
||||
Logger::info('Start', ['uri-id' => $id]);
|
||||
DI::logger()->info('Start', ['uri-id' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
$posts = Post::selectPosts(['uri-id', 'parent-uri-id'], ["`uri-id` < ? AND `gravity` IN (?, ?)", $id, Item::GRAVITY_COMMENT, Item::GRAVITY_PARENT], ['order' => ['uri-id' => true], 'limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1334,11 +1359,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1544_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1544);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1368,7 +1393,7 @@ class PostUpdate
|
|||
try {
|
||||
Post\Engagement::storeFromItem($item);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Exception on storing engagement', ['uri-id' => $engagement['uri-id'], 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Exception on storing engagement', ['uri-id' => $engagement['uri-id'], 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
DBA::close($engagements);
|
||||
|
@ -1376,10 +1401,10 @@ class PostUpdate
|
|||
$id = (int)(DI::keyValue()->get('post_update_version_1550_id') ?? 0);
|
||||
if ($id == 0) {
|
||||
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
$id = (int)($post['uri-id'] ?? 0);
|
||||
}
|
||||
|
||||
Logger::info('Start', ['uri-id' => $id]);
|
||||
DI::logger()->info('Start', ['uri-id' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
|
@ -1393,7 +1418,7 @@ class PostUpdate
|
|||
$posts = Post::selectPosts(['uri-id', 'created'], $condition, ['order' => ['uri-id' => true], 'limit' => 1000]);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1406,11 +1431,11 @@ class PostUpdate
|
|||
|
||||
DI::keyValue()->set('post_update_version_1550_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
DI::logger()->info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
if ($rows <= 100) {
|
||||
DI::keyValue()->set('post_update_version', 1550);
|
||||
Logger::info('Done');
|
||||
DI::logger()->info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Content\ContactSelector;
|
|||
use Friendica\Content\Item as ContentItem;
|
||||
use Friendica\Content\Smilies;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -222,8 +221,8 @@ class Status extends BaseFactory
|
|||
|
||||
$application = new \Friendica\Object\Api\Mastodon\Application($item['app'] ?: $platform);
|
||||
|
||||
$mentions = $this->mstdnMentionFactory->createFromUriId($uriId)->getArrayCopy();
|
||||
$tags = $this->mstdnTagFactory->createFromUriId($uriId);
|
||||
$mentions = $this->mstdnMentionFactory->createFromUriId($uriId)->getArrayCopy();
|
||||
$tags = $this->mstdnTagFactory->createFromUriId($uriId);
|
||||
if ($item['has-media']) {
|
||||
$card = $this->mstdnCardFactory->createFromUriId($uriId);
|
||||
$attachments = $this->mstdnAttachmentFactory->createFromUriId($uriId);
|
||||
|
@ -309,7 +308,7 @@ class Status extends BaseFactory
|
|||
try {
|
||||
$reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray();
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
DI::logger()->info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$reshare = [];
|
||||
}
|
||||
} else {
|
||||
|
@ -320,7 +319,7 @@ class Status extends BaseFactory
|
|||
try {
|
||||
$in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray();
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
DI::logger()->info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$in_reply = [];
|
||||
}
|
||||
} else {
|
||||
|
@ -350,7 +349,7 @@ class Status extends BaseFactory
|
|||
$quote_id = $media['media-uri-id'];
|
||||
} else {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['plink' => $media[0]['url'], 'uid' => [$uid, 0]]);
|
||||
$quote_id = $shared_item['uri-id'] ?? 0;
|
||||
$quote_id = $shared_item['uri-id'] ?? 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -361,7 +360,7 @@ class Status extends BaseFactory
|
|||
try {
|
||||
$quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray();
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
DI::logger()->info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$quote = [];
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -9,12 +9,10 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\ActivityNamespace;
|
||||
|
@ -95,12 +93,12 @@ class APContact
|
|||
public static function getByURL(string $url, bool $update = null): array
|
||||
{
|
||||
if (empty($url) || Network::isUrlBlocked($url)) {
|
||||
Logger::info('Domain is blocked', ['url' => $url]);
|
||||
DI::logger()->info('Domain is blocked', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!Network::isValidHttpUrl($url) && !filter_var($url, FILTER_VALIDATE_EMAIL)) {
|
||||
Logger::info('Invalid URL', ['url' => $url]);
|
||||
DI::logger()->info('Invalid URL', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -154,9 +152,9 @@ class APContact
|
|||
// Detect multiple fast repeating request to the same address
|
||||
// See https://github.com/friendica/friendica/issues/9303
|
||||
$cachekey = 'apcontact:' . ItemURI::getIdByURI($url);
|
||||
$result = DI::cache()->get($cachekey);
|
||||
$result = DI::cache()->get($cachekey);
|
||||
if (!is_null($result)) {
|
||||
Logger::info('Multiple requests for the address', ['url' => $url, 'update' => $update, 'result' => $result]);
|
||||
DI::logger()->info('Multiple requests for the address', ['url' => $url, 'update' => $update, 'result' => $result]);
|
||||
if (!empty($fetched_contact)) {
|
||||
return $fetched_contact;
|
||||
}
|
||||
|
@ -166,7 +164,7 @@ class APContact
|
|||
|
||||
if (DI::baseUrl()->isLocalUrl($url) && ($local_uid = User::getIdForURL($url))) {
|
||||
try {
|
||||
$data = Transmitter::getProfile($local_uid);
|
||||
$data = Transmitter::getProfile($local_uid);
|
||||
$local_owner = User::getOwnerDataById($local_uid);
|
||||
} catch(HTTPException\NotFoundException $e) {
|
||||
$data = null;
|
||||
|
@ -178,11 +176,11 @@ class APContact
|
|||
|
||||
try {
|
||||
$curlResult = HTTPSignature::fetchRaw($url);
|
||||
$failed = empty($curlResult->getBodyString()) ||
|
||||
$failed = empty($curlResult->getBodyString()) ||
|
||||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
|
||||
|
||||
if (!$failed) {
|
||||
$data = json_decode($curlResult->getBodyString(), true);
|
||||
if (!$failed) {
|
||||
$data = json_decode($curlResult->getBodyString(), true);
|
||||
$failed = empty($data) || !is_array($data);
|
||||
}
|
||||
|
||||
|
@ -192,7 +190,7 @@ class APContact
|
|||
$failed = true;
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
|
||||
DI::logger()->notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
|
||||
$failed = true;
|
||||
}
|
||||
|
||||
|
@ -207,13 +205,13 @@ class APContact
|
|||
return $fetched_contact;
|
||||
}
|
||||
|
||||
$apcontact['url'] = $compacted['@id'];
|
||||
$apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
|
||||
$apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
|
||||
$apcontact['url'] = $compacted['@id'];
|
||||
$apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
|
||||
$apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
|
||||
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
|
||||
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
|
||||
$apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
|
||||
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
||||
$apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
|
||||
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
||||
|
||||
$apcontact['sharedinbox'] = '';
|
||||
if (!empty($compacted['as:endpoints'])) {
|
||||
|
@ -291,7 +289,7 @@ class APContact
|
|||
try {
|
||||
$apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority();
|
||||
} catch (\Throwable $e) {
|
||||
Logger::warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]);
|
||||
DI::logger()->warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]);
|
||||
$apcontact['addr'] = '';
|
||||
}
|
||||
}
|
||||
|
@ -304,12 +302,12 @@ class APContact
|
|||
}
|
||||
}
|
||||
|
||||
$apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
|
||||
$apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
|
||||
$apcontact['posting-restricted'] = (int)JsonLD::fetchElement($compacted, 'lemmy:postingRestrictedToMods');
|
||||
$apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended');
|
||||
$apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended');
|
||||
|
||||
if (!empty($compacted['as:generator'])) {
|
||||
$apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
|
||||
$apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
|
||||
$apcontact['generator'] = JsonLD::fetchElement($compacted['as:generator'], 'as:name', '@value');
|
||||
}
|
||||
|
||||
|
@ -349,7 +347,7 @@ class APContact
|
|||
if (!empty($local_owner)) {
|
||||
$statuses_count = self::getStatusesCount($local_owner);
|
||||
} else {
|
||||
$outbox = HTTPSignature::fetch($apcontact['outbox']);
|
||||
$outbox = HTTPSignature::fetch($apcontact['outbox']);
|
||||
$statuses_count = $outbox['totalItems'] ?? 0;
|
||||
}
|
||||
if (!empty($statuses_count)) {
|
||||
|
@ -371,7 +369,7 @@ class APContact
|
|||
$apcontact['photo'] = Network::addBasePath($apcontact['photo'], $apcontact['url']);
|
||||
|
||||
if (!Network::isValidHttpUrl($apcontact['photo'])) {
|
||||
Logger::warning('Invalid URL for photo', ['url' => $apcontact['url'], 'photo' => $apcontact['photo']]);
|
||||
DI::logger()->warning('Invalid URL for photo', ['url' => $apcontact['url'], 'photo' => $apcontact['photo']]);
|
||||
$apcontact['photo'] = '';
|
||||
}
|
||||
}
|
||||
|
@ -457,9 +455,9 @@ class APContact
|
|||
if (in_array($name, APContact\Endpoint::ENDPOINT_NAMES)) {
|
||||
$key = array_search($name, APContact\Endpoint::ENDPOINT_NAMES);
|
||||
APContact\Endpoint::update($apcontact['uri-id'], $key, $endpoint['@id']);
|
||||
Logger::debug('Store endpoint', ['key' => $key, 'name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
DI::logger()->debug('Store endpoint', ['key' => $key, 'name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
} elseif (!in_array($name, ['as:sharedInbox', 'as:uploadMedia', 'as:oauthTokenEndpoint', 'as:oauthAuthorizationEndpoint', 'litepub:oauthRegistrationEndpoint'])) {
|
||||
Logger::debug('Unknown endpoint', ['name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
DI::logger()->debug('Unknown endpoint', ['name' => $name, 'endpoint' => $endpoint['@id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +466,7 @@ class APContact
|
|||
|
||||
// We delete the old entry when the URL is changed
|
||||
if ($url != $apcontact['url']) {
|
||||
Logger::info('Delete changed profile url', ['old' => $url, 'new' => $apcontact['url']]);
|
||||
DI::logger()->info('Delete changed profile url', ['old' => $url, 'new' => $apcontact['url']]);
|
||||
DBA::delete('apcontact', ['url' => $url]);
|
||||
}
|
||||
|
||||
|
@ -481,7 +479,7 @@ class APContact
|
|||
DBA::replace('apcontact', $apcontact);
|
||||
}
|
||||
|
||||
Logger::info('Updated profile', ['url' => $url]);
|
||||
DI::logger()->info('Updated profile', ['url' => $url]);
|
||||
|
||||
return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
|
||||
}
|
||||
|
@ -532,7 +530,7 @@ class APContact
|
|||
public static function markForArchival(array $apcontact)
|
||||
{
|
||||
if (!empty($apcontact['inbox'])) {
|
||||
Logger::info('Set inbox status to failure', ['inbox' => $apcontact['inbox']]);
|
||||
DI::logger()->info('Set inbox status to failure', ['inbox' => $apcontact['inbox']]);
|
||||
HTTPSignature::setInboxStatus($apcontact['inbox'], false, false, $apcontact['gsid']);
|
||||
}
|
||||
|
||||
|
@ -542,7 +540,7 @@ class APContact
|
|||
$apcontact['sharedinbox']]);
|
||||
if (!$available) {
|
||||
// If all known personal inboxes are failing then set their shared inbox to failure as well
|
||||
Logger::info('Set shared inbox status to failure', ['sharedinbox' => $apcontact['sharedinbox']]);
|
||||
DI::logger()->info('Set shared inbox status to failure', ['sharedinbox' => $apcontact['sharedinbox']]);
|
||||
HTTPSignature::setInboxStatus($apcontact['sharedinbox'], false, true, $apcontact['gsid']);
|
||||
}
|
||||
}
|
||||
|
@ -557,11 +555,11 @@ class APContact
|
|||
public static function unmarkForArchival(array $apcontact)
|
||||
{
|
||||
if (!empty($apcontact['inbox'])) {
|
||||
Logger::info('Set inbox status to success', ['inbox' => $apcontact['inbox']]);
|
||||
DI::logger()->info('Set inbox status to success', ['inbox' => $apcontact['inbox']]);
|
||||
HTTPSignature::setInboxStatus($apcontact['inbox'], true, false, $apcontact['gsid']);
|
||||
}
|
||||
if (!empty($apcontact['sharedinbox'])) {
|
||||
Logger::info('Set shared inbox status to success', ['sharedinbox' => $apcontact['sharedinbox']]);
|
||||
DI::logger()->info('Set shared inbox status to success', ['sharedinbox' => $apcontact['sharedinbox']]);
|
||||
HTTPSignature::setInboxStatus($apcontact['sharedinbox'], true, true, $apcontact['gsid']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -24,7 +23,7 @@ use Friendica\Protocol\ActivityPub;
|
|||
class Circle
|
||||
{
|
||||
const FOLLOWERS = '~';
|
||||
const MUTUALS = '&';
|
||||
const MUTUALS = '&';
|
||||
|
||||
/**
|
||||
* Fetches circle record by user id and maybe includes deleted circles as well
|
||||
|
@ -164,7 +163,8 @@ class Circle
|
|||
*/
|
||||
public static function countUnseen(int $uid)
|
||||
{
|
||||
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
|
||||
$stmt = DBA::p(
|
||||
"SELECT `circle`.`id`, `circle`.`name`,
|
||||
(SELECT COUNT(*) FROM `post-user`
|
||||
WHERE `uid` = ?
|
||||
AND `unseen`
|
||||
|
@ -231,15 +231,15 @@ class Circle
|
|||
|
||||
if ($user['def_gid'] == $gid) {
|
||||
$user['def_gid'] = 0;
|
||||
$change = true;
|
||||
$change = true;
|
||||
}
|
||||
if (strpos($user['allow_gid'], '<' . $gid . '>') !== false) {
|
||||
$user['allow_gid'] = str_replace('<' . $gid . '>', '', $user['allow_gid']);
|
||||
$change = true;
|
||||
$change = true;
|
||||
}
|
||||
if (strpos($user['deny_gid'], '<' . $gid . '>') !== false) {
|
||||
$user['deny_gid'] = str_replace('<' . $gid . '>', '', $user['deny_gid']);
|
||||
$change = true;
|
||||
$change = true;
|
||||
}
|
||||
|
||||
if ($change) {
|
||||
|
@ -411,13 +411,13 @@ class Circle
|
|||
if ($key !== false) {
|
||||
if ($expand_followers) {
|
||||
$followers = Contact::selectToArray(['id'], [
|
||||
'uid' => $uid,
|
||||
'rel' => [Contact::FOLLOWER, Contact::FRIEND],
|
||||
'network' => $networks,
|
||||
'uid' => $uid,
|
||||
'rel' => [Contact::FOLLOWER, Contact::FRIEND],
|
||||
'network' => $networks,
|
||||
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION],
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
]);
|
||||
|
||||
foreach ($followers as $follower) {
|
||||
|
@ -432,13 +432,13 @@ class Circle
|
|||
$key = array_search(self::MUTUALS, $circle_ids);
|
||||
if ($key !== false) {
|
||||
$mutuals = Contact::selectToArray(['id'], [
|
||||
'uid' => $uid,
|
||||
'rel' => [Contact::FRIEND],
|
||||
'network' => $networks,
|
||||
'uid' => $uid,
|
||||
'rel' => [Contact::FRIEND],
|
||||
'network' => $networks,
|
||||
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
]);
|
||||
|
||||
foreach ($mutuals as $mutual) {
|
||||
|
@ -479,8 +479,8 @@ class Circle
|
|||
{
|
||||
$display_circles = [
|
||||
[
|
||||
'name' => '',
|
||||
'id' => '0',
|
||||
'name' => '',
|
||||
'id' => '0',
|
||||
'selected' => ''
|
||||
]
|
||||
];
|
||||
|
@ -488,18 +488,18 @@ class Circle
|
|||
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null], ['order' => ['name']]);
|
||||
while ($circle = DBA::fetch($stmt)) {
|
||||
$display_circles[] = [
|
||||
'name' => $circle['name'],
|
||||
'id' => $circle['id'],
|
||||
'name' => $circle['name'],
|
||||
'id' => $circle['id'],
|
||||
'selected' => $gid == $circle['id'] ? 'true' : ''
|
||||
];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
Logger::info('Got circles', $display_circles);
|
||||
DI::logger()->info('Got circles', $display_circles);
|
||||
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('circle_selection.tpl'), [
|
||||
'$id' => $id,
|
||||
'$label' => $label,
|
||||
'$id' => $id,
|
||||
'$label' => $label,
|
||||
'$circles' => $display_circles
|
||||
]);
|
||||
return $o;
|
||||
|
@ -527,10 +527,10 @@ class Circle
|
|||
|
||||
$display_circles = [
|
||||
[
|
||||
'text' => DI::l10n()->t('Everybody'),
|
||||
'id' => 0,
|
||||
'text' => DI::l10n()->t('Everybody'),
|
||||
'id' => 0,
|
||||
'selected' => (($circle_id === 'everyone') ? 'circle-selected' : ''),
|
||||
'href' => $every,
|
||||
'href' => $every,
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -545,7 +545,7 @@ class Circle
|
|||
|
||||
if ($editmode == 'full') {
|
||||
$circleedit = [
|
||||
'href' => 'circle/' . $circle['id'],
|
||||
'href' => 'circle/' . $circle['id'],
|
||||
'title' => DI::l10n()->t('edit'),
|
||||
];
|
||||
} else {
|
||||
|
@ -553,23 +553,23 @@ class Circle
|
|||
}
|
||||
|
||||
if ($each == 'circle') {
|
||||
$networks = Widget::unavailableNetworks();
|
||||
$networks = Widget::unavailableNetworks();
|
||||
$sql_values = array_merge([$circle['id']], $networks);
|
||||
$condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
|
||||
$condition = array_merge($condition, $sql_values);
|
||||
$condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
|
||||
$condition = array_merge($condition, $sql_values);
|
||||
|
||||
$count = DBA::count('circle-member-view', $condition);
|
||||
$count = DBA::count('circle-member-view', $condition);
|
||||
$circle_name = sprintf('%s (%d)', $circle['name'], $count);
|
||||
} else {
|
||||
$circle_name = $circle['name'];
|
||||
}
|
||||
|
||||
$display_circles[] = [
|
||||
'id' => $circle['id'],
|
||||
'cid' => $cid,
|
||||
'text' => $circle_name,
|
||||
'href' => $each . '/' . $circle['id'],
|
||||
'edit' => $circleedit,
|
||||
'id' => $circle['id'],
|
||||
'cid' => $cid,
|
||||
'text' => $circle_name,
|
||||
'href' => $each . '/' . $circle['id'],
|
||||
'edit' => $circleedit,
|
||||
'selected' => $selected,
|
||||
'ismember' => in_array($circle['id'], $member_of),
|
||||
];
|
||||
|
@ -582,18 +582,18 @@ class Circle
|
|||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('circle_side.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$add' => DI::l10n()->t('add'),
|
||||
'$title' => DI::l10n()->t('Circles'),
|
||||
'$circles' => $display_circles,
|
||||
'$new_circle' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
|
||||
'$circle_page' => 'circle/',
|
||||
'$edittext' => DI::l10n()->t('Edit circle'),
|
||||
'$uncircled' => $every === 'contact' ? DI::l10n()->t('Contacts not in any circle') : '',
|
||||
'$uncircled_selected' => (($circle_id === 'none') ? 'circle-selected' : ''),
|
||||
'$createtext' => DI::l10n()->t('Create a new circle'),
|
||||
'$create_circle' => DI::l10n()->t('Circle Name: '),
|
||||
'$edit_circles_text' => DI::l10n()->t('Edit circles'),
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$add' => DI::l10n()->t('add'),
|
||||
'$title' => DI::l10n()->t('Circles'),
|
||||
'$circles' => $display_circles,
|
||||
'$new_circle' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
|
||||
'$circle_page' => 'circle/',
|
||||
'$edittext' => DI::l10n()->t('Edit circle'),
|
||||
'$uncircled' => $every === 'contact' ? DI::l10n()->t('Contacts not in any circle') : '',
|
||||
'$uncircled_selected' => (($circle_id === 'none') ? 'circle-selected' : ''),
|
||||
'$createtext' => DI::l10n()->t('Create a new circle'),
|
||||
'$create_circle' => DI::l10n()->t('Circle Name: '),
|
||||
'$edit_circles_text' => DI::l10n()->t('Edit circles'),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('circle_edit'),
|
||||
]);
|
||||
|
||||
|
@ -608,7 +608,7 @@ class Circle
|
|||
*/
|
||||
public static function getIdForGroup(int $id): int
|
||||
{
|
||||
Logger::info('Get id for group id', ['id' => $id]);
|
||||
DI::logger()->info('Get id for group id', ['id' => $id]);
|
||||
$contact = Contact::getById($id, ['uid', 'name', 'contact-type', 'manually-approve']);
|
||||
if (empty($contact) || ($contact['contact-type'] != Contact::TYPE_COMMUNITY) || !$contact['manually-approve']) {
|
||||
return 0;
|
||||
|
@ -638,7 +638,7 @@ class Circle
|
|||
*/
|
||||
public static function updateMembersForGroup(int $id)
|
||||
{
|
||||
Logger::info('Update group members', ['id' => $id]);
|
||||
DI::logger()->info('Update group members', ['id' => $id]);
|
||||
|
||||
$contact = Contact::getById($id, ['uid', 'url']);
|
||||
if (empty($contact)) {
|
||||
|
@ -673,6 +673,6 @@ class Circle
|
|||
}
|
||||
|
||||
DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $current]);
|
||||
Logger::info('Updated group members', ['id' => $id, 'count' => DBA::count('group_member', ['gid' => $gid])]);
|
||||
DI::logger()->info('Updated group members', ['id' => $id, 'count' => DBA::count('group_member', ['gid' => $gid])]);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,6 @@ namespace Friendica\Model\Contact;
|
|||
|
||||
use Exception;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -67,7 +66,7 @@ class Relation
|
|||
{
|
||||
$contact = Contact::selectFirst(['id', 'url', 'network'], ['id' => Contact::getPublicIdByUserId($uid)]);
|
||||
if (empty($contact)) {
|
||||
Logger::warning('Self contact for user not found', ['uid' => $uid]);
|
||||
DI::logger()->warning('Self contact for user not found', ['uid' => $uid]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,22 +86,22 @@ class Relation
|
|||
{
|
||||
$contact = Contact::getByURL($url);
|
||||
if (empty($contact)) {
|
||||
Logger::info('Contact not found', ['url' => $url]);
|
||||
DI::logger()->info('Contact not found', ['url' => $url]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self::isDiscoverable($url, $contact)) {
|
||||
Logger::info('Contact is not discoverable', ['url' => $url]);
|
||||
DI::logger()->info('Contact is not discoverable', ['url' => $url]);
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = User::getIdForURL($url);
|
||||
if (!empty($uid)) {
|
||||
Logger::info('Fetch the followers/followings locally', ['url' => $url]);
|
||||
$followers = self::getContacts($uid, [Contact::FOLLOWER, Contact::FRIEND]);
|
||||
DI::logger()->info('Fetch the followers/followings locally', ['url' => $url]);
|
||||
$followers = self::getContacts($uid, [Contact::FOLLOWER, Contact::FRIEND]);
|
||||
$followings = self::getContacts($uid, [Contact::SHARING, Contact::FRIEND]);
|
||||
} elseif (!Contact::isLocal($url)) {
|
||||
Logger::info('Fetch the followers/followings by polling the endpoints', ['url' => $url]);
|
||||
DI::logger()->info('Fetch the followers/followings by polling the endpoints', ['url' => $url]);
|
||||
$apcontact = APContact::getByURL($url, false);
|
||||
|
||||
if (!empty($apcontact['followers']) && is_string($apcontact['followers'])) {
|
||||
|
@ -117,8 +116,8 @@ class Relation
|
|||
$followings = [];
|
||||
}
|
||||
} else {
|
||||
Logger::warning('Contact seems to be local but could not be found here', ['url' => $url]);
|
||||
$followers = [];
|
||||
DI::logger()->warning('Contact seems to be local but could not be found here', ['url' => $url]);
|
||||
$followers = [];
|
||||
$followings = [];
|
||||
}
|
||||
|
||||
|
@ -137,7 +136,7 @@ class Relation
|
|||
{
|
||||
if (empty($followers) && empty($followings)) {
|
||||
Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
Logger::info('The contact does not offer discoverable data', ['id' => $contact['id'], 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||
DI::logger()->info('The contact does not offer discoverable data', ['id' => $contact['id'], 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,10 +158,10 @@ class Relation
|
|||
}
|
||||
$contacts = array_unique($contacts);
|
||||
|
||||
$follower_counter = 0;
|
||||
$follower_counter = 0;
|
||||
$following_counter = 0;
|
||||
|
||||
Logger::info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
|
||||
DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
|
||||
foreach ($contacts as $contact) {
|
||||
$actor = Contact::getIdForURL($contact);
|
||||
if (!empty($actor)) {
|
||||
|
@ -186,7 +185,7 @@ class Relation
|
|||
}
|
||||
|
||||
Contact::update(['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
|
||||
Logger::info('Contacts discovery finished', ['id' => $target, 'url' => $url, 'follower' => $follower_counter, 'following' => $following_counter]);
|
||||
DI::logger()->info('Contacts discovery finished', ['id' => $target, 'url' => $url, 'follower' => $follower_counter, 'following' => $following_counter]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -200,7 +199,7 @@ class Relation
|
|||
*/
|
||||
private static function getContacts(int $uid, array $rel, bool $only_ap = true): array
|
||||
{
|
||||
$list = [];
|
||||
$list = [];
|
||||
$profile = Profile::getByUID($uid);
|
||||
if (!empty($profile['hide-friends'])) {
|
||||
return $list;
|
||||
|
@ -260,34 +259,34 @@ class Relation
|
|||
}
|
||||
|
||||
if ($contact['last-discovery'] > DateTimeFormat::utc('now - 1 month')) {
|
||||
Logger::info('No discovery - Last was less than a month ago.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['last-discovery']]);
|
||||
DI::logger()->info('No discovery - Last was less than a month ago.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['last-discovery']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($contact_discovery != self::DISCOVERY_ALL) {
|
||||
$local = DBA::exists('contact', ["`nurl` = ? AND `uid` != ?", Strings::normaliseLink($url), 0]);
|
||||
if (($contact_discovery == self::DISCOVERY_LOCAL) && !$local) {
|
||||
Logger::info('No discovery - This contact is not followed/following locally.', ['id' => $contact['id'], 'url' => $url]);
|
||||
DI::logger()->info('No discovery - This contact is not followed/following locally.', ['id' => $contact['id'], 'url' => $url]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($contact_discovery == self::DISCOVERY_INTERACTOR) {
|
||||
$interactor = DBA::exists('contact-relation', ["`relation-cid` = ? AND `last-interaction` > ?", $contact['id'], DBA::NULL_DATETIME]);
|
||||
if (!$local && !$interactor) {
|
||||
Logger::info('No discovery - This contact is not interacting locally.', ['id' => $contact['id'], 'url' => $url]);
|
||||
DI::logger()->info('No discovery - This contact is not interacting locally.', ['id' => $contact['id'], 'url' => $url]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($contact['created'] > DateTimeFormat::utc('now - 1 day')) {
|
||||
// Newly created contacts are not discovered to avoid DDoS attacks
|
||||
Logger::info('No discovery - Contact record is less than a day old.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['created']]);
|
||||
DI::logger()->info('No discovery - Contact record is less than a day old.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['created']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
|
||||
$apcontact = APContact::getByURL($url, false);
|
||||
if (empty($apcontact)) {
|
||||
Logger::info('No discovery - The contact does not seem to speak ActivityPub.', ['id' => $contact['id'], 'url' => $url, 'network' => $contact['network']]);
|
||||
DI::logger()->info('No discovery - The contact does not seem to speak ActivityPub.', ['id' => $contact['id'], 'url' => $url, 'network' => $contact['network']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +300,7 @@ class Relation
|
|||
* @param integer $uid
|
||||
* @return boolean
|
||||
*/
|
||||
static public function areSuggestionsOutdated(int $uid): bool
|
||||
public static function areSuggestionsOutdated(int $uid): bool
|
||||
{
|
||||
return DI::pConfig()->get($uid, 'suggestion', 'last_update') + 3600 < time();
|
||||
}
|
||||
|
@ -312,7 +311,7 @@ class Relation
|
|||
* @param integer $uid
|
||||
* @return void
|
||||
*/
|
||||
static public function updateCachedSuggestions(int $uid)
|
||||
public static function updateCachedSuggestions(int $uid)
|
||||
{
|
||||
if (!self::areSuggestionsOutdated($uid)) {
|
||||
return;
|
||||
|
@ -335,11 +334,11 @@ class Relation
|
|||
* @param int $limit optional, default 80
|
||||
* @return array
|
||||
*/
|
||||
static public function getCachedSuggestions(int $uid, int $start = 0, int $limit = 80): array
|
||||
public static function getCachedSuggestions(int $uid, int $start = 0, int $limit = 80): array
|
||||
{
|
||||
$condition = ["`uid` = ? AND `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE NOT `ignore` AND `uid` = ?)", 0, $uid];
|
||||
$params = ['limit' => [$start, $limit]];
|
||||
$cached = DBA::selectToArray('contact', [], $condition, $params);
|
||||
$params = ['limit' => [$start, $limit]];
|
||||
$cached = DBA::selectToArray('contact', [], $condition, $params);
|
||||
|
||||
if (!empty($cached)) {
|
||||
return $cached;
|
||||
|
@ -356,33 +355,37 @@ class Relation
|
|||
* @param int $limit optional, default 80
|
||||
* @return array
|
||||
*/
|
||||
static public function getSuggestions(int $uid, int $start = 0, int $limit = 80): array
|
||||
public static function getSuggestions(int $uid, int $start = 0, int $limit = 80): array
|
||||
{
|
||||
if ($uid == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cid = Contact::getPublicIdByUserId($uid);
|
||||
$cid = Contact::getPublicIdByUserId($uid);
|
||||
$totallimit = $start + $limit;
|
||||
$contacts = [];
|
||||
$contacts = [];
|
||||
|
||||
Logger::info('Collecting suggestions', ['uid' => $uid, 'cid' => $cid, 'start' => $start, 'limit' => $limit]);
|
||||
DI::logger()->info('Collecting suggestions', ['uid' => $uid, 'cid' => $cid, 'start' => $start, 'limit' => $limit]);
|
||||
|
||||
$diaspora = DI::config()->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::ACTIVITYPUB;
|
||||
|
||||
// The query returns contacts where contacts interacted with whom the given user follows.
|
||||
// Contacts who already are in the user's contact table are ignored.
|
||||
$results = DBA::select('contact', [], ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
|
||||
$results = DBA::select(
|
||||
'contact',
|
||||
[],
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
|
||||
(SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ?)
|
||||
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
|
||||
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))) AND `id` = `cid`)
|
||||
AND NOT `hidden` AND `network` IN (?, ?, ?)
|
||||
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
|
||||
$cid,
|
||||
0,
|
||||
$uid, Contact::FRIEND, Contact::SHARING,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid
|
||||
], [
|
||||
$cid,
|
||||
0,
|
||||
$uid, Contact::FRIEND, Contact::SHARING,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid
|
||||
],
|
||||
[
|
||||
'order' => ['last-item' => true],
|
||||
'limit' => $totallimit,
|
||||
]
|
||||
|
@ -394,7 +397,7 @@ class Relation
|
|||
|
||||
DBA::close($results);
|
||||
|
||||
Logger::info('Contacts of contacts who are followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
DI::logger()->info('Contacts of contacts who are followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
|
||||
if (count($contacts) >= $totallimit) {
|
||||
return array_slice($contacts, $start, $limit);
|
||||
|
@ -402,15 +405,17 @@ class Relation
|
|||
|
||||
// The query returns contacts where contacts interacted with whom also interacted with the given user.
|
||||
// Contacts who already are in the user's contact table are ignored.
|
||||
$results = DBA::select('contact', [],
|
||||
$results = DBA::select(
|
||||
'contact',
|
||||
[],
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
|
||||
(SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)
|
||||
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
|
||||
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))) AND `id` = `cid`)
|
||||
AND NOT `hidden` AND `network` IN (?, ?, ?)
|
||||
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
|
||||
$cid, 0, $uid, Contact::FRIEND, Contact::SHARING,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
$cid, 0, $uid, Contact::FRIEND, Contact::SHARING,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
['order' => ['last-item' => true], 'limit' => $totallimit]
|
||||
);
|
||||
|
||||
|
@ -419,19 +424,21 @@ class Relation
|
|||
}
|
||||
DBA::close($results);
|
||||
|
||||
Logger::info('Contacts of contacts who are following the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
DI::logger()->info('Contacts of contacts who are following the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
|
||||
if (count($contacts) >= $totallimit) {
|
||||
return array_slice($contacts, $start, $limit);
|
||||
}
|
||||
|
||||
// The query returns contacts that follow the given user but aren't followed by that user.
|
||||
$results = DBA::select('contact', [],
|
||||
$results = DBA::select(
|
||||
'contact',
|
||||
[],
|
||||
["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` = ?)
|
||||
AND NOT `hidden` AND `uid` = ? AND `network` IN (?, ?, ?)
|
||||
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
|
||||
$uid, Contact::FOLLOWER, 0,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
$uid, Contact::FOLLOWER, 0,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
['order' => ['last-item' => true], 'limit' => $totallimit]
|
||||
);
|
||||
|
||||
|
@ -440,19 +447,21 @@ class Relation
|
|||
}
|
||||
DBA::close($results);
|
||||
|
||||
Logger::info('Followers that are not followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
DI::logger()->info('Followers that are not followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
|
||||
if (count($contacts) >= $totallimit) {
|
||||
return array_slice($contacts, $start, $limit);
|
||||
}
|
||||
|
||||
// The query returns any contact that isn't followed by that user.
|
||||
$results = DBA::select('contact', [],
|
||||
$results = DBA::select(
|
||||
'contact',
|
||||
[],
|
||||
["NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?) AND `nurl` = `nurl`)
|
||||
AND NOT `hidden` AND `uid` = ? AND `network` IN (?, ?, ?)
|
||||
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
|
||||
$uid, Contact::FRIEND, Contact::SHARING, 0,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
$uid, Contact::FRIEND, Contact::SHARING, 0,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
|
||||
['order' => ['last-item' => true], 'limit' => $totallimit]
|
||||
);
|
||||
|
||||
|
@ -461,7 +470,7 @@ class Relation
|
|||
}
|
||||
DBA::close($results);
|
||||
|
||||
Logger::info('Any contact', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
DI::logger()->info('Any contact', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||
|
||||
return array_slice($contacts, $start, $limit);
|
||||
}
|
||||
|
@ -477,7 +486,7 @@ class Relation
|
|||
public static function countFollows(int $cid, array $condition = []): int
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
|
||||
|
||||
$result = DBA::fetchFirst($sql, $condition);
|
||||
return $result['total'] ?? 0;
|
||||
|
@ -496,7 +505,7 @@ class Relation
|
|||
public static function listFollows(int $cid, array $condition = [], int $count = 30, int $offset = 0)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
|
||||
$sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
|
||||
if ($count > 0) {
|
||||
$sql .= " LIMIT ?, ?";
|
||||
$condition = array_merge($condition, [$offset, $count]);
|
||||
|
@ -515,7 +524,7 @@ class Relation
|
|||
public static function countFollowers(int $cid, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
|
||||
|
||||
$result = DBA::fetchFirst($sql, $condition);
|
||||
return $result['total'] ?? 0;
|
||||
|
@ -534,7 +543,7 @@ class Relation
|
|||
public static function listFollowers(int $cid, array $condition = [], int $count = 30, int $offset = 0)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
|
||||
$sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
|
||||
if ($count > 0) {
|
||||
$sql .= " LIMIT ?, ?";
|
||||
$condition = array_merge($condition, [$offset, $count]);
|
||||
|
@ -554,13 +563,13 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
|
||||
$contacts = 0;
|
||||
$query = DBA::p($sql, $union);
|
||||
$query = DBA::p($sql, $union);
|
||||
while (DBA::fetch($query)) {
|
||||
$contacts++;
|
||||
}
|
||||
|
@ -583,10 +592,10 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
if ($count > 0) {
|
||||
$sql .= " LIMIT ?, ?";
|
||||
$union = array_merge($union, [$offset, $count]);
|
||||
|
@ -606,13 +615,13 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " UNION " . $sql2;
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " UNION " . $sql2;
|
||||
|
||||
$contacts = 0;
|
||||
$query = DBA::p($sql, $union);
|
||||
$query = DBA::p($sql, $union);
|
||||
while (DBA::fetch($query)) {
|
||||
$contacts++;
|
||||
}
|
||||
|
@ -635,10 +644,10 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " UNION " . $sql2;
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " UNION " . $sql2;
|
||||
if ($count > 0) {
|
||||
$sql .= " LIMIT ?, ?";
|
||||
$union = array_merge($union, [$offset, $count]);
|
||||
|
@ -660,13 +669,13 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $sourceId]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $targetId]);
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
$sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
|
||||
$contacts = 0;
|
||||
$query = DBA::p($sql, $union);
|
||||
$query = DBA::p($sql, $union);
|
||||
while (DBA::fetch($query)) {
|
||||
$contacts++;
|
||||
}
|
||||
|
@ -691,10 +700,10 @@ class Relation
|
|||
{
|
||||
$condition1 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $sourceId]);
|
||||
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $targetId]);
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
$sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
|
||||
$sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
|
||||
$union = array_merge($condition1, $condition2);
|
||||
$sql = $sql1 . " INTERSECT " . $sql2;
|
||||
if ($count > 0) {
|
||||
$sql .= " LIMIT ?, ?";
|
||||
$union = array_merge($union, [$offset, $count]);
|
||||
|
@ -713,10 +722,11 @@ class Relation
|
|||
*/
|
||||
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = []): int
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||
$sourceId, $targetId]
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
return DI::dba()->count('contact', $condition);
|
||||
|
@ -736,13 +746,17 @@ class Relation
|
|||
*/
|
||||
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
return DI::dba()->selectToArray(
|
||||
'contact',
|
||||
[],
|
||||
$condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
}
|
||||
|
@ -758,10 +772,11 @@ class Relation
|
|||
*/
|
||||
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = []): int
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
return DI::dba()->count('contact', $condition);
|
||||
|
@ -781,13 +796,17 @@ class Relation
|
|||
*/
|
||||
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
return DI::dba()->selectToArray(
|
||||
'contact',
|
||||
[],
|
||||
$condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
}
|
||||
|
@ -800,84 +819,162 @@ class Relation
|
|||
*/
|
||||
public static function calculateInteractionScore(int $uid)
|
||||
{
|
||||
$days = DI::config()->get('channel', 'interaction_score_days');
|
||||
$days = DI::config()->get('channel', 'interaction_score_days');
|
||||
$contact_id = Contact::getPublicIdByUserId($uid);
|
||||
|
||||
Logger::debug('Calculation - start', ['uid' => $uid, 'cid' => $contact_id, 'days' => $days]);
|
||||
DI::logger()->debug('Calculation - start', ['uid' => $uid, 'cid' => $contact_id, 'days' => $days]);
|
||||
|
||||
$follow = Verb::getID(Activity::FOLLOW);
|
||||
$view = Verb::getID(Activity::VIEW);
|
||||
$read = Verb::getID(Activity::READ);
|
||||
$view = Verb::getID(Activity::VIEW);
|
||||
$read = Verb::getID(Activity::READ);
|
||||
|
||||
DBA::update('contact-relation', ['score' => 0, 'relation-score' => 0, 'thread-score' => 0, 'relation-thread-score' => 0], ['relation-cid' => $contact_id]);
|
||||
|
||||
$total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$total = DBA::fetchFirst(
|
||||
"SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
|
||||
Logger::debug('Calculate relation-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
DI::logger()->debug('Calculate relation-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
|
||||
$interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
|
||||
$interactions = DBA::p(
|
||||
"SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
|
||||
FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$uid, Contact::SHARING, Contact::FRIEND, $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$uid,
|
||||
Contact::SHARING,
|
||||
Contact::FRIEND,
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
while ($interaction = DBA::fetch($interactions)) {
|
||||
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
|
||||
DBA::update('contact-relation', ['relation-score' => $score, 'follows' => $interaction['follows']], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
|
||||
}
|
||||
DBA::close($interactions);
|
||||
|
||||
$total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$total = DBA::fetchFirst(
|
||||
"SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
|
||||
Logger::debug('Calculate relation-thread-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
DI::logger()->debug('Calculate relation-thread-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
|
||||
$interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
|
||||
$interactions = DBA::p(
|
||||
"SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
|
||||
FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$uid, Contact::SHARING, Contact::FRIEND, $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$uid,
|
||||
Contact::SHARING,
|
||||
Contact::FRIEND,
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
while ($interaction = DBA::fetch($interactions)) {
|
||||
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
|
||||
DBA::update('contact-relation', ['relation-thread-score' => $score, 'follows' => !empty($interaction['follows'])], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
|
||||
}
|
||||
DBA::close($interactions);
|
||||
|
||||
$total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$total = DBA::fetchFirst(
|
||||
"SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
|
||||
Logger::debug('Calculate score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
DI::logger()->debug('Calculate score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
|
||||
$interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$interactions = DBA::p(
|
||||
"SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
while ($interaction = DBA::fetch($interactions)) {
|
||||
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
|
||||
DBA::update('contact-relation', ['score' => $score], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
|
||||
}
|
||||
DBA::close($interactions);
|
||||
|
||||
$total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$total = DBA::fetchFirst(
|
||||
"SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
|
||||
Logger::debug('Calculate thread-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
DI::logger()->debug('Calculate thread-score', ['uid' => $uid, 'total' => $total['activity']]);
|
||||
|
||||
$interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
|
||||
$interactions = DBA::p(
|
||||
"SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
|
||||
$contact_id,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day'),
|
||||
$uid,
|
||||
$contact_id,
|
||||
$follow,
|
||||
$view,
|
||||
$read
|
||||
);
|
||||
while ($interaction = DBA::fetch($interactions)) {
|
||||
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
|
||||
DBA::update('contact-relation', ['thread-score' => $score], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
|
||||
}
|
||||
DBA::close($interactions);
|
||||
|
||||
$total = DBA::fetchFirst("SELECT count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ?",
|
||||
$contact_id, $uid, DateTimeFormat::utc('now - ' . $days . ' day'));
|
||||
$total = DBA::fetchFirst(
|
||||
"SELECT count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ?",
|
||||
$contact_id,
|
||||
$uid,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day')
|
||||
);
|
||||
|
||||
Logger::debug('Calculate post-score', ['uid' => $uid, 'total' => $total['posts']]);
|
||||
DI::logger()->debug('Calculate post-score', ['uid' => $uid, 'total' => $total['posts']]);
|
||||
|
||||
$posts = DBA::p("SELECT `author-id`, count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ? GROUP BY `author-id`",
|
||||
$contact_id, $uid, DateTimeFormat::utc('now - ' . $days . ' day'));
|
||||
$posts = DBA::p(
|
||||
"SELECT `author-id`, count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ? GROUP BY `author-id`",
|
||||
$contact_id,
|
||||
$uid,
|
||||
DateTimeFormat::utc('now - ' . $days . ' day')
|
||||
);
|
||||
while ($post = DBA::fetch($posts)) {
|
||||
$score = min((int)(($post['posts'] / $total['posts']) * 65535), 65535);
|
||||
DBA::update('contact-relation', ['post-score' => $score], ['relation-cid' => $contact_id, 'cid' => $post['author-id']]);
|
||||
}
|
||||
DBA::close($posts);
|
||||
|
||||
Logger::debug('Calculation - end', ['uid' => $uid]);
|
||||
DI::logger()->debug('Calculation - end', ['uid' => $uid]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Model\Contact;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -41,7 +40,7 @@ class User
|
|||
}
|
||||
|
||||
if (empty($contact['uri-id']) && empty($contact['url'])) {
|
||||
Logger::info('Missing contact details', ['contact' => $contact]);
|
||||
DI::logger()->info('Missing contact details', ['contact' => $contact]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -53,18 +52,18 @@ class User
|
|||
if (!empty($contact['uri-id']) && DBA::isResult($pcontact)) {
|
||||
$pcid = $pcontact['id'];
|
||||
} elseif (empty($contact['url']) || !($pcid = Contact::getIdForURL($contact['url'], 0, false))) {
|
||||
Logger::info('Public contact for user not found', ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']]);
|
||||
DI::logger()->info('Public contact for user not found', ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = self::preparedFields($contact);
|
||||
$fields['cid'] = $pcid;
|
||||
$fields['uid'] = $contact['uid'];
|
||||
$fields = self::preparedFields($contact);
|
||||
$fields['cid'] = $pcid;
|
||||
$fields['uid'] = $contact['uid'];
|
||||
$fields['uri-id'] = $contact['uri-id'];
|
||||
|
||||
$ret = DBA::insert('user-contact', $fields, Database::INSERT_UPDATE);
|
||||
|
||||
Logger::info('Inserted user contact', ['uid' => $contact['uid'], 'cid' => $pcid, 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
|
||||
DI::logger()->info('Inserted user contact', ['uid' => $contact['uid'], 'cid' => $pcid, 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -90,8 +89,8 @@ class User
|
|||
continue;
|
||||
}
|
||||
$update_fields['cid'] = $contact['pid'];
|
||||
$ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true);
|
||||
Logger::info('Updated user contact', ['uid' => $contact['uid'], 'id' => $contact['pid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
|
||||
$ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true);
|
||||
DI::logger()->info('Updated user contact', ['uid' => $contact['uid'], 'id' => $contact['pid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
|
||||
}
|
||||
|
||||
DBA::close($contacts);
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Friendica\Model;
|
|||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -30,7 +29,6 @@ use Friendica\Util\XML;
|
|||
*/
|
||||
class Event
|
||||
{
|
||||
|
||||
public static function getHTML(array $event, bool $simple = false, int $uriid = 0): string
|
||||
{
|
||||
if (empty($event)) {
|
||||
|
@ -219,7 +217,7 @@ class Event
|
|||
}
|
||||
|
||||
DBA::delete('event', ['id' => $event_id]);
|
||||
Logger::info("Deleted event", ['id' => $event_id]);
|
||||
DI::logger()->info("Deleted event", ['id' => $event_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,28 +231,28 @@ class Event
|
|||
*/
|
||||
public static function store(array $arr): int
|
||||
{
|
||||
$guid = $arr['guid'] ?? '' ?: System::createUUID();
|
||||
$uri = $arr['uri'] ?? '' ?: Item::newURI($guid);
|
||||
$guid = $arr['guid'] ?? '' ?: System::createUUID();
|
||||
$uri = $arr['uri'] ?? '' ?: Item::newURI($guid);
|
||||
$event = [
|
||||
'id' => intval($arr['id'] ?? 0),
|
||||
'uid' => intval($arr['uid'] ?? 0),
|
||||
'cid' => intval($arr['cid'] ?? 0),
|
||||
'id' => intval($arr['id'] ?? 0),
|
||||
'uid' => intval($arr['uid'] ?? 0),
|
||||
'cid' => intval($arr['cid'] ?? 0),
|
||||
'guid' => $guid,
|
||||
'uri' => $uri,
|
||||
'uri-id' => ItemURI::insert(['uri' => $uri, 'guid' => $guid]),
|
||||
'type' => ($arr['type'] ?? '') ?: 'event',
|
||||
'summary' => $arr['summary'] ?? '',
|
||||
'desc' => $arr['desc'] ?? '',
|
||||
'location' => $arr['location'] ?? '',
|
||||
'allow_cid' => $arr['allow_cid'] ?? '',
|
||||
'allow_gid' => $arr['allow_gid'] ?? '',
|
||||
'deny_cid' => $arr['deny_cid'] ?? '',
|
||||
'deny_gid' => $arr['deny_gid'] ?? '',
|
||||
'type' => ($arr['type'] ?? '') ?: 'event',
|
||||
'summary' => $arr['summary'] ?? '',
|
||||
'desc' => $arr['desc'] ?? '',
|
||||
'location' => $arr['location'] ?? '',
|
||||
'allow_cid' => $arr['allow_cid'] ?? '',
|
||||
'allow_gid' => $arr['allow_gid'] ?? '',
|
||||
'deny_cid' => $arr['deny_cid'] ?? '',
|
||||
'deny_gid' => $arr['deny_gid'] ?? '',
|
||||
'nofinish' => intval($arr['nofinish'] ?? (!empty($arr['start']) && empty($arr['finish']))),
|
||||
'created' => DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now'),
|
||||
'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
|
||||
'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
|
||||
'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
|
||||
'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
|
||||
'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
|
||||
'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
|
||||
];
|
||||
|
||||
|
||||
|
@ -358,7 +356,7 @@ class Event
|
|||
$item['body'] = self::getBBCode($event);
|
||||
$item['event-id'] = $event['id'];
|
||||
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item['object'] .= '</object>' . "\n";
|
||||
|
||||
|
@ -376,13 +374,13 @@ class Event
|
|||
return $item;
|
||||
}
|
||||
|
||||
$item['post-type'] = Item::PT_EVENT;
|
||||
$item['title'] = '';
|
||||
$item['object-type'] = Activity\ObjectType::EVENT;
|
||||
$item['body'] = self::getBBCode($event);
|
||||
$item['event-id'] = $event_id;
|
||||
$item['post-type'] = Item::PT_EVENT;
|
||||
$item['title'] = '';
|
||||
$item['object-type'] = Activity\ObjectType::EVENT;
|
||||
$item['body'] = self::getBBCode($event);
|
||||
$item['event-id'] = $event_id;
|
||||
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item['object'] .= '</object>' . "\n";
|
||||
|
||||
|
@ -399,7 +397,7 @@ class Event
|
|||
{
|
||||
// First day of the week (0 = Sunday).
|
||||
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?? 0;
|
||||
$defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month';
|
||||
$defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month';
|
||||
|
||||
return [
|
||||
'firstDay' => $firstDay,
|
||||
|
@ -650,12 +648,12 @@ class Event
|
|||
if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $event['uid'] && $event['type'] == 'event') {
|
||||
$edit = !$event['cid'] ? ['calendar/event/edit/' . $event['id'], DI::l10n()->t('Edit event'), '', ''] : null;
|
||||
$copy = !$event['cid'] ? ['calendar/event/copy/' . $event['id'], DI::l10n()->t('Duplicate event'), '', ''] : null;
|
||||
$drop = ['calendar/api/delete/' . $event['id'], DI::l10n()->t('Delete event'), '', ''];
|
||||
$drop = ['calendar/api/delete/' . $event['id'], DI::l10n()->t('Delete event'), '', ''];
|
||||
}
|
||||
|
||||
$title = strip_tags(BBCode::convertForUriId($event['uri-id'], $event['summary']));
|
||||
if (!$title) {
|
||||
[$title, $_trash] = explode("<br", BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['desc'])), BBCode::TWITTER_API);
|
||||
list($title, $_trash) = explode("<br", BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['desc'])), BBCode::TWITTER_API);
|
||||
}
|
||||
|
||||
$event['author-link'] = Contact::magicLink($event['author-link']);
|
||||
|
@ -695,7 +693,7 @@ class Event
|
|||
}
|
||||
|
||||
switch ($format) {
|
||||
// Format the exported data as a CSV file.
|
||||
// Format the exported data as a CSV file.
|
||||
case "csv":
|
||||
$o .= '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
|
||||
|
||||
|
@ -745,21 +743,21 @@ class Event
|
|||
$tmp = $event['summary'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'SUMMARY:' . $tmp . PHP_EOL;
|
||||
$o .= 'SUMMARY:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($event['desc']) {
|
||||
$tmp = $event['desc'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
|
||||
$o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($event['location']) {
|
||||
$tmp = $event['location'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'LOCATION:' . $tmp . PHP_EOL;
|
||||
$o .= 'LOCATION:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
$o .= 'END:VEVENT' . PHP_EOL;
|
||||
|
@ -913,7 +911,7 @@ class Event
|
|||
}
|
||||
|
||||
// Construct the profile link (magic-auth).
|
||||
$author = [
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Friendica\Model;
|
|||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use Exception;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -40,44 +39,44 @@ use Psr\Http\Message\UriInterface;
|
|||
class GServer
|
||||
{
|
||||
// Directory types
|
||||
const DT_NONE = 0;
|
||||
const DT_POCO = 1;
|
||||
const DT_NONE = 0;
|
||||
const DT_POCO = 1;
|
||||
const DT_MASTODON = 2;
|
||||
|
||||
// Methods to detect server types
|
||||
|
||||
// Non endpoint specific methods
|
||||
const DETECT_MANUAL = 0;
|
||||
const DETECT_HEADER = 1;
|
||||
const DETECT_BODY = 2;
|
||||
const DETECT_HOST_META = 3;
|
||||
const DETECT_CONTACTS = 4;
|
||||
const DETECT_AP_ACTOR = 5;
|
||||
const DETECT_MANUAL = 0;
|
||||
const DETECT_HEADER = 1;
|
||||
const DETECT_BODY = 2;
|
||||
const DETECT_HOST_META = 3;
|
||||
const DETECT_CONTACTS = 4;
|
||||
const DETECT_AP_ACTOR = 5;
|
||||
const DETECT_AP_COLLECTION = 6;
|
||||
|
||||
const DETECT_UNSPECIFIC = [self::DETECT_MANUAL, self::DETECT_HEADER, self::DETECT_BODY, self::DETECT_HOST_META, self::DETECT_CONTACTS, self::DETECT_AP_ACTOR];
|
||||
|
||||
// Implementation specific endpoints
|
||||
// @todo Possibly add Lemmy detection via the endpoint /api/v3/site
|
||||
const DETECT_FRIENDIKA = 10;
|
||||
const DETECT_FRIENDICA = 11;
|
||||
const DETECT_STATUSNET = 12;
|
||||
const DETECT_GNUSOCIAL = 13;
|
||||
const DETECT_CONFIG_JSON = 14; // Statusnet, GNU Social, Older Hubzilla/Redmatrix
|
||||
const DETECT_FRIENDIKA = 10;
|
||||
const DETECT_FRIENDICA = 11;
|
||||
const DETECT_STATUSNET = 12;
|
||||
const DETECT_GNUSOCIAL = 13;
|
||||
const DETECT_CONFIG_JSON = 14; // Statusnet, GNU Social, Older Hubzilla/Redmatrix
|
||||
const DETECT_SITEINFO_JSON = 15; // Newer Hubzilla
|
||||
const DETECT_MASTODON_API = 16;
|
||||
const DETECT_STATUS_PHP = 17; // Nextcloud
|
||||
const DETECT_V1_CONFIG = 18;
|
||||
const DETECT_SYSTEM_ACTOR = 20; // Mistpark, Osada, Roadhouse, Zap
|
||||
const DETECT_THREADS = 21;
|
||||
const DETECT_MASTODON_API = 16;
|
||||
const DETECT_STATUS_PHP = 17; // Nextcloud
|
||||
const DETECT_V1_CONFIG = 18;
|
||||
const DETECT_SYSTEM_ACTOR = 20; // Mistpark, Osada, Roadhouse, Zap
|
||||
const DETECT_THREADS = 21;
|
||||
|
||||
// Standardized endpoints
|
||||
const DETECT_STATISTICS_JSON = 100;
|
||||
const DETECT_NODEINFO_10 = 101; // Nodeinfo Version 1.0
|
||||
const DETECT_NODEINFO_20 = 102; // Nodeinfo Version 2.0
|
||||
const DETECT_NODEINFO2_10 = 103; // Nodeinfo2 Version 1.0
|
||||
const DETECT_NODEINFO_21 = 104; // Nodeinfo Version 2.1
|
||||
const DETECT_NODEINFO_22 = 105; // Nodeinfo Version 2.2
|
||||
const DETECT_NODEINFO_10 = 101; // Nodeinfo Version 1.0
|
||||
const DETECT_NODEINFO_20 = 102; // Nodeinfo Version 2.0
|
||||
const DETECT_NODEINFO2_10 = 103; // Nodeinfo2 Version 1.0
|
||||
const DETECT_NODEINFO_21 = 104; // Nodeinfo Version 2.1
|
||||
const DETECT_NODEINFO_22 = 105; // Nodeinfo Version 2.2
|
||||
|
||||
/**
|
||||
* Check for the existence of a server and adds it in the background if not existant
|
||||
|
@ -114,7 +113,7 @@ class GServer
|
|||
|
||||
$gserver = DBA::selectFirst('gserver', ['id'], ['nurl' => Strings::normaliseLink($url)]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
Logger::debug('Got ID for URL', ['id' => $gserver['id'], 'url' => $url]);
|
||||
DI::logger()->debug('Got ID for URL', ['id' => $gserver['id'], 'url' => $url]);
|
||||
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
self::setBlockedById($gserver['id']);
|
||||
|
@ -336,7 +335,7 @@ class GServer
|
|||
}
|
||||
|
||||
if (Network::isUrlBlocked($server_url)) {
|
||||
Logger::info('Server is blocked', ['url' => $server_url]);
|
||||
DI::logger()->info('Server is blocked', ['url' => $server_url]);
|
||||
self::setBlockedByUrl($server_url);
|
||||
return false;
|
||||
}
|
||||
|
@ -344,18 +343,18 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
if ($gserver['created'] <= DBA::NULL_DATETIME) {
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$condition = ['nurl' => Strings::normaliseLink($server_url)];
|
||||
self::update($fields, $condition);
|
||||
}
|
||||
|
||||
if (!$force && (strtotime($gserver['next_contact']) > time())) {
|
||||
Logger::info('No update needed', ['server' => $server_url]);
|
||||
DI::logger()->info('No update needed', ['server' => $server_url]);
|
||||
return (!$gserver['failed']);
|
||||
}
|
||||
Logger::info('Server is outdated. Start discovery.', ['Server' => $server_url, 'Force' => $force]);
|
||||
DI::logger()->info('Server is outdated. Start discovery.', ['Server' => $server_url, 'Force' => $force]);
|
||||
} else {
|
||||
Logger::info('Server is unknown. Start discovery.', ['Server' => $server_url]);
|
||||
DI::logger()->info('Server is unknown. Start discovery.', ['Server' => $server_url]);
|
||||
}
|
||||
|
||||
return self::detect($server_url, $network, $only_nodeinfo);
|
||||
|
@ -381,7 +380,7 @@ class GServer
|
|||
$fields['network'] = $network;
|
||||
}
|
||||
self::update($fields, ['id' => $gsid]);
|
||||
Logger::info('Reset failed status for server', ['url' => $gserver['url']]);
|
||||
DI::logger()->info('Reset failed status for server', ['url' => $gserver['url']]);
|
||||
|
||||
if (strtotime($gserver['next_contact']) < time()) {
|
||||
UpdateGServer::add(Worker::PRIORITY_LOW, $gserver['url']);
|
||||
|
@ -403,7 +402,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['url', 'failed', 'next_contact'], ['id' => $gsid]);
|
||||
if (DBA::isResult($gserver) && !$gserver['failed']) {
|
||||
self::update(['failed' => true, 'blocked' => Network::isUrlBlocked($gserver['url']), 'last_failure' => DateTimeFormat::utcNow()], ['id' => $gsid]);
|
||||
Logger::info('Set failed status for server', ['url' => $gserver['url']]);
|
||||
DI::logger()->info('Set failed status for server', ['url' => $gserver['url']]);
|
||||
|
||||
if (strtotime($gserver['next_contact']) < time()) {
|
||||
UpdateGServer::add(Worker::PRIORITY_LOW, $gserver['url']);
|
||||
|
@ -416,7 +415,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['url'], ["(`blocked` OR `blocked` IS NULL) AND `id` = ?", $gsid]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
self::update(['blocked' => false], ['id' => $gsid]);
|
||||
Logger::info('Set unblocked status for server', ['url' => $gserver['url']]);
|
||||
DI::logger()->info('Set unblocked status for server', ['url' => $gserver['url']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +424,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['url'], ["(NOT `blocked` OR `blocked` IS NULL) AND `id` = ?", $gsid]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
self::update(['blocked' => true, 'failed' => true], ['id' => $gsid]);
|
||||
Logger::info('Set blocked status for server', ['url' => $gserver['url']]);
|
||||
DI::logger()->info('Set blocked status for server', ['url' => $gserver['url']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,7 +433,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['url', 'id'], ["(NOT `blocked` OR `blocked` IS NULL) AND `nurl` = ?", Strings::normaliseLink($url)]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
self::update(['blocked' => true, 'failed' => true], ['id' => $gserver['id']]);
|
||||
Logger::info('Set blocked status for server', ['url' => $gserver['url']]);
|
||||
DI::logger()->info('Set blocked status for server', ['url' => $gserver['url']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,10 +450,12 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
||||
self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
||||
['nurl' => $nurl]);
|
||||
Logger::info('Set failed status for existing server', ['url' => $url]);
|
||||
self::update(
|
||||
['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
||||
['nurl' => $nurl]
|
||||
);
|
||||
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
||||
if (self::isDefunct($gserver)) {
|
||||
self::archiveContacts($gserver['id']);
|
||||
}
|
||||
|
@ -462,9 +463,9 @@ class GServer
|
|||
}
|
||||
|
||||
self::insert(['url' => $url, 'nurl' => $nurl,
|
||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||
Logger::info('Set failed status for new server', ['url' => $url]);
|
||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||
DI::logger()->info('Set failed status for new server', ['url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -493,7 +494,7 @@ class GServer
|
|||
try {
|
||||
return (string)self::cleanUri(new Uri($dirtyUrl));
|
||||
} catch (\Throwable $e) {
|
||||
Logger::warning('Invalid URL', ['dirtyUrl' => $dirtyUrl]);
|
||||
DI::logger()->warning('Invalid URL', ['dirtyUrl' => $dirtyUrl]);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -533,14 +534,14 @@ class GServer
|
|||
*/
|
||||
private static function detect(string $url, string $network = '', bool $only_nodeinfo = false): bool
|
||||
{
|
||||
Logger::info('Detect server type', ['server' => $url]);
|
||||
DI::logger()->info('Detect server type', ['server' => $url]);
|
||||
|
||||
$original_url = $url;
|
||||
|
||||
// Remove URL content that is not supposed to exist for a server url
|
||||
$url = rtrim(self::cleanURL($url), '/');
|
||||
if (empty($url)) {
|
||||
Logger::notice('Empty URL.');
|
||||
DI::logger()->notice('Empty URL.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -566,7 +567,7 @@ class GServer
|
|||
// Some systems have got redirects on their landing page to a single account page. This check handles it.
|
||||
if (((parse_url($url, PHP_URL_HOST) != parse_url($valid_url, PHP_URL_HOST)) && (parse_url($url, PHP_URL_PATH) == parse_url($valid_url, PHP_URL_PATH))) ||
|
||||
(((parse_url($url, PHP_URL_HOST) != parse_url($valid_url, PHP_URL_HOST)) || (parse_url($url, PHP_URL_PATH) != parse_url($valid_url, PHP_URL_PATH))) && empty(parse_url($valid_url, PHP_URL_PATH)))) {
|
||||
Logger::debug('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $valid_url]);
|
||||
DI::logger()->debug('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $valid_url]);
|
||||
self::setFailureByUrl($url);
|
||||
if (!self::getID($valid_url, true) && !Network::isUrlBlocked($valid_url)) {
|
||||
self::detect($valid_url, $network, $only_nodeinfo);
|
||||
|
@ -576,7 +577,7 @@ class GServer
|
|||
|
||||
if ((parse_url($url, PHP_URL_HOST) != parse_url($valid_url, PHP_URL_HOST)) && (parse_url($url, PHP_URL_PATH) != parse_url($valid_url, PHP_URL_PATH)) &&
|
||||
(parse_url($url, PHP_URL_PATH) == '')) {
|
||||
Logger::debug('Found redirect. Mark old entry as failure and redirect to the basepath.', ['old' => $url, 'new' => $valid_url]);
|
||||
DI::logger()->debug('Found redirect. Mark old entry as failure and redirect to the basepath.', ['old' => $url, 'new' => $valid_url]);
|
||||
$parts = (array)parse_url($valid_url);
|
||||
unset($parts['path']);
|
||||
$valid_url = (string)Uri::fromParts($parts);
|
||||
|
@ -587,13 +588,13 @@ class GServer
|
|||
}
|
||||
return false;
|
||||
}
|
||||
Logger::debug('Found redirect, but ignore it.', ['old' => $url, 'new' => $valid_url]);
|
||||
DI::logger()->debug('Found redirect, but ignore it.', ['old' => $url, 'new' => $valid_url]);
|
||||
}
|
||||
|
||||
if ((parse_url($url, PHP_URL_HOST) == parse_url($valid_url, PHP_URL_HOST)) &&
|
||||
(parse_url($url, PHP_URL_PATH) == parse_url($valid_url, PHP_URL_PATH)) &&
|
||||
(parse_url($url, PHP_URL_SCHEME) != parse_url($valid_url, PHP_URL_SCHEME))) {
|
||||
$url = $valid_url;
|
||||
$url = $valid_url;
|
||||
}
|
||||
|
||||
$in_webroot = empty(parse_url($url, PHP_URL_PATH));
|
||||
|
@ -617,7 +618,7 @@ class GServer
|
|||
}
|
||||
|
||||
if ($only_nodeinfo && empty($serverdata)) {
|
||||
Logger::info('Invalid nodeinfo in nodeinfo-mode, server is marked as failure', ['url' => $url]);
|
||||
DI::logger()->info('Invalid nodeinfo in nodeinfo-mode, server is marked as failure', ['url' => $url]);
|
||||
self::setFailureByUrl($url);
|
||||
return false;
|
||||
} elseif (empty($serverdata)) {
|
||||
|
@ -628,10 +629,10 @@ class GServer
|
|||
if ($serverdata['network'] == Protocol::PHANTOM) {
|
||||
if ($in_webroot) {
|
||||
// Fetch the landing page, possibly it reveals some data
|
||||
$accept = 'application/activity+json,application/ld+json,application/json,*/*;q=0.9';
|
||||
$accept = 'application/activity+json,application/ld+json,application/json,*/*;q=0.9';
|
||||
$curlResult = DI::httpClient()->get($url, $accept, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess() && $curlResult->getReturnCode() == '406') {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$html_fetched = true;
|
||||
} else {
|
||||
$html_fetched = false;
|
||||
|
@ -640,8 +641,8 @@ class GServer
|
|||
if ($curlResult->isSuccess()) {
|
||||
$json = json_decode($curlResult->getBodyString(), true);
|
||||
if (!empty($json) && is_array($json)) {
|
||||
$data = self::fetchDataFromSystemActor($json, $serverdata);
|
||||
$serverdata = $data['server'];
|
||||
$data = self::fetchDataFromSystemActor($json, $serverdata);
|
||||
$serverdata = $data['server'];
|
||||
$systemactor = $data['actor'];
|
||||
if (!$html_fetched && !in_array($serverdata['detection-method'], [self::DETECT_SYSTEM_ACTOR, self::DETECT_AP_COLLECTION])) {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
|
@ -740,7 +741,7 @@ class GServer
|
|||
return false;
|
||||
}
|
||||
|
||||
$serverdata['url'] = $url;
|
||||
$serverdata['url'] = $url;
|
||||
$serverdata['nurl'] = Strings::normaliseLink($url);
|
||||
|
||||
// We have to prevent an endless loop here.
|
||||
|
@ -804,10 +805,11 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
||||
if (!DBA::isResult($gserver)) {
|
||||
$serverdata['created'] = DateTimeFormat::utcNow();
|
||||
|
||||
$ret = self::insert($serverdata);
|
||||
$id = DBA::lastInsertId();
|
||||
$id = DBA::lastInsertId();
|
||||
} else {
|
||||
$ret = self::update($serverdata, ['nurl' => $serverdata['nurl']]);
|
||||
$ret = self::update($serverdata, ['nurl' => $serverdata['nurl']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['id'], ['nurl' => $serverdata['nurl']]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$id = $gserver['id'];
|
||||
|
@ -817,17 +819,17 @@ class GServer
|
|||
// Count the number of known contacts from this server
|
||||
if (!empty($id) && !in_array($serverdata['network'], [Protocol::PHANTOM, Protocol::FEED])) {
|
||||
$apcontacts = DBA::count('apcontact', ['gsid' => $id]);
|
||||
$contacts = DBA::count('contact', ['uid' => 0, 'gsid' => $id, 'failed' => false]);
|
||||
$max_users = max($apcontacts, $contacts);
|
||||
$contacts = DBA::count('contact', ['uid' => 0, 'gsid' => $id, 'failed' => false]);
|
||||
$max_users = max($apcontacts, $contacts);
|
||||
if ($max_users > $serverdata['registered-users']) {
|
||||
Logger::info('Update registered users', ['id' => $id, 'url' => $serverdata['nurl'], 'registered-users' => $max_users]);
|
||||
DI::logger()->info('Update registered users', ['id' => $id, 'url' => $serverdata['nurl'], 'registered-users' => $max_users]);
|
||||
self::update(['registered-users' => $max_users], ['id' => $id]);
|
||||
}
|
||||
|
||||
if (empty($serverdata['active-month-users'])) {
|
||||
$contacts = DBA::count('contact', ["`uid` = ? AND `gsid` = ? AND NOT `failed` AND `last-item` > ?", 0, $id, DateTimeFormat::utc('now - 30 days')]);
|
||||
if ($contacts > 0) {
|
||||
Logger::info('Update monthly users', ['id' => $id, 'url' => $serverdata['nurl'], 'monthly-users' => $contacts]);
|
||||
DI::logger()->info('Update monthly users', ['id' => $id, 'url' => $serverdata['nurl'], 'monthly-users' => $contacts]);
|
||||
self::update(['active-month-users' => $contacts], ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
@ -835,7 +837,7 @@ class GServer
|
|||
if (empty($serverdata['active-halfyear-users'])) {
|
||||
$contacts = DBA::count('contact', ["`uid` = ? AND `gsid` = ? AND NOT `failed` AND `last-item` > ?", 0, $id, DateTimeFormat::utc('now - 180 days')]);
|
||||
if ($contacts > 0) {
|
||||
Logger::info('Update halfyear users', ['id' => $id, 'url' => $serverdata['nurl'], 'halfyear-users' => $contacts]);
|
||||
DI::logger()->info('Update halfyear users', ['id' => $id, 'url' => $serverdata['nurl'], 'halfyear-users' => $contacts]);
|
||||
self::update(['active-halfyear-users' => $contacts], ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
@ -847,7 +849,7 @@ class GServer
|
|||
|
||||
if (!empty($systemactor)) {
|
||||
$contact = Contact::getByURL($systemactor, true, ['gsid', 'baseurl', 'id', 'network', 'url', 'name']);
|
||||
Logger::debug('Fetched system actor', ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
|
||||
DI::logger()->debug('Fetched system actor', ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
@ -864,7 +866,7 @@ class GServer
|
|||
*/
|
||||
private static function discoverRelay(string $server_url)
|
||||
{
|
||||
Logger::info('Discover relay data', ['server' => $server_url]);
|
||||
DI::logger()->info('Discover relay data', ['server' => $server_url]);
|
||||
|
||||
$curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay', HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
|
@ -880,9 +882,9 @@ class GServer
|
|||
$data['subscribe'] = (bool)($data['subscribe'] ?? false);
|
||||
|
||||
if (!$data['subscribe'] || empty($data['scope']) || !in_array(strtolower($data['scope']), ['all', 'tags'])) {
|
||||
$data['scope'] = '';
|
||||
$data['scope'] = '';
|
||||
$data['subscribe'] = false;
|
||||
$data['tags'] = [];
|
||||
$data['tags'] = [];
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'url', 'network', 'relay-subscribe', 'relay-scope'], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
|
@ -947,7 +949,7 @@ class GServer
|
|||
}
|
||||
}
|
||||
|
||||
Logger::info('Discovery ended', ['server' => $server_url, 'data' => $fields]);
|
||||
DI::logger()->info('Discovery ended', ['server' => $server_url, 'data' => $fields]);
|
||||
|
||||
Relay::updateContact($gserver, $fields);
|
||||
}
|
||||
|
@ -976,13 +978,14 @@ class GServer
|
|||
return $serverdata;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
$valid = false;
|
||||
$old_serverdata = $serverdata;
|
||||
|
||||
$serverdata['detection-method'] = self::DETECT_STATISTICS_JSON;
|
||||
|
||||
if (!empty($data['version'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['version'] = $data['version'];
|
||||
// Version numbers on statistics.json are presented with additional info, e.g.:
|
||||
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
||||
|
@ -991,11 +994,13 @@ class GServer
|
|||
|
||||
if (!empty($data['name'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['site_name'] = $data['name'];
|
||||
}
|
||||
|
||||
if (!empty($data['network'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['platform'] = strtolower($data['network']);
|
||||
|
||||
if ($serverdata['platform'] == 'diaspora') {
|
||||
|
@ -1011,21 +1016,25 @@ class GServer
|
|||
|
||||
if (!empty($data['total_users'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['registered-users'] = max($data['total_users'], 1);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_monthly'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['active-month-users'] = max($data['active_users_monthly'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_halfyear'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['local_posts'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['local-posts'] = max($data['local_posts'], 0);
|
||||
}
|
||||
|
||||
|
@ -1066,26 +1075,26 @@ class GServer
|
|||
return [];
|
||||
}
|
||||
|
||||
$nodeinfo1_url = '';
|
||||
$nodeinfo2_url = '';
|
||||
$nodeinfo1_url = '';
|
||||
$nodeinfo2_url = '';
|
||||
$detection_method = self::DETECT_MANUAL;
|
||||
|
||||
foreach ($nodeinfo['links'] as $link) {
|
||||
if (!is_array($link) || empty($link['rel']) || empty($link['href'])) {
|
||||
Logger::info('Invalid nodeinfo format', ['url' => $url]);
|
||||
DI::logger()->info('Invalid nodeinfo format', ['url' => $url]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
|
||||
$nodeinfo1_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_20) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_20;
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_21) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.1')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_21;
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_22) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.2')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_22;
|
||||
}
|
||||
}
|
||||
|
@ -1133,7 +1142,7 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => self::DETECT_NODEINFO_10,
|
||||
'register_policy' => Register::CLOSED
|
||||
'register_policy' => Register::CLOSED
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
@ -1233,8 +1242,8 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => $detection_method,
|
||||
'register_policy' => Register::CLOSED,
|
||||
'platform' => 'unknown',
|
||||
'register_policy' => Register::CLOSED,
|
||||
'platform' => 'unknown',
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
@ -1364,7 +1373,7 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => self::DETECT_NODEINFO2_10,
|
||||
'register_policy' => Register::CLOSED
|
||||
'register_policy' => Register::CLOSED
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
@ -1472,7 +1481,7 @@ class GServer
|
|||
|
||||
if (!empty($data['platform'])) {
|
||||
$serverdata['platform'] = strtolower($data['platform']);
|
||||
$serverdata['version'] = $data['version'] ?? 'N/A';
|
||||
$serverdata['version'] = $data['version'] ?? 'N/A';
|
||||
}
|
||||
|
||||
if (!empty($data['plugins'])) {
|
||||
|
@ -1548,17 +1557,17 @@ class GServer
|
|||
|
||||
$actor = JsonLD::compact($data, false);
|
||||
if (in_array(JsonLD::fetchElement($actor, '@type'), ActivityPub\Receiver::ACCOUNT_TYPES)) {
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['site_name'] = JsonLD::fetchElement($actor, 'as:name', '@value');
|
||||
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
||||
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
||||
if (self::isNomad($actor)) {
|
||||
$serverdata['platform'] = self::getNomadName($actor['@id']);
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['platform'] = self::getNomadName($actor['@id']);
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||
} elseif (!empty($actor['as:generator'])) {
|
||||
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
||||
$serverdata['platform'] = strtolower(array_shift($generator));
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
||||
$serverdata['platform'] = strtolower(array_shift($generator));
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||
} else {
|
||||
$serverdata['detection-method'] = self::DETECT_AP_ACTOR;
|
||||
|
@ -1566,8 +1575,8 @@ class GServer
|
|||
return ['server' => $serverdata, 'actor' => $actor['@id']];
|
||||
} elseif ((JsonLD::fetchElement($actor, '@type') == 'as:Collection')) {
|
||||
// By now only Ktistec seems to provide collections this way
|
||||
$serverdata['platform'] = 'ktistec';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['platform'] = 'ktistec';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['detection-method'] = self::DETECT_AP_COLLECTION;
|
||||
|
||||
$actors = JsonLD::fetchElementArray($actor, 'as:items');
|
||||
|
@ -1611,7 +1620,7 @@ class GServer
|
|||
*/
|
||||
private static function getNomadName(string $url): string
|
||||
{
|
||||
$name = 'nomad';
|
||||
$name = 'nomad';
|
||||
$curlResult = DI::httpClient()->get($url . '/manifest', 'application/manifest+json', [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBodyString() == '')) {
|
||||
if ($curlResult->getReturnCode() == 418) {
|
||||
|
@ -1730,7 +1739,7 @@ class GServer
|
|||
private static function validHostMeta(string $url): bool
|
||||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpClient()->get($url . Probe::HOST_META, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$curlResult = DI::httpClient()->get($url . Probe::HOST_META, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1829,10 +1838,9 @@ class GServer
|
|||
}
|
||||
|
||||
if (!empty($data['totalResults'])) {
|
||||
$registeredUsers = $serverdata['registered-users'] ?? 0;
|
||||
$serverdata['registered-users'] = max($data['totalResults'], $registeredUsers, 1);
|
||||
$serverdata['directory-type'] = self::DT_POCO;
|
||||
$serverdata['poco'] = $url . '/poco';
|
||||
$serverdata['registered-users'] = max($data['totalResults'], $serverdata['registered-users'] ?? 0, 1);
|
||||
$serverdata['directory-type'] = self::DT_POCO;
|
||||
$serverdata['poco'] = $url . '/poco';
|
||||
}
|
||||
|
||||
return $serverdata;
|
||||
|
@ -1887,8 +1895,8 @@ class GServer
|
|||
|
||||
if (!empty($data['instance']) && !empty($data['serverVersion'])) {
|
||||
$serverdata['platform'] = 'peertube';
|
||||
$serverdata['version'] = $data['serverVersion'];
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['version'] = $data['serverVersion'];
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
if (!empty($data['instance']['name'])) {
|
||||
$serverdata['site_name'] = $data['instance']['name'];
|
||||
|
@ -1935,7 +1943,7 @@ class GServer
|
|||
|
||||
if (!empty($data['version'])) {
|
||||
$serverdata['platform'] = 'nextcloud';
|
||||
$serverdata['version'] = $data['version'];
|
||||
$serverdata['version'] = $data['version'];
|
||||
|
||||
if ($validHostMeta) {
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
@ -2013,8 +2021,9 @@ class GServer
|
|||
|
||||
if (!empty($data['version'])) {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['version'] = $data['version'] ?? '';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['version'] = $data['version'] ?? '';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2024,7 +2033,8 @@ class GServer
|
|||
|
||||
if (!empty($data['title']) && empty($serverdata['platform']) && ($serverdata['network'] == Protocol::PHANTOM)) {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2038,19 +2048,22 @@ class GServer
|
|||
|
||||
if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
|
||||
$serverdata['platform'] = strtolower($matches[1]);
|
||||
$serverdata['version'] = $matches[2];
|
||||
$serverdata['version'] = $matches[2];
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2087,14 +2100,14 @@ class GServer
|
|||
|
||||
if (!empty($data['site']['platform'])) {
|
||||
$serverdata['platform'] = strtolower($data['site']['platform']['PLATFORM_NAME']);
|
||||
$serverdata['version'] = $data['site']['platform']['STD_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
$serverdata['version'] = $data['site']['platform']['STD_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
if (!empty($data['site']['hubzilla'])) {
|
||||
$serverdata['platform'] = strtolower($data['site']['hubzilla']['PLATFORM_NAME']);
|
||||
$serverdata['version'] = $data['site']['hubzilla']['RED_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
$serverdata['version'] = $data['site']['hubzilla']['RED_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
if (!empty($data['site']['redmatrix'])) {
|
||||
|
@ -2108,9 +2121,9 @@ class GServer
|
|||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
$private = false;
|
||||
$private = false;
|
||||
$inviteonly = false;
|
||||
$closed = false;
|
||||
$closed = false;
|
||||
|
||||
if (!empty($data['site']['closed'])) {
|
||||
$closed = self::toBoolean($data['site']['closed']);
|
||||
|
@ -2197,11 +2210,11 @@ class GServer
|
|||
|
||||
if (!empty($serverdata['version']) && strtolower(substr($serverdata['version'], 0, 7)) == 'pleroma') {
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
} else {
|
||||
$serverdata['platform'] = 'statusnet';
|
||||
$serverdata['network'] = Protocol::OSTATUS;
|
||||
$serverdata['network'] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
if (in_array($serverdata['detection-method'], self::DETECT_UNSPECIFIC)) {
|
||||
|
@ -2227,11 +2240,11 @@ class GServer
|
|||
$curlResult = DI::httpClient()->get($url . '/friendica/json', HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
$curlResult = DI::httpClient()->get($url . '/friendika/json', HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$friendika = true;
|
||||
$platform = 'Friendika';
|
||||
$friendika = true;
|
||||
$platform = 'Friendika';
|
||||
} else {
|
||||
$friendika = false;
|
||||
$platform = 'Friendica';
|
||||
$platform = 'Friendica';
|
||||
}
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
|
@ -2277,7 +2290,7 @@ class GServer
|
|||
$serverdata['register_policy'] = Register::CLOSED;
|
||||
break;
|
||||
default:
|
||||
Logger::info('Register policy is invalid', ['policy' => $register_policy, 'server' => $url]);
|
||||
DI::logger()->info('Register policy is invalid', ['policy' => $register_policy, 'server' => $url]);
|
||||
$serverdata['register_policy'] = Register::CLOSED;
|
||||
break;
|
||||
}
|
||||
|
@ -2318,12 +2331,14 @@ class GServer
|
|||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($curlResult->getBodyString());
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
$assigned = false;
|
||||
|
||||
// We can only detect honk via some HTML element on their page
|
||||
if ($xpath->query('//div[@id="honksonpage"]')->count() == 1) {
|
||||
$serverdata['platform'] = 'honk';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
|
@ -2359,9 +2374,11 @@ class GServer
|
|||
'twitter:app:name:googleplay', 'twitter:app:name:iphone', 'twitter:app:name:ipad', 'generator'])) {
|
||||
$platform = str_ireplace(array_keys($platforms), array_values($platforms), $attr['content']);
|
||||
$platform = str_replace('/', ' ', $platform);
|
||||
|
||||
$platform_parts = explode(' ', $platform);
|
||||
if ((count($platform_parts) >= 2) && in_array(strtolower($platform_parts[0]), array_values($platforms))) {
|
||||
$platform = $platform_parts[0];
|
||||
|
||||
$serverdata['version'] = $platform_parts[1];
|
||||
}
|
||||
if (in_array($platform, array_values($grouped_platforms['dfrn_platforms']))) {
|
||||
|
@ -2373,6 +2390,7 @@ class GServer
|
|||
}
|
||||
if (in_array($platform, array_values($platforms))) {
|
||||
$serverdata['platform'] = $platform;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2408,6 +2426,7 @@ class GServer
|
|||
if (in_array($attr['property'], ['og:platform', 'generator'])) {
|
||||
if (in_array($attr['content'], array_keys($platforms))) {
|
||||
$serverdata['platform'] = $platforms[$attr['content']];
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
|
@ -2423,9 +2442,10 @@ class GServer
|
|||
foreach ($list as $node) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
if (parse_url(trim($attribute->value), PHP_URL_HOST) == 'micro.blog') {
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2436,9 +2456,10 @@ class GServer
|
|||
foreach ($list as $node) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
if (trim($attribute->value) == 'https://micro.blog/micropub') {
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2464,15 +2485,15 @@ class GServer
|
|||
{
|
||||
if ($curlResult->getHeader('server') == 'Mastodon') {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
} elseif ($curlResult->inHeader('x-diaspora-version')) {
|
||||
$serverdata['platform'] = 'diaspora';
|
||||
$serverdata['network'] = Protocol::DIASPORA;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-diaspora-version')[0] ?? '';
|
||||
$serverdata['network'] = Protocol::DIASPORA;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-diaspora-version')[0] ?? '';
|
||||
} elseif ($curlResult->inHeader('x-friendica-version')) {
|
||||
$serverdata['platform'] = 'friendica';
|
||||
$serverdata['network'] = Protocol::DFRN;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-friendica-version')[0] ?? '';
|
||||
$serverdata['network'] = Protocol::DFRN;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-friendica-version')[0] ?? '';
|
||||
} else {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -2489,10 +2510,6 @@ class GServer
|
|||
*/
|
||||
public static function discover()
|
||||
{
|
||||
if (!DI::config()->get('system', 'discover_servers')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the server list
|
||||
self::discoverFederation();
|
||||
|
||||
|
@ -2502,15 +2519,18 @@ class GServer
|
|||
|
||||
$last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
|
||||
|
||||
$gservers = DBA::select('gserver', ['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
||||
$gservers = DBA::select(
|
||||
'gserver',
|
||||
['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
||||
["NOT `blocked` AND NOT `failed` AND `directory-type` != ? AND `last_poco_query` < ?", GServer::DT_NONE, $last_update],
|
||||
['order' => ['RAND()']]);
|
||||
['order' => ['RAND()']]
|
||||
);
|
||||
|
||||
while ($gserver = DBA::fetch($gservers)) {
|
||||
Logger::info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
|
||||
|
||||
Logger::info('Update directory', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
DI::logger()->info('Update directory', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
|
||||
|
||||
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
|
||||
|
@ -2542,7 +2562,7 @@ class GServer
|
|||
// Discover federated servers
|
||||
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
|
||||
foreach ($protocols as $protocol) {
|
||||
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
|
||||
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
|
||||
$curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), HttpClientAccept::JSON, 0, '', HttpClientRequest::SERVERDISCOVER);
|
||||
if (!empty($curlResult)) {
|
||||
$data = json_decode($curlResult, true);
|
||||
|
@ -2559,7 +2579,7 @@ class GServer
|
|||
$accesstoken = DI::config()->get('system', 'instances_social_key');
|
||||
|
||||
if (!empty($accesstoken)) {
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$curlResult = DI::httpClient()->get($api, HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken], HttpClientOptions::REQUEST => HttpClientRequest::SERVERDISCOVER]]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$servers = json_decode($curlResult->getBodyString(), true);
|
||||
|
@ -2651,7 +2671,7 @@ class GServer
|
|||
}
|
||||
}
|
||||
|
||||
Logger::info('Protocol for server', ['protocol' => $protocol, 'old' => $old, 'id' => $gsid, 'url' => $gserver['url']]);
|
||||
DI::logger()->info('Protocol for server', ['protocol' => $protocol, 'old' => $old, 'id' => $gsid, 'url' => $gserver['url']]);
|
||||
self::update(['protocol' => $protocol], ['id' => $gsid]);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -32,7 +31,7 @@ class ItemURI
|
|||
$itemuri = DBA::selectFirst('item-uri', ['id', 'guid'], ['uri' => $fields['uri']]);
|
||||
if (!DBA::isResult($itemuri)) {
|
||||
// This shouldn't happen
|
||||
Logger::warning('Item-uri not found', $fields);
|
||||
DI::logger()->warning('Item-uri not found', $fields);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -58,7 +57,7 @@ class Mail
|
|||
|
||||
if (DBA::exists('mail', ['uri' => $msg['uri'], 'uid' => $msg['uid']])) {
|
||||
DBA::unlock();
|
||||
Logger::info('duplicate message already delivered.');
|
||||
DI::logger()->info('duplicate message already delivered.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,7 @@ class Mail
|
|||
|
||||
DI::notify()->createFromArray($notif_params);
|
||||
|
||||
Logger::info('Mail is processed, notification was sent.', ['id' => $msg['id'], 'uri' => $msg['uri']]);
|
||||
DI::logger()->info('Mail is processed, notification was sent.', ['id' => $msg['id'], 'uri' => $msg['uri']]);
|
||||
}
|
||||
|
||||
return $msg['id'];
|
||||
|
@ -138,15 +137,15 @@ class Mail
|
|||
Photo::setPermissionFromBody($body, $sender_uid, $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
||||
|
||||
$guid = System::createUUID();
|
||||
$uri = Item::newURI($guid);
|
||||
$uri = Item::newURI($guid);
|
||||
|
||||
$convid = 0;
|
||||
$reply = false;
|
||||
$reply = false;
|
||||
|
||||
// look for any existing conversation structure
|
||||
|
||||
if (strlen($replyto)) {
|
||||
$reply = true;
|
||||
$reply = true;
|
||||
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
||||
$sender_uid, $replyto, $replyto];
|
||||
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
||||
|
@ -159,18 +158,18 @@ class Mail
|
|||
if (!$convid) {
|
||||
// create a new conversation
|
||||
$conv_guid = System::createUUID();
|
||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||
|
||||
$fields = ['uid' => $sender_uid, 'guid' => $conv_guid, 'creator' => $me['addr'],
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||
if (DBA::insert('conv', $fields)) {
|
||||
$convid = DBA::lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$convid) {
|
||||
Logger::warning('conversation not found.');
|
||||
DI::logger()->warning('conversation not found.');
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
@ -180,21 +179,21 @@ class Mail
|
|||
|
||||
$post_id = self::insert(
|
||||
[
|
||||
'uid' => $sender_uid,
|
||||
'guid' => $guid,
|
||||
'convid' => $convid,
|
||||
'from-name' => $me['name'],
|
||||
'uid' => $sender_uid,
|
||||
'guid' => $guid,
|
||||
'convid' => $convid,
|
||||
'from-name' => $me['name'],
|
||||
'from-photo' => $me['thumb'],
|
||||
'from-url' => $me['url'],
|
||||
'from-url' => $me['url'],
|
||||
'contact-id' => $recipient,
|
||||
'title' => $subject,
|
||||
'body' => $body,
|
||||
'seen' => 1,
|
||||
'reply' => $reply,
|
||||
'replied' => 0,
|
||||
'uri' => $uri,
|
||||
'title' => $subject,
|
||||
'body' => $body,
|
||||
'seen' => 1,
|
||||
'reply' => $reply,
|
||||
'replied' => 0,
|
||||
'uri' => $uri,
|
||||
'parent-uri' => $replyto,
|
||||
'created' => DateTimeFormat::utcNow()
|
||||
'created' => DateTimeFormat::utcNow()
|
||||
],
|
||||
false
|
||||
);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -583,7 +582,7 @@ class Photo
|
|||
$photo_failure = false;
|
||||
|
||||
if (!Network::isValidHttpUrl($image_url)) {
|
||||
Logger::warning('Invalid image url', ['image_url' => $image_url, 'uid' => $uid, 'cid' => $cid]);
|
||||
DI::logger()->warning('Invalid image url', ['image_url' => $image_url, 'uid' => $uid, 'cid' => $cid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -592,10 +591,10 @@ class Photo
|
|||
try {
|
||||
$ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
DI::logger()->debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
$img_str = $ret->getBodyString();
|
||||
$type = $ret->getContentType();
|
||||
} else {
|
||||
|
@ -615,24 +614,24 @@ class Photo
|
|||
$maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
|
||||
|
||||
if ($maximagesize && ($filesize > $maximagesize)) {
|
||||
Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
DI::logger()->info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
if ($image->getImageType() == IMAGETYPE_GIF) {
|
||||
$image->toStatic();
|
||||
$image = new Image($image->asString(), image_type_to_mime_type(IMAGETYPE_PNG));
|
||||
|
||||
$filesize = strlen($image->asString());
|
||||
Logger::info('Converted gif to a static png', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
DI::logger()->info('Converted gif to a static png', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
}
|
||||
if ($filesize > $maximagesize) {
|
||||
foreach ([160, 80] as $pixels) {
|
||||
if ($filesize > $maximagesize) {
|
||||
Logger::info('Resize', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'max' => $maximagesize, 'pixels' => $pixels, 'type' => $image->getType()]);
|
||||
DI::logger()->info('Resize', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'max' => $maximagesize, 'pixels' => $pixels, 'type' => $image->getType()]);
|
||||
$image->scaleDown($pixels);
|
||||
$filesize = strlen($image->asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger::info('Avatar is resized', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
DI::logger()->info('Avatar is resized', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]);
|
||||
}
|
||||
|
||||
$r = self::store($image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 4, self::CONTACT_AVATAR);
|
||||
|
@ -869,9 +868,9 @@ class Photo
|
|||
if (!self::exists($condition)) {
|
||||
$photo = self::selectFirst(['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'uid'], ['resource-id' => $image_rid]);
|
||||
if (!DBA::isResult($photo)) {
|
||||
Logger::info('Image not found', ['resource-id' => $image_rid]);
|
||||
DI::logger()->info('Image not found', ['resource-id' => $image_rid]);
|
||||
} else {
|
||||
Logger::info('Mismatching permissions', ['condition' => $condition, 'photo' => $photo]);
|
||||
DI::logger()->info('Mismatching permissions', ['condition' => $condition, 'photo' => $photo]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -910,7 +909,7 @@ class Photo
|
|||
];
|
||||
|
||||
$condition = ['resource-id' => $image_rid, 'uid' => $uid];
|
||||
Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
|
||||
DI::logger()->info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
|
||||
self::update($fields, $condition);
|
||||
}
|
||||
|
||||
|
@ -1010,7 +1009,7 @@ class Photo
|
|||
// Scale down to multiples of 640 until the maximum size isn't exceeded anymore
|
||||
foreach ([5120, 2560, 1280, 640, 320] as $pixels) {
|
||||
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
|
||||
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
|
||||
DI::logger()->info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
|
||||
$image->scaleDown($pixels);
|
||||
$filesize = strlen($image->asString());
|
||||
$width = $image->getWidth();
|
||||
|
@ -1033,7 +1032,7 @@ class Photo
|
|||
$max_length = DI::config()->get('system', 'max_image_length');
|
||||
if ($max_length > 0) {
|
||||
$image->scaleDown($max_length);
|
||||
Logger::info('File upload: Scaling picture to new size', ['max-length' => $max_length]);
|
||||
DI::logger()->info('File upload: Scaling picture to new size', ['max-length' => $max_length]);
|
||||
}
|
||||
|
||||
return self::resizeToFileSize($image, Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')));
|
||||
|
@ -1052,10 +1051,10 @@ class Photo
|
|||
try {
|
||||
$ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::MEDIAPROXY]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
DI::logger()->debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
$img_str = $ret->getBodyString();
|
||||
$type = $ret->getContentType();
|
||||
} else {
|
||||
|
@ -1064,7 +1063,7 @@ class Photo
|
|||
}
|
||||
|
||||
if (empty($img_str)) {
|
||||
Logger::notice('Empty content');
|
||||
DI::logger()->notice('Empty content');
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1086,10 +1085,10 @@ class Photo
|
|||
*/
|
||||
private static function uploadImage(array $files): array
|
||||
{
|
||||
Logger::info('starting new upload');
|
||||
DI::logger()->info('starting new upload');
|
||||
|
||||
if (empty($files)) {
|
||||
Logger::notice('Empty upload file');
|
||||
DI::logger()->notice('Empty upload file');
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1134,16 +1133,16 @@ class Photo
|
|||
}
|
||||
|
||||
if (empty($src)) {
|
||||
Logger::notice('No source file name', ['files' => $files]);
|
||||
DI::logger()->notice('No source file name', ['files' => $files]);
|
||||
return [];
|
||||
}
|
||||
|
||||
Logger::info('File upload', ['src' => $src, 'filename' => $filename, 'size' => $filesize, 'type' => $filetype]);
|
||||
DI::logger()->info('File upload', ['src' => $src, 'filename' => $filename, 'size' => $filesize, 'type' => $filetype]);
|
||||
|
||||
$imagedata = @file_get_contents($src);
|
||||
$image = new Image($imagedata, $filetype, $filename);
|
||||
if (!$image->isValid()) {
|
||||
Logger::notice('Image is unvalid', ['files' => $files]);
|
||||
DI::logger()->notice('Image is unvalid', ['files' => $files]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1177,13 +1176,13 @@ class Photo
|
|||
{
|
||||
$user = User::getOwnerDataById($uid);
|
||||
if (empty($user)) {
|
||||
Logger::notice('User not found', ['uid' => $uid]);
|
||||
DI::logger()->notice('User not found', ['uid' => $uid]);
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = self::uploadImage($files);
|
||||
if (empty($data)) {
|
||||
Logger::info('upload failed');
|
||||
DI::logger()->info('upload failed');
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1201,14 +1200,14 @@ class Photo
|
|||
|
||||
$preview = self::storeWithPreview($image, $user['uid'], $resource_id, $filename, $filesize, $album, $desc, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
||||
if ($preview < 0) {
|
||||
Logger::warning('Photo could not be stored', ['uid' => $user['uid'], 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
DI::logger()->warning('Photo could not be stored', ['uid' => $user['uid'], 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
return [];
|
||||
}
|
||||
|
||||
$condition = ['resource-id' => $resource_id];
|
||||
$photo = self::selectFirst(['id', 'datasize', 'width', 'height', 'type'], $condition, ['order' => ['width' => true]]);
|
||||
if (empty($photo)) {
|
||||
Logger::notice('Photo not found', ['condition' => $condition]);
|
||||
DI::logger()->notice('Photo not found', ['condition' => $condition]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1224,7 +1223,7 @@ class Photo
|
|||
$picture['picture'] = DI::baseUrl() . '/photo/' . $resource_id . '-0.' . $image->getExt();
|
||||
$picture['preview'] = DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview . '.' . $image->getExt();
|
||||
|
||||
Logger::info('upload done', ['picture' => $picture]);
|
||||
DI::logger()->info('upload done', ['picture' => $picture]);
|
||||
return $picture;
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1255,7 @@ class Photo
|
|||
|
||||
$result = self::store($image, $uid, 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $description);
|
||||
if (!$result) {
|
||||
Logger::warning('Photo could not be stored', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
DI::logger()->warning('Photo could not be stored', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1291,17 +1290,17 @@ class Photo
|
|||
if (!empty($files)) {
|
||||
$data = self::uploadImage($files);
|
||||
if (empty($data)) {
|
||||
Logger::info('upload failed');
|
||||
DI::logger()->info('upload failed');
|
||||
return '';
|
||||
}
|
||||
} elseif (!empty($url)) {
|
||||
$data = self::loadImageFromURL($url);
|
||||
if (empty($data)) {
|
||||
Logger::info('loading from external url failed');
|
||||
DI::logger()->info('loading from external url failed');
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
Logger::info('Neither files nor url provided');
|
||||
DI::logger()->info('Neither files nor url provided');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1314,7 +1313,7 @@ class Photo
|
|||
$album = DI::l10n()->t(self::PROFILE_PHOTOS);
|
||||
|
||||
// upload profile image (scales 4, 5, 6)
|
||||
logger::info('starting new profile image upload');
|
||||
DI::logger()->info('starting new profile image upload');
|
||||
|
||||
if ($width > 300 || $height > 300) {
|
||||
$image->scaleDown(300);
|
||||
|
@ -1322,7 +1321,7 @@ class Photo
|
|||
|
||||
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR);
|
||||
if (!$r) {
|
||||
logger::warning('profile image upload with scale 4 (300) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
DI::logger()->warning('profile image upload with scale 4 (300) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
}
|
||||
|
||||
if ($width > 80 || $height > 80) {
|
||||
|
@ -1331,7 +1330,7 @@ class Photo
|
|||
|
||||
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR);
|
||||
if (!$r) {
|
||||
logger::warning('profile image upload with scale 5 (80) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
DI::logger()->warning('profile image upload with scale 5 (80) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
}
|
||||
|
||||
if ($width > 48 || $height > 48) {
|
||||
|
@ -1340,10 +1339,10 @@ class Photo
|
|||
|
||||
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR);
|
||||
if (!$r) {
|
||||
logger::warning('profile image upload with scale 6 (48) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
DI::logger()->warning('profile image upload with scale 6 (48) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
|
||||
}
|
||||
|
||||
logger::info('new profile image upload ended');
|
||||
DI::logger()->info('new profile image upload ended');
|
||||
|
||||
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $resource_id, $uid];
|
||||
self::update(['profile' => false, 'photo-type' => self::DEFAULT], $condition);
|
||||
|
@ -1369,17 +1368,17 @@ class Photo
|
|||
if (!empty($files)) {
|
||||
$data = self::uploadImage($files);
|
||||
if (empty($data)) {
|
||||
Logger::info('upload failed');
|
||||
DI::logger()->info('upload failed');
|
||||
return '';
|
||||
}
|
||||
} elseif (!empty($url)) {
|
||||
$data = self::loadImageFromURL($url);
|
||||
if (empty($data)) {
|
||||
Logger::info('loading from external url failed');
|
||||
DI::logger()->info('loading from external url failed');
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
Logger::info('Neither files nor url provided');
|
||||
DI::logger()->info('Neither files nor url provided');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1397,10 +1396,10 @@ class Photo
|
|||
|
||||
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 3, self::USER_BANNER);
|
||||
if (!$r) {
|
||||
logger::warning('profile banner upload with scale 3 (960) failed');
|
||||
DI::logger()->warning('profile banner upload with scale 3 (960) failed');
|
||||
}
|
||||
|
||||
logger::info('new profile banner upload ended', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename]);
|
||||
DI::logger()->info('new profile banner upload ended', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename]);
|
||||
|
||||
$condition = ["`photo-type` = ? AND `resource-id` != ? AND `uid` = ?", self::USER_BANNER, $resource_id, $uid];
|
||||
self::update(['photo-type' => self::DEFAULT], $condition);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -213,7 +212,7 @@ class Post
|
|||
public static function selectOriginal(array $fields = [], array $condition = [], array $params = [])
|
||||
{
|
||||
$original_fields = $fields;
|
||||
$remove = [];
|
||||
$remove = [];
|
||||
if (!empty($fields)) {
|
||||
foreach (['gravity', 'verb', 'thr-parent-id', 'uid'] as $field) {
|
||||
if (!in_array($field, $fields)) {
|
||||
|
@ -448,7 +447,8 @@ class Post
|
|||
$selected = Item::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`visible` AND NOT `deleted`
|
||||
AND NOT `author-blocked` AND NOT `owner-blocked`
|
||||
AND (NOT `causer-blocked` OR `causer-id` = ? OR `causer-id` IS NULL) AND NOT `contact-blocked`
|
||||
|
@ -457,7 +457,8 @@ class Post
|
|||
AND NOT EXISTS(SELECT `uri-id` FROM `post-user` WHERE `uid` = ? AND `uri-id` = " . DBA::quoteIdentifier($view) . ".`uri-id` AND `hidden`)
|
||||
AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` IN (`author-id`, `owner-id`) AND (`blocked` OR `ignored` OR `is-blocked`))
|
||||
AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = ? AND `gsid` IN (`author-gsid`, `owner-gsid`, `causer-gsid`) AND `ignored`)",
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid]);
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid]
|
||||
);
|
||||
|
||||
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
|
||||
|
||||
|
@ -582,7 +583,7 @@ class Post
|
|||
public static function selectOriginalForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
|
||||
{
|
||||
$original_selected = $selected;
|
||||
$remove = [];
|
||||
$remove = [];
|
||||
if (!empty($selected)) {
|
||||
foreach (['gravity', 'verb', 'thr-parent-id'] as $field) {
|
||||
if (!in_array($field, $selected)) {
|
||||
|
@ -621,7 +622,7 @@ class Post
|
|||
{
|
||||
$affected = 0;
|
||||
|
||||
Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
DI::logger()->info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
|
||||
// Don't allow changes to fields that are responsible for the relation between the records
|
||||
unset($fields['id']);
|
||||
|
@ -647,7 +648,7 @@ class Post
|
|||
$puids = array_column($rows, 'post-user-id');
|
||||
if (!DBA::update('post-user', $update_fields, ['id' => $puids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -664,7 +665,7 @@ class Post
|
|||
$uriids = array_column($rows, 'uri-id');
|
||||
if (!DBA::update('post-content', $update_fields, ['uri-id' => $uriids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post-content failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -687,7 +688,7 @@ class Post
|
|||
|
||||
if (!DBA::update('post', $update_fields, ['uri-id' => $uriids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -704,7 +705,7 @@ class Post
|
|||
$uriids = array_column($rows, 'uri-id');
|
||||
if (!DBA::update('post-delivery-data', $update_fields, ['uri-id' => $uriids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post-delivery-data failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -721,7 +722,7 @@ class Post
|
|||
$uriids = array_column($rows, 'uri-id');
|
||||
if (!DBA::update('post-thread', $update_fields, ['uri-id' => $uriids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -738,7 +739,7 @@ class Post
|
|||
$thread_puids = array_column($rows, 'post-user-id');
|
||||
if (!DBA::update('post-thread-user', $update_fields, ['post-user-id' => $thread_puids])) {
|
||||
DBA::rollback();
|
||||
Logger::warning('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
DI::logger()->warning('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]);
|
||||
return false;
|
||||
}
|
||||
$affected_count += DBA::affectedRows();
|
||||
|
@ -749,7 +750,7 @@ class Post
|
|||
|
||||
DBA::commit();
|
||||
|
||||
Logger::info('Updated posts', ['rows' => $affected]);
|
||||
DI::logger()->info('Updated posts', ['rows' => $affected]);
|
||||
return $affected;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Model\Post;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -45,7 +44,7 @@ class Delayed
|
|||
public static function add(string $uri, array $item, int $notify = 0, int $preparation_mode = self::PREPARED, string $delayed = '', array $taglist = [], array $attachments = [])
|
||||
{
|
||||
if (empty($item['uid']) || self::exists($uri, $item['uid'])) {
|
||||
Logger::notice('No uid or already found');
|
||||
DI::logger()->notice('No uid or already found');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,11 +53,11 @@ class Delayed
|
|||
|
||||
$last_publish = DI::pConfig()->get($item['uid'], 'system', 'last_publish', 0, true);
|
||||
$next_publish = max($last_publish + (60 * $min_posting), time());
|
||||
$delayed = date(DateTimeFormat::MYSQL, $next_publish);
|
||||
$delayed = date(DateTimeFormat::MYSQL, $next_publish);
|
||||
DI::pConfig()->set($item['uid'], 'system', 'last_publish', $next_publish);
|
||||
}
|
||||
|
||||
Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
|
||||
DI::logger()->notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
|
||||
|
||||
$wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
|
||||
if (!$wid) {
|
||||
|
@ -152,13 +151,13 @@ class Delayed
|
|||
}
|
||||
|
||||
return [
|
||||
'parameters' => $delayed,
|
||||
'item' => $parameters[0],
|
||||
'notify' => $parameters[1],
|
||||
'taglist' => $parameters[2],
|
||||
'parameters' => $delayed,
|
||||
'item' => $parameters[0],
|
||||
'notify' => $parameters[1],
|
||||
'taglist' => $parameters[2],
|
||||
'attachments' => $parameters[3],
|
||||
'unprepared' => $parameters[4],
|
||||
'uri' => $parameters[5],
|
||||
'unprepared' => $parameters[4],
|
||||
'uri' => $parameters[5],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -181,7 +180,7 @@ class Delayed
|
|||
|
||||
$id = Item::insert($item, $notify, $preparation_mode == self::PREPARED);
|
||||
|
||||
Logger::notice('Post stored', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id'] ?? 'N/A']);
|
||||
DI::logger()->notice('Post stored', ['id' => $id, 'uid' => $item['uid'], 'cid' => $item['contact-id'] ?? 'N/A']);
|
||||
|
||||
if (empty($uri) && !empty($item['uri'])) {
|
||||
$uri = $item['uri'];
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Model\Post;
|
|||
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -28,16 +27,16 @@ class Engagement
|
|||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language', 'media'];
|
||||
const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application'];
|
||||
const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application',
|
||||
'media:picture' => 'media:image', 'media:photo' => 'media:image',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||
'network:diaspora' => 'network:dspr', 'network:discourse' => 'network:dscs',
|
||||
'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||
const MEDIA_NONE = 0;
|
||||
'media:picture' => 'media:image', 'media:photo' => 'media:image',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||
'network:diaspora' => 'network:dspr', 'network:discourse' => 'network:dscs',
|
||||
'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||
const MEDIA_NONE = 0;
|
||||
const MEDIA_IMAGE = 1;
|
||||
const MEDIA_VIDEO = 2;
|
||||
const MEDIA_AUDIO = 4;
|
||||
const MEDIA_CARD = 8;
|
||||
const MEDIA_POST = 16;
|
||||
const MEDIA_CARD = 8;
|
||||
const MEDIA_POST = 16;
|
||||
|
||||
/**
|
||||
* Store engagement data from an item array
|
||||
|
@ -48,18 +47,20 @@ class Engagement
|
|||
public static function storeFromItem(array $item): int
|
||||
{
|
||||
if (in_array($item['verb'], [Activity::FOLLOW, Activity::VIEW, Activity::READ])) {
|
||||
Logger::debug('Technical activities are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'verb' => $item['verb']]);
|
||||
DI::logger()->debug('Technical activities are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'verb' => $item['verb']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['uri-id', 'created', 'uid', 'private', 'quote-uri-id',
|
||||
'contact-contact-type', 'network', 'title', 'content-warning', 'body', 'language',
|
||||
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
||||
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
||||
['uri-id' => $item['parent-uri-id']]);
|
||||
$parent = Post::selectFirst(
|
||||
['uri-id', 'created', 'uid', 'private', 'quote-uri-id',
|
||||
'contact-contact-type', 'network', 'title', 'content-warning', 'body', 'language',
|
||||
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
||||
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
||||
['uri-id' => $item['parent-uri-id']]
|
||||
);
|
||||
|
||||
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
||||
Logger::debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
||||
DI::logger()->debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -114,16 +115,16 @@ class Engagement
|
|||
])
|
||||
];
|
||||
if (!$store && ($engagement['comments'] == 0) && ($engagement['activities'] == 0)) {
|
||||
Logger::debug('No media, follower, subscribed tags, comments or activities. Engagement not stored', ['fields' => $engagement]);
|
||||
DI::logger()->debug('No media, follower, subscribed tags, comments or activities. Engagement not stored', ['fields' => $engagement]);
|
||||
return 0;
|
||||
}
|
||||
$exists = DBA::exists('post-engagement', ['uri-id' => $engagement['uri-id']]);
|
||||
if ($exists) {
|
||||
$ret = DBA::update('post-engagement', $engagement, ['uri-id' => $engagement['uri-id']]);
|
||||
Logger::debug('Engagement updated', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]);
|
||||
DI::logger()->debug('Engagement updated', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]);
|
||||
} else {
|
||||
$ret = DBA::insert('post-engagement', $engagement);
|
||||
Logger::debug('Engagement inserted', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]);
|
||||
DI::logger()->debug('Engagement inserted', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]);
|
||||
}
|
||||
return ($ret && !$exists) ? $engagement['uri-id'] : 0;
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ class Engagement
|
|||
$body = BBCode::removeSharedData($body);
|
||||
$body = preg_replace('/[^@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $body);
|
||||
$body = BBCode::removeLinks($body);
|
||||
$msg = BBCode::toPlaintext($body, false);
|
||||
$msg = BBCode::toPlaintext($body, false);
|
||||
|
||||
return mb_strlen($msg);
|
||||
}
|
||||
|
@ -204,7 +205,7 @@ class Engagement
|
|||
$body = '[nosmile]network_' . $item['network'];
|
||||
|
||||
if (!empty($item['author-gsid'])) {
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['author-gsid']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['author-gsid']]);
|
||||
$platform = preg_replace('/[\W]/', '', $gserver['platform'] ?? '');
|
||||
if (!empty($platform)) {
|
||||
$body .= ' platform_' . $platform;
|
||||
|
@ -213,7 +214,7 @@ class Engagement
|
|||
}
|
||||
|
||||
if (($item['owner-contact-type'] == Contact::TYPE_COMMUNITY) && !empty($item['owner-gsid']) && ($item['owner-gsid'] != ($item['author-gsid'] ?? 0))) {
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['owner-gsid']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['owner-gsid']]);
|
||||
$platform = preg_replace('/[\W]/', '', $gserver['platform'] ?? '');
|
||||
if (!empty($platform) && !strpos($body, 'platform_' . $platform)) {
|
||||
$body .= ' platform_' . $platform;
|
||||
|
@ -253,7 +254,7 @@ class Engagement
|
|||
$body .= ' from_' . $item['author-nick'] . ' from_' . $item['author-addr'];
|
||||
}
|
||||
|
||||
if ($item['author-id'] != $item['owner-id']) {
|
||||
if ($item['author-id'] != $item['owner-id']) {
|
||||
if ($item['owner-contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$body .= ' group_' . $item['owner-nick'] . ' group_' . $item['owner-addr'];
|
||||
} elseif (in_array($item['owner-contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
|
||||
|
@ -315,8 +316,10 @@ class Engagement
|
|||
|
||||
private static function addResharers(string $text, int $uri_id): string
|
||||
{
|
||||
$result = Post::selectPosts(['author-addr', 'author-nick', 'author-contact-type'],
|
||||
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]);
|
||||
$result = Post::selectPosts(
|
||||
['author-addr', 'author-nick', 'author-contact-type'],
|
||||
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]
|
||||
);
|
||||
while ($reshare = Post::fetch($result)) {
|
||||
$prefix = '';
|
||||
|
||||
|
@ -369,11 +372,11 @@ class Engagement
|
|||
{
|
||||
$limit = self::getCreationDateLimit(true);
|
||||
if (empty($limit)) {
|
||||
Logger::notice('Expiration limit not reached');
|
||||
DI::logger()->notice('Expiration limit not reached');
|
||||
return;
|
||||
}
|
||||
DBA::delete('post-engagement', ["`created` < ?", $limit]);
|
||||
Logger::notice('Cleared expired engagements', ['limit' => $limit, 'rows' => DBA::affectedRows()]);
|
||||
DI::logger()->notice('Cleared expired engagements', ['limit' => $limit, 'rows' => DBA::affectedRows()]);
|
||||
}
|
||||
|
||||
private static function getCreationDateLimit(bool $forDeletion): string
|
||||
|
@ -393,11 +396,11 @@ class Engagement
|
|||
|
||||
public static function escapeKeywords(string $fullTextSearch): string
|
||||
{
|
||||
foreach (SELF::SHORTCUTS as $search => $replace) {
|
||||
foreach (self::SHORTCUTS as $search => $replace) {
|
||||
$fullTextSearch = preg_replace('~' . $search . ':(.[\w\*@\.-]+)~', $replace . ':$1', $fullTextSearch);
|
||||
}
|
||||
|
||||
foreach (SELF::ALTERNATIVES as $search => $replace) {
|
||||
foreach (self::ALTERNATIVES as $search => $replace) {
|
||||
$fullTextSearch = str_replace($search, $replace, $fullTextSearch);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Model\Post;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
|
@ -28,12 +27,12 @@ class History
|
|||
|
||||
$post = Post::selectFirstPost($fields, ['uri-id' => $uri_id]);
|
||||
if (empty($post)) {
|
||||
Logger::warning('Post not found', ['uri-id' => $uri_id]);
|
||||
DI::logger()->warning('Post not found', ['uri-id' => $uri_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item['edited'] <= $post['edited']) {
|
||||
Logger::info('New edit date is not newer than the old one', ['uri-id' => $uri_id, 'old' => $post['edited'], 'new' => $item['edited']]);
|
||||
DI::logger()->info('New edit date is not newer than the old one', ['uri-id' => $uri_id, 'old' => $post['edited'], 'new' => $item['edited']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,9 +48,9 @@ class History
|
|||
|
||||
if ($update) {
|
||||
DBA::insert('post-history', $post, Database::INSERT_IGNORE);
|
||||
Logger::info('Added history', ['uri-id' => $uri_id, 'edited' => $post['edited']]);
|
||||
DI::logger()->info('Added history', ['uri-id' => $uri_id, 'edited' => $post['edited']]);
|
||||
} else {
|
||||
Logger::info('No content fields had been changed', ['uri-id' => $uri_id, 'edited' => $post['edited']]);
|
||||
DI::logger()->info('No content fields had been changed', ['uri-id' => $uri_id, 'edited' => $post['edited']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Model\Post;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -53,22 +52,22 @@ class Link
|
|||
}
|
||||
|
||||
if (!in_array(parse_url($url, PHP_URL_SCHEME), ['http', 'https'])) {
|
||||
Logger::info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]);
|
||||
DI::logger()->info('Bad URL, quitting', ['uri-id' => $uriId, 'url' => $url]);
|
||||
return $url;
|
||||
}
|
||||
|
||||
$link = DBA::selectFirst('post-link', ['id'], ['uri-id' => $uriId, 'url' => $url]);
|
||||
if (!empty($link['id'])) {
|
||||
$id = $link['id'];
|
||||
Logger::info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]);
|
||||
DI::logger()->info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]);
|
||||
} else {
|
||||
$fields = self::fetchMimeType($url);
|
||||
$fields = self::fetchMimeType($url);
|
||||
$fields['uri-id'] = $uriId;
|
||||
$fields['url'] = Network::sanitizeUrl($url);
|
||||
$fields['url'] = Network::sanitizeUrl($url);
|
||||
|
||||
DBA::insert('post-link', $fields, Database::INSERT_IGNORE);
|
||||
$id = DBA::lastInsertId();
|
||||
Logger::info('Inserted', $fields);
|
||||
DI::logger()->info('Inserted', $fields);
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
|
@ -114,12 +113,12 @@ class Link
|
|||
try {
|
||||
$curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
|
||||
DI::logger()->notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
Logger::notice('Fetching unsuccessful', ['url' => $url]);
|
||||
DI::logger()->notice('Fetching unsuccessful', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -127,7 +126,7 @@ class Link
|
|||
|
||||
if (Images::isSupportedMimeType($fields['mimetype'])) {
|
||||
$img_str = $curlResult->getBodyString();
|
||||
$image = new Image($img_str, $fields['mimetype'], $url, false);
|
||||
$image = new Image($img_str, $fields['mimetype'], $url, false);
|
||||
if ($image->isValid()) {
|
||||
$fields['mimetype'] = $image->getType();
|
||||
$fields['width'] = $image->getWidth();
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Model\Post;
|
|||
|
||||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -67,12 +66,12 @@ class Media
|
|||
public static function insert(array $media, bool $force = false): bool
|
||||
{
|
||||
if (empty($media['url']) || empty($media['uri-id']) || !isset($media['type'])) {
|
||||
Logger::warning('Incomplete media data', ['media' => $media]);
|
||||
DI::logger()->warning('Incomplete media data', ['media' => $media]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DBA::exists('post-media', ['uri-id' => $media['uri-id'], 'preview' => $media['url']])) {
|
||||
Logger::info('Media already exists as preview', ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
DI::logger()->info('Media already exists as preview', ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -80,12 +79,12 @@ class Media
|
|||
// and embedded as picture then we only store the picture or replace the document
|
||||
$found = DBA::selectFirst('post-media', ['type'], ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
if (!$force && !empty($found) && (!in_array($found['type'], [self::UNKNOWN, self::DOCUMENT]) || ($media['type'] == self::DOCUMENT))) {
|
||||
Logger::info('Media already exists', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'found' => $found['type'], 'new' => $media['type']]);
|
||||
DI::logger()->info('Media already exists', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'found' => $found['type'], 'new' => $media['type']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ItemURI::exists($media['uri-id'])) {
|
||||
Logger::info('Media referenced URI ID not found', ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
DI::logger()->info('Media referenced URI ID not found', ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ class Media
|
|||
// We are storing as fast as possible to avoid duplicated network requests
|
||||
// when fetching additional information for pictures and other content.
|
||||
$result = DBA::insert('post-media', $media, Database::INSERT_UPDATE);
|
||||
Logger::info('Stored media', ['result' => $result, 'media' => $media]);
|
||||
DI::logger()->info('Stored media', ['result' => $result, 'media' => $media]);
|
||||
$stored = $media;
|
||||
|
||||
$media = self::fetchAdditionalData($media);
|
||||
|
@ -106,9 +105,9 @@ class Media
|
|||
|
||||
if (array_diff_assoc($media, $stored)) {
|
||||
$result = DBA::insert('post-media', $media, Database::INSERT_UPDATE);
|
||||
Logger::info('Updated media', ['result' => $result, 'media' => $media]);
|
||||
DI::logger()->info('Updated media', ['result' => $result, 'media' => $media]);
|
||||
} else {
|
||||
Logger::info('Nothing to update', ['media' => $media]);
|
||||
DI::logger()->info('Nothing to update', ['media' => $media]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ class Media
|
|||
return $media;
|
||||
}
|
||||
if (empty($media['mimetype']) || empty($media['size'])) {
|
||||
Logger::debug('Unknown local link', ['url' => $media['url']]);
|
||||
DI::logger()->debug('Unknown local link', ['url' => $media['url']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,10 +204,10 @@ class Media
|
|||
$media['size'] = (int)($curlResult->getHeader('Content-Length')[0] ?? strlen($curlResult->getBodyString() ?? ''));
|
||||
}
|
||||
} else {
|
||||
Logger::notice('Could not fetch head', ['media' => $media, 'code' => $curlResult->getReturnCode()]);
|
||||
DI::logger()->notice('Could not fetch head', ['media' => $media, 'code' => $curlResult->getReturnCode()]);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +215,7 @@ class Media
|
|||
$media = self::addType($media);
|
||||
}
|
||||
|
||||
Logger::debug('Got type for url', ['type' => $media['type'], 'mimetype' => $media['mimetype'] ?? '', 'url' => $media['url']]);
|
||||
DI::logger()->debug('Got type for url', ['type' => $media['type'], 'mimetype' => $media['mimetype'] ?? '', 'url' => $media['url']]);
|
||||
|
||||
if ($media['type'] == self::IMAGE) {
|
||||
$imagedata = Images::getInfoFromURLCached($media['url'], empty($media['description']));
|
||||
|
@ -228,10 +227,10 @@ class Media
|
|||
$media['blurhash'] = $imagedata['blurhash'] ?? null;
|
||||
if (!empty($imagedata['description']) && empty($media['description'])) {
|
||||
$media['description'] = $imagedata['description'];
|
||||
Logger::debug('Detected text for image', $media);
|
||||
DI::logger()->debug('Detected text for image', $media);
|
||||
}
|
||||
} else {
|
||||
Logger::notice('No image data', ['media' => $media]);
|
||||
DI::logger()->notice('No image data', ['media' => $media]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,13 +308,13 @@ class Media
|
|||
|
||||
$item = Post::selectFirst([], ['id' => $id, 'network' => Protocol::FEDERATED]);
|
||||
if (empty($item['id'])) {
|
||||
Logger::debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
DI::logger()->debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
||||
$media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type'];
|
||||
return $media;
|
||||
}
|
||||
|
||||
if ($item['uri-id'] == $media['uri-id']) {
|
||||
Logger::info('Media-Uri-Id is identical to Uri-Id', ['uri-id' => $media['uri-id']]);
|
||||
DI::logger()->info('Media-Uri-Id is identical to Uri-Id', ['uri-id' => $media['uri-id']]);
|
||||
$media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type'];
|
||||
return $media;
|
||||
}
|
||||
|
@ -324,7 +323,7 @@ class Media
|
|||
!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
|
||||
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)
|
||||
) {
|
||||
Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||
DI::logger()->debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||
$media['type'] = $media['type'] == self::ACTIVITY ? self::JSON : $media['type'];
|
||||
return $media;
|
||||
}
|
||||
|
@ -357,7 +356,7 @@ class Media
|
|||
$media['publisher-name'] = $gserver['site_name'] ?? null;
|
||||
$media['publisher-image'] = null;
|
||||
|
||||
Logger::debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||
DI::logger()->debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
|
||||
return $media;
|
||||
}
|
||||
|
||||
|
@ -399,7 +398,7 @@ class Media
|
|||
$media['publisher-name'] = $gserver['site_name'] ?? null;
|
||||
$media['publisher-image'] = null;
|
||||
|
||||
Logger::debug('Account detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'uri' => $contact['url']]);
|
||||
DI::logger()->debug('Account detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'uri' => $contact['url']]);
|
||||
return $media;
|
||||
}
|
||||
|
||||
|
@ -415,7 +414,7 @@ class Media
|
|||
if (empty($data['images'][0]['src']) && empty($data['text']) && empty($data['title'])) {
|
||||
if (!empty($media['preview'])) {
|
||||
$media = self::addPreviewData($media);
|
||||
Logger::debug('Detected site data is empty, use suggested media data instead', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'type' => $data['type']]);
|
||||
DI::logger()->debug('Detected site data is empty, use suggested media data instead', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'type' => $data['type']]);
|
||||
}
|
||||
} else {
|
||||
$media['preview'] = $data['images'][0]['src'] ?? null;
|
||||
|
@ -489,7 +488,7 @@ class Media
|
|||
public static function addType(array $data): array
|
||||
{
|
||||
if (empty($data['mimetype'])) {
|
||||
Logger::info('No MimeType provided', ['media' => $data]);
|
||||
DI::logger()->info('No MimeType provided', ['media' => $data]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -501,7 +500,7 @@ class Media
|
|||
{
|
||||
$type = explode('/', current(explode(';', $mimeType)));
|
||||
if (count($type) < 2) {
|
||||
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $mimeType]);
|
||||
DI::logger()->info('Unknown MimeType', ['type' => $type, 'media' => $mimeType]);
|
||||
return self::UNKNOWN;
|
||||
}
|
||||
|
||||
|
@ -536,10 +535,10 @@ class Media
|
|||
$type = self::APPLICATION;
|
||||
} else {
|
||||
$type = self::UNKNOWN;
|
||||
Logger::info('Unknown type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
DI::logger()->info('Unknown type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
}
|
||||
|
||||
Logger::debug('Detected type', ['type' => $type, 'filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
DI::logger()->debug('Detected type', ['type' => $type, 'filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
@ -777,15 +776,15 @@ class Media
|
|||
// Search for pure links
|
||||
if (preg_match_all("/\[url\](https?:.*?)\[\/url\]/ism", $body, $matches)) {
|
||||
foreach ($matches[1] as $url) {
|
||||
Logger::info('Got page url (link without description)', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->info('Got page url (link without description)', ['uri-id' => $uriid, 'url' => $url]);
|
||||
$result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);
|
||||
if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) {
|
||||
self::revertHTMLType($uriid, $url, $fullbody);
|
||||
Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);
|
||||
} elseif ($result) {
|
||||
Logger::debug('Media had been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Media had been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
} else {
|
||||
Logger::debug('Media had not been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Media had not been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -793,15 +792,15 @@ class Media
|
|||
// Search for links with descriptions
|
||||
if (preg_match_all("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches)) {
|
||||
foreach ($matches[1] as $url) {
|
||||
Logger::info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]);
|
||||
$result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);
|
||||
if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) {
|
||||
self::revertHTMLType($uriid, $url, $fullbody);
|
||||
Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);
|
||||
} elseif ($result) {
|
||||
Logger::debug('Media has been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Media has been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
} else {
|
||||
Logger::debug('Media has not been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
DI::logger()->debug('Media has not been added', ['uri-id' => $uriid, 'url' => $url]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -838,7 +837,7 @@ class Media
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::info('Adding attachment data', ['data' => $data]);
|
||||
DI::logger()->info('Adding attachment data', ['data' => $data]);
|
||||
$attachment = [
|
||||
'uri-id' => $uriid,
|
||||
'type' => self::HTML,
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Model\Post;
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -74,7 +73,7 @@ class SearchIndex
|
|||
return;
|
||||
}
|
||||
DBA::delete('post-searchindex', ["`created` < ?", $limit]);
|
||||
Logger::notice('Cleared expired searchindex entries', ['limit' => $limit, 'rows' => DBA::affectedRows()]);
|
||||
DI::logger()->notice('Cleared expired searchindex entries', ['limit' => $limit, 'rows' => DBA::affectedRows()]);
|
||||
}
|
||||
|
||||
public static function searchAgeDateLimit(): string
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Friendica\Model\Post;
|
|||
use BadMethodCallException;
|
||||
use Exception;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -119,7 +118,7 @@ class UserNotification
|
|||
$fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity', 'vid', 'gravity',
|
||||
'contact-id', 'author-id', 'author-gsid', 'owner-id', 'owner-gsid', 'causer-id', 'causer-gsid',
|
||||
'private', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'verb'];
|
||||
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
|
||||
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
}
|
||||
|
@ -174,14 +173,14 @@ class UserNotification
|
|||
continue;
|
||||
}
|
||||
if (Contact\User::isBlocked($author_id, $uid) || Contact\User::isIgnored($author_id, $uid) || Contact\User::isCollapsed($author_id, $uid)) {
|
||||
Logger::debug('Author is blocked/ignored/collapsed by user', ['uid' => $uid, 'author' => $author_id, 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->debug('Author is blocked/ignored/collapsed by user', ['uid' => $uid, 'author' => $author_id, 'uri-id' => $item['uri-id']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_unique([$parent['author-gsid'], $parent['owner-gsid'], $parent['causer-gsid'], $item['author-gsid'], $item['owner-gsid'], $item['causer-gsid']]) as $gsid) {
|
||||
if ($gsid && DI::userGServer()->isIgnoredByUser($uid, $gsid)) {
|
||||
Logger::debug('Server is ignored by user', ['uid' => $uid, 'gsid' => $gsid, 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->debug('Server is ignored by user', ['uid' => $uid, 'gsid' => $gsid, 'uri-id' => $item['uri-id']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +312,7 @@ class UserNotification
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::info('Set notification', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]);
|
||||
DI::logger()->info('Set notification', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'notification-type' => $notification_type]);
|
||||
|
||||
$fields = ['notification-type' => $notification_type];
|
||||
Post\User::update($item['uri-id'], $uid, $fields);
|
||||
|
|
|
@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Content\Widget\ContactBlock;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
|
@ -202,7 +201,7 @@ class Profile
|
|||
{
|
||||
$profile = User::getOwnerDataByNick($nickname);
|
||||
if (!isset($profile['account_removed']) || $profile['account_removed']) {
|
||||
Logger::info('profile error: ' . DI::args()->getQueryString());
|
||||
DI::logger()->info('profile error: ' . DI::args()->getQueryString());
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -267,7 +266,7 @@ class Profile
|
|||
*/
|
||||
public static function getVCardHtml(array $profile, bool $block, bool $show_contacts): string
|
||||
{
|
||||
$o = '';
|
||||
$o = '';
|
||||
$location = false;
|
||||
|
||||
$profile_contact = [];
|
||||
|
@ -294,8 +293,8 @@ class Profile
|
|||
|
||||
$cid = $contact['id'];
|
||||
|
||||
$follow_link = null;
|
||||
$unfollow_link = null;
|
||||
$follow_link = null;
|
||||
$unfollow_link = null;
|
||||
$wallmessage_link = null;
|
||||
|
||||
// Who is the logged-in user to this profile?
|
||||
|
@ -304,13 +303,11 @@ class Profile
|
|||
$visitor_contact = Contact::selectFirst(['rel'], ['uid' => $profile['uid'], 'nurl' => Strings::normaliseLink(DI::userSession()->getMyUrl())]);
|
||||
}
|
||||
|
||||
$local_user_is_self = DI::userSession()->getMyUrl() && ($profile['url'] == DI::userSession()->getMyUrl());
|
||||
$local_user_is_self = DI::userSession()->getMyUrl() && ($profile['url'] == DI::userSession()->getMyUrl());
|
||||
$visitor_is_authenticated = (bool)DI::userSession()->getMyUrl();
|
||||
$visitor_is_following =
|
||||
in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
|
||||
$visitor_is_following = in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
|
||||
|| in_array($profile_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
|
||||
$visitor_is_followed =
|
||||
in_array($visitor_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND])
|
||||
$visitor_is_followed = in_array($visitor_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND])
|
||||
|| in_array($profile_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
|
||||
$visitor_base_path = DI::userSession()->getMyUrl() ? preg_replace('=/profile/(.*)=ism', '', DI::userSession()->getMyUrl()) : '';
|
||||
|
||||
|
@ -342,15 +339,15 @@ class Profile
|
|||
$profile['edit'] = [DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')];
|
||||
$profile['menu'] = [
|
||||
'chg_photo' => DI::l10n()->t('Change profile photo'),
|
||||
'cr_new' => null,
|
||||
'entries' => [],
|
||||
'cr_new' => null,
|
||||
'entries' => [],
|
||||
];
|
||||
}
|
||||
|
||||
// Fetch the account type
|
||||
$account_type = Contact::getAccountType($profile['account-type']);
|
||||
|
||||
if (!empty($profile['address']) || !empty($profile['location'])) {
|
||||
if (!empty($profile['address']) || !empty($profile['location'])) {
|
||||
$location = DI::l10n()->t('Location:');
|
||||
}
|
||||
|
||||
|
@ -364,8 +361,8 @@ class Profile
|
|||
}
|
||||
|
||||
$split_name = Diaspora::splitName($profile['name']);
|
||||
$firstname = $split_name['first'];
|
||||
$lastname = $split_name['last'];
|
||||
$firstname = $split_name['first'];
|
||||
$lastname = $split_name['last'];
|
||||
|
||||
if (!empty($profile['guid'])) {
|
||||
$diaspora = [
|
||||
|
@ -385,7 +382,7 @@ class Profile
|
|||
}
|
||||
|
||||
$contact_block = '';
|
||||
$updated = '';
|
||||
$updated = '';
|
||||
$contact_count = 0;
|
||||
|
||||
if (!empty($profile['last-item'])) {
|
||||
|
@ -416,7 +413,7 @@ class Profile
|
|||
'upubkey' => null,
|
||||
];
|
||||
foreach ($profile as $k => $v) {
|
||||
$k = str_replace('-', '_', $k);
|
||||
$k = str_replace('-', '_', $k);
|
||||
$p[$k] = $v;
|
||||
}
|
||||
|
||||
|
@ -433,7 +430,7 @@ class Profile
|
|||
$p['url'] = Contact::magicLinkById($cid, $profile['url']);
|
||||
|
||||
if (!isset($profile['hidewall'])) {
|
||||
Logger::warning('Missing hidewall key in profile array', ['profile' => $profile]);
|
||||
DI::logger()->warning('Missing hidewall key in profile array', ['profile' => $profile]);
|
||||
}
|
||||
|
||||
if ($profile['account-type'] == Contact::TYPE_COMMUNITY) {
|
||||
|
@ -445,35 +442,35 @@ class Profile
|
|||
$mention_url = 'compose/0?body=@' . $profile['addr'];
|
||||
$network_label = DI::l10n()->t('Network Posts');
|
||||
}
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$profile' => $p,
|
||||
'$xmpp' => $xmpp,
|
||||
'$matrix' => $matrix,
|
||||
'$follow' => DI::l10n()->t('Follow'),
|
||||
'$follow_link' => $follow_link,
|
||||
'$unfollow' => DI::l10n()->t('Unfollow'),
|
||||
'$unfollow_link' => $unfollow_link,
|
||||
'$subscribe_feed' => DI::l10n()->t('Atom feed'),
|
||||
'$profile' => $p,
|
||||
'$xmpp' => $xmpp,
|
||||
'$matrix' => $matrix,
|
||||
'$follow' => DI::l10n()->t('Follow'),
|
||||
'$follow_link' => $follow_link,
|
||||
'$unfollow' => DI::l10n()->t('Unfollow'),
|
||||
'$unfollow_link' => $unfollow_link,
|
||||
'$subscribe_feed' => DI::l10n()->t('Atom feed'),
|
||||
'$subscribe_feed_link' => $profile['hidewall'] ?? 0 ? '' : $profile['poll'],
|
||||
'$wallmessage' => DI::l10n()->t('Message'),
|
||||
'$wallmessage_link' => $wallmessage_link,
|
||||
'$account_type' => $account_type,
|
||||
'$location' => $location,
|
||||
'$homepage' => $homepage,
|
||||
'$homepage_verified' => DI::l10n()->t('This website has been verified to belong to the same person.'),
|
||||
'$about' => $about,
|
||||
'$network' => DI::l10n()->t('Network:'),
|
||||
'$contacts' => $contact_count,
|
||||
'$updated' => $updated,
|
||||
'$diaspora' => $diaspora,
|
||||
'$contact_block' => $contact_block,
|
||||
'$mention_label' => $mention_label,
|
||||
'$mention_url' => $mention_url,
|
||||
'$network_label' => $network_label,
|
||||
'$network_url' => $network_url,
|
||||
'$wallmessage' => DI::l10n()->t('Message'),
|
||||
'$wallmessage_link' => $wallmessage_link,
|
||||
'$account_type' => $account_type,
|
||||
'$location' => $location,
|
||||
'$homepage' => $homepage,
|
||||
'$homepage_verified' => DI::l10n()->t('This website has been verified to belong to the same person.'),
|
||||
'$about' => $about,
|
||||
'$network' => DI::l10n()->t('Network:'),
|
||||
'$contacts' => $contact_count,
|
||||
'$updated' => $updated,
|
||||
'$diaspora' => $diaspora,
|
||||
'$contact_block' => $contact_block,
|
||||
'$mention_label' => $mention_label,
|
||||
'$mention_url' => $mention_url,
|
||||
'$network_label' => $network_label,
|
||||
'$network_url' => $network_url,
|
||||
]);
|
||||
|
||||
$arr = ['profile' => &$profile, 'entry' => &$o];
|
||||
|
@ -604,7 +601,7 @@ class Profile
|
|||
*/
|
||||
public static function getEventsReminderHTML(int $uid, int $pcid): string
|
||||
{
|
||||
$bd_format = DI::l10n()->t('g A l F d'); // 8 AM Friday January 18
|
||||
$bd_format = DI::l10n()->t('g A l F d'); // 8 AM Friday January 18
|
||||
$classtoday = '';
|
||||
|
||||
$condition = [
|
||||
|
@ -617,13 +614,13 @@ class Profile
|
|||
|
||||
if (DBA::isResult($s)) {
|
||||
$istoday = false;
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
|
||||
while ($rr = DBA::fetch($s)) {
|
||||
$condition = [
|
||||
'parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => $pcid,
|
||||
'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
|
||||
'visible' => true, 'deleted' => false
|
||||
'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
|
||||
'visible' => true, 'deleted' => false
|
||||
];
|
||||
if (!Post::exists($condition)) {
|
||||
continue;
|
||||
|
@ -657,11 +654,11 @@ class Profile
|
|||
|
||||
$today = substr($strt, 0, 10) === DateTimeFormat::localNow('Y-m-d');
|
||||
|
||||
$rr['title'] = $title;
|
||||
$rr['title'] = $title;
|
||||
$rr['description'] = $description;
|
||||
$rr['date'] = DI::l10n()->getDay(DateTimeFormat::local($rr['start'], $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
|
||||
$rr['startime'] = $strt;
|
||||
$rr['today'] = $today;
|
||||
$rr['date'] = DI::l10n()->getDay(DateTimeFormat::local($rr['start'], $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
|
||||
$rr['startime'] = $strt;
|
||||
$rr['today'] = $today;
|
||||
|
||||
$r[] = $rr;
|
||||
}
|
||||
|
@ -670,11 +667,11 @@ class Profile
|
|||
}
|
||||
$tpl = Renderer::getMarkupTemplate('events_reminder.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$classtoday' => $classtoday,
|
||||
'$count' => count($r),
|
||||
'$classtoday' => $classtoday,
|
||||
'$count' => count($r),
|
||||
'$event_reminders' => DI::l10n()->t('Event Reminders'),
|
||||
'$event_title' => DI::l10n()->t('Upcoming events the next 7 days:'),
|
||||
'$events' => $r,
|
||||
'$event_title' => DI::l10n()->t('Upcoming events the next 7 days:'),
|
||||
'$events' => $r,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -709,9 +706,9 @@ class Profile
|
|||
public static function searchProfiles(int $start = 0, int $count = 100, string $search = null): array
|
||||
{
|
||||
if (!empty($search)) {
|
||||
$publish = (DI::config()->get('system', 'publish_all') ? '' : "AND `publish` ");
|
||||
$publish = (DI::config()->get('system', 'publish_all') ? '' : "AND `publish` ");
|
||||
$searchTerm = '%' . $search . '%';
|
||||
$condition = [
|
||||
$condition = [
|
||||
"`verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`
|
||||
$publish
|
||||
AND ((`name` LIKE ?) OR
|
||||
|
@ -823,7 +820,7 @@ class Profile
|
|||
$profile['profile-name'] = null;
|
||||
$profile['is-default'] = null;
|
||||
DBA::update('profile', $profile, ['id' => $profile['id']]);
|
||||
} else if (!empty($profile['id'])) {
|
||||
} elseif (!empty($profile['id'])) {
|
||||
DBA::delete('profile', ['id' => $profile['id']]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
|
||||
use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
|
||||
use Friendica\Object\Api\Mastodon\Notification;
|
||||
use Minishlink\WebPush\VAPID;
|
||||
|
||||
class Subscription
|
||||
|
@ -133,7 +131,7 @@ class Subscription
|
|||
|
||||
$subscriptions = DBA::select('subscription', [], ['uid' => $notification->uid, $type => true]);
|
||||
while ($subscription = DBA::fetch($subscriptions)) {
|
||||
Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
|
||||
DI::logger()->info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
|
||||
Worker::add(Worker::PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
|
||||
}
|
||||
DBA::close($subscriptions);
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -27,13 +26,13 @@ use Friendica\Util\Strings;
|
|||
*/
|
||||
class Tag
|
||||
{
|
||||
const UNKNOWN = 0;
|
||||
const HASHTAG = 1;
|
||||
const MENTION = 2;
|
||||
const UNKNOWN = 0;
|
||||
const HASHTAG = 1;
|
||||
const MENTION = 2;
|
||||
/**
|
||||
* An implicit mention is a mention in a comment body that is redundant with the threading information.
|
||||
*/
|
||||
const IMPLICIT_MENTION = 8;
|
||||
const IMPLICIT_MENTION = 8;
|
||||
/**
|
||||
* An exclusive mention transmits the post only to the target account without transmitting it to the followers, usually a group.
|
||||
*/
|
||||
|
@ -91,7 +90,7 @@ class Tag
|
|||
return;
|
||||
}
|
||||
|
||||
$cid = 0;
|
||||
$cid = 0;
|
||||
$tagid = 0;
|
||||
|
||||
if (in_array($type, [self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION, self::TO, self::CC, self::BTO, self::BCC, self::AUDIENCE, self::ATTRIBUTED])) {
|
||||
|
@ -101,11 +100,11 @@ class Tag
|
|||
}
|
||||
|
||||
if ((substr($url, 0, 7) == 'https//') || (substr($url, 0, 6) == 'http//')) {
|
||||
Logger::notice('Wrong scheme in url', ['url' => $url]);
|
||||
DI::logger()->notice('Wrong scheme in url', ['url' => $url]);
|
||||
}
|
||||
|
||||
$cid = Contact::getIdForURL($url, 0, false);
|
||||
Logger::debug('Got id for contact', ['cid' => $cid, 'url' => $url]);
|
||||
DI::logger()->debug('Got id for contact', ['cid' => $cid, 'url' => $url]);
|
||||
|
||||
if (empty($cid)) {
|
||||
$tag = DBA::selectFirst('tag', ['name', 'type'], ['url' => $url]);
|
||||
|
@ -138,17 +137,17 @@ class Tag
|
|||
$fields = ['uri-id' => $uriId, 'type' => $type, 'tid' => $tagid, 'cid' => $cid];
|
||||
|
||||
if (in_array($type, [self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION])) {
|
||||
$condition = $fields;
|
||||
$condition = $fields;
|
||||
$condition['type'] = [self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION];
|
||||
if (DBA::exists('post-tag', $condition)) {
|
||||
Logger::info('Tag already exists', $fields);
|
||||
DI::logger()->info('Tag already exists', $fields);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DBA::insert('post-tag', $fields, Database::INSERT_IGNORE);
|
||||
|
||||
Logger::debug('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type]);
|
||||
DI::logger()->debug('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,26 +169,26 @@ class Tag
|
|||
if (!empty($tag['type'])) {
|
||||
$target = $tag['type'];
|
||||
if ($target != self::GENERAL_COLLECTION) {
|
||||
Logger::debug('Found existing type', ['type' => $tag['type'], 'url' => $url]);
|
||||
DI::logger()->debug('Found existing type', ['type' => $tag['type'], 'url' => $url]);
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
if ($url == ActivityPub::PUBLIC_COLLECTION) {
|
||||
$target = self::PUBLIC_COLLECTION;
|
||||
Logger::debug('Public collection', ['url' => $url]);
|
||||
DI::logger()->debug('Public collection', ['url' => $url]);
|
||||
} else {
|
||||
if (DBA::exists('apcontact', ['followers' => $url])) {
|
||||
$target = self::FOLLOWER_COLLECTION;
|
||||
Logger::debug('Found collection via existing apcontact', ['url' => $url]);
|
||||
DI::logger()->debug('Found collection via existing apcontact', ['url' => $url]);
|
||||
} elseif (Contact::getIdForURL($url, 0, $fetch ? null : false)) {
|
||||
$target = self::ACCOUNT;
|
||||
Logger::debug('URL is an account', ['url' => $url]);
|
||||
DI::logger()->debug('URL is an account', ['url' => $url]);
|
||||
} elseif ($fetch && ($target != self::GENERAL_COLLECTION)) {
|
||||
$content = HTTPSignature::fetch($url);
|
||||
if (!empty($content['type']) && ($content['type'] == 'OrderedCollection')) {
|
||||
$target = self::GENERAL_COLLECTION;
|
||||
Logger::debug('URL is an ordered collection', ['url' => $url]);
|
||||
DI::logger()->debug('URL is an ordered collection', ['url' => $url]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +198,7 @@ class Tag
|
|||
}
|
||||
|
||||
if (empty($target)) {
|
||||
Logger::debug('No type could be detected', ['url' => $url]);
|
||||
DI::logger()->debug('No type could be detected', ['url' => $url]);
|
||||
}
|
||||
|
||||
return $target;
|
||||
|
@ -238,7 +237,7 @@ class Tag
|
|||
// Also log type
|
||||
$fields['type'] = $type;
|
||||
|
||||
Logger::error('No tag id created', $fields);
|
||||
DI::logger()->error('No tag id created', $fields);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -305,7 +304,7 @@ class Tag
|
|||
*/
|
||||
public static function storeFromArray(array $item, string $tags = null)
|
||||
{
|
||||
Logger::info('Check for tags', ['uri-id' => $item['uri-id'], 'hash' => $tags]);
|
||||
DI::logger()->info('Check for tags', ['uri-id' => $item['uri-id'], 'hash' => $tags]);
|
||||
|
||||
if (is_null($tags)) {
|
||||
$tags = self::TAG_CHARACTER[self::HASHTAG] . self::TAG_CHARACTER[self::MENTION] . self::TAG_CHARACTER[self::EXCLUSIVE_MENTION];
|
||||
|
@ -336,14 +335,14 @@ class Tag
|
|||
*/
|
||||
public static function storeRawTagsFromBody(int $uriId, string $body)
|
||||
{
|
||||
Logger::info('Check for tags', ['uri-id' => $uriId]);
|
||||
DI::logger()->info('Check for tags', ['uri-id' => $uriId]);
|
||||
|
||||
$result = BBCode::getTags($body);
|
||||
if (empty($result)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::info('Found tags', ['uri-id' => $uriId, 'result' => $result]);
|
||||
DI::logger()->info('Found tags', ['uri-id' => $uriId, 'result' => $result]);
|
||||
|
||||
foreach ($result as $tag) {
|
||||
if (substr($tag, 0, 1) != self::TAG_CHARACTER[self::HASHTAG]) {
|
||||
|
@ -397,7 +396,7 @@ class Tag
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url]);
|
||||
DI::logger()->debug('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url]);
|
||||
DBA::delete('post-tag', ['uri-id' => $uriId, 'type' => $type, 'tid' => $tag['tid'], 'cid' => $tag['cid']]);
|
||||
}
|
||||
|
||||
|
@ -529,9 +528,9 @@ class Tag
|
|||
public static function populateFromItem(array &$item): array
|
||||
{
|
||||
$return = [
|
||||
'tags' => [],
|
||||
'hashtags' => [],
|
||||
'mentions' => [],
|
||||
'tags' => [],
|
||||
'hashtags' => [],
|
||||
'mentions' => [],
|
||||
'implicit_mentions' => [],
|
||||
];
|
||||
|
||||
|
@ -557,7 +556,7 @@ class Tag
|
|||
}
|
||||
|
||||
$return['hashtags'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
$return['tags'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
$return['tags'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
break;
|
||||
|
||||
case self::MENTION:
|
||||
|
@ -568,7 +567,7 @@ class Tag
|
|||
$tag['url'] = Contact::magicLink($tag['url']);
|
||||
}
|
||||
$return['mentions'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
$return['tags'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
$return['tags'][] = '<bdi>' . $prefix . '<a href="' . $tag['url'] . '" target="_blank" rel="noopener noreferrer">' . htmlspecialchars($tag['name']) . '</a></bdi>';
|
||||
break;
|
||||
|
||||
case self::IMPLICIT_MENTION:
|
||||
|
@ -576,7 +575,7 @@ class Tag
|
|||
break;
|
||||
|
||||
default:
|
||||
Logger::warning('Unknown tag type found', $tag);
|
||||
DI::logger()->warning('Unknown tag type found', $tag);
|
||||
}
|
||||
}
|
||||
DBA::close($taglist);
|
||||
|
@ -809,7 +808,7 @@ class Tag
|
|||
*/
|
||||
private static function getUIDListByTag(string $tag): array
|
||||
{
|
||||
$uids = [];
|
||||
$uids = [];
|
||||
$searches = DBA::select('search', ['uid'], ['term' => $tag]);
|
||||
while ($search = DBA::fetch($searches)) {
|
||||
$uids[] = $search['uid'];
|
||||
|
@ -832,7 +831,7 @@ class Tag
|
|||
foreach (self::getByURIId($uriId, [self::HASHTAG]) as $tag) {
|
||||
foreach (self::getUIDListByTag(self::TAG_CHARACTER[self::HASHTAG] . $tag['name']) as $uid) {
|
||||
$uids[$uid][] = $tag['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uids;
|
||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\App;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\System;
|
||||
|
@ -85,12 +84,12 @@ class User
|
|||
* This will only be assigned to contacts, not to user accounts
|
||||
* @{
|
||||
*/
|
||||
const ACCOUNT_TYPE_PERSON = 0;
|
||||
const ACCOUNT_TYPE_PERSON = 0;
|
||||
const ACCOUNT_TYPE_ORGANISATION = 1;
|
||||
const ACCOUNT_TYPE_NEWS = 2;
|
||||
const ACCOUNT_TYPE_COMMUNITY = 3;
|
||||
const ACCOUNT_TYPE_RELAY = 4;
|
||||
const ACCOUNT_TYPE_DELETED = 127;
|
||||
const ACCOUNT_TYPE_NEWS = 2;
|
||||
const ACCOUNT_TYPE_COMMUNITY = 3;
|
||||
const ACCOUNT_TYPE_RELAY = 4;
|
||||
const ACCOUNT_TYPE_DELETED = 127;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -151,42 +150,42 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
$system['name'] = App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION;
|
||||
$system['uprvkey'] = $system['prvkey'];
|
||||
$system['upubkey'] = $system['pubkey'];
|
||||
$system['nickname'] = $system['nick'];
|
||||
$system['page-flags'] = self::PAGE_FLAGS_SOAPBOX;
|
||||
$system['name'] = App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION;
|
||||
$system['uprvkey'] = $system['prvkey'];
|
||||
$system['upubkey'] = $system['pubkey'];
|
||||
$system['nickname'] = $system['nick'];
|
||||
$system['page-flags'] = self::PAGE_FLAGS_SOAPBOX;
|
||||
$system['account-type'] = $system['contact-type'];
|
||||
$system['guid'] = '';
|
||||
$system['picdate'] = '';
|
||||
$system['theme'] = '';
|
||||
$system['publish'] = false;
|
||||
$system['net-publish'] = false;
|
||||
$system['guid'] = '';
|
||||
$system['picdate'] = '';
|
||||
$system['theme'] = '';
|
||||
$system['publish'] = false;
|
||||
$system['net-publish'] = false;
|
||||
$system['hide-friends'] = true;
|
||||
$system['hidewall'] = true;
|
||||
$system['hidewall'] = true;
|
||||
$system['prv_keywords'] = '';
|
||||
$system['pub_keywords'] = '';
|
||||
$system['address'] = '';
|
||||
$system['locality'] = '';
|
||||
$system['region'] = '';
|
||||
$system['postal-code'] = '';
|
||||
$system['address'] = '';
|
||||
$system['locality'] = '';
|
||||
$system['region'] = '';
|
||||
$system['postal-code'] = '';
|
||||
$system['country-name'] = '';
|
||||
$system['homepage'] = (string)DI::baseUrl();
|
||||
$system['dob'] = '0000-00-00';
|
||||
$system['homepage'] = (string)DI::baseUrl();
|
||||
$system['dob'] = '0000-00-00';
|
||||
|
||||
// Ensure that the user contains data
|
||||
$user = DBA::selectFirst('user', ['prvkey', 'guid', 'language'], ['uid' => 0]);
|
||||
if (empty($user['prvkey']) || empty($user['guid'])) {
|
||||
$fields = [
|
||||
'username' => $system['name'],
|
||||
'nickname' => $system['nick'],
|
||||
'username' => $system['name'],
|
||||
'nickname' => $system['nick'],
|
||||
'register_date' => $system['created'],
|
||||
'pubkey' => $system['pubkey'],
|
||||
'prvkey' => $system['prvkey'],
|
||||
'guid' => System::createUUID(),
|
||||
'verified' => true,
|
||||
'page-flags' => self::PAGE_FLAGS_SOAPBOX,
|
||||
'account-type' => self::ACCOUNT_TYPE_RELAY,
|
||||
'pubkey' => $system['pubkey'],
|
||||
'prvkey' => $system['prvkey'],
|
||||
'guid' => System::createUUID(),
|
||||
'verified' => true,
|
||||
'page-flags' => self::PAGE_FLAGS_SOAPBOX,
|
||||
'account-type' => self::ACCOUNT_TYPE_RELAY,
|
||||
];
|
||||
|
||||
DBA::update('user', $fields, ['uid' => 0]);
|
||||
|
@ -350,12 +349,12 @@ class User
|
|||
DI::pConfig()->set($uid, 'system', 'unlisted', true);
|
||||
|
||||
$fields = [
|
||||
'allow_cid' => '',
|
||||
'allow_gid' => $user['page-flags'] == self::PAGE_FLAGS_PRVGROUP ? '<' . Circle::FOLLOWERS . '>' : '',
|
||||
'deny_cid' => '',
|
||||
'deny_gid' => '',
|
||||
'blockwall' => true,
|
||||
'blocktags' => true,
|
||||
'allow_cid' => '',
|
||||
'allow_gid' => $user['page-flags'] == self::PAGE_FLAGS_PRVGROUP ? '<' . Circle::FOLLOWERS . '>' : '',
|
||||
'deny_cid' => '',
|
||||
'deny_gid' => '',
|
||||
'blockwall' => true,
|
||||
'blocktags' => true,
|
||||
];
|
||||
|
||||
self::update($fields, $uid);
|
||||
|
@ -491,12 +490,12 @@ class User
|
|||
// Check if the returned data is valid, otherwise fix it. See issue #6122
|
||||
|
||||
// Check for correct url and normalised nurl
|
||||
$url = DI::baseUrl() . '/profile/' . $owner['nickname'];
|
||||
$url = DI::baseUrl() . '/profile/' . $owner['nickname'];
|
||||
$repair = empty($owner['baseurl']) || empty($owner['network']) || ($owner['url'] != $url) || ($owner['nurl'] != Strings::normaliseLink($owner['url']));
|
||||
|
||||
if (!$repair) {
|
||||
// Check if "addr" is present and correct
|
||||
$addr = $owner['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
|
||||
$addr = $owner['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
|
||||
$repair = ($addr != $owner['addr']) || empty($owner['prvkey']) || empty($owner['pubkey']);
|
||||
}
|
||||
|
||||
|
@ -629,7 +628,7 @@ class User
|
|||
$users = DBA::select('user', ['uid', 'language'], $condition);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
$uids[] = $user['uid'];
|
||||
$code = DI::l10n()->toISO6391($user['language']);
|
||||
$code = DI::l10n()->toISO6391($user['language']);
|
||||
if (!in_array($code, $supported)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -645,7 +644,7 @@ class User
|
|||
$values = unserialize($channel['v']);
|
||||
if (!empty($values) && is_array($values)) {
|
||||
foreach ($values as $language) {
|
||||
$language = DI::l10n()->toISO6391($language);
|
||||
$language = DI::l10n()->toISO6391($language);
|
||||
$languages[$language] = $language;
|
||||
}
|
||||
}
|
||||
|
@ -808,11 +807,11 @@ class User
|
|||
} elseif (is_int($user_info) || is_string($user_info)) {
|
||||
$fields = ['uid', 'nickname', 'password', 'legacy_password'];
|
||||
if (is_int($user_info)) {
|
||||
$condition = [
|
||||
'uid' => $user_info,
|
||||
$condition = [
|
||||
'uid' => $user_info,
|
||||
'account_expired' => false,
|
||||
'account_removed' => false,
|
||||
'verified' => true
|
||||
'verified' => true
|
||||
];
|
||||
if (!$with_blocked) {
|
||||
$condition = DBA::mergeConditions($condition, ['blocked' => false]);
|
||||
|
@ -857,7 +856,7 @@ class User
|
|||
$fields['login_date'] = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
Logger::debug('Set last activity for user', ['uid' => $user['uid'], 'fields' => $fields]);
|
||||
DI::logger()->debug('Set last activity for user', ['uid' => $user['uid'], 'fields' => $fields]);
|
||||
self::update($fields, $user['uid']);
|
||||
// Set the last activity for all identities of the user
|
||||
DBA::update('user', $fields, ['parent-uid' => $user['uid'], 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
|
||||
|
@ -898,10 +897,10 @@ class User
|
|||
|
||||
return $passwordExposedChecker->passwordExposed($password) === PasswordExposed\Enums\PasswordStatus::EXPOSED;
|
||||
} catch (Exception $e) {
|
||||
Logger::error('Password Exposed Exception: ' . $e->getMessage(), [
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
DI::logger()->error('Password Exposed Exception: ' . $e->getMessage(), [
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
|
||||
|
@ -1002,9 +1001,9 @@ class User
|
|||
private static function updatePasswordHashed(int $uid, string $password_hashed): bool
|
||||
{
|
||||
$fields = [
|
||||
'password' => $password_hashed,
|
||||
'pwdreset' => null,
|
||||
'pwdreset_time' => null,
|
||||
'password' => $password_hashed,
|
||||
'pwdreset' => null,
|
||||
'pwdreset_time' => null,
|
||||
'legacy_password' => false
|
||||
];
|
||||
return DBA::update('user', $fields, ['uid' => $uid]);
|
||||
|
@ -1110,7 +1109,7 @@ class User
|
|||
break;
|
||||
}
|
||||
|
||||
$updated = '';
|
||||
$updated = '';
|
||||
$mimetype = '';
|
||||
|
||||
$photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => $scale, 'uid' => $user['uid'], 'profile' => true]);
|
||||
|
@ -1215,14 +1214,14 @@ class User
|
|||
throw new Exception(DI::l10n()->t('Invalid OpenID url'));
|
||||
}
|
||||
$_SESSION['register'] = 1;
|
||||
$_SESSION['openid'] = $openid_url;
|
||||
$_SESSION['openid'] = $openid_url;
|
||||
|
||||
$openid = new LightOpenID(DI::baseUrl()->getHost());
|
||||
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
|
||||
$openid->identity = $openid_url;
|
||||
$openid->identity = $openid_url;
|
||||
$openid->returnUrl = DI::baseUrl() . '/openid';
|
||||
$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
|
||||
$openid->optional = ['namePerson/first', 'media/image/aspect11', 'media/image/default'];
|
||||
$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
|
||||
$openid->optional = ['namePerson/first', 'media/image/aspect11', 'media/image/default'];
|
||||
try {
|
||||
$authurl = $openid->authUrl();
|
||||
} catch (Exception $e) {
|
||||
|
@ -1246,8 +1245,8 @@ class User
|
|||
$username_max_length = max(1, min(64, intval(DI::config()->get('system', 'username_max_length', 48))));
|
||||
|
||||
if ($username_min_length > $username_max_length) {
|
||||
Logger::error(DI::l10n()->t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length));
|
||||
$tmp = $username_min_length;
|
||||
DI::logger()->error(DI::l10n()->t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length));
|
||||
$tmp = $username_min_length;
|
||||
$username_min_length = $username_max_length;
|
||||
$username_max_length = $tmp;
|
||||
}
|
||||
|
@ -1304,7 +1303,7 @@ class User
|
|||
throw new Exception(DI::l10n()->t('Nickname is already registered. Please choose another.'));
|
||||
}
|
||||
|
||||
$new_password = strlen($password) ? $password : self::generateNewPassword();
|
||||
$new_password = strlen($password) ? $password : self::generateNewPassword();
|
||||
$new_password_encoded = self::hashPassword($new_password);
|
||||
|
||||
$return['password'] = $new_password;
|
||||
|
@ -1318,24 +1317,24 @@ class User
|
|||
$pubkey = $keys['pubkey'];
|
||||
|
||||
$insert_result = DBA::insert('user', [
|
||||
'guid' => System::createUUID(),
|
||||
'username' => $username,
|
||||
'password' => $new_password_encoded,
|
||||
'email' => $email,
|
||||
'openid' => $openid_url,
|
||||
'nickname' => $nickname,
|
||||
'pubkey' => $pubkey,
|
||||
'prvkey' => $prvkey,
|
||||
'verified' => $verified,
|
||||
'blocked' => $blocked,
|
||||
'language' => $language,
|
||||
'timezone' => 'UTC',
|
||||
'register_date' => DateTimeFormat::utcNow(),
|
||||
'guid' => System::createUUID(),
|
||||
'username' => $username,
|
||||
'password' => $new_password_encoded,
|
||||
'email' => $email,
|
||||
'openid' => $openid_url,
|
||||
'nickname' => $nickname,
|
||||
'pubkey' => $pubkey,
|
||||
'prvkey' => $prvkey,
|
||||
'verified' => $verified,
|
||||
'blocked' => $blocked,
|
||||
'language' => $language,
|
||||
'timezone' => 'UTC',
|
||||
'register_date' => DateTimeFormat::utcNow(),
|
||||
'default-location' => ''
|
||||
]);
|
||||
|
||||
if ($insert_result) {
|
||||
$uid = DBA::lastInsertId();
|
||||
$uid = DBA::lastInsertId();
|
||||
$user = DBA::selectFirst('user', [], ['uid' => $uid]);
|
||||
} else {
|
||||
throw new Exception(DI::l10n()->t('An error occurred during registration. Please try again.'));
|
||||
|
@ -1355,11 +1354,11 @@ class User
|
|||
}
|
||||
|
||||
$insert_result = DBA::insert('profile', [
|
||||
'uid' => $uid,
|
||||
'name' => $username,
|
||||
'photo' => self::getAvatarUrl($user),
|
||||
'thumb' => self::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'publish' => $publish,
|
||||
'uid' => $uid,
|
||||
'name' => $username,
|
||||
'photo' => self::getAvatarUrl($user),
|
||||
'thumb' => self::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'publish' => $publish,
|
||||
'net-publish' => $netpublish,
|
||||
]);
|
||||
if (!$insert_result) {
|
||||
|
@ -1409,17 +1408,17 @@ class User
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($photo, HttpClientAccept::IMAGE, [HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]);
|
||||
DI::logger()->debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]);
|
||||
$img_str = $curlResult->getBodyString();
|
||||
$type = $curlResult->getContentType();
|
||||
$type = $curlResult->getContentType();
|
||||
} else {
|
||||
$img_str = '';
|
||||
$type = '';
|
||||
$type = '';
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
$img_str = '';
|
||||
$type = '';
|
||||
$type = '';
|
||||
}
|
||||
|
||||
$image = new Image($img_str, $type, $photo);
|
||||
|
@ -1497,7 +1496,7 @@ class User
|
|||
* @param bool $block Block state (default is true)
|
||||
*
|
||||
* @return bool True, if successfully blocked
|
||||
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function block(int $uid, bool $block = true): bool
|
||||
|
@ -1602,21 +1601,21 @@ class User
|
|||
public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT, string $avatar = ''): bool
|
||||
{
|
||||
if (empty($name) ||
|
||||
empty($email) ||
|
||||
empty($nick)) {
|
||||
empty($email) ||
|
||||
empty($nick)) {
|
||||
throw new HTTPException\InternalServerErrorException('Invalid arguments.');
|
||||
}
|
||||
|
||||
$result = self::create([
|
||||
'username' => $name,
|
||||
'email' => $email,
|
||||
'email' => $email,
|
||||
'nickname' => $nick,
|
||||
'verified' => 1,
|
||||
'language' => $lang,
|
||||
'photo' => $avatar
|
||||
'photo' => $avatar
|
||||
]);
|
||||
|
||||
$user = $result['user'];
|
||||
$user = $result['user'];
|
||||
$preamble = Strings::deindent(DI::l10n()->t('
|
||||
Dear %1$s,
|
||||
the administrator of %2$s has set up an account for you.'));
|
||||
|
@ -1648,7 +1647,7 @@ class User
|
|||
Thank you and welcome to %4$s.'));
|
||||
|
||||
$preamble = sprintf($preamble, $user['username'], DI::config()->get('config', 'sitename'));
|
||||
$body = sprintf($body, DI::baseUrl(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename'));
|
||||
$body = sprintf($body, DI::baseUrl(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename'));
|
||||
|
||||
$email = DI::emailer()
|
||||
->newSystemMail()
|
||||
|
@ -1777,7 +1776,7 @@ class User
|
|||
throw new \InvalidArgumentException('uid needs to be greater than 0');
|
||||
}
|
||||
|
||||
Logger::notice('Removing user', ['user' => $uid]);
|
||||
DI::logger()->notice('Removing user', ['user' => $uid]);
|
||||
|
||||
$user = self::getById($uid);
|
||||
if (!$user) {
|
||||
|
@ -1849,7 +1848,7 @@ class User
|
|||
if (!$user['parent-uid']) {
|
||||
// First add our own entry
|
||||
$identities = [[
|
||||
'uid' => $user['uid'],
|
||||
'uid' => $user['uid'],
|
||||
'username' => $user['username'],
|
||||
'nickname' => $user['nickname']
|
||||
]];
|
||||
|
@ -1947,17 +1946,20 @@ class User
|
|||
'active_users_weekly' => 0,
|
||||
];
|
||||
|
||||
$userStmt = DBA::select('owner-view', ['uid', 'last-activity', 'last-item'],
|
||||
$userStmt = DBA::select(
|
||||
'owner-view',
|
||||
['uid', 'last-activity', 'last-item'],
|
||||
["`verified` AND `last-activity` > ? AND NOT `blocked`
|
||||
AND NOT `account_removed` AND NOT `account_expired`",
|
||||
DBA::NULL_DATETIME]);
|
||||
DBA::NULL_DATETIME]
|
||||
);
|
||||
if (!DBA::isResult($userStmt)) {
|
||||
return $statistics;
|
||||
}
|
||||
|
||||
$halfyear = time() - (180 * 24 * 60 * 60);
|
||||
$month = time() - (30 * 24 * 60 * 60);
|
||||
$week = time() - (7 * 24 * 60 * 60);
|
||||
$month = time() - (30 * 24 * 60 * 60);
|
||||
$week = time() - (7 * 24 * 60 * 60);
|
||||
|
||||
while ($user = DBA::fetch($userStmt)) {
|
||||
$statistics['total_users']++;
|
||||
|
@ -1995,18 +1997,18 @@ class User
|
|||
*/
|
||||
public static function getList(int $start = 0, int $count = Pager::ITEMS_PER_PAGE, string $type = 'all', string $order = 'name', bool $descending = false)
|
||||
{
|
||||
$param = ['limit' => [$start, $count], 'order' => [$order => $descending]];
|
||||
$param = ['limit' => [$start, $count], 'order' => [$order => $descending]];
|
||||
$condition = [];
|
||||
switch ($type) {
|
||||
case 'active':
|
||||
$condition['account_removed'] = false;
|
||||
$condition['blocked'] = false;
|
||||
$condition['blocked'] = false;
|
||||
break;
|
||||
|
||||
case 'blocked':
|
||||
$condition['account_removed'] = false;
|
||||
$condition['blocked'] = true;
|
||||
$condition['verified'] = true;
|
||||
$condition['blocked'] = true;
|
||||
$condition['verified'] = true;
|
||||
break;
|
||||
|
||||
case 'removed':
|
||||
|
@ -2086,19 +2088,19 @@ class User
|
|||
|
||||
$register_policy = DI::config()->get('config', 'register_policy');
|
||||
if (!in_array($register_policy, [Module\Register::OPEN, Module\Register::CLOSED])) {
|
||||
Logger::debug('Unsupported register policy.', ['policy' => $register_policy]);
|
||||
DI::logger()->debug('Unsupported register policy.', ['policy' => $register_policy]);
|
||||
return;
|
||||
}
|
||||
|
||||
$users = DBA::count('user', ['blocked' => false, 'account_removed' => false, 'account_expired' => false]);
|
||||
if (($users >= $max_registered_users) && ($register_policy == Module\Register::OPEN)) {
|
||||
DI::config()->set('config', 'register_policy', Module\Register::CLOSED);
|
||||
Logger::notice('Max users reached, registration is closed.', ['users' => $users, 'max' => $max_registered_users]);
|
||||
DI::logger()->notice('Max users reached, registration is closed.', ['users' => $users, 'max' => $max_registered_users]);
|
||||
} elseif (($users < $max_registered_users) && ($register_policy == Module\Register::CLOSED)) {
|
||||
DI::config()->set('config', 'register_policy', Module\Register::OPEN);
|
||||
Logger::notice('Below maximum users, registration is opened.', ['users' => $users, 'max' => $max_registered_users]);
|
||||
DI::logger()->notice('Below maximum users, registration is opened.', ['users' => $users, 'max' => $max_registered_users]);
|
||||
} else {
|
||||
Logger::debug('Unchanged register policy', ['policy' => $register_policy, 'users' => $users, 'max' => $max_registered_users]);
|
||||
DI::logger()->debug('Unchanged register policy', ['policy' => $register_policy, 'users' => $users, 'max' => $max_registered_users]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
namespace Friendica\Moderation\Repository;
|
||||
|
||||
use Friendica\BaseEntity;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Moderation\Factory;
|
||||
use Friendica\Moderation\Collection;
|
||||
|
@ -73,7 +73,7 @@ final class Report extends \Friendica\BaseRepository
|
|||
if (Post::exists(['uri-id' => $post->uriId])) {
|
||||
$this->db->insert('report-post', ['rid' => $newReportId, 'uri-id' => $post->uriId, 'status' => $post->status]);
|
||||
} else {
|
||||
Logger::notice('Post does not exist', ['uri-id' => $post->uriId, 'report' => $Report]);
|
||||
DI::logger()->notice('Post does not exist', ['uri-id' => $post->uriId, 'report' => $Report]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\ActivityPub;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -66,7 +65,7 @@ class Inbox extends BaseApi
|
|||
}
|
||||
|
||||
if (!HTTPSignature::isValidContentType($this->server['CONTENT_TYPE'] ?? '')) {
|
||||
Logger::notice('Unexpected content type', ['content-type' => $this->server['CONTENT_TYPE'] ?? '', 'agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
|
||||
$this->logger->notice('Unexpected content type', ['content-type' => $this->server['CONTENT_TYPE'] ?? '', 'agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
|
||||
throw new \Friendica\Network\HTTPException\UnsupportedMediaTypeException();
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ class Inbox extends BaseApi
|
|||
}
|
||||
$tempfile = tempnam(System::getTempPath(), $filename);
|
||||
file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
||||
Logger::notice('Incoming message stored', ['file' => $tempfile]);
|
||||
$this->logger->notice('Incoming message stored', ['file' => $tempfile]);
|
||||
}
|
||||
|
||||
if (!empty($this->parameters['nickname'])) {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
namespace Friendica\Module\ActivityPub;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -39,18 +37,18 @@ class Objects extends BaseModule
|
|||
$itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $this->parameters['guid']]);
|
||||
|
||||
if (DBA::isResult($itemuri)) {
|
||||
Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]);
|
||||
$this->logger->info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]);
|
||||
} else {
|
||||
// The item URI does not always contain the GUID. This means that we have to search the URL instead
|
||||
$url = DI::baseUrl() . '/' . DI::args()->getQueryString();
|
||||
$nurl = Strings::normaliseLink($url);
|
||||
$url = DI::baseUrl() . '/' . DI::args()->getQueryString();
|
||||
$nurl = Strings::normaliseLink($url);
|
||||
$ssl_url = str_replace('http://', 'https://', $nurl);
|
||||
|
||||
$itemuri = DBA::selectFirst('item-uri', ['guid', 'id'], ['uri' => [$url, $nurl, $ssl_url]]);
|
||||
if (DBA::isResult($itemuri)) {
|
||||
Logger::info('URL found.', ['url' => $url, 'guid' => $itemuri['guid'], 'uri-id' => $itemuri['id']]);
|
||||
$this->logger->info('URL found.', ['url' => $url, 'guid' => $itemuri['guid'], 'uri-id' => $itemuri['id']]);
|
||||
} else {
|
||||
Logger::info('URL not found.', ['url' => $url]);
|
||||
$this->logger->info('URL not found.', ['url' => $url]);
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +63,7 @@ class Objects extends BaseModule
|
|||
if (!$validated) {
|
||||
$requester = HTTPSignature::getSigner('', $_SERVER);
|
||||
if (!empty($requester)) {
|
||||
$receivers = Item::enumeratePermissions($item, false);
|
||||
$receivers = Item::enumeratePermissions($item, false);
|
||||
$receivers[] = $item['contact-id'];
|
||||
|
||||
$validated = in_array(Contact::getIdForURL($requester, $item['uid']), $receivers);
|
||||
|
@ -98,16 +96,18 @@ class Objects extends BaseModule
|
|||
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data = array_merge($data, $activity['object']);
|
||||
} elseif (empty($this->parameters['activity']) || in_array($this->parameters['activity'],
|
||||
} elseif (empty($this->parameters['activity']) || in_array(
|
||||
$this->parameters['activity'],
|
||||
['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject',
|
||||
'TentativeAccept', 'Follow', 'Add'])) {
|
||||
'TentativeAccept', 'Follow', 'Add']
|
||||
)) {
|
||||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item['id']);
|
||||
if (empty($data)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
if (!empty($this->parameters['activity']) && ($this->parameters['activity'] != 'Create')) {
|
||||
$data['type'] = $this->parameters['activity'];
|
||||
$data['id'] = str_replace('/Create', '/' . $this->parameters['activity'], $data['id']);
|
||||
$data['id'] = str_replace('/Create', '/' . $this->parameters['activity'], $data['id']);
|
||||
}
|
||||
} else {
|
||||
throw new HTTPException\NotFoundException();
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\System;
|
||||
|
@ -20,7 +19,6 @@ use Friendica\Model\User;
|
|||
use Friendica\Module\BaseAdmin;
|
||||
use Friendica\Module\Conversation\Community;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Navigation\SystemMessages;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\EMailer\MailBuilder;
|
||||
|
@ -58,80 +56,81 @@ class Site extends BaseAdmin
|
|||
$maximagelength = (!empty($_POST['maximagelength']) ? intval(trim($_POST['maximagelength'])) : -1);
|
||||
$jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality'])) : 100);
|
||||
|
||||
$register_policy = (!empty($_POST['register_policy']) ? intval(trim($_POST['register_policy'])) : 0);
|
||||
$max_registered_users = (!empty($_POST['max_registered_users']) ? intval(trim($_POST['max_registered_users'])) : 0);
|
||||
$daily_registrations = (!empty($_POST['max_daily_registrations']) ? intval(trim($_POST['max_daily_registrations'])) : 0);
|
||||
$abandon_days = (!empty($_POST['abandon_days']) ? intval(trim($_POST['abandon_days'])) : 0);
|
||||
$register_policy = (!empty($_POST['register_policy']) ? intval(trim($_POST['register_policy'])) : 0);
|
||||
$max_registered_users = (!empty($_POST['max_registered_users']) ? intval(trim($_POST['max_registered_users'])) : 0);
|
||||
$daily_registrations = (!empty($_POST['max_daily_registrations']) ? intval(trim($_POST['max_daily_registrations'])) : 0);
|
||||
$abandon_days = (!empty($_POST['abandon_days']) ? intval(trim($_POST['abandon_days'])) : 0);
|
||||
|
||||
$register_text = (!empty($_POST['register_text']) ? strip_tags(trim($_POST['register_text'])) : '');
|
||||
$register_text = (!empty($_POST['register_text']) ? strip_tags(trim($_POST['register_text'])) : '');
|
||||
|
||||
$allowed_sites = (!empty($_POST['allowed_sites']) ? trim($_POST['allowed_sites']) : '');
|
||||
$allowed_email = (!empty($_POST['allowed_email']) ? trim($_POST['allowed_email']) : '');
|
||||
$disallowed_email = (!empty($_POST['disallowed_email']) ? trim($_POST['disallowed_email']) : '');
|
||||
$forbidden_nicknames = (!empty($_POST['forbidden_nicknames']) ? strtolower(trim($_POST['forbidden_nicknames'])) : '');
|
||||
$system_actor_name = (!empty($_POST['system_actor_name']) ? trim($_POST['system_actor_name']) : '');
|
||||
$no_oembed_rich_content = !empty($_POST['no_oembed_rich_content']);
|
||||
$allowed_oembed = (!empty($_POST['allowed_oembed']) ? trim($_POST['allowed_oembed']) : '');
|
||||
$block_public = !empty($_POST['block_public']);
|
||||
$force_publish = !empty($_POST['publish_all']);
|
||||
$global_directory = (!empty($_POST['directory']) ? trim($_POST['directory']) : '');
|
||||
$newuser_private = !empty($_POST['newuser_private']);
|
||||
$enotify_no_content = !empty($_POST['enotify_no_content']);
|
||||
$private_addons = !empty($_POST['private_addons']);
|
||||
$disable_embedded = !empty($_POST['disable_embedded']);
|
||||
$allowed_sites = (!empty($_POST['allowed_sites']) ? trim($_POST['allowed_sites']) : '');
|
||||
$allowed_email = (!empty($_POST['allowed_email']) ? trim($_POST['allowed_email']) : '');
|
||||
$disallowed_email = (!empty($_POST['disallowed_email']) ? trim($_POST['disallowed_email']) : '');
|
||||
$forbidden_nicknames = (!empty($_POST['forbidden_nicknames']) ? strtolower(trim($_POST['forbidden_nicknames'])) : '');
|
||||
$system_actor_name = (!empty($_POST['system_actor_name']) ? trim($_POST['system_actor_name']) : '');
|
||||
$no_oembed_rich_content = !empty($_POST['no_oembed_rich_content']);
|
||||
$allowed_oembed = (!empty($_POST['allowed_oembed']) ? trim($_POST['allowed_oembed']) : '');
|
||||
$block_public = !empty($_POST['block_public']);
|
||||
$force_publish = !empty($_POST['publish_all']);
|
||||
$global_directory = (!empty($_POST['directory']) ? trim($_POST['directory']) : '');
|
||||
$newuser_private = !empty($_POST['newuser_private']);
|
||||
$enotify_no_content = !empty($_POST['enotify_no_content']);
|
||||
$private_addons = !empty($_POST['private_addons']);
|
||||
$disable_embedded = !empty($_POST['disable_embedded']);
|
||||
$allow_users_remote_self = !empty($_POST['allow_users_remote_self']);
|
||||
$allow_relay_channels = !empty($_POST['allow_relay_channels']);
|
||||
$adjust_poll_frequency = !empty($_POST['adjust_poll_frequency']);
|
||||
$min_poll_interval = (!empty($_POST['min_poll_interval']) ? intval(trim($_POST['min_poll_interval'])) : 0);
|
||||
$explicit_content = !empty($_POST['explicit_content']);
|
||||
$local_search = !empty($_POST['local_search']);
|
||||
$blocked_tags = (!empty($_POST['blocked_tags']) ? trim($_POST['blocked_tags']) : '');
|
||||
$cache_contact_avatar = !empty($_POST['cache_contact_avatar']);
|
||||
$allow_relay_channels = !empty($_POST['allow_relay_channels']);
|
||||
$adjust_poll_frequency = !empty($_POST['adjust_poll_frequency']);
|
||||
$min_poll_interval = (!empty($_POST['min_poll_interval']) ? intval(trim($_POST['min_poll_interval'])) : 0);
|
||||
$explicit_content = !empty($_POST['explicit_content']);
|
||||
$local_search = !empty($_POST['local_search']);
|
||||
$blocked_tags = (!empty($_POST['blocked_tags']) ? trim($_POST['blocked_tags']) : '');
|
||||
$cache_contact_avatar = !empty($_POST['cache_contact_avatar']);
|
||||
|
||||
$enable_multi_reg = !empty($_POST['enable_multi_reg']);
|
||||
$enable_openid = !empty($_POST['enable_openid']);
|
||||
$enable_regfullname = !empty($_POST['enable_regfullname']);
|
||||
$register_notification = !empty($_POST['register_notification']);
|
||||
$community_page_style = (!empty($_POST['community_page_style']) ? intval(trim($_POST['community_page_style'])) : 0);
|
||||
$enable_multi_reg = !empty($_POST['enable_multi_reg']);
|
||||
$enable_openid = !empty($_POST['enable_openid']);
|
||||
$enable_regfullname = !empty($_POST['enable_regfullname']);
|
||||
$register_notification = !empty($_POST['register_notification']);
|
||||
$community_page_style = (!empty($_POST['community_page_style']) ? intval(trim($_POST['community_page_style'])) : 0);
|
||||
$max_author_posts_community_page = (!empty($_POST['max_author_posts_community_page']) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
|
||||
$max_server_posts_community_page = (!empty($_POST['max_server_posts_community_page']) ? intval(trim($_POST['max_server_posts_community_page'])) : 0);
|
||||
|
||||
$verifyssl = !empty($_POST['verifyssl']);
|
||||
$proxyuser = (!empty($_POST['proxyuser']) ? trim($_POST['proxyuser']) : '');
|
||||
$proxy = (!empty($_POST['proxy']) ? trim($_POST['proxy']) : '');
|
||||
$timeout = (!empty($_POST['timeout']) ? intval(trim($_POST['timeout'])) : 60);
|
||||
$maxloadavg = (!empty($_POST['maxloadavg']) ? intval(trim($_POST['maxloadavg'])) : 20);
|
||||
$min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0);
|
||||
$optimize_tables = (!empty($_POST['optimize_tables']) ? intval(trim($_POST['optimize_tables'])) : false);
|
||||
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE);
|
||||
$update_active_contacts = (!empty($_POST['update_active_contacts']) ? intval(trim($_POST['update_active_contacts'])) : false);
|
||||
$synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false);
|
||||
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
|
||||
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false);
|
||||
$poco_local_search = !empty($_POST['poco_local_search']);
|
||||
$nodeinfo = !empty($_POST['nodeinfo']);
|
||||
$mail_enabled = !empty($_POST['mail_enabled']);
|
||||
$diaspora_enabled = !empty($_POST['diaspora_enabled']);
|
||||
$force_ssl = !empty($_POST['force_ssl']);
|
||||
$show_help = !empty($_POST['show_help']);
|
||||
$dbclean = !empty($_POST['dbclean']);
|
||||
$dbclean_expire_days = (!empty($_POST['dbclean_expire_days']) ? intval($_POST['dbclean_expire_days']) : 0);
|
||||
$dbclean_unclaimed = (!empty($_POST['dbclean_unclaimed']) ? intval($_POST['dbclean_unclaimed']) : 0);
|
||||
$dbclean_expire_conv = (!empty($_POST['dbclean_expire_conv']) ? intval($_POST['dbclean_expire_conv']) : 0);
|
||||
$suppress_tags = !empty($_POST['suppress_tags']);
|
||||
$max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0);
|
||||
$max_display_comments = (!empty($_POST['max_display_comments']) ? intval($_POST['max_display_comments']) : 0);
|
||||
$itemspage_network = (!empty($_POST['itemspage_network']) ? intval($_POST['itemspage_network']) : 0);
|
||||
$verifyssl = !empty($_POST['verifyssl']);
|
||||
$proxyuser = (!empty($_POST['proxyuser']) ? trim($_POST['proxyuser']) : '');
|
||||
$proxy = (!empty($_POST['proxy']) ? trim($_POST['proxy']) : '');
|
||||
$timeout = (!empty($_POST['timeout']) ? intval(trim($_POST['timeout'])) : 60);
|
||||
$maxloadavg = (!empty($_POST['maxloadavg']) ? intval(trim($_POST['maxloadavg'])) : 20);
|
||||
$min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0);
|
||||
$optimize_tables = (!empty($_POST['optimize_tables']) ? intval(trim($_POST['optimize_tables'])) : false);
|
||||
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE);
|
||||
$update_active_contacts = (!empty($_POST['update_active_contacts']) ? intval(trim($_POST['update_active_contacts'])) : false);
|
||||
$update_known_contacts = (!empty($_POST['update_known_contacts']) ? intval(trim($_POST['update_known_contacts'])) : false);
|
||||
$synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false);
|
||||
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
|
||||
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false);
|
||||
$poco_local_search = !empty($_POST['poco_local_search']);
|
||||
$nodeinfo = !empty($_POST['nodeinfo']);
|
||||
$mail_enabled = !empty($_POST['mail_enabled']);
|
||||
$diaspora_enabled = !empty($_POST['diaspora_enabled']);
|
||||
$force_ssl = !empty($_POST['force_ssl']);
|
||||
$show_help = !empty($_POST['show_help']);
|
||||
$dbclean = !empty($_POST['dbclean']);
|
||||
$dbclean_expire_days = (!empty($_POST['dbclean_expire_days']) ? intval($_POST['dbclean_expire_days']) : 0);
|
||||
$dbclean_unclaimed = (!empty($_POST['dbclean_unclaimed']) ? intval($_POST['dbclean_unclaimed']) : 0);
|
||||
$dbclean_expire_conv = (!empty($_POST['dbclean_expire_conv']) ? intval($_POST['dbclean_expire_conv']) : 0);
|
||||
$suppress_tags = !empty($_POST['suppress_tags']);
|
||||
$max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0);
|
||||
$max_display_comments = (!empty($_POST['max_display_comments']) ? intval($_POST['max_display_comments']) : 0);
|
||||
$itemspage_network = (!empty($_POST['itemspage_network']) ? intval($_POST['itemspage_network']) : 0);
|
||||
$itemspage_network_mobile = (!empty($_POST['itemspage_network_mobile']) ? intval($_POST['itemspage_network_mobile']) : 0);
|
||||
$temppath = (!empty($_POST['temppath']) ? trim($_POST['temppath']) : '');
|
||||
$singleuser = (!empty($_POST['singleuser']) ? trim($_POST['singleuser']) : '');
|
||||
$only_tag_search = !empty($_POST['only_tag_search']);
|
||||
$limited_search_scope = !empty($_POST['limited_search_scope']);
|
||||
$search_age_days = (!empty($_POST['search_age_days']) ? intval($_POST['search_age_days']) : 0);
|
||||
$compute_circle_counts = !empty($_POST['compute_circle_counts']);
|
||||
$process_view = !empty($_POST['process_view']);
|
||||
$archival_days = (!empty($_POST['archival_days']) ? intval($_POST['archival_days']) : 0);
|
||||
$check_new_version_url = (!empty($_POST['check_new_version_url']) ? trim($_POST['check_new_version_url']) : 'none');
|
||||
$temppath = (!empty($_POST['temppath']) ? trim($_POST['temppath']) : '');
|
||||
$singleuser = (!empty($_POST['singleuser']) ? trim($_POST['singleuser']) : '');
|
||||
$only_tag_search = !empty($_POST['only_tag_search']);
|
||||
$limited_search_scope = !empty($_POST['limited_search_scope']);
|
||||
$search_age_days = (!empty($_POST['search_age_days']) ? intval($_POST['search_age_days']) : 0);
|
||||
$compute_circle_counts = !empty($_POST['compute_circle_counts']);
|
||||
$process_view = !empty($_POST['process_view']);
|
||||
$archival_days = (!empty($_POST['archival_days']) ? intval($_POST['archival_days']) : 0);
|
||||
$check_new_version_url = (!empty($_POST['check_new_version_url']) ? trim($_POST['check_new_version_url']) : 'none');
|
||||
|
||||
$worker_queues = (!empty($_POST['worker_queues']) ? intval($_POST['worker_queues']) : 10);
|
||||
$worker_load_cooldown = (!empty($_POST['worker_load_cooldown']) ? intval($_POST['worker_load_cooldown']) : 0);
|
||||
|
@ -140,7 +139,6 @@ class Site extends BaseAdmin
|
|||
$cron_interval = (!empty($_POST['cron_interval']) ? intval($_POST['cron_interval']) : 1);
|
||||
$worker_defer_limit = (!empty($_POST['worker_defer_limit']) ? intval($_POST['worker_defer_limit']) : 15);
|
||||
$worker_fetch_limit = (!empty($_POST['worker_fetch_limit']) ? intval($_POST['worker_fetch_limit']) : 1);
|
||||
|
||||
|
||||
$relay_directly = !empty($_POST['relay_directly']);
|
||||
$relay_scope = (!empty($_POST['relay_scope']) ? trim($_POST['relay_scope']) : '');
|
||||
|
@ -159,7 +157,7 @@ class Site extends BaseAdmin
|
|||
$max_posts_per_author = (!empty($_POST['max_posts_per_author']) ? intval($_POST['max_posts_per_author']) : 0);
|
||||
$sharer_interaction_days = (!empty($_POST['sharer_interaction_days']) ? intval($_POST['sharer_interaction_days']) : 0);
|
||||
|
||||
$active_panel = (!empty($_POST['active_panel']) ? "#" . trim($_POST['active_panel']) : '');
|
||||
$active_panel = (!empty($_POST['active_panel']) ? "#" . trim($_POST['active_panel']) : '');
|
||||
|
||||
$transactionConfig = DI::config()->beginTransaction();
|
||||
|
||||
|
@ -173,23 +171,24 @@ class Site extends BaseAdmin
|
|||
$diaspora_enabled = false;
|
||||
}
|
||||
|
||||
$transactionConfig->set('system', 'maxloadavg' , $maxloadavg);
|
||||
$transactionConfig->set('system', 'min_memory' , $min_memory);
|
||||
$transactionConfig->set('system', 'optimize_tables' , $optimize_tables);
|
||||
$transactionConfig->set('system', 'contact_discovery' , $contact_discovery);
|
||||
$transactionConfig->set('system', 'update_active_contacts' , $update_active_contacts);
|
||||
$transactionConfig->set('system', 'synchronize_directory' , $synchronize_directory);
|
||||
$transactionConfig->set('system', 'poco_requery_days' , $poco_requery_days);
|
||||
$transactionConfig->set('system', 'poco_discovery' , $poco_discovery);
|
||||
$transactionConfig->set('system', 'poco_local_search' , $poco_local_search);
|
||||
$transactionConfig->set('system', 'nodeinfo' , $nodeinfo);
|
||||
$transactionConfig->set('system', 'maxloadavg', $maxloadavg);
|
||||
$transactionConfig->set('system', 'min_memory', $min_memory);
|
||||
$transactionConfig->set('system', 'optimize_tables', $optimize_tables);
|
||||
$transactionConfig->set('system', 'contact_discovery', $contact_discovery);
|
||||
$transactionConfig->set('system', 'update_active_contacts', $update_active_contacts);
|
||||
$transactionConfig->set('system', 'update_known_contacts', $update_known_contacts);
|
||||
$transactionConfig->set('system', 'synchronize_directory', $synchronize_directory);
|
||||
$transactionConfig->set('system', 'poco_requery_days', $poco_requery_days);
|
||||
$transactionConfig->set('system', 'poco_discovery', $poco_discovery);
|
||||
$transactionConfig->set('system', 'poco_local_search', $poco_local_search);
|
||||
$transactionConfig->set('system', 'nodeinfo', $nodeinfo);
|
||||
if (DI::config()->isWritable('config', 'sitename')) {
|
||||
$transactionConfig->set('config', 'sitename', $sitename);
|
||||
}
|
||||
$transactionConfig->set('config', 'sender_email' , $sender_email);
|
||||
$transactionConfig->set('system', 'suppress_tags' , $suppress_tags);
|
||||
$transactionConfig->set('system', 'shortcut_icon' , $shortcut_icon);
|
||||
$transactionConfig->set('system', 'touch_icon' , $touch_icon);
|
||||
$transactionConfig->set('config', 'sender_email', $sender_email);
|
||||
$transactionConfig->set('system', 'suppress_tags', $suppress_tags);
|
||||
$transactionConfig->set('system', 'shortcut_icon', $shortcut_icon);
|
||||
$transactionConfig->set('system', 'touch_icon', $touch_icon);
|
||||
|
||||
if ($banner == "") {
|
||||
$transactionConfig->delete('system', 'banner');
|
||||
|
@ -234,60 +233,60 @@ class Site extends BaseAdmin
|
|||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('%s is no valid input for maximum image size', $maximagesize));
|
||||
}
|
||||
$transactionConfig->set('system', 'max_image_length' , $maximagelength);
|
||||
$transactionConfig->set('system', 'jpeg_quality' , $jpegimagequality);
|
||||
$transactionConfig->set('system', 'max_image_length', $maximagelength);
|
||||
$transactionConfig->set('system', 'jpeg_quality', $jpegimagequality);
|
||||
|
||||
$transactionConfig->set('config', 'register_policy' , $register_policy);
|
||||
$transactionConfig->set('config', 'max_registered_users' , $max_registered_users);
|
||||
$transactionConfig->set('config', 'register_policy', $register_policy);
|
||||
$transactionConfig->set('config', 'max_registered_users', $max_registered_users);
|
||||
$transactionConfig->set('system', 'max_daily_registrations', $daily_registrations);
|
||||
|
||||
User::setRegisterMethodByUserCount();
|
||||
|
||||
$transactionConfig->set('system', 'account_abandon_days' , $abandon_days);
|
||||
$transactionConfig->set('config', 'register_text' , $register_text);
|
||||
$transactionConfig->set('system', 'allowed_sites' , $allowed_sites);
|
||||
$transactionConfig->set('system', 'allowed_email' , $allowed_email);
|
||||
$transactionConfig->set('system', 'disallowed_email' , $disallowed_email);
|
||||
$transactionConfig->set('system', 'forbidden_nicknames' , $forbidden_nicknames);
|
||||
$transactionConfig->set('system', 'system_actor_name' , $system_actor_name);
|
||||
$transactionConfig->set('system', 'no_oembed_rich_content' , $no_oembed_rich_content);
|
||||
$transactionConfig->set('system', 'allowed_oembed' , $allowed_oembed);
|
||||
$transactionConfig->set('system', 'block_public' , $block_public);
|
||||
$transactionConfig->set('system', 'publish_all' , $force_publish);
|
||||
$transactionConfig->set('system', 'newuser_private' , $newuser_private);
|
||||
$transactionConfig->set('system', 'enotify_no_content' , $enotify_no_content);
|
||||
$transactionConfig->set('system', 'disable_embedded' , $disable_embedded);
|
||||
$transactionConfig->set('system', 'account_abandon_days', $abandon_days);
|
||||
$transactionConfig->set('config', 'register_text', $register_text);
|
||||
$transactionConfig->set('system', 'allowed_sites', $allowed_sites);
|
||||
$transactionConfig->set('system', 'allowed_email', $allowed_email);
|
||||
$transactionConfig->set('system', 'disallowed_email', $disallowed_email);
|
||||
$transactionConfig->set('system', 'forbidden_nicknames', $forbidden_nicknames);
|
||||
$transactionConfig->set('system', 'system_actor_name', $system_actor_name);
|
||||
$transactionConfig->set('system', 'no_oembed_rich_content', $no_oembed_rich_content);
|
||||
$transactionConfig->set('system', 'allowed_oembed', $allowed_oembed);
|
||||
$transactionConfig->set('system', 'block_public', $block_public);
|
||||
$transactionConfig->set('system', 'publish_all', $force_publish);
|
||||
$transactionConfig->set('system', 'newuser_private', $newuser_private);
|
||||
$transactionConfig->set('system', 'enotify_no_content', $enotify_no_content);
|
||||
$transactionConfig->set('system', 'disable_embedded', $disable_embedded);
|
||||
$transactionConfig->set('system', 'allow_users_remote_self', $allow_users_remote_self);
|
||||
$transactionConfig->set('system', 'allow_relay_channels' , $allow_relay_channels);
|
||||
$transactionConfig->set('system', 'adjust_poll_frequency' , $adjust_poll_frequency);
|
||||
$transactionConfig->set('system', 'min_poll_interval' , $min_poll_interval);
|
||||
$transactionConfig->set('system', 'explicit_content' , $explicit_content);
|
||||
$transactionConfig->set('system', 'local_search' , $local_search);
|
||||
$transactionConfig->set('system', 'blocked_tags' , Strings::cleanTags($blocked_tags));
|
||||
$transactionConfig->set('system', 'cache_contact_avatar' , $cache_contact_avatar);
|
||||
$transactionConfig->set('system', 'check_new_version_url' , $check_new_version_url);
|
||||
$transactionConfig->set('system', 'allow_relay_channels', $allow_relay_channels);
|
||||
$transactionConfig->set('system', 'adjust_poll_frequency', $adjust_poll_frequency);
|
||||
$transactionConfig->set('system', 'min_poll_interval', $min_poll_interval);
|
||||
$transactionConfig->set('system', 'explicit_content', $explicit_content);
|
||||
$transactionConfig->set('system', 'local_search', $local_search);
|
||||
$transactionConfig->set('system', 'blocked_tags', Strings::cleanTags($blocked_tags));
|
||||
$transactionConfig->set('system', 'cache_contact_avatar', $cache_contact_avatar);
|
||||
$transactionConfig->set('system', 'check_new_version_url', $check_new_version_url);
|
||||
|
||||
$transactionConfig->set('system', 'block_extended_register', !$enable_multi_reg);
|
||||
$transactionConfig->set('system', 'no_openid' , !$enable_openid);
|
||||
$transactionConfig->set('system', 'no_regfullname' , !$enable_regfullname);
|
||||
$transactionConfig->set('system', 'register_notification' , $register_notification);
|
||||
$transactionConfig->set('system', 'community_page_style' , $community_page_style);
|
||||
$transactionConfig->set('system', 'no_openid', !$enable_openid);
|
||||
$transactionConfig->set('system', 'no_regfullname', !$enable_regfullname);
|
||||
$transactionConfig->set('system', 'register_notification', $register_notification);
|
||||
$transactionConfig->set('system', 'community_page_style', $community_page_style);
|
||||
$transactionConfig->set('system', 'max_author_posts_community_page', $max_author_posts_community_page);
|
||||
$transactionConfig->set('system', 'max_server_posts_community_page', $max_server_posts_community_page);
|
||||
$transactionConfig->set('system', 'verifyssl' , $verifyssl);
|
||||
$transactionConfig->set('system', 'proxyuser' , $proxyuser);
|
||||
$transactionConfig->set('system', 'proxy' , $proxy);
|
||||
$transactionConfig->set('system', 'curl_timeout' , $timeout);
|
||||
$transactionConfig->set('system', 'imap_disabled' , !$mail_enabled && function_exists('imap_open'));
|
||||
$transactionConfig->set('system', 'diaspora_enabled' , $diaspora_enabled);
|
||||
$transactionConfig->set('system', 'verifyssl', $verifyssl);
|
||||
$transactionConfig->set('system', 'proxyuser', $proxyuser);
|
||||
$transactionConfig->set('system', 'proxy', $proxy);
|
||||
$transactionConfig->set('system', 'curl_timeout', $timeout);
|
||||
$transactionConfig->set('system', 'imap_disabled', !$mail_enabled && function_exists('imap_open'));
|
||||
$transactionConfig->set('system', 'diaspora_enabled', $diaspora_enabled);
|
||||
|
||||
$transactionConfig->set('config', 'private_addons' , $private_addons);
|
||||
$transactionConfig->set('config', 'private_addons', $private_addons);
|
||||
|
||||
$transactionConfig->set('system', 'force_ssl' , $force_ssl);
|
||||
$transactionConfig->set('system', 'hide_help' , !$show_help);
|
||||
$transactionConfig->set('system', 'force_ssl', $force_ssl);
|
||||
$transactionConfig->set('system', 'hide_help', !$show_help);
|
||||
|
||||
$transactionConfig->set('system', 'dbclean' , $dbclean);
|
||||
$transactionConfig->set('system', 'dbclean-expire-days' , $dbclean_expire_days);
|
||||
$transactionConfig->set('system', 'dbclean', $dbclean);
|
||||
$transactionConfig->set('system', 'dbclean-expire-days', $dbclean_expire_days);
|
||||
$transactionConfig->set('system', 'dbclean_expire_conversation', $dbclean_expire_conv);
|
||||
|
||||
if ($dbclean_unclaimed == 0) {
|
||||
|
@ -314,28 +313,28 @@ class Site extends BaseAdmin
|
|||
$transactionConfig->set('system', 'process_view', $process_view);
|
||||
$transactionConfig->set('system', 'archival_days', $archival_days);
|
||||
|
||||
$transactionConfig->set('system', 'worker_queues' , $worker_queues);
|
||||
$transactionConfig->set('system', 'worker_queues', $worker_queues);
|
||||
$transactionConfig->set('system', 'worker_load_cooldown', $worker_load_cooldown);
|
||||
$transactionConfig->set('system', 'worker_fastlane' , $worker_fastlane);
|
||||
$transactionConfig->set('system', 'decoupled_receiver' , $decoupled_receiver);
|
||||
$transactionConfig->set('system', 'cron_interval' , max($cron_interval, 1));
|
||||
$transactionConfig->set('system', 'worker_defer_limit' , $worker_defer_limit);
|
||||
$transactionConfig->set('system', 'worker_fetch_limit' , max($worker_fetch_limit, 1));
|
||||
|
||||
$transactionConfig->set('system', 'relay_directly' , $relay_directly);
|
||||
$transactionConfig->set('system', 'relay_scope' , $relay_scope);
|
||||
$transactionConfig->set('system', 'relay_server_tags' , Strings::cleanTags($relay_server_tags));
|
||||
$transactionConfig->set('system', 'relay_deny_tags' , Strings::cleanTags($relay_deny_tags));
|
||||
$transactionConfig->set('system', 'relay_max_tags' , $relay_max_tags);
|
||||
$transactionConfig->set('system', 'relay_user_tags' , $relay_user_tags);
|
||||
$transactionConfig->set('system', 'relay_deny_undetected_language', $relay_deny_undetected_language);
|
||||
$transactionConfig->set('system', 'relay_language_quality' , $relay_language_quality);
|
||||
$transactionConfig->set('system', 'relay_languages' , max($relay_languages, 1));
|
||||
$transactionConfig->set('system', 'worker_fastlane', $worker_fastlane);
|
||||
$transactionConfig->set('system', 'decoupled_receiver', $decoupled_receiver);
|
||||
$transactionConfig->set('system', 'cron_interval', max($cron_interval, 1));
|
||||
$transactionConfig->set('system', 'worker_defer_limit', $worker_defer_limit);
|
||||
$transactionConfig->set('system', 'worker_fetch_limit', max($worker_fetch_limit, 1));
|
||||
|
||||
$transactionConfig->set('channel', 'engagement_hours' , $engagement_hours);
|
||||
$transactionConfig->set('channel', 'engagement_post_limit' , $engagement_post_limit);
|
||||
$transactionConfig->set('channel', 'interaction_score_days' , $interaction_score_days);
|
||||
$transactionConfig->set('channel', 'max_posts_per_author' , $max_posts_per_author);
|
||||
$transactionConfig->set('system', 'relay_directly', $relay_directly);
|
||||
$transactionConfig->set('system', 'relay_scope', $relay_scope);
|
||||
$transactionConfig->set('system', 'relay_server_tags', Strings::cleanTags($relay_server_tags));
|
||||
$transactionConfig->set('system', 'relay_deny_tags', Strings::cleanTags($relay_deny_tags));
|
||||
$transactionConfig->set('system', 'relay_max_tags', $relay_max_tags);
|
||||
$transactionConfig->set('system', 'relay_user_tags', $relay_user_tags);
|
||||
$transactionConfig->set('system', 'relay_deny_undetected_language', $relay_deny_undetected_language);
|
||||
$transactionConfig->set('system', 'relay_language_quality', $relay_language_quality);
|
||||
$transactionConfig->set('system', 'relay_languages', max($relay_languages, 1));
|
||||
|
||||
$transactionConfig->set('channel', 'engagement_hours', $engagement_hours);
|
||||
$transactionConfig->set('channel', 'engagement_post_limit', $engagement_post_limit);
|
||||
$transactionConfig->set('channel', 'interaction_score_days', $interaction_score_days);
|
||||
$transactionConfig->set('channel', 'max_posts_per_author', $max_posts_per_author);
|
||||
$transactionConfig->set('channel', 'sharer_interaction_days', $sharer_interaction_days);
|
||||
|
||||
$transactionConfig->commit();
|
||||
|
@ -357,10 +356,10 @@ class Site extends BaseAdmin
|
|||
}
|
||||
|
||||
/* Installed themes */
|
||||
$theme_choices = [];
|
||||
$theme_choices_mobile = [];
|
||||
$theme_choices = [];
|
||||
$theme_choices_mobile = [];
|
||||
$theme_choices_mobile['---'] = DI::l10n()->t('No special theme for mobile devices');
|
||||
$files = glob('view/theme/*');
|
||||
$files = glob('view/theme/*');
|
||||
if (is_array($files)) {
|
||||
$allowed_theme_list = DI::config()->get('system', 'allowed_themes');
|
||||
|
||||
|
@ -397,7 +396,7 @@ class Site extends BaseAdmin
|
|||
|
||||
/* get user names to make the install a personal install of X */
|
||||
// @TODO Move to Model\User::getNames()
|
||||
$user_names = [];
|
||||
$user_names = [];
|
||||
$user_names['---'] = DI::l10n()->t('Multi user instance');
|
||||
|
||||
$usersStmt = DBA::select('user', ['username', 'nickname'], ['account_removed' => 0, 'account_expired' => 0]);
|
||||
|
@ -421,20 +420,20 @@ class Site extends BaseAdmin
|
|||
|
||||
/* Register policy */
|
||||
$register_choices = [
|
||||
Register::CLOSED => DI::l10n()->t('Closed'),
|
||||
Register::CLOSED => DI::l10n()->t('Closed'),
|
||||
Register::APPROVE => DI::l10n()->t('Requires approval'),
|
||||
Register::OPEN => DI::l10n()->t('Open')
|
||||
Register::OPEN => DI::l10n()->t('Open')
|
||||
];
|
||||
|
||||
$check_git_version_choices = [
|
||||
'none' => DI::l10n()->t('Don\'t check'),
|
||||
'stable' => DI::l10n()->t('check the stable version'),
|
||||
'none' => DI::l10n()->t('Don\'t check'),
|
||||
'stable' => DI::l10n()->t('check the stable version'),
|
||||
'develop' => DI::l10n()->t('check the development version')
|
||||
];
|
||||
|
||||
$discovery_choices = [
|
||||
Contact\Relation::DISCOVERY_NONE => DI::l10n()->t('none'),
|
||||
Contact\Relation::DISCOVERY_LOCAL => DI::l10n()->t('Local contacts'),
|
||||
Contact\Relation::DISCOVERY_NONE => DI::l10n()->t('none'),
|
||||
Contact\Relation::DISCOVERY_LOCAL => DI::l10n()->t('Local contacts'),
|
||||
Contact\Relation::DISCOVERY_INTERACTOR => DI::l10n()->t('Interactors'),
|
||||
// "All" is deactivated until we are sure not to put too much stress on the fediverse with this
|
||||
// ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'),
|
||||
|
@ -467,118 +466,119 @@ class Site extends BaseAdmin
|
|||
'$relocate_cmd' => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'),
|
||||
|
||||
// name, label, value, help string, extra data...
|
||||
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), !DI::config()->isWritable('config', 'sitename') ? DI::l10n()->t('<strong>Read-only</strong> because it is set by an environment variable') : '', '', !DI::config()->isWritable('config', 'sitename') ? 'disabled' : ''],
|
||||
'$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'],
|
||||
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), !DI::config()->isWritable('config', 'sitename') ? DI::l10n()->t('<strong>Read-only</strong> because it is set by an environment variable') : '', '', !DI::config()->isWritable('config', 'sitename') ? 'disabled' : ''],
|
||||
'$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'],
|
||||
'$system_actor_name' => ['system_actor_name', DI::l10n()->t('Name of the system actor'), User::getActorName(), DI::l10n()->t("Name of the internal system account that is used to perform ActivityPub requests. This must be an unused username. If set, this can't be changed again.")],
|
||||
'$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''],
|
||||
'$email_banner' => ['email_banner', DI::l10n()->t('Email Banner/Logo'), $email_banner, ''],
|
||||
'$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')],
|
||||
'$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')],
|
||||
'$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())],
|
||||
'$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), !DI::config()->isWritable('system', 'language') ? DI::l10n()->t("<strong>Read-only</strong> because it is set by an environment variable") : '', $lang_choices, !DI::config()->isWritable('system', 'language') ? 'disabled' : ''],
|
||||
'$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl() . '/admin/themes'), $theme_choices],
|
||||
'$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile],
|
||||
'$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')],
|
||||
'$show_help' => ['show_help', DI::l10n()->t('Show help entry from navigation menu'), !DI::config()->get('system', 'hide_help'), DI::l10n()->t('Displays the menu entry for the Help pages from the navigation menu. It is always accessible by calling /help directly.')],
|
||||
'$singleuser' => ['singleuser', DI::l10n()->t('Single user instance'), DI::config()->get('system', 'singleuser', '---'), DI::l10n()->t('Make this instance multi-user or single-user for the named user'), $user_names],
|
||||
'$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''],
|
||||
'$email_banner' => ['email_banner', DI::l10n()->t('Email Banner/Logo'), $email_banner, ''],
|
||||
'$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')],
|
||||
'$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')],
|
||||
'$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())],
|
||||
'$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), !DI::config()->isWritable('system', 'language') ? DI::l10n()->t("<strong>Read-only</strong> because it is set by an environment variable") : '', $lang_choices, !DI::config()->isWritable('system', 'language') ? 'disabled' : ''],
|
||||
'$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl() . '/admin/themes'), $theme_choices],
|
||||
'$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile],
|
||||
'$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')],
|
||||
'$show_help' => ['show_help', DI::l10n()->t('Show help entry from navigation menu'), !DI::config()->get('system', 'hide_help'), DI::l10n()->t('Displays the menu entry for the Help pages from the navigation menu. It is always accessible by calling /help directly.')],
|
||||
'$singleuser' => ['singleuser', DI::l10n()->t('Single user instance'), DI::config()->get('system', 'singleuser', '---'), DI::l10n()->t('Make this instance multi-user or single-user for the named user'), $user_names],
|
||||
|
||||
'$maximagesize' => ['maximagesize', DI::l10n()->t('Maximum image size'), DI::config()->get('system', 'maximagesize'), DI::l10n()->t('Maximum size in bytes of uploaded images. Default is 0, which means no limits. You can put k, m, or g behind the desired value for KiB, MiB, GiB, respectively.
|
||||
'$maximagesize' => ['maximagesize', DI::l10n()->t('Maximum image size'), DI::config()->get('system', 'maximagesize'), DI::l10n()->t('Maximum size in bytes of uploaded images. Default is 0, which means no limits. You can put k, m, or g behind the desired value for KiB, MiB, GiB, respectively.
|
||||
The value of <code>upload_max_filesize</code> in your <code>PHP.ini</code> needs be set to at least the desired limit.
|
||||
Currently <code>upload_max_filesize</code> is set to %s (%s byte)', Strings::formatBytes(Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))), Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))),
|
||||
'', 'pattern="\d+(?:\s*[kmg])?"'],
|
||||
'', 'pattern="\d+(?:\s*[kmg])?"'],
|
||||
'$maximagelength' => ['maximagelength', DI::l10n()->t('Maximum image length'), DI::config()->get('system', 'max_image_length'), DI::l10n()->t('Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.')],
|
||||
'$jpegimagequality' => ['jpegimagequality', DI::l10n()->t('JPEG image quality'), DI::config()->get('system', 'jpeg_quality'), DI::l10n()->t('Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.')],
|
||||
'$maxfilesize' => ['maxfilesize', DI::l10n()->t('Maximum media file size'), DI::config()->get('system', 'maxfilesize'), DI::l10n()->t('Maximum size in bytes of uploaded media files. Default is 0, which means no limits. You can put k, m, or g behind the desired value for KiB, MiB, GiB, respectively.
|
||||
The value of <code>upload_max_filesize</code> in your <code>PHP.ini</code> needs be set to at least the desired limit.
|
||||
Currently <code>upload_max_filesize</code> is set to %s (%s byte)', Strings::formatBytes(Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))), Strings::getBytesFromShorthand(ini_get('upload_max_filesize'))),
|
||||
'', 'pattern="\d+(?:\s*[kmg])?"'],
|
||||
'', 'pattern="\d+(?:\s*[kmg])?"'],
|
||||
|
||||
'$register_policy' => ['register_policy', DI::l10n()->t('Register policy'), DI::config()->get('config', 'register_policy'), '', $register_choices],
|
||||
'$max_registered_users' => ['max_registered_users', DI::l10n()->t('Maximum Users'), DI::config()->get('config', 'max_registered_users'), DI::l10n()->t('If defined, the register policy is automatically closed when the given number of users is reached and reopens the registry when the number drops below the limit. It only works when the policy is set to open or close, but not when the policy is set to approval.')],
|
||||
'$daily_registrations' => ['max_daily_registrations', DI::l10n()->t('Maximum Daily Registrations'), DI::config()->get('system', 'max_daily_registrations'), DI::l10n()->t('If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.')],
|
||||
'$register_text' => ['register_text', DI::l10n()->t('Register text'), DI::config()->get('config', 'register_text'), DI::l10n()->t('Will be displayed prominently on the registration page. You can use BBCode here.')],
|
||||
'$forbidden_nicknames' => ['forbidden_nicknames', DI::l10n()->t('Forbidden Nicknames'), DI::config()->get('system', 'forbidden_nicknames'), DI::l10n()->t('Comma separated list of nicknames that are forbidden from registration. Preset is a list of role names according RFC 2142.')],
|
||||
'$abandon_days' => ['abandon_days', DI::l10n()->t('Accounts abandoned after x days'), DI::config()->get('system', 'account_abandon_days'), DI::l10n()->t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
|
||||
'$allowed_sites' => ['allowed_sites', DI::l10n()->t('Allowed friend domains'), DI::config()->get('system', 'allowed_sites'), DI::l10n()->t('Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains')],
|
||||
'$allowed_email' => ['allowed_email', DI::l10n()->t('Allowed email domains'), DI::config()->get('system', 'allowed_email'), DI::l10n()->t('Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains')],
|
||||
'$disallowed_email' => ['disallowed_email', DI::l10n()->t('Disallowed email domains'), DI::config()->get('system', 'disallowed_email'), DI::l10n()->t('Comma separated list of domains which are rejected as email addresses for registrations to this site. Wildcards are accepted.')],
|
||||
'$no_oembed_rich_content' => ['no_oembed_rich_content', DI::l10n()->t('No OEmbed rich content'), DI::config()->get('system', 'no_oembed_rich_content'), DI::l10n()->t('Don\'t show the rich content (e.g. embedded PDF), except from the domains listed below.')],
|
||||
'$allowed_oembed' => ['allowed_oembed', DI::l10n()->t('Trusted third-party domains'), DI::config()->get('system', 'allowed_oembed'), DI::l10n()->t('Comma separated list of domains from which content is allowed to be embedded in posts like with OEmbed. All sub-domains of the listed domains are allowed as well.')],
|
||||
'$block_public' => ['block_public', DI::l10n()->t('Block public'), DI::config()->get('system', 'block_public'), DI::l10n()->t('Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.')],
|
||||
'$force_publish' => ['publish_all', DI::l10n()->t('Force publish'), DI::config()->get('system', 'publish_all'), DI::l10n()->t('Check to force all profiles on this site to be listed in the site directory.') . '<strong>' . DI::l10n()->t('Enabling this may violate privacy laws like the GDPR') . '</strong>'],
|
||||
'$global_directory' => ['directory', DI::l10n()->t('Global directory URL'), DI::config()->get('system', 'directory'), DI::l10n()->t('URL to the global directory. If this is not set, the global directory is completely unavailable to the application.')],
|
||||
'$newuser_private' => ['newuser_private', DI::l10n()->t('Private posts by default for new users'), DI::config()->get('system', 'newuser_private'), DI::l10n()->t('Set default post permissions for all new members to the default privacy circle rather than public.')],
|
||||
'$enotify_no_content' => ['enotify_no_content', DI::l10n()->t('Don\'t include post content in email notifications'), DI::config()->get('system', 'enotify_no_content'), DI::l10n()->t('Don\'t include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.')],
|
||||
'$private_addons' => ['private_addons', DI::l10n()->t('Disallow public access to addons listed in the apps menu.'), DI::config()->get('config', 'private_addons'), DI::l10n()->t('Checking this box will restrict addons listed in the apps menu to members only.')],
|
||||
'$disable_embedded' => ['disable_embedded', DI::l10n()->t('Don\'t embed private images in posts'), DI::config()->get('system', 'disable_embedded'), DI::l10n()->t('Don\'t replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.')],
|
||||
'$explicit_content' => ['explicit_content', DI::l10n()->t('Explicit Content'), DI::config()->get('system', 'explicit_content'), DI::l10n()->t('Set this to announce that your node is used mostly for explicit content that might not be suited for minors. This information will be published in the node information and might be used, e.g. by the global directory, to filter your node from listings of nodes to join. Additionally a note about this will be shown at the user registration page.')],
|
||||
'$local_search' => ['local_search', DI::l10n()->t('Only local search'), DI::config()->get('system', 'local_search'), DI::l10n()->t('Blocks search for users who are not logged in to prevent crawlers from blocking your system.')],
|
||||
'$blocked_tags' => ['blocked_tags', DI::l10n()->t('Blocked tags for trending tags'), DI::config()->get('system', 'blocked_tags'), DI::l10n()->t("Comma separated list of hashtags that shouldn't be displayed in the trending tags.")],
|
||||
'$cache_contact_avatar' => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
|
||||
'$allow_users_remote_self'=> ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
|
||||
'$allow_relay_channels' => ['allow_relay_channels', DI::l10n()->t('Allow Users to set up relay channels'), DI::config()->get('system', 'allow_relay_channels'), DI::l10n()->t('If enabled, it is possible to create relay users that are used to reshare content based on user defined channels.')],
|
||||
'$adjust_poll_frequency' => ['adjust_poll_frequency', DI::l10n()->t('Adjust the feed poll frequency'), DI::config()->get('system', 'adjust_poll_frequency'), DI::l10n()->t('Automatically detect and set the best feed poll frequency.')],
|
||||
'$min_poll_interval' => ['min_poll_interval', DI::l10n()->t('Minimum poll interval'), DI::config()->get('system', 'min_poll_interval'), DI::l10n()->t('Minimal distance in minutes between two polls for mail and feed contacts. Reasonable values are between 1 and 59.')],
|
||||
'$enable_multi_reg' => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
|
||||
'$enable_openid' => ['enable_openid', DI::l10n()->t('Enable OpenID'), !DI::config()->get('system', 'no_openid'), DI::l10n()->t('Enable OpenID support for registration and logins.')],
|
||||
'$enable_regfullname' => ['enable_regfullname', DI::l10n()->t('Enable full name check'), !DI::config()->get('system', 'no_regfullname'), DI::l10n()->t('Prevents users from registering with a display name with fewer than two parts separated by spaces.')],
|
||||
'$register_notification' => ['register_notification', DI::l10n()->t('Email administrators on new registration'), DI::config()->get('system', 'register_notification'), DI::l10n()->t('If enabled and the system is set to an open registration, an email for each new registration is sent to the administrators.')],
|
||||
'$community_page_style' => ['community_page_style', DI::l10n()->t('Community pages for visitors'), DI::config()->get('system', 'community_page_style'), DI::l10n()->t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices],
|
||||
'$register_policy' => ['register_policy', DI::l10n()->t('Register policy'), DI::config()->get('config', 'register_policy'), '', $register_choices],
|
||||
'$max_registered_users' => ['max_registered_users', DI::l10n()->t('Maximum Users'), DI::config()->get('config', 'max_registered_users'), DI::l10n()->t('If defined, the register policy is automatically closed when the given number of users is reached and reopens the registry when the number drops below the limit. It only works when the policy is set to open or close, but not when the policy is set to approval.')],
|
||||
'$daily_registrations' => ['max_daily_registrations', DI::l10n()->t('Maximum Daily Registrations'), DI::config()->get('system', 'max_daily_registrations'), DI::l10n()->t('If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.')],
|
||||
'$register_text' => ['register_text', DI::l10n()->t('Register text'), DI::config()->get('config', 'register_text'), DI::l10n()->t('Will be displayed prominently on the registration page. You can use BBCode here.')],
|
||||
'$forbidden_nicknames' => ['forbidden_nicknames', DI::l10n()->t('Forbidden Nicknames'), DI::config()->get('system', 'forbidden_nicknames'), DI::l10n()->t('Comma separated list of nicknames that are forbidden from registration. Preset is a list of role names according RFC 2142.')],
|
||||
'$abandon_days' => ['abandon_days', DI::l10n()->t('Accounts abandoned after x days'), DI::config()->get('system', 'account_abandon_days'), DI::l10n()->t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
|
||||
'$allowed_sites' => ['allowed_sites', DI::l10n()->t('Allowed friend domains'), DI::config()->get('system', 'allowed_sites'), DI::l10n()->t('Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains')],
|
||||
'$allowed_email' => ['allowed_email', DI::l10n()->t('Allowed email domains'), DI::config()->get('system', 'allowed_email'), DI::l10n()->t('Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains')],
|
||||
'$disallowed_email' => ['disallowed_email', DI::l10n()->t('Disallowed email domains'), DI::config()->get('system', 'disallowed_email'), DI::l10n()->t('Comma separated list of domains which are rejected as email addresses for registrations to this site. Wildcards are accepted.')],
|
||||
'$no_oembed_rich_content' => ['no_oembed_rich_content', DI::l10n()->t('No OEmbed rich content'), DI::config()->get('system', 'no_oembed_rich_content'), DI::l10n()->t('Don\'t show the rich content (e.g. embedded PDF), except from the domains listed below.')],
|
||||
'$allowed_oembed' => ['allowed_oembed', DI::l10n()->t('Trusted third-party domains'), DI::config()->get('system', 'allowed_oembed'), DI::l10n()->t('Comma separated list of domains from which content is allowed to be embedded in posts like with OEmbed. All sub-domains of the listed domains are allowed as well.')],
|
||||
'$block_public' => ['block_public', DI::l10n()->t('Block public'), DI::config()->get('system', 'block_public'), DI::l10n()->t('Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.')],
|
||||
'$force_publish' => ['publish_all', DI::l10n()->t('Force publish'), DI::config()->get('system', 'publish_all'), DI::l10n()->t('Check to force all profiles on this site to be listed in the site directory.') . '<strong>' . DI::l10n()->t('Enabling this may violate privacy laws like the GDPR') . '</strong>'],
|
||||
'$global_directory' => ['directory', DI::l10n()->t('Global directory URL'), DI::config()->get('system', 'directory'), DI::l10n()->t('URL to the global directory. If this is not set, the global directory is completely unavailable to the application.')],
|
||||
'$newuser_private' => ['newuser_private', DI::l10n()->t('Private posts by default for new users'), DI::config()->get('system', 'newuser_private'), DI::l10n()->t('Set default post permissions for all new members to the default privacy circle rather than public.')],
|
||||
'$enotify_no_content' => ['enotify_no_content', DI::l10n()->t('Don\'t include post content in email notifications'), DI::config()->get('system', 'enotify_no_content'), DI::l10n()->t('Don\'t include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.')],
|
||||
'$private_addons' => ['private_addons', DI::l10n()->t('Disallow public access to addons listed in the apps menu.'), DI::config()->get('config', 'private_addons'), DI::l10n()->t('Checking this box will restrict addons listed in the apps menu to members only.')],
|
||||
'$disable_embedded' => ['disable_embedded', DI::l10n()->t('Don\'t embed private images in posts'), DI::config()->get('system', 'disable_embedded'), DI::l10n()->t('Don\'t replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.')],
|
||||
'$explicit_content' => ['explicit_content', DI::l10n()->t('Explicit Content'), DI::config()->get('system', 'explicit_content'), DI::l10n()->t('Set this to announce that your node is used mostly for explicit content that might not be suited for minors. This information will be published in the node information and might be used, e.g. by the global directory, to filter your node from listings of nodes to join. Additionally a note about this will be shown at the user registration page.')],
|
||||
'$local_search' => ['local_search', DI::l10n()->t('Only local search'), DI::config()->get('system', 'local_search'), DI::l10n()->t('Blocks search for users who are not logged in to prevent crawlers from blocking your system.')],
|
||||
'$blocked_tags' => ['blocked_tags', DI::l10n()->t('Blocked tags for trending tags'), DI::config()->get('system', 'blocked_tags'), DI::l10n()->t("Comma separated list of hashtags that shouldn't be displayed in the trending tags.")],
|
||||
'$cache_contact_avatar' => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
|
||||
'$allow_users_remote_self' => ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
|
||||
'$allow_relay_channels' => ['allow_relay_channels', DI::l10n()->t('Allow Users to set up relay channels'), DI::config()->get('system', 'allow_relay_channels'), DI::l10n()->t('If enabled, it is possible to create relay users that are used to reshare content based on user defined channels.')],
|
||||
'$adjust_poll_frequency' => ['adjust_poll_frequency', DI::l10n()->t('Adjust the feed poll frequency'), DI::config()->get('system', 'adjust_poll_frequency'), DI::l10n()->t('Automatically detect and set the best feed poll frequency.')],
|
||||
'$min_poll_interval' => ['min_poll_interval', DI::l10n()->t('Minimum poll interval'), DI::config()->get('system', 'min_poll_interval'), DI::l10n()->t('Minimal distance in minutes between two polls for mail and feed contacts. Reasonable values are between 1 and 59.')],
|
||||
'$enable_multi_reg' => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
|
||||
'$enable_openid' => ['enable_openid', DI::l10n()->t('Enable OpenID'), !DI::config()->get('system', 'no_openid'), DI::l10n()->t('Enable OpenID support for registration and logins.')],
|
||||
'$enable_regfullname' => ['enable_regfullname', DI::l10n()->t('Enable full name check'), !DI::config()->get('system', 'no_regfullname'), DI::l10n()->t('Prevents users from registering with a display name with fewer than two parts separated by spaces.')],
|
||||
'$register_notification' => ['register_notification', DI::l10n()->t('Email administrators on new registration'), DI::config()->get('system', 'register_notification'), DI::l10n()->t('If enabled and the system is set to an open registration, an email for each new registration is sent to the administrators.')],
|
||||
'$community_page_style' => ['community_page_style', DI::l10n()->t('Community pages for visitors'), DI::config()->get('system', 'community_page_style'), DI::l10n()->t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices],
|
||||
'$max_author_posts_community_page' => ['max_author_posts_community_page', DI::l10n()->t('Posts per user on community page'), DI::config()->get('system', 'max_author_posts_community_page'), DI::l10n()->t('The maximum number of posts per user on the local community page. This is useful, when a single user floods the local community page.')],
|
||||
'$max_server_posts_community_page' => ['max_server_posts_community_page', DI::l10n()->t('Posts per server on community page'), DI::config()->get('system', 'max_server_posts_community_page'), DI::l10n()->t('The maximum number of posts per server on the global community page. This is useful, when posts from a single server flood the global community page.')],
|
||||
'$mail_able' => function_exists('imap_open'),
|
||||
'$mail_enabled' => ['mail_enabled', DI::l10n()->t('Enable Mail support'), !DI::config()->get('system', 'imap_disabled', !function_exists('imap_open')), DI::l10n()->t('Enable built-in mail support to poll IMAP folders and to reply via mail.')],
|
||||
'$mail_not_able' => DI::l10n()->t('Mail support can\'t be enabled because the PHP IMAP module is not installed.'),
|
||||
'$diaspora_able' => $diaspora_able,
|
||||
'$diaspora_not_able' => DI::l10n()->t('Diaspora support can\'t be enabled because Friendica was installed into a sub directory.'),
|
||||
'$diaspora_enabled' => ['diaspora_enabled', DI::l10n()->t('Enable Diaspora support'), DI::config()->get('system', 'diaspora_enabled', $diaspora_able), DI::l10n()->t('Enable built-in Diaspora network compatibility for communicating with diaspora servers.')],
|
||||
'$verifyssl' => ['verifyssl', DI::l10n()->t('Verify SSL'), DI::config()->get('system', 'verifyssl'), DI::l10n()->t('If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.')],
|
||||
'$proxyuser' => ['proxyuser', DI::l10n()->t('Proxy user'), DI::config()->get('system', 'proxyuser'), DI::l10n()->t('User name for the proxy server.')],
|
||||
'$proxy' => ['proxy', DI::l10n()->t('Proxy URL'), DI::config()->get('system', 'proxy'), DI::l10n()->t('If you want to use a proxy server that Friendica should use to connect to the network, put the URL of the proxy here.')],
|
||||
'$timeout' => ['timeout', DI::l10n()->t('Network timeout'), DI::config()->get('system', 'curl_timeout'), DI::l10n()->t('Value is in seconds. Set to 0 for unlimited (not recommended).')],
|
||||
'$maxloadavg' => ['maxloadavg', DI::l10n()->t('Maximum Load Average'), DI::config()->get('system', 'maxloadavg'), DI::l10n()->t('Maximum system load before delivery and poll processes are deferred - default %d.', 20)],
|
||||
'$min_memory' => ['min_memory', DI::l10n()->t('Minimal Memory'), DI::config()->get('system', 'min_memory'), DI::l10n()->t('Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).')],
|
||||
'$optimize_tables' => ['optimize_tables', DI::l10n()->t('Periodically optimize tables'), DI::config()->get('system', 'optimize_tables'), DI::l10n()->t('Periodically optimize tables like the cache and the workerqueue')],
|
||||
'$mail_able' => function_exists('imap_open'),
|
||||
'$mail_enabled' => ['mail_enabled', DI::l10n()->t('Enable Mail support'), !DI::config()->get('system', 'imap_disabled', !function_exists('imap_open')), DI::l10n()->t('Enable built-in mail support to poll IMAP folders and to reply via mail.')],
|
||||
'$mail_not_able' => DI::l10n()->t('Mail support can\'t be enabled because the PHP IMAP module is not installed.'),
|
||||
'$diaspora_able' => $diaspora_able,
|
||||
'$diaspora_not_able' => DI::l10n()->t('Diaspora support can\'t be enabled because Friendica was installed into a sub directory.'),
|
||||
'$diaspora_enabled' => ['diaspora_enabled', DI::l10n()->t('Enable Diaspora support'), DI::config()->get('system', 'diaspora_enabled', $diaspora_able), DI::l10n()->t('Enable built-in Diaspora network compatibility for communicating with diaspora servers.')],
|
||||
'$verifyssl' => ['verifyssl', DI::l10n()->t('Verify SSL'), DI::config()->get('system', 'verifyssl'), DI::l10n()->t('If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.')],
|
||||
'$proxyuser' => ['proxyuser', DI::l10n()->t('Proxy user'), DI::config()->get('system', 'proxyuser'), DI::l10n()->t('User name for the proxy server.')],
|
||||
'$proxy' => ['proxy', DI::l10n()->t('Proxy URL'), DI::config()->get('system', 'proxy'), DI::l10n()->t('If you want to use a proxy server that Friendica should use to connect to the network, put the URL of the proxy here.')],
|
||||
'$timeout' => ['timeout', DI::l10n()->t('Network timeout'), DI::config()->get('system', 'curl_timeout'), DI::l10n()->t('Value is in seconds. Set to 0 for unlimited (not recommended).')],
|
||||
'$maxloadavg' => ['maxloadavg', DI::l10n()->t('Maximum Load Average'), DI::config()->get('system', 'maxloadavg'), DI::l10n()->t('Maximum system load before delivery and poll processes are deferred - default %d.', 20)],
|
||||
'$min_memory' => ['min_memory', DI::l10n()->t('Minimal Memory'), DI::config()->get('system', 'min_memory'), DI::l10n()->t('Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).')],
|
||||
'$optimize_tables' => ['optimize_tables', DI::l10n()->t('Periodically optimize tables'), DI::config()->get('system', 'optimize_tables'), DI::l10n()->t('Periodically optimize tables like the cache and the workerqueue')],
|
||||
|
||||
'$contact_discovery' => ['contact_discovery', DI::l10n()->t('Discover followers/followings from contacts'), DI::config()->get('system', 'contact_discovery'), DI::l10n()->t('If enabled, contacts are checked for their followers and following contacts.') . '<ul>' .
|
||||
'$contact_discovery' => ['contact_discovery', DI::l10n()->t('Discover followers/followings from contacts'), DI::config()->get('system', 'contact_discovery'), DI::l10n()->t('If enabled, contacts are checked for their followers and following contacts.') . '<ul>' .
|
||||
'<li>' . DI::l10n()->t('None - deactivated') . '</li>' .
|
||||
'<li>' . DI::l10n()->t('Local contacts - contacts of our local contacts are discovered for their followers/followings.') . '</li>' .
|
||||
'<li>' . DI::l10n()->t('Interactors - contacts of our local contacts and contacts who interacted on locally visible postings are discovered for their followers/followings.') . '</li></ul>',
|
||||
$discovery_choices],
|
||||
'$update_active_contacts' => ['update_active_contacts', DI::l10n()->t('Only update contacts/servers with local data'), DI::config()->get('system', 'update_active_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts and servers that engaged on this system by either being in a contact list of a user or when posts or comments exists from the contact on this system.')],
|
||||
'$update_active_contacts' => ['update_active_contacts', DI::l10n()->t('Only update contacts/servers with local data'), DI::config()->get('system', 'update_active_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts and servers that engaged on this system by either being in a contact list of a user or when posts or comments exists from the contact on this system.')],
|
||||
'$update_known_contacts' => ['update_known_contacts', DI::l10n()->t('Only update contacts with relations'), DI::config()->get('system', 'update_known_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts that are in a contact list of a user on this system.')],
|
||||
'$synchronize_directory' => ['synchronize_directory', DI::l10n()->t('Synchronize the contacts with the directory server'), DI::config()->get('system', 'synchronize_directory'), DI::l10n()->t('if enabled, the system will check periodically for new contacts on the defined directory server.')],
|
||||
|
||||
'$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts and servers that they know of. The system queries Friendica, Mastodon and Hubzilla servers. Keep it deactivated on small machines to decrease the database size and load.')],
|
||||
'$poco_requery_days' => ['poco_requery_days', DI::l10n()->t('Days between requery'), DI::config()->get('system', 'poco_requery_days'), DI::l10n()->t('Number of days after which a server is requeried for their contacts and servers it knows of. This is only used when the discovery is activated.')],
|
||||
'$poco_local_search' => ['poco_local_search', DI::l10n()->t('Search the local directory'), DI::config()->get('system', 'poco_local_search'), DI::l10n()->t('Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.')],
|
||||
'$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts and servers that they know of. The system queries Friendica, Mastodon and Hubzilla servers. Keep it deactivated on small machines to decrease the database size and load.')],
|
||||
'$poco_requery_days' => ['poco_requery_days', DI::l10n()->t('Days between requery'), DI::config()->get('system', 'poco_requery_days'), DI::l10n()->t('Number of days after which a server is requeried for their contacts and servers it knows of. This is only used when the discovery is activated.')],
|
||||
'$poco_local_search' => ['poco_local_search', DI::l10n()->t('Search the local directory'), DI::config()->get('system', 'poco_local_search'), DI::l10n()->t('Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.')],
|
||||
|
||||
'$nodeinfo' => ['nodeinfo', DI::l10n()->t('Publish server information'), DI::config()->get('system', 'nodeinfo'), DI::l10n()->t('If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href="http://the-federation.info/">the-federation.info</a> for details.')],
|
||||
'$nodeinfo' => ['nodeinfo', DI::l10n()->t('Publish server information'), DI::config()->get('system', 'nodeinfo'), DI::l10n()->t('If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href="http://the-federation.info/">the-federation.info</a> for details.')],
|
||||
|
||||
'$check_new_version_url' => ['check_new_version_url', DI::l10n()->t('Check upstream version'), DI::config()->get('system', 'check_new_version_url'), DI::l10n()->t('Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview.'), $check_git_version_choices],
|
||||
'$suppress_tags' => ['suppress_tags', DI::l10n()->t('Suppress Tags'), DI::config()->get('system', 'suppress_tags'), DI::l10n()->t('Suppress showing a list of hashtags at the end of the posting.')],
|
||||
'$dbclean' => ['dbclean', DI::l10n()->t('Clean database'), DI::config()->get('system', 'dbclean'), DI::l10n()->t('Remove old remote items, orphaned database records and old content from some other helper tables.')],
|
||||
'$dbclean_expire_days' => ['dbclean_expire_days', DI::l10n()->t('Lifespan of remote items'), DI::config()->get('system', 'dbclean-expire-days'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which remote items will be deleted. Own items, and marked or filed items are always kept. 0 disables this behaviour.')],
|
||||
'$dbclean_unclaimed' => ['dbclean_unclaimed', DI::l10n()->t('Lifespan of unclaimed items'), DI::config()->get('system', 'dbclean-expire-unclaimed'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which unclaimed remote items (mostly content from the relay) will be deleted. Default value is 90 days. Defaults to the general lifespan value of remote items if set to 0.')],
|
||||
'$dbclean_expire_conv' => ['dbclean_expire_conv', DI::l10n()->t('Lifespan of raw conversation data'), DI::config()->get('system', 'dbclean_expire_conversation'), DI::l10n()->t('The conversation data is used for ActivityPub, as well as for debug purposes. It should be safe to remove it after 14 days, default is 90 days.')],
|
||||
'$max_comments' => ['max_comments', DI::l10n()->t('Maximum numbers of comments per post'), DI::config()->get('system', 'max_comments'), DI::l10n()->t('How much comments should be shown for each post? Default value is 100.')],
|
||||
'$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
|
||||
'$itemspage_network' => ['itemspage_network', DI::l10n()->t('Items per page'), DI::config()->get('system', 'itemspage_network'), DI::l10n()->t('Number of items per page in stream pages (network, community, profile/contact statuses, search).')],
|
||||
'$check_new_version_url' => ['check_new_version_url', DI::l10n()->t('Check upstream version'), DI::config()->get('system', 'check_new_version_url'), DI::l10n()->t('Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview.'), $check_git_version_choices],
|
||||
'$suppress_tags' => ['suppress_tags', DI::l10n()->t('Suppress Tags'), DI::config()->get('system', 'suppress_tags'), DI::l10n()->t('Suppress showing a list of hashtags at the end of the posting.')],
|
||||
'$dbclean' => ['dbclean', DI::l10n()->t('Clean database'), DI::config()->get('system', 'dbclean'), DI::l10n()->t('Remove old remote items, orphaned database records and old content from some other helper tables.')],
|
||||
'$dbclean_expire_days' => ['dbclean_expire_days', DI::l10n()->t('Lifespan of remote items'), DI::config()->get('system', 'dbclean-expire-days'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which remote items will be deleted. Own items, and marked or filed items are always kept. 0 disables this behaviour.')],
|
||||
'$dbclean_unclaimed' => ['dbclean_unclaimed', DI::l10n()->t('Lifespan of unclaimed items'), DI::config()->get('system', 'dbclean-expire-unclaimed'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which unclaimed remote items (mostly content from the relay) will be deleted. Default value is 90 days. Defaults to the general lifespan value of remote items if set to 0.')],
|
||||
'$dbclean_expire_conv' => ['dbclean_expire_conv', DI::l10n()->t('Lifespan of raw conversation data'), DI::config()->get('system', 'dbclean_expire_conversation'), DI::l10n()->t('The conversation data is used for ActivityPub, as well as for debug purposes. It should be safe to remove it after 14 days, default is 90 days.')],
|
||||
'$max_comments' => ['max_comments', DI::l10n()->t('Maximum numbers of comments per post'), DI::config()->get('system', 'max_comments'), DI::l10n()->t('How much comments should be shown for each post? Default value is 100.')],
|
||||
'$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
|
||||
'$itemspage_network' => ['itemspage_network', DI::l10n()->t('Items per page'), DI::config()->get('system', 'itemspage_network'), DI::l10n()->t('Number of items per page in stream pages (network, community, profile/contact statuses, search).')],
|
||||
'$itemspage_network_mobile' => ['itemspage_network_mobile', DI::l10n()->t('Items per page for mobile devices'), DI::config()->get('system', 'itemspage_network_mobile'), DI::l10n()->t('Number of items per page in stream pages (network, community, profile/contact statuses, search) for mobile devices.')],
|
||||
'$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
|
||||
'$only_tag_search' => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
|
||||
'$limited_search_scope' => ['limited_search_scope', DI::l10n()->t('Limited search scope'), DI::config()->get('system', 'limited_search_scope'), DI::l10n()->t('If enabled, searches will only be performed in the data used for the channels and not in all posts.')],
|
||||
'$search_age_days' => ['search_age_days', DI::l10n()->t('Maximum age of items in the search table'), DI::config()->get('system', 'search_age_days'), DI::l10n()->t('Maximum age of items in the search table in days. Lower values will increase the performance and reduce disk usage. 0 means no age restriction.')],
|
||||
'$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')],
|
||||
'$process_view' => ['process_view', DI::l10n()->t('Process "view" activities'), DI::config()->get('system', 'process_view'), DI::l10n()->t('"view" activities are mostly geberated by Peertube systems. Per default they are not processed for performance reasons. Only activate this option on performant system.')],
|
||||
'$archival_days' => ['archival_days', DI::l10n()->t('Days, after which a contact is archived'), DI::config()->get('system', 'archival_days'), DI::l10n()->t('Number of days that we try to deliver content or to update the contact data before we archive a contact.')],
|
||||
'$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
|
||||
'$only_tag_search' => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
|
||||
'$limited_search_scope' => ['limited_search_scope', DI::l10n()->t('Limited search scope'), DI::config()->get('system', 'limited_search_scope'), DI::l10n()->t('If enabled, searches will only be performed in the data used for the channels and not in all posts.')],
|
||||
'$search_age_days' => ['search_age_days', DI::l10n()->t('Maximum age of items in the search table'), DI::config()->get('system', 'search_age_days'), DI::l10n()->t('Maximum age of items in the search table in days. Lower values will increase the performance and reduce disk usage. 0 means no age restriction.')],
|
||||
'$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')],
|
||||
'$process_view' => ['process_view', DI::l10n()->t('Process "view" activities'), DI::config()->get('system', 'process_view'), DI::l10n()->t('"view" activities are mostly geberated by Peertube systems. Per default they are not processed for performance reasons. Only activate this option on performant system.')],
|
||||
'$archival_days' => ['archival_days', DI::l10n()->t('Days, after which a contact is archived'), DI::config()->get('system', 'archival_days'), DI::l10n()->t('Number of days that we try to deliver content or to update the contact data before we archive a contact.')],
|
||||
|
||||
'$worker_queues' => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
|
||||
'$worker_load_cooldown' => ['worker_load_cooldown', DI::l10n()->t('Maximum load for workers'), DI::config()->get('system', 'worker_load_cooldown'), DI::l10n()->t('Maximum load that causes a cooldown before each worker function call.')],
|
||||
'$worker_fastlane' => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
|
||||
'$decoupled_receiver' => ['decoupled_receiver', DI::l10n()->t('Decoupled receiver'), DI::config()->get('system', 'decoupled_receiver'), DI::l10n()->t('Decouple incoming ActivityPub posts by processing them in the background via a worker process. Only enable this on fast systems.')],
|
||||
'$cron_interval' => ['cron_interval', DI::l10n()->t('Cron interval'), DI::config()->get('system', 'cron_interval'), DI::l10n()->t('Minimal period in minutes between two calls of the "Cron" worker job.')],
|
||||
'$worker_defer_limit' => ['worker_defer_limit', DI::l10n()->t('Worker defer limit'), DI::config()->get('system', 'worker_defer_limit'), DI::l10n()->t('Per default the systems tries delivering for 15 times before dropping it.')],
|
||||
'$worker_fetch_limit' => ['worker_fetch_limit', DI::l10n()->t('Worker fetch limit'), DI::config()->get('system', 'worker_fetch_limit'), DI::l10n()->t('Number of worker tasks that are fetched in a single query. Higher values should increase the performance, too high values will mostly likely decrease it. Only change it, when you know how to measure the performance of your system.')],
|
||||
'$worker_queues' => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
|
||||
'$worker_load_cooldown' => ['worker_load_cooldown', DI::l10n()->t('Maximum load for workers'), DI::config()->get('system', 'worker_load_cooldown'), DI::l10n()->t('Maximum load that causes a cooldown before each worker function call.')],
|
||||
'$worker_fastlane' => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
|
||||
'$decoupled_receiver' => ['decoupled_receiver', DI::l10n()->t('Decoupled receiver'), DI::config()->get('system', 'decoupled_receiver'), DI::l10n()->t('Decouple incoming ActivityPub posts by processing them in the background via a worker process. Only enable this on fast systems.')],
|
||||
'$cron_interval' => ['cron_interval', DI::l10n()->t('Cron interval'), DI::config()->get('system', 'cron_interval'), DI::l10n()->t('Minimal period in minutes between two calls of the "Cron" worker job.')],
|
||||
'$worker_defer_limit' => ['worker_defer_limit', DI::l10n()->t('Worker defer limit'), DI::config()->get('system', 'worker_defer_limit'), DI::l10n()->t('Per default the systems tries delivering for 15 times before dropping it.')],
|
||||
'$worker_fetch_limit' => ['worker_fetch_limit', DI::l10n()->t('Worker fetch limit'), DI::config()->get('system', 'worker_fetch_limit'), DI::l10n()->t('Number of worker tasks that are fetched in a single query. Higher values should increase the performance, too high values will mostly likely decrease it. Only change it, when you know how to measure the performance of your system.')],
|
||||
|
||||
'$relay_directly' => ['relay_directly', DI::l10n()->t('Direct relay transfer'), DI::config()->get('system', 'relay_directly'), DI::l10n()->t('Enables the direct transfer to other servers without using the relay servers')],
|
||||
'$relay_scope' => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [Relay::SCOPE_NONE => DI::l10n()->t('Disabled'), Relay::SCOPE_ALL => DI::l10n()->t('all'), Relay::SCOPE_TAGS => DI::l10n()->t('tags')]],
|
||||
|
@ -596,8 +596,8 @@ class Site extends BaseAdmin
|
|||
'$max_posts_per_author' => ['max_posts_per_author', DI::l10n()->t('Maximum number of posts per author'), DI::config()->get('channel', 'max_posts_per_author'), DI::l10n()->t('Maximum number of posts per page by author if the contact frequency is set to "Display only few posts". If there are more posts, then the post with the most interactions will be displayed.')],
|
||||
'$sharer_interaction_days' => ['sharer_interaction_days', DI::l10n()->t('Sharer interaction days'), DI::config()->get('channel', 'sharer_interaction_days'), DI::l10n()->t('Number of days of the last interaction that are used to define which sharers are used for the "sharers of sharers" channel.')],
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_site'),
|
||||
'$relocate_button' => DI::l10n()->t('Start Relocation'),
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_site'),
|
||||
'$relocate_button' => DI::l10n()->t('Start Relocation'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\GNUSocial\Statusnet;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
|
@ -40,7 +39,7 @@ class Conversation extends BaseApi
|
|||
$id = $this->getRequestValue($request, 'id', 0);
|
||||
}
|
||||
|
||||
Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
|
||||
$this->logger->info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
|
||||
|
||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||
$item = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Conversation;
|
||||
|
@ -62,14 +60,14 @@ class Statuses extends BaseApi
|
|||
} elseif (!$uid) {
|
||||
$condition = [
|
||||
'author-id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'uid' => 0, 'network' => Protocol::FEDERATED
|
||||
'uid' => 0, 'network' => Protocol::FEDERATED
|
||||
];
|
||||
} else {
|
||||
$condition = ["`author-id` = ? AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))", $id, $uid];
|
||||
}
|
||||
|
||||
$condition = $this->addPagingConditions($request, $condition);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
|
||||
if (!$request['pinned'] && !$request['only_media']) {
|
||||
if ($request['exclude_replies']) {
|
||||
|
@ -100,11 +98,11 @@ class Statuses extends BaseApi
|
|||
$statuses = [];
|
||||
while ($item = Post::fetch($items)) {
|
||||
try {
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$this->updateBoundaries($status, $item, $request['friendica_order']);
|
||||
$statuses[] = $status;
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
|
@ -71,9 +70,9 @@ class UpdateCredentials extends BaseApi
|
|||
$profile['about'] = $request['note'];
|
||||
}
|
||||
|
||||
Logger::debug('Patch data', ['data' => $request, 'files' => $_FILES]);
|
||||
$this->logger->debug('Patch data', ['data' => $request, 'files' => $_FILES]);
|
||||
|
||||
Logger::info('Update profile and user', ['uid' => $uid, 'user' => $user, 'profile' => $profile]);
|
||||
$this->logger->info('Update profile and user', ['uid' => $uid, 'user' => $user, 'profile' => $profile]);
|
||||
|
||||
if (!empty($request['avatar'])) {
|
||||
Photo::uploadAvatar($uid, $request['avatar']);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -64,7 +62,7 @@ class Bookmarks extends BaseApi
|
|||
try {
|
||||
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
@ -34,18 +32,18 @@ class Directory extends BaseApi
|
|||
'local' => false, // Only return local accounts.
|
||||
], $request);
|
||||
|
||||
Logger::info('directory', ['offset' => $request['offset'], 'limit' => $request['limit'], 'order' => $request['order'], 'local' => $request['local']]);
|
||||
$this->logger->info('directory', ['offset' => $request['offset'], 'limit' => $request['limit'], 'order' => $request['order'], 'local' => $request['local']]);
|
||||
|
||||
if ($request['local']) {
|
||||
$table = 'owner-view';
|
||||
$table = 'owner-view';
|
||||
$condition = ['net-publish' => true];
|
||||
} else {
|
||||
$table = 'contact';
|
||||
$table = 'contact';
|
||||
$condition = ['uid' => 0, 'hidden' => false, 'network' => Protocol::FEDERATED];
|
||||
}
|
||||
|
||||
$params = ['limit' => [$request['offset'], $request['limit']],
|
||||
'order' => [($request['order'] == 'active') ? 'last-item' : 'created' => true]];
|
||||
'order' => [($request['order'] == 'active') ? 'last-item' : 'created' => true]];
|
||||
|
||||
$accounts = [];
|
||||
$contacts = DBA::select($table, ['id', 'uid'], $condition, $params);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -66,7 +64,7 @@ class Favourited extends BaseApi
|
|||
try {
|
||||
$statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Attach;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -33,10 +32,10 @@ class Media extends BaseApi
|
|||
'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0
|
||||
], $request);
|
||||
|
||||
Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]);
|
||||
$this->logger->info('Photo post', ['request' => $request, 'files' => $_FILES]);
|
||||
|
||||
if (empty($request['file'])) {
|
||||
Logger::notice('Upload is invalid', ['request' => $request]);
|
||||
$this->logger->notice('Upload is invalid', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ class Media extends BaseApi
|
|||
if (in_array($type, [Post\Media::IMAGE, Post\Media::UNKNOWN, Post\Media::APPLICATION])) {
|
||||
$media = Photo::upload($uid, $request['file'], '', null, null, '', '', $request['description']);
|
||||
if (!empty($media)) {
|
||||
Logger::info('Uploaded photo', ['media' => $media]);
|
||||
$this->logger->info('Uploaded photo', ['media' => $media]);
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
||||
} elseif ($type == Post\Media::IMAGE) {
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
|
||||
|
@ -58,20 +57,20 @@ class Media extends BaseApi
|
|||
$maxFileSize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maxfilesize'));
|
||||
|
||||
if ($fileSize <= 0) {
|
||||
Logger::notice('Filesize is invalid', ['size' => $fileSize, 'request' => $request]);
|
||||
$this->logger->notice('Filesize is invalid', ['size' => $fileSize, 'request' => $request]);
|
||||
@unlink($tempFileName);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if ($maxFileSize && $fileSize > $maxFileSize) {
|
||||
Logger::notice('Filesize is too large', ['size' => $fileSize, 'max' => $maxFileSize, 'request' => $request]);
|
||||
$this->logger->notice('Filesize is too large', ['size' => $fileSize, 'max' => $maxFileSize, 'request' => $request]);
|
||||
@unlink($tempFileName);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = Attach::storeFile($tempFileName, self::getCurrentUserID(), $fileName, $request['file']['type'], '<' . Contact::getPublicIdByUserId(self::getCurrentUserID()) . '>');
|
||||
@unlink($tempFileName);
|
||||
Logger::info('Uploaded media', ['id' => $id]);
|
||||
$this->logger->info('Uploaded media', ['id' => $id]);
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromAttach($id));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -54,27 +53,27 @@ class Search extends BaseApi
|
|||
$result = ['accounts' => [], 'statuses' => [], 'hashtags' => []];
|
||||
|
||||
if (empty($request['type']) || ($request['type'] == 'accounts')) {
|
||||
$result['accounts'] = self::searchAccounts($uid, $request['q'], $request['resolve'], $limit, $request['offset'], $request['following']);
|
||||
$result['accounts'] = $this->searchAccounts($uid, $request['q'], $request['resolve'], $limit, $request['offset'], $request['following']);
|
||||
|
||||
if (!is_array($result['accounts'])) {
|
||||
// Curbing the search if we got an exact result
|
||||
$request['type'] = 'accounts';
|
||||
$request['type'] = 'accounts';
|
||||
$result['accounts'] = [$result['accounts']];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($request['type']) || ($request['type'] == 'statuses')) {
|
||||
$result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
|
||||
$result['statuses'] = $this->searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
|
||||
|
||||
if (!is_array($result['statuses'])) {
|
||||
// Curbing the search if we got an exact result
|
||||
$request['type'] = 'statuses';
|
||||
$request['type'] = 'statuses';
|
||||
$result['statuses'] = [$result['statuses']];
|
||||
}
|
||||
}
|
||||
|
||||
if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) {
|
||||
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
|
||||
$result['hashtags'] = $this->searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
|
||||
}
|
||||
|
||||
$this->jsonExit($result);
|
||||
|
@ -92,7 +91,7 @@ class Search extends BaseApi
|
|||
* @throws \Friendica\Network\HTTPException\NotFoundException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function searchAccounts(int $uid, string $q, bool $resolve, int $limit, int $offset, bool $following)
|
||||
private function searchAccounts(int $uid, string $q, bool $resolve, int $limit, int $offset, bool $following)
|
||||
{
|
||||
if (($offset == 0) && (strrpos($q, '@') > 0 || Network::isValidHttpUrl($q))
|
||||
&& $id = Contact::getIdForURL($q, 0, $resolve ? null : false)
|
||||
|
@ -121,7 +120,7 @@ class Search extends BaseApi
|
|||
* @throws \Friendica\Network\HTTPException\NotFoundException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function searchStatuses(int $uid, string $q, string $account_id, int $max_id, int $min_id, int $limit, int $offset)
|
||||
private function searchStatuses(int $uid, string $q, string $account_id, int $max_id, int $min_id, int $limit, int $offset)
|
||||
{
|
||||
if (Network::isValidHttpUrl($q)) {
|
||||
// Unique post search, any offset greater than 0 should return empty result
|
||||
|
@ -144,9 +143,9 @@ class Search extends BaseApi
|
|||
substr($q, 1), 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, $uid, 0];
|
||||
$table = 'tag-search-view';
|
||||
} else {
|
||||
$q = Post\Engagement::escapeKeywords($q);
|
||||
$q = Post\Engagement::escapeKeywords($q);
|
||||
$condition = ["MATCH (`searchtext`) AGAINST (? IN BOOLEAN MODE) AND (NOT `restricted` OR `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `uid` = ?))", $q, $uid];
|
||||
$table = SearchIndex::getSearchTable();
|
||||
$table = SearchIndex::getSearchTable();
|
||||
}
|
||||
|
||||
if (!empty($account_id)) {
|
||||
|
@ -173,7 +172,7 @@ class Search extends BaseApi
|
|||
try {
|
||||
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
@ -186,7 +185,7 @@ class Search extends BaseApi
|
|||
return $statuses;
|
||||
}
|
||||
|
||||
private static function searchHashtags(string $q, bool $exclude_unreviewed, int $limit, int $offset, int $version): array
|
||||
private function searchHashtags(string $q, bool $exclude_unreviewed, int $limit, int $offset, int $version): array
|
||||
{
|
||||
$q = ltrim($q, '#');
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon\Timelines;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -45,7 +44,7 @@ class Home extends BaseApi
|
|||
$condition = ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'uid' => $uid];
|
||||
|
||||
$condition = $this->addPagingConditions($request, $condition);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
|
||||
if ($request['local']) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
||||
|
@ -75,11 +74,11 @@ class Home extends BaseApi
|
|||
$statuses = [];
|
||||
while ($item = Post::fetch($items)) {
|
||||
try {
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$this->updateBoundaries($status, $item, $request['friendica_order']);
|
||||
$statuses[] = $status;
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
|
|
@ -11,7 +11,6 @@ use Friendica\App\Arguments;
|
|||
use Friendica\App\BaseURL;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -73,18 +72,18 @@ class ListTimeline extends BaseApi
|
|||
$items = $this->getStatusesForGroup($uid, $request);
|
||||
} elseif (substr($this->parameters['id'], 0, 8) == 'channel:') {
|
||||
$items = $this->getStatusesForChannel($uid, $request);
|
||||
} else{
|
||||
} else {
|
||||
$items = $this->getStatusesForCircle($uid, $request);
|
||||
}
|
||||
|
||||
$statuses = [];
|
||||
foreach ($items as $item) {
|
||||
try {
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$this->updateBoundaries($status, $item, $request['friendica_order']);
|
||||
$statuses[] = $status;
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,7 @@ class ListTimeline extends BaseApi
|
|||
];
|
||||
|
||||
$condition = $this->addPagingConditions($request, $condition);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
|
||||
if ($request['only_media']) {
|
||||
$condition = DBA::mergeConditions($condition, [
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\App\BaseURL;
|
|||
use Friendica\AppHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -75,7 +74,7 @@ class PublicTimeline extends BaseApi
|
|||
];
|
||||
|
||||
$condition = $this->addPagingConditions($request, $condition);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
$params = $this->buildOrderAndLimitParams($request);
|
||||
|
||||
if ($request['local']) {
|
||||
$condition = DBA::mergeConditions($condition, ['origin' => true]);
|
||||
|
@ -109,11 +108,11 @@ class PublicTimeline extends BaseApi
|
|||
$statuses = [];
|
||||
while ($item = Post::fetch($items)) {
|
||||
try {
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$status = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
$this->updateBoundaries($status, $item, $request['friendica_order']);
|
||||
$statuses[] = $status;
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
|
||||
namespace Friendica\Module\Api\Mastodon\Timelines;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -107,7 +105,7 @@ class Tag extends BaseApi
|
|||
try {
|
||||
$statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\App\BaseURL;
|
|||
use Friendica\AppHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -52,7 +51,7 @@ class Statuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
$request = $this->getRequest([
|
||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||
'offset' => 0, // Offset in set, Defaults to 0.
|
||||
], $request);
|
||||
|
||||
|
@ -67,7 +66,7 @@ class Statuses extends BaseApi
|
|||
try {
|
||||
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
|
||||
} catch (\Exception $exception) {
|
||||
Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
$this->logger->info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'exception' => $exception]);
|
||||
}
|
||||
}
|
||||
DBA::close($statuses);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
@ -29,7 +28,7 @@ class Favorites extends BaseApi
|
|||
|
||||
// in friendica starred item are private
|
||||
// return favorites only for self
|
||||
Logger::info(BaseApi::LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
|
||||
$this->logger->info(BaseApi::LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
|
||||
|
||||
// params
|
||||
$count = $this->getRequestValue($request, 'count', 20, 1, 100);
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\App\Arguments;
|
|||
use Friendica\App\BaseURL;
|
||||
use Friendica\AppHelper;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Factory\Api\Twitter\User as TwitterUser;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
|
@ -47,21 +46,21 @@ class Destroy extends ContactEndpoint
|
|||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (!$owner) {
|
||||
Logger::notice(BaseApi::LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
|
||||
$this->logger->notice(BaseApi::LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
|
||||
throw new HTTPException\NotFoundException('Error Processing Request');
|
||||
}
|
||||
|
||||
$contact_id = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), 0);
|
||||
|
||||
if (empty($contact_id)) {
|
||||
Logger::notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
|
||||
$this->logger->notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
|
||||
throw new HTTPException\BadRequestException('no user_id specified');
|
||||
}
|
||||
|
||||
// Get Contact by given id
|
||||
$ucid = Contact::getUserContactId($contact_id, $uid);
|
||||
if (!$ucid) {
|
||||
Logger::notice(BaseApi::LOG_PREFIX . 'Not following contact', ['module' => 'api', 'action' => 'friendships_destroy']);
|
||||
$this->logger->notice(BaseApi::LOG_PREFIX . 'Not following contact', ['module' => 'api', 'action' => 'friendships_destroy']);
|
||||
throw new HTTPException\NotFoundException('Not following Contact');
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ class Destroy extends ContactEndpoint
|
|||
try {
|
||||
Contact::unfollow($contact);
|
||||
} catch (Exception $e) {
|
||||
Logger::error(BaseApi::LOG_PREFIX . $e->getMessage(), ['contact' => $contact]);
|
||||
$this->logger->error(BaseApi::LOG_PREFIX . $e->getMessage(), ['contact' => $contact]);
|
||||
throw new HTTPException\InternalServerErrorException('Unable to unfollow this contact, please contact your administrator');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter\Media\Metadata;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
@ -44,7 +43,7 @@ class Create extends BaseApi
|
|||
throw new BadRequestException('No alt text.');
|
||||
}
|
||||
|
||||
Logger::info('Updating metadata', ['media_id' => $data['media_id']]);
|
||||
$this->logger->info('Updating metadata', ['media_id' => $data['media_id']]);
|
||||
|
||||
$condition = ['id' => $data['media_id'], 'uid' => $uid];
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter\Media;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
@ -49,7 +47,7 @@ class Upload extends BaseApi
|
|||
"friendica_preview_url" => $media["preview"]
|
||||
];
|
||||
|
||||
Logger::info('Media uploaded', ['return' => $returndata]);
|
||||
$this->logger->info('Media uploaded', ['return' => $returndata]);
|
||||
|
||||
$this->response->addFormattedContent('media', ['media' => $returndata], $this->parameters['extension'] ?? null);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter\Statuses;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
|
@ -34,7 +33,7 @@ class Show extends BaseApi
|
|||
throw new BadRequestException('An id is missing.');
|
||||
}
|
||||
|
||||
Logger::notice('API: api_statuses_show: ' . $id);
|
||||
$this->logger->notice('API: api_statuses_show: ' . $id);
|
||||
|
||||
$conversation = !empty($request['conversation']);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter\Statuses;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -27,7 +26,7 @@ class UserTimeline extends BaseApi
|
|||
$this->checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
|
||||
$this->logger->info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
|
||||
|
||||
$cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
|
||||
$count = $this->getRequestValue($request, 'count', 20, 1, 100);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Attach as MAttach;
|
||||
|
@ -43,7 +42,7 @@ class Attach extends BaseModule
|
|||
|
||||
$data = MAttach::getData($item);
|
||||
if (is_null($data)) {
|
||||
Logger::notice('NULL data for attachment with id ' . $item['id']);
|
||||
$this->logger->notice('NULL data for attachment with id ' . $item['id']);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Item was not found.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\App\Router;
|
|||
use Friendica\AppHelper;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -227,7 +226,7 @@ class BaseApi extends BaseModule
|
|||
self::setBoundaries($post_item['uri-id']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Logger::debug('Error processing page boundary calculation, skipping', ['error' => $e]);
|
||||
$this->logger->debug('Error processing page boundary calculation, skipping', ['error' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,8 +287,8 @@ class BaseApi extends BaseModule
|
|||
$prev_request = $next_request = $request;
|
||||
|
||||
if ($asDate) {
|
||||
$max_date = self::$boundaries['max'];
|
||||
$min_date = self::$boundaries['min'];
|
||||
$max_date = self::$boundaries['max'];
|
||||
$min_date = self::$boundaries['min'];
|
||||
$prev_request['min_id'] = $max_date->format(DateTimeFormat::JSON);
|
||||
$next_request['max_id'] = $min_date->format(DateTimeFormat::JSON);
|
||||
} else {
|
||||
|
@ -433,48 +432,48 @@ class BaseApi extends BaseModule
|
|||
// Check for throttling (maximum posts per day, week and month)
|
||||
$throttle_day = DI::config()->get('system', 'throttle_limit_day');
|
||||
if ($throttle_day > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_day = Post::countThread($condition);
|
||||
|
||||
if ($posts_day > $throttle_day) {
|
||||
$this->logger->notice('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]);
|
||||
$error = $this->t('Too Many Requests');
|
||||
$error = $this->t('Too Many Requests');
|
||||
$error_description = $this->tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$this->jsonError(429, $errorobj->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
$throttle_week = DI::config()->get('system', 'throttle_limit_week');
|
||||
if ($throttle_week > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60 * 7);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_week = Post::countThread($condition);
|
||||
|
||||
if ($posts_week > $throttle_week) {
|
||||
Logger::notice('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]);
|
||||
$error = $this->t('Too Many Requests');
|
||||
$this->logger->notice('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]);
|
||||
$error = $this->t('Too Many Requests');
|
||||
$error_description = $this->tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$this->jsonError(429, $errorobj->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
$throttle_month = DI::config()->get('system', 'throttle_limit_month');
|
||||
if ($throttle_month > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60 * 30);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_month = Post::countThread($condition);
|
||||
|
||||
if ($posts_month > $throttle_month) {
|
||||
Logger::notice('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]);
|
||||
$error = $this->t('Too Many Requests');
|
||||
$this->logger->notice('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]);
|
||||
$error = $this->t('Too Many Requests');
|
||||
$error_description = $this->tt('Monthly posting limit of %d post reached. The post was rejected.', 'Monthly posting limit of %d posts reached. The post was rejected.', $throttle_month);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
$this->jsonError(429, $errorobj->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\DI;
|
||||
|
@ -48,13 +47,13 @@ class BaseSearch extends BaseModule
|
|||
return '';
|
||||
}
|
||||
|
||||
$header = '';
|
||||
$header = '';
|
||||
$results = new ResultList();
|
||||
|
||||
if (strpos($search, '@') === 0) {
|
||||
$search = trim(substr($search, 1));
|
||||
$type = Search::TYPE_PEOPLE;
|
||||
$header = DI::l10n()->t('People Search - %s', $search);
|
||||
$search = trim(substr($search, 1));
|
||||
$type = Search::TYPE_PEOPLE;
|
||||
$header = DI::l10n()->t('People Search - %s', $search);
|
||||
} elseif (strpos($search, '!') === 0) {
|
||||
$search = trim(substr($search, 1));
|
||||
$type = Search::TYPE_GROUP;
|
||||
|
@ -64,11 +63,19 @@ class BaseSearch extends BaseModule
|
|||
$search = Network::convertToIdn($search);
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
$itemsPerPage = DI::pConfig()->get(
|
||||
DI::userSession()->getLocalUserId(),
|
||||
'system',
|
||||
'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile')
|
||||
);
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
$itemsPerPage = DI::pConfig()->get(
|
||||
DI::userSession()->getLocalUserId(),
|
||||
'system',
|
||||
'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network')
|
||||
);
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||
|
@ -132,7 +139,8 @@ class BaseSearch extends BaseModule
|
|||
'$filtered' => $filtered ? DI::l10n()->tt(
|
||||
'%d result was filtered out because your node blocks the domain it is registered on. You can review the list of domains your node is currently blocking in the <a href="/friendica">About page</a>.',
|
||||
'%d results were filtered out because your node blocks the domain they are registered on. You can review the list of domains your node is currently blocking in the <a href="/friendica">About page</a>.',
|
||||
$filtered) : '',
|
||||
$filtered
|
||||
) : '',
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull($results->getTotal()),
|
||||
]);
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Content\ContactSelector;
|
|||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Theme;
|
||||
|
@ -32,11 +31,11 @@ use Friendica\Worker\UpdateContact;
|
|||
class Contact extends BaseModule
|
||||
{
|
||||
const TAB_CONVERSATIONS = 1;
|
||||
const TAB_POSTS = 2;
|
||||
const TAB_PROFILE = 3;
|
||||
const TAB_CONTACTS = 4;
|
||||
const TAB_ADVANCED = 5;
|
||||
const TAB_MEDIA = 6;
|
||||
const TAB_POSTS = 2;
|
||||
const TAB_PROFILE = 3;
|
||||
const TAB_CONTACTS = 4;
|
||||
const TAB_ADVANCED = 5;
|
||||
const TAB_MEDIA = 6;
|
||||
|
||||
private static function batchActions()
|
||||
{
|
||||
|
@ -121,7 +120,7 @@ class Contact extends BaseModule
|
|||
try {
|
||||
UpdateContact::add(Worker::PRIORITY_HIGH, $contact_id);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::notice($e->getMessage(), ['contact' => $contact]);
|
||||
DI::logger()->notice($e->getMessage(), ['contact' => $contact]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,11 +168,11 @@ class Contact extends BaseModule
|
|||
}
|
||||
|
||||
$search = trim($_GET['search'] ?? '');
|
||||
$nets = trim($_GET['nets'] ?? '');
|
||||
$rel = trim($_GET['rel'] ?? '');
|
||||
$nets = trim($_GET['nets'] ?? '');
|
||||
$rel = trim($_GET['rel'] ?? '');
|
||||
$circle = trim($_GET['circle'] ?? '');
|
||||
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttypeid = User::getAccountTypeByString($accounttype);
|
||||
|
||||
$page = DI::page();
|
||||
|
@ -183,7 +182,7 @@ class Contact extends BaseModule
|
|||
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
||||
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
|
||||
|
||||
$vcard_widget = '';
|
||||
$vcard_widget = '';
|
||||
$findpeople_widget = Widget::findPeople();
|
||||
if (isset($_GET['add'])) {
|
||||
$follow_widget = Widget::follow($_GET['add']);
|
||||
|
@ -249,10 +248,10 @@ class Contact extends BaseModule
|
|||
$sql_values[] = $accounttypeid;
|
||||
}
|
||||
|
||||
$searching = false;
|
||||
$searching = false;
|
||||
$search_hdr = null;
|
||||
if ($search) {
|
||||
$searching = true;
|
||||
$searching = true;
|
||||
$search_hdr = $search;
|
||||
$search_txt = preg_quote(trim($search, ' @!'));
|
||||
$sql_extra .= " AND (`name` REGEXP ? OR `url` REGEXP ? OR `nick` REGEXP ? OR `addr` REGEXP ? OR `alias` REGEXP ?)";
|
||||
|
@ -314,80 +313,80 @@ class Contact extends BaseModule
|
|||
$stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
while ($contact = DBA::fetch($stmt)) {
|
||||
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contacts[] = self::getContactTemplateVars($contact);
|
||||
$contacts[] = self::getContactTemplateVars($contact);
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
$tabs = [
|
||||
[
|
||||
'label' => DI::l10n()->t('All Contacts'),
|
||||
'url' => 'contact',
|
||||
'sel' => !$type ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Show all contacts'),
|
||||
'id' => 'showall-tab',
|
||||
'label' => DI::l10n()->t('All Contacts'),
|
||||
'url' => 'contact',
|
||||
'sel' => !$type ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Show all contacts'),
|
||||
'id' => 'showall-tab',
|
||||
'accesskey' => 'l',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Pending'),
|
||||
'url' => 'contact/pending',
|
||||
'sel' => $type == 'pending' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show pending contacts'),
|
||||
'id' => 'showpending-tab',
|
||||
'label' => DI::l10n()->t('Pending'),
|
||||
'url' => 'contact/pending',
|
||||
'sel' => $type == 'pending' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show pending contacts'),
|
||||
'id' => 'showpending-tab',
|
||||
'accesskey' => 'p',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Blocked'),
|
||||
'url' => 'contact/blocked',
|
||||
'sel' => $type == 'blocked' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show blocked contacts'),
|
||||
'id' => 'showblocked-tab',
|
||||
'label' => DI::l10n()->t('Blocked'),
|
||||
'url' => 'contact/blocked',
|
||||
'sel' => $type == 'blocked' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show blocked contacts'),
|
||||
'id' => 'showblocked-tab',
|
||||
'accesskey' => 'b',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Ignored'),
|
||||
'url' => 'contact/ignored',
|
||||
'sel' => $type == 'ignored' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show ignored contacts'),
|
||||
'id' => 'showignored-tab',
|
||||
'label' => DI::l10n()->t('Ignored'),
|
||||
'url' => 'contact/ignored',
|
||||
'sel' => $type == 'ignored' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show ignored contacts'),
|
||||
'id' => 'showignored-tab',
|
||||
'accesskey' => 'i',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Collapsed'),
|
||||
'url' => 'contact/collapsed',
|
||||
'sel' => $type == 'collapsed' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show collapsed contacts'),
|
||||
'id' => 'showcollapsed-tab',
|
||||
'label' => DI::l10n()->t('Collapsed'),
|
||||
'url' => 'contact/collapsed',
|
||||
'sel' => $type == 'collapsed' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show collapsed contacts'),
|
||||
'id' => 'showcollapsed-tab',
|
||||
'accesskey' => 'c',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Archived'),
|
||||
'url' => 'contact/archived',
|
||||
'sel' => $type == 'archived' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show archived contacts'),
|
||||
'id' => 'showarchived-tab',
|
||||
'label' => DI::l10n()->t('Archived'),
|
||||
'url' => 'contact/archived',
|
||||
'sel' => $type == 'archived' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show archived contacts'),
|
||||
'id' => 'showarchived-tab',
|
||||
'accesskey' => 'y',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Hidden'),
|
||||
'url' => 'contact/hidden',
|
||||
'sel' => $type == 'hidden' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show hidden contacts'),
|
||||
'id' => 'showhidden-tab',
|
||||
'label' => DI::l10n()->t('Hidden'),
|
||||
'url' => 'contact/hidden',
|
||||
'sel' => $type == 'hidden' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only show hidden contacts'),
|
||||
'id' => 'showhidden-tab',
|
||||
'accesskey' => 'h',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Circles'),
|
||||
'url' => 'circle',
|
||||
'sel' => '',
|
||||
'title' => DI::l10n()->t('Organize your contact circles'),
|
||||
'id' => 'contactcircles-tab',
|
||||
'label' => DI::l10n()->t('Circles'),
|
||||
'url' => 'circle',
|
||||
'sel' => '',
|
||||
'title' => DI::l10n()->t('Organize your contact circles'),
|
||||
'id' => 'contactcircles-tab',
|
||||
'accesskey' => 'e',
|
||||
],
|
||||
];
|
||||
|
||||
$tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs]);
|
||||
|
||||
switch ($rel) {
|
||||
|
@ -432,26 +431,26 @@ class Contact extends BaseModule
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('contacts-template.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$header' => $header,
|
||||
'$tabs' => $tabs_html,
|
||||
'$total' => $total,
|
||||
'$search' => $search_hdr,
|
||||
'$desc' => DI::l10n()->t('Search your contacts'),
|
||||
'$finding' => $searching ? DI::l10n()->t('Results for: %s', $search) : '',
|
||||
'$submit' => DI::l10n()->t('Find'),
|
||||
'$cmd' => DI::args()->getCommand(),
|
||||
'$parameter' => http_build_query($request),
|
||||
'$contacts' => $contacts,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
|
||||
'multiselect' => 1,
|
||||
'$batch_actions' => [
|
||||
'contacts_batch_update' => DI::l10n()->t('Update'),
|
||||
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
|
||||
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
|
||||
'contacts_batch_collapse' => DI::l10n()->t('Collapse') . '/' . DI::l10n()->t('Uncollapse'),
|
||||
'$header' => $header,
|
||||
'$tabs' => $tabs_html,
|
||||
'$total' => $total,
|
||||
'$search' => $search_hdr,
|
||||
'$desc' => DI::l10n()->t('Search your contacts'),
|
||||
'$finding' => $searching ? DI::l10n()->t('Results for: %s', $search) : '',
|
||||
'$submit' => DI::l10n()->t('Find'),
|
||||
'$cmd' => DI::args()->getCommand(),
|
||||
'$parameter' => http_build_query($request),
|
||||
'$contacts' => $contacts,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
|
||||
'multiselect' => 1,
|
||||
'$batch_actions' => [
|
||||
'contacts_batch_update' => DI::l10n()->t('Update'),
|
||||
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
|
||||
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
|
||||
'contacts_batch_collapse' => DI::l10n()->t('Collapse') . '/' . DI::l10n()->t('Uncollapse'),
|
||||
],
|
||||
'$h_batch_actions' => DI::l10n()->t('Batch Actions'),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
@ -471,7 +470,7 @@ class Contact extends BaseModule
|
|||
*/
|
||||
public static function getTabsHTML(array $contact, int $active_tab)
|
||||
{
|
||||
$cid = $pcid = $contact['id'];
|
||||
$cid = $pcid = $contact['id'];
|
||||
$data = Model\Contact::getPublicAndUserContactID($contact['id'], DI::userSession()->getLocalUserId());
|
||||
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
|
||||
$cid = $data['user'];
|
||||
|
@ -482,54 +481,54 @@ class Contact extends BaseModule
|
|||
// tabs
|
||||
$tabs = [
|
||||
[
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => 'contact/' . $cid,
|
||||
'sel' => (($active_tab == self::TAB_PROFILE) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Profile Details'),
|
||||
'id' => 'profile-tab',
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => 'contact/' . $cid,
|
||||
'sel' => (($active_tab == self::TAB_PROFILE) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Profile Details'),
|
||||
'id' => 'profile-tab',
|
||||
'accesskey' => 'o',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Conversations'),
|
||||
'url' => 'contact/' . $pcid . '/conversations',
|
||||
'sel' => (($active_tab == self::TAB_CONVERSATIONS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Conversations started by this contact'),
|
||||
'id' => 'status-tab',
|
||||
'label' => DI::l10n()->t('Conversations'),
|
||||
'url' => 'contact/' . $pcid . '/conversations',
|
||||
'sel' => (($active_tab == self::TAB_CONVERSATIONS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Conversations started by this contact'),
|
||||
'id' => 'status-tab',
|
||||
'accesskey' => 'm',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Posts and Comments'),
|
||||
'url' => 'contact/' . $pcid . '/posts',
|
||||
'sel' => (($active_tab == self::TAB_POSTS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Individual Posts and Replies'),
|
||||
'id' => 'posts-tab',
|
||||
'label' => DI::l10n()->t('Posts and Comments'),
|
||||
'url' => 'contact/' . $pcid . '/posts',
|
||||
'sel' => (($active_tab == self::TAB_POSTS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Individual Posts and Replies'),
|
||||
'id' => 'posts-tab',
|
||||
'accesskey' => 'p',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => 'contact/' . $pcid . '/media',
|
||||
'sel' => (($active_tab == self::TAB_MEDIA) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Posts containing media objects'),
|
||||
'id' => 'media-tab',
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => 'contact/' . $pcid . '/media',
|
||||
'sel' => (($active_tab == self::TAB_MEDIA) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Posts containing media objects'),
|
||||
'id' => 'media-tab',
|
||||
'accesskey' => 'd',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Contacts'),
|
||||
'url' => 'contact/' . $pcid . '/contacts',
|
||||
'sel' => (($active_tab == self::TAB_CONTACTS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('View all known contacts'),
|
||||
'id' => 'contacts-tab',
|
||||
'label' => DI::l10n()->t('Contacts'),
|
||||
'url' => 'contact/' . $pcid . '/contacts',
|
||||
'sel' => (($active_tab == self::TAB_CONTACTS) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('View all known contacts'),
|
||||
'id' => 'contacts-tab',
|
||||
'accesskey' => 't'
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($contact['network']) && in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) && ($cid != $pcid)) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Advanced'),
|
||||
'url' => 'contact/' . $cid . '/advanced/',
|
||||
'sel' => (($active_tab == self::TAB_ADVANCED) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Advanced Contact Settings'),
|
||||
'id' => 'advanced-tab',
|
||||
'label' => DI::l10n()->t('Advanced'),
|
||||
'url' => 'contact/' . $cid . '/advanced/',
|
||||
'sel' => (($active_tab == self::TAB_ADVANCED) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Advanced Contact Settings'),
|
||||
'id' => 'advanced-tab',
|
||||
'accesskey' => 'r'
|
||||
];
|
||||
}
|
||||
|
@ -567,11 +566,11 @@ class Contact extends BaseModule
|
|||
$alt_text = DI::l10n()->t('Mutual Friendship');
|
||||
break;
|
||||
|
||||
case Model\Contact::FOLLOWER;
|
||||
case Model\Contact::FOLLOWER:
|
||||
$alt_text = DI::l10n()->t('is a fan of yours');
|
||||
break;
|
||||
|
||||
case Model\Contact::SHARING;
|
||||
case Model\Contact::SHARING:
|
||||
$alt_text = DI::l10n()->t('you are a fan of');
|
||||
break;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\OAuth;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Security\OAuth;
|
||||
|
@ -36,18 +35,18 @@ class Authorize extends BaseApi
|
|||
], $request);
|
||||
|
||||
if ($request['response_type'] != 'code') {
|
||||
Logger::warning('Unsupported or missing response type', ['request' => $request]);
|
||||
$this->logger->warning('Unsupported or missing response type', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type')));
|
||||
}
|
||||
|
||||
if (empty($request['client_id']) || empty($request['redirect_uri'])) {
|
||||
Logger::warning('Incomplete request data', ['request' => $request]);
|
||||
$this->logger->warning('Incomplete request data', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
if (empty($application)) {
|
||||
Logger::warning('An application could not be fetched.', ['request' => $request]);
|
||||
$this->logger->warning('An application could not be fetched.', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
|
@ -59,14 +58,14 @@ class Authorize extends BaseApi
|
|||
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
if (empty($uid)) {
|
||||
Logger::info('Redirect to login');
|
||||
$this->logger->info('Redirect to login');
|
||||
DI::appHelper()->redirect('login?' . http_build_query(['return_authorize' => $redirect]));
|
||||
} else {
|
||||
Logger::info('Already logged in user', ['uid' => $uid]);
|
||||
$this->logger->info('Already logged in user', ['uid' => $uid]);
|
||||
}
|
||||
|
||||
if (!OAuth::existsTokenForUser($application, $uid) && !DI::session()->get('oauth_acknowledge')) {
|
||||
Logger::info('Redirect to acknowledge');
|
||||
$this->logger->info('Redirect to acknowledge');
|
||||
DI::appHelper()->redirect('oauth/acknowledge?' . http_build_query(['return_authorize' => $redirect, 'application' => $application['name']]));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\OAuth;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
@ -58,7 +57,8 @@ class Token extends BaseApi
|
|||
|
||||
if (empty($request['client_id']) || empty($request['client_secret'])) {
|
||||
$this->logger->warning('Incomplete request data', ['request' => $request]);
|
||||
$this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));;
|
||||
$this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));
|
||||
;
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
|
@ -69,7 +69,7 @@ class Token extends BaseApi
|
|||
$grant_type = (string) $request['grant_type'];
|
||||
|
||||
if (!in_array($grant_type, ['client_credentials', 'authorization_code'])) {
|
||||
Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
$this->logger->warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@ class Token extends BaseApi
|
|||
|
||||
// now check for $grant_type === 'authorization_code'
|
||||
// For security reasons only allow freshly created tokens
|
||||
$redirect_uri = strtok($request['redirect_uri'],'?');
|
||||
$condition = [
|
||||
$redirect_uri = strtok($request['redirect_uri'], '?');
|
||||
$condition = [
|
||||
"`redirect_uri` LIKE ? AND `id` = ? AND `code` = ? AND `created_at` > ?",
|
||||
$redirect_uri, $application['id'], $request['code'], DateTimeFormat::utc('now - 5 minutes')
|
||||
];
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\OpenWebAuthToken;
|
||||
|
@ -60,10 +59,10 @@ class Owa extends BaseModule
|
|||
$verified = HTTPSignature::verifyMagic($contact['pubkey']);
|
||||
|
||||
if ($verified && $verified['header_signed'] && $verified['header_valid']) {
|
||||
Logger::debug('OWA header', ['addr' => $contact['addr'], 'data' => $verified]);
|
||||
$this->logger->debug('OWA header', ['addr' => $contact['addr'], 'data' => $verified]);
|
||||
|
||||
$ret['success'] = true;
|
||||
$token = Strings::getRandomHex(32);
|
||||
$token = Strings::getRandomHex(32);
|
||||
|
||||
// Store the generated token in the database.
|
||||
OpenWebAuthToken::create('owt', 0, $token, $contact['addr']);
|
||||
|
@ -77,10 +76,10 @@ class Owa extends BaseModule
|
|||
openssl_public_encrypt($token, $result, $contact['pubkey']);
|
||||
$ret['encrypted_token'] = Strings::base64UrlEncode($result);
|
||||
} else {
|
||||
Logger::info('OWA fail', ['id' => $contact['id'], 'addr' => $contact['addr'], 'url' => $contact['url']]);
|
||||
$this->logger->info('OWA fail', ['id' => $contact['id'], 'addr' => $contact['addr'], 'url' => $contact['url']]);
|
||||
}
|
||||
} else {
|
||||
Logger::info('Contact not found', ['handle' => $handle]);
|
||||
$this->logger->info('Contact not found', ['handle' => $handle]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\Contact\Header;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -27,6 +26,7 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Network\HTTPException\NotModifiedException;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Security\OpenWebAuth;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\ParseUrl;
|
||||
use Friendica\Util\Proxy;
|
||||
|
@ -64,19 +64,19 @@ class Photo extends BaseApi
|
|||
|
||||
OpenWebAuth::addVisitorCookieForHTTPSigner($this->server);
|
||||
|
||||
$customsize = 0;
|
||||
$customsize = 0;
|
||||
$square_resize = true;
|
||||
$scale = null;
|
||||
$stamp = microtime(true);
|
||||
$scale = null;
|
||||
$stamp = microtime(true);
|
||||
// User avatar
|
||||
if (!empty($this->parameters['type'])) {
|
||||
if (!empty($this->parameters['customsize'])) {
|
||||
$customsize = intval($this->parameters['customsize']);
|
||||
$customsize = intval($this->parameters['customsize']);
|
||||
$square_resize = !in_array($this->parameters['type'], ['media', 'preview']);
|
||||
}
|
||||
|
||||
if (!empty($this->parameters['guid'])) {
|
||||
$guid = $this->parameters['guid'];
|
||||
$guid = $this->parameters['guid'];
|
||||
$account = DBA::selectFirst('account-user-view', ['id'], ['guid' => $guid], ['order' => ['uid' => true]]);
|
||||
if (empty($account)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
|
@ -91,7 +91,7 @@ class Photo extends BaseApi
|
|||
|
||||
if (!empty($this->parameters['nickname_ext'])) {
|
||||
$nickname = pathinfo($this->parameters['nickname_ext'], PATHINFO_FILENAME);
|
||||
$user = User::getByNickname($nickname, ['uid']);
|
||||
$user = User::getByNickname($nickname, ['uid']);
|
||||
if (empty($user)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
@ -104,16 +104,16 @@ class Photo extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($id)) {
|
||||
Logger::notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]);
|
||||
$this->logger->notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]);
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.'));
|
||||
}
|
||||
|
||||
$photo = self::getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||
$photo = $this->getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||
} else {
|
||||
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
|
||||
$scale = 0;
|
||||
$scale = 0;
|
||||
if (substr($photoid, -2, 1) == '-') {
|
||||
$scale = intval(substr($photoid, -1, 1));
|
||||
$scale = intval(substr($photoid, -1, 1));
|
||||
$photoid = substr($photoid, 0, -2);
|
||||
}
|
||||
|
||||
|
@ -172,10 +172,10 @@ class Photo extends BaseApi
|
|||
$data = microtime(true) - $stamp;
|
||||
|
||||
if (empty($imgdata)) {
|
||||
Logger::warning('Invalid photo', ['id' => $photo['id']]);
|
||||
$this->logger->warning('Invalid photo', ['id' => $photo['id']]);
|
||||
if (in_array($photo['backend-class'], [ExternalResource::NAME])) {
|
||||
$reference = json_decode($photo['backend-ref'], true);
|
||||
$error = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
|
||||
$error = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
|
||||
} else {
|
||||
$error = DI::l10n()->t('Invalid photo with id %s.', $photo['id']);
|
||||
}
|
||||
|
@ -229,13 +229,13 @@ class Photo extends BaseApi
|
|||
$output = microtime(true) - $stamp;
|
||||
|
||||
$total = microtime(true) - $totalstamp;
|
||||
$rest = $total - ($fetch + $data + $checksum + $output);
|
||||
$rest = $total - ($fetch + $data + $checksum + $output);
|
||||
|
||||
if (!is_null($scale) && ($scale < 4)) {
|
||||
Logger::debug('Performance:', [
|
||||
'scale' => $scale, 'resource' => $photo['resource-id'],
|
||||
'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3),
|
||||
'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3),
|
||||
$this->logger->debug('Performance:', [
|
||||
'scale' => $scale, 'resource' => $photo['resource-id'],
|
||||
'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3),
|
||||
'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3),
|
||||
'output' => number_format($output, 3), 'rest' => number_format($rest, 3)
|
||||
]);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Photo extends BaseApi
|
|||
* @param int $customsize Custom size (?)
|
||||
* @return array|bool Array on success, false on error
|
||||
*/
|
||||
private static function getPhotoById(int $id, string $type, int $customsize)
|
||||
private function getPhotoById(int $id, string $type, int $customsize)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'preview':
|
||||
|
@ -297,7 +297,7 @@ class Photo extends BaseApi
|
|||
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '', $link['blurhash'] ?? '', $link['width'] ?? 0, $link['height'] ?? 0);
|
||||
case 'contact':
|
||||
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated'];
|
||||
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated', 'next-update'];
|
||||
$contact = Contact::getById($id, $fields);
|
||||
if (empty($contact)) {
|
||||
return false;
|
||||
|
@ -355,29 +355,29 @@ class Photo extends BaseApi
|
|||
} else {
|
||||
// Only update federated accounts that hadn't failed before and hadn't been updated recently
|
||||
$update = in_array($contact['network'], Protocol::FEDERATED) && !$contact['failed']
|
||||
&& ((time() - strtotime($contact['updated']) > 86400));
|
||||
&& ($contact['next-update'] < DateTimeFormat::utcNow());
|
||||
if ($update) {
|
||||
$curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE, HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
|
||||
$update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
|
||||
Logger::debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
|
||||
$this->logger->debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
}
|
||||
if ($update) {
|
||||
try {
|
||||
UpdateContact::add(Worker::PRIORITY_LOW, $id);
|
||||
Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$this->logger->info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Logger::notice($e->getMessage(), ['id' => $id, 'contact' => $contact]);
|
||||
$this->logger->notice($e->getMessage(), ['id' => $id, 'contact' => $contact]);
|
||||
}
|
||||
} else {
|
||||
Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
$this->logger->info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
|
||||
}
|
||||
}
|
||||
if (!empty($mimetext) && ($mime[0] != 'image') && ($mimetext != 'application/octet-stream')) {
|
||||
Logger::info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$this->logger->info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$mimetext = '';
|
||||
}
|
||||
if (!empty($mimetext)) {
|
||||
Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
$this->logger->debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ class Photo extends BaseApi
|
|||
}
|
||||
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext, $contact['blurhash'] ?? null, $customsize, $customsize);
|
||||
case 'header':
|
||||
$fields = ['uid', 'url', 'header', 'network', 'gsid'];
|
||||
$fields = ['uid', 'url', 'header', 'network', 'gsid'];
|
||||
$contact = Contact::getById($id, $fields);
|
||||
if (empty($contact)) {
|
||||
return false;
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -89,7 +88,7 @@ class Register extends BaseModule
|
|||
if ($max_dailies) {
|
||||
$count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
|
||||
if ($count >= $max_dailies) {
|
||||
Logger::notice('max daily registrations exceeded.');
|
||||
$this->logger->notice('max daily registrations exceeded.');
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
|
||||
return '';
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ class Register extends BaseModule
|
|||
if (DI::config()->get('system', 'publish_all')) {
|
||||
$profile_publish = '<input type="hidden" name="profile_publish_reg" value="1" />';
|
||||
} else {
|
||||
$publish_tpl = Renderer::getMarkupTemplate('profile/publish.tpl');
|
||||
$publish_tpl = Renderer::getMarkupTemplate('profile/publish.tpl');
|
||||
$profile_publish = Renderer::replaceMacros($publish_tpl, [
|
||||
'$instance' => 'reg',
|
||||
'$pubdesc' => DI::l10n()->t('Include your profile in member directory?'),
|
||||
|
@ -137,44 +136,44 @@ class Register extends BaseModule
|
|||
$tpl = $arr['template'];
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$invitations' => DI::config()->get('system', 'invitation_only'),
|
||||
'$permonly' => self::getPolicy() === self::APPROVE,
|
||||
'$permonlybox' => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), DI::l10n()->t('Required')],
|
||||
'$invite_desc' => DI::l10n()->t('Membership on this site is by invitation only.'),
|
||||
'$invite_label' => DI::l10n()->t('Your invitation code: '),
|
||||
'$invite_id' => $invite_id,
|
||||
'$regtitle' => DI::l10n()->t('Registration'),
|
||||
'$registertext' => BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('config', 'register_text', '')),
|
||||
'$fillwith' => $fillwith,
|
||||
'$fillext' => $fillext,
|
||||
'$oidlabel' => $oidlabel,
|
||||
'$openid' => $openid_url,
|
||||
'$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system'),
|
||||
'$addrlabel' => DI::l10n()->t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'),
|
||||
'$addrlabel2' => DI::l10n()->t('Please repeat your e-mail address:'),
|
||||
'$ask_password' => $ask_password,
|
||||
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],
|
||||
'$password2' => ['confirm', DI::l10n()->t('Confirm:'), '', ''],
|
||||
'$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', DI::baseUrl()->getHost()),
|
||||
'$nicklabel' => DI::l10n()->t('Choose a nickname: '),
|
||||
'$photo' => $photo,
|
||||
'$publish' => $profile_publish,
|
||||
'$regbutt' => DI::l10n()->t('Register'),
|
||||
'$username' => $username,
|
||||
'$email' => $email,
|
||||
'$nickname' => $nickname,
|
||||
'$sitename' => DI::baseUrl()->getHost(),
|
||||
'$importh' => DI::l10n()->t('Import'),
|
||||
'$importt' => DI::l10n()->t('Import your profile to this friendica instance'),
|
||||
'$showtoslink' => DI::config()->get('system', 'tosdisplay'),
|
||||
'$tostext' => DI::l10n()->t('Terms of Service'),
|
||||
'$showprivstatement' => DI::config()->get('system', 'tosprivstatement'),
|
||||
'$privstatement'=> $this->tos->privacy_complete,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
|
||||
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
|
||||
'$invitations' => DI::config()->get('system', 'invitation_only'),
|
||||
'$permonly' => self::getPolicy() === self::APPROVE,
|
||||
'$permonlybox' => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), DI::l10n()->t('Required')],
|
||||
'$invite_desc' => DI::l10n()->t('Membership on this site is by invitation only.'),
|
||||
'$invite_label' => DI::l10n()->t('Your invitation code: '),
|
||||
'$invite_id' => $invite_id,
|
||||
'$regtitle' => DI::l10n()->t('Registration'),
|
||||
'$registertext' => BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('config', 'register_text', '')),
|
||||
'$fillwith' => $fillwith,
|
||||
'$fillext' => $fillext,
|
||||
'$oidlabel' => $oidlabel,
|
||||
'$openid' => $openid_url,
|
||||
'$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system'),
|
||||
'$addrlabel' => DI::l10n()->t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'),
|
||||
'$addrlabel2' => DI::l10n()->t('Please repeat your e-mail address:'),
|
||||
'$ask_password' => $ask_password,
|
||||
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],
|
||||
'$password2' => ['confirm', DI::l10n()->t('Confirm:'), '', ''],
|
||||
'$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', DI::baseUrl()->getHost()),
|
||||
'$nicklabel' => DI::l10n()->t('Choose a nickname: '),
|
||||
'$photo' => $photo,
|
||||
'$publish' => $profile_publish,
|
||||
'$regbutt' => DI::l10n()->t('Register'),
|
||||
'$username' => $username,
|
||||
'$email' => $email,
|
||||
'$nickname' => $nickname,
|
||||
'$sitename' => DI::baseUrl()->getHost(),
|
||||
'$importh' => DI::l10n()->t('Import'),
|
||||
'$importt' => DI::l10n()->t('Import your profile to this friendica instance'),
|
||||
'$showtoslink' => DI::config()->get('system', 'tosdisplay'),
|
||||
'$tostext' => DI::l10n()->t('Terms of Service'),
|
||||
'$showprivstatement' => DI::config()->get('system', 'tosprivstatement'),
|
||||
'$privstatement' => $this->tos->privacy_complete,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
|
||||
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
|
||||
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
|
||||
'$additional' => !empty(DI::userSession()->getLocalUserId()),
|
||||
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
|
||||
'$additional' => !empty(DI::userSession()->getLocalUserId()),
|
||||
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
|
||||
|
||||
]);
|
||||
|
||||
|
@ -224,12 +223,12 @@ class Register extends BaseModule
|
|||
|
||||
switch (self::getPolicy()) {
|
||||
case self::OPEN:
|
||||
$blocked = 0;
|
||||
$blocked = 0;
|
||||
$verified = 1;
|
||||
break;
|
||||
|
||||
case self::APPROVE:
|
||||
$blocked = 1;
|
||||
$blocked = 1;
|
||||
$verified = 0;
|
||||
break;
|
||||
|
||||
|
@ -239,7 +238,7 @@ class Register extends BaseModule
|
|||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return;
|
||||
}
|
||||
$blocked = 1;
|
||||
$blocked = 1;
|
||||
$verified = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -250,7 +249,7 @@ class Register extends BaseModule
|
|||
|
||||
// Is there text in the tar pit?
|
||||
if (!empty($arr['email'])) {
|
||||
Logger::info('Tar pit', $arr);
|
||||
$this->logger->info('Tar pit', $arr);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You have entered too much information.'));
|
||||
DI::baseUrl()->redirect('register/');
|
||||
}
|
||||
|
@ -262,18 +261,18 @@ class Register extends BaseModule
|
|||
DI::baseUrl()->redirect('register');
|
||||
}
|
||||
|
||||
$blocked = 0;
|
||||
$blocked = 0;
|
||||
$verified = 1;
|
||||
|
||||
$arr['password1'] = $arr['confirm'] = $arr['parent_password'];
|
||||
$arr['repeat'] = $arr['email'] = $user['email'];
|
||||
$arr['repeat'] = $arr['email'] = $user['email'];
|
||||
} else {
|
||||
// Overwriting the "tar pit" field with the real one
|
||||
$arr['email'] = $arr['field1'];
|
||||
}
|
||||
|
||||
if ($arr['email'] != $arr['repeat']) {
|
||||
Logger::info('Mail mismatch', $arr);
|
||||
$this->logger->info('Mail mismatch', $arr);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter the identical mail address in the second field.'));
|
||||
$regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']];
|
||||
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
|
||||
|
@ -281,9 +280,9 @@ class Register extends BaseModule
|
|||
|
||||
//Check if nickname contains only US-ASCII and do not start with a digit
|
||||
if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $arr['nickname'])) {
|
||||
if (is_numeric(substr($arr['nickname'], 0, 1))) {
|
||||
if (is_numeric(substr($arr['nickname'], 0, 1))) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t("Nickname cannot start with a digit."));
|
||||
} else {
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t("Nickname can only contain US-ASCII characters."));
|
||||
}
|
||||
$regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']];
|
||||
|
@ -291,7 +290,7 @@ class Register extends BaseModule
|
|||
return;
|
||||
}
|
||||
|
||||
$arr['blocked'] = $blocked;
|
||||
$arr['blocked'] = $blocked;
|
||||
$arr['verified'] = $verified;
|
||||
$arr['language'] = L10n::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language'));
|
||||
|
||||
|
@ -319,7 +318,7 @@ class Register extends BaseModule
|
|||
|
||||
$using_invites = DI::config()->get('system', 'invitation_only');
|
||||
$num_invites = DI::config()->get('system', 'number_invites');
|
||||
$invite_id = (!empty($_POST['invite_id']) ? trim($_POST['invite_id']) : '');
|
||||
$invite_id = (!empty($_POST['invite_id']) ? trim($_POST['invite_id']) : '');
|
||||
|
||||
if (self::getPolicy() === self::OPEN) {
|
||||
if ($using_invites && $invite_id) {
|
||||
|
@ -345,9 +344,11 @@ class Register extends BaseModule
|
|||
DI::baseUrl()->redirect();
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(
|
||||
DI::l10n()->t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
|
||||
DI::l10n()->t(
|
||||
'Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
|
||||
$user['email'],
|
||||
$result['password'])
|
||||
$result['password']
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -423,7 +424,7 @@ class Register extends BaseModule
|
|||
public static function getPolicy(): int
|
||||
{
|
||||
$admins = User::getAdminList(['login_date']);
|
||||
$days = DI::config()->get('system', 'admin_inactivity_limit');
|
||||
$days = DI::config()->get('system', 'admin_inactivity_limit');
|
||||
if ($days == 0 || empty($admins)) {
|
||||
return intval(DI::config()->get('config', 'register_policy'));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\Content\Text\HTML;
|
|||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -60,12 +59,14 @@ class Index extends BaseSearch
|
|||
// 10 requests are "free", after the 11th only a call per minute is allowed
|
||||
|
||||
$free_crawls = intval(DI::config()->get('system', 'free_crawls'));
|
||||
if ($free_crawls == 0)
|
||||
if ($free_crawls == 0) {
|
||||
$free_crawls = 10;
|
||||
}
|
||||
|
||||
$crawl_permit_period = intval(DI::config()->get('system', 'crawl_permit_period'));
|
||||
if ($crawl_permit_period == 0)
|
||||
if ($crawl_permit_period == 0) {
|
||||
$crawl_permit_period = 10;
|
||||
}
|
||||
|
||||
$remote = $this->remoteAddress;
|
||||
$result = DI::cache()->get('remote_search:' . $remote);
|
||||
|
@ -88,16 +89,16 @@ class Index extends BaseSearch
|
|||
|
||||
$tag = false;
|
||||
if (!empty($_GET['tag'])) {
|
||||
$tag = true;
|
||||
$tag = true;
|
||||
$search = '#' . trim(rawurldecode($_GET['tag']));
|
||||
}
|
||||
|
||||
// construct a wrapper for the search header
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('content_wrapper.tpl'), [
|
||||
'name' => 'search-header',
|
||||
'$title' => DI::l10n()->t('Search'),
|
||||
'name' => 'search-header',
|
||||
'$title' => DI::l10n()->t('Search'),
|
||||
'$title_size' => 3,
|
||||
'$content' => HTML::search($search, 'search-box', false)
|
||||
'$content' => HTML::search($search, 'search-box', false)
|
||||
]);
|
||||
|
||||
if (!$search) {
|
||||
|
@ -105,7 +106,7 @@ class Index extends BaseSearch
|
|||
}
|
||||
|
||||
if (strpos($search, '#') === 0) {
|
||||
$tag = true;
|
||||
$tag = true;
|
||||
$search = substr($search, 1);
|
||||
} else {
|
||||
if (strpos($search, '@') === 0 || strpos($search, '!') === 0) {
|
||||
|
@ -134,7 +135,7 @@ class Index extends BaseSearch
|
|||
// Don't perform a fulltext or tag search on search results that look like an URL
|
||||
// Tags don't look like an URL and the fulltext search does only work with natural words
|
||||
if (parse_url($search, PHP_URL_SCHEME) && parse_url($search, PHP_URL_HOST)) {
|
||||
Logger::info('Skipping tag and fulltext search since the search looks like a URL.', ['q' => $search]);
|
||||
$this->logger->info('Skipping tag and fulltext search since the search looks like a URL.', ['q' => $search]);
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('No results.'));
|
||||
return $o;
|
||||
}
|
||||
|
@ -147,11 +148,19 @@ class Index extends BaseSearch
|
|||
// No items will be shown if the member has a blocked profile wall.
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
$itemsPerPage = DI::pConfig()->get(
|
||||
DI::userSession()->getLocalUserId(),
|
||||
'system',
|
||||
'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile')
|
||||
);
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
$itemsPerPage = DI::pConfig()->get(
|
||||
DI::userSession()->getLocalUserId(),
|
||||
'system',
|
||||
'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network')
|
||||
);
|
||||
}
|
||||
|
||||
$last_uriid = isset($_GET['last_uriid']) ? intval($_GET['last_uriid']) : 0;
|
||||
|
@ -159,20 +168,20 @@ class Index extends BaseSearch
|
|||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||
|
||||
if ($tag) {
|
||||
Logger::info('Start tag search.', ['q' => $search, 'start' => $pager->getStart(), 'items' => $pager->getItemsPerPage(), 'last' => $last_uriid]);
|
||||
$this->logger->info('Start tag search.', ['q' => $search, 'start' => $pager->getStart(), 'items' => $pager->getItemsPerPage(), 'last' => $last_uriid]);
|
||||
$uriids = Tag::getURIIdListByTag($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Tag::countByTag($search, DI::userSession()->getLocalUserId());
|
||||
$count = Tag::countByTag($search, DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
Logger::info('Start fulltext search.', ['q' => $search]);
|
||||
$this->logger->info('Start fulltext search.', ['q' => $search]);
|
||||
$uriids = Post\Content::getURIIdListBySearch($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Post\Content::countBySearch($search, DI::userSession()->getLocalUserId());
|
||||
$count = Post\Content::countBySearch($search, DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
if (!empty($uriids)) {
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, DI::userSession()->getLocalUserId()];
|
||||
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
|
||||
$params = ['order' => ['uri-id' => true]];
|
||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
$params = ['order' => ['uri-id' => true]];
|
||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
}
|
||||
|
||||
if (empty($items)) {
|
||||
|
@ -197,7 +206,7 @@ class Index extends BaseSearch
|
|||
'$title' => $title
|
||||
]);
|
||||
|
||||
Logger::info('Start Conversation.', ['q' => $search]);
|
||||
$this->logger->info('Start Conversation.', ['q' => $search]);
|
||||
|
||||
$o .= DI::conversation()->render($items, Conversation::MODE_SEARCH, false, false, 'commented', DI::userSession()->getLocalUserId());
|
||||
|
||||
|
|
|
@ -9,9 +9,7 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +32,7 @@ class Smilies extends BaseModule
|
|||
protected function content(array $request = []): string
|
||||
{
|
||||
$smilies = Content\Smilies::getList();
|
||||
$count = count($smilies['texts'] ?? []);
|
||||
$count = count($smilies['texts'] ?? []);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('smilies.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Friendica\Network\HTTPClient\Response;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use GuzzleHttp\RedirectMiddleware;
|
||||
|
@ -65,7 +65,7 @@ class GuzzleResponse extends Response implements ICanHandleHttpResponses, Respon
|
|||
}
|
||||
|
||||
if (!$this->isSuccess) {
|
||||
Logger::debug('debug', ['info' => $this->getHeaders()]);
|
||||
DI::logger()->debug('debug', ['info' => $this->getHeaders()]);
|
||||
}
|
||||
|
||||
if (!$this->isSuccess && $this->errorNumber == CURLE_OPERATION_TIMEDOUT) {
|
||||
|
|
|
@ -12,7 +12,6 @@ use DomXPath;
|
|||
use Exception;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -116,7 +115,7 @@ class Probe
|
|||
$data['photo'] = Network::addBasePath($data['photo'], $data['url']);
|
||||
|
||||
if (!Network::isValidHttpUrl($data['photo'])) {
|
||||
Logger::warning('Invalid URL for photo', ['url' => $data['url'], 'photo' => $data['photo']]);
|
||||
DI::logger()->warning('Invalid URL for photo', ['url' => $data['url'], 'photo' => $data['photo']]);
|
||||
unset($data['photo']);
|
||||
}
|
||||
}
|
||||
|
@ -205,21 +204,21 @@ class Probe
|
|||
// Handles the case when the hostname contains the scheme
|
||||
if (!parse_url($host, PHP_URL_SCHEME)) {
|
||||
$ssl_url = 'https://' . $host . self::HOST_META;
|
||||
$url = 'http://' . $host . self::HOST_META;
|
||||
$url = 'http://' . $host . self::HOST_META;
|
||||
} else {
|
||||
$ssl_url = $host . self::HOST_META;
|
||||
$url = '';
|
||||
$url = '';
|
||||
}
|
||||
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
|
||||
|
||||
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url]);
|
||||
DI::logger()->info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url]);
|
||||
$xrd = null;
|
||||
|
||||
try {
|
||||
$curlResult = DI::httpClient()->get($ssl_url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -234,7 +233,7 @@ class Probe
|
|||
$host_url = 'https://' . $host;
|
||||
}
|
||||
} elseif ($curlResult->isTimeout()) {
|
||||
Logger::info('Probing timeout', ['url' => $ssl_url]);
|
||||
DI::logger()->info('Probing timeout', ['url' => $ssl_url]);
|
||||
self::$isTimeout = true;
|
||||
return [];
|
||||
}
|
||||
|
@ -243,12 +242,12 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
|
||||
if ($curlResult->isTimeout()) {
|
||||
Logger::info('Probing timeout', ['url' => $url]);
|
||||
DI::logger()->info('Probing timeout', ['url' => $url]);
|
||||
self::$isTimeout = true;
|
||||
return [];
|
||||
} elseif ($connection_error && $ssl_connection_error) {
|
||||
|
@ -256,18 +255,18 @@ class Probe
|
|||
return [];
|
||||
}
|
||||
|
||||
$xml = $curlResult->getBodyString();
|
||||
$xrd = XML::parseString($xml, true);
|
||||
$xml = $curlResult->getBodyString();
|
||||
$xrd = XML::parseString($xml, true);
|
||||
$host_url = 'http://' . $host;
|
||||
}
|
||||
if (!is_object($xrd)) {
|
||||
Logger::info('No xrd object found', ['host' => $host]);
|
||||
DI::logger()->info('No xrd object found', ['host' => $host]);
|
||||
return [];
|
||||
}
|
||||
|
||||
$links = XML::elementToArray($xrd);
|
||||
if (!isset($links['xrd']['link'])) {
|
||||
Logger::info('No xrd data found', ['host' => $host]);
|
||||
DI::logger()->info('No xrd data found', ['host' => $host]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -290,13 +289,13 @@ class Probe
|
|||
}
|
||||
|
||||
if (Network::isUrlBlocked($host_url)) {
|
||||
Logger::info('Domain is blocked', ['url' => $host]);
|
||||
DI::logger()->info('Domain is blocked', ['url' => $host]);
|
||||
return [];
|
||||
}
|
||||
|
||||
self::$baseurl = $host_url;
|
||||
|
||||
Logger::info('Probing successful', ['host' => $host]);
|
||||
DI::logger()->info('Probing successful', ['host' => $host]);
|
||||
|
||||
return $lrdd;
|
||||
}
|
||||
|
@ -317,7 +316,7 @@ class Probe
|
|||
$webfinger = $data['webfinger'];
|
||||
|
||||
if (empty($webfinger['links'])) {
|
||||
Logger::info('No webfinger links found', ['uri' => $uri]);
|
||||
DI::logger()->info('No webfinger links found', ['uri' => $uri]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -331,7 +330,7 @@ class Probe
|
|||
foreach ($webfinger['aliases'] as $alias) {
|
||||
$data[] = [
|
||||
'@attributes' => [
|
||||
'rel' => 'alias',
|
||||
'rel' => 'alias',
|
||||
'href' => $alias,
|
||||
]
|
||||
];
|
||||
|
@ -384,18 +383,18 @@ class Probe
|
|||
unset($data['networks']);
|
||||
if (!empty($data['network'])) {
|
||||
$networks[$data['network']] = $data;
|
||||
$ap_profile['guid'] = $ap_profile['guid'] ?? $data['guid'] ?? null;
|
||||
$ap_profile['about'] = $ap_profile['about'] ?? $data['about'] ?? null;
|
||||
$ap_profile['keywords'] = $data['keywords'] ?? null;
|
||||
$ap_profile['location'] = $data['location'] ?? null;
|
||||
$ap_profile['poco'] = $data['poco'] ?? null;
|
||||
$ap_profile['openwebauth'] = $data['openwebauth'] ?? null;
|
||||
$ap_profile['guid'] = $ap_profile['guid'] ?? $data['guid'] ?? null;
|
||||
$ap_profile['about'] = $ap_profile['about'] ?? $data['about'] ?? null;
|
||||
$ap_profile['keywords'] = $data['keywords'] ?? null;
|
||||
$ap_profile['location'] = $data['location'] ?? null;
|
||||
$ap_profile['poco'] = $data['poco'] ?? null;
|
||||
$ap_profile['openwebauth'] = $data['openwebauth'] ?? null;
|
||||
}
|
||||
$data = $ap_profile;
|
||||
$data = $ap_profile;
|
||||
$data['networks'] = $networks;
|
||||
} elseif (!empty($ap_profile)) {
|
||||
$ap_profile['batch'] = '';
|
||||
$data = array_merge($ap_profile, $data);
|
||||
$data = array_merge($ap_profile, $data);
|
||||
}
|
||||
} else {
|
||||
$data = $ap_profile;
|
||||
|
@ -464,7 +463,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
if (!$curlResult->isSuccess()) {
|
||||
|
@ -583,7 +582,7 @@ class Probe
|
|||
|
||||
if (empty($webfinger) && empty($lrdd)) {
|
||||
while (empty($lrdd) && empty($webfinger) && (count($path_parts) > 1)) {
|
||||
$host .= '/' . array_shift($path_parts);
|
||||
$host .= '/' . array_shift($path_parts);
|
||||
$baseurl = $parts['scheme'] . '://' . $host;
|
||||
|
||||
if (!empty($nick)) {
|
||||
|
@ -631,7 +630,7 @@ class Probe
|
|||
$baseurl = self::$baseurl;
|
||||
}
|
||||
} else {
|
||||
Logger::info('URI was not detectable', ['uri' => $uri]);
|
||||
DI::logger()->info('URI was not detectable', ['uri' => $uri]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -672,7 +671,7 @@ class Probe
|
|||
private static function getWebfinger(string $template, string $type, string $uri, string $addr): ?array
|
||||
{
|
||||
if (Network::isUrlBlocked($template)) {
|
||||
Logger::info('Domain is blocked', ['url' => $template]);
|
||||
DI::logger()->info('Domain is blocked', ['url' => $template]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -680,8 +679,8 @@ class Probe
|
|||
|
||||
// First try the address because this is the primary purpose of webfinger
|
||||
if ($addr !== '') {
|
||||
$detected = $addr;
|
||||
$path = str_replace('{uri}', urlencode('acct:' . $addr), $template);
|
||||
$detected = $addr;
|
||||
$path = str_replace('{uri}', urlencode('acct:' . $addr), $template);
|
||||
$webfinger = self::webfinger($path, $type);
|
||||
if (is_null($webfinger)) {
|
||||
return null;
|
||||
|
@ -690,8 +689,8 @@ class Probe
|
|||
|
||||
// Then try the URI
|
||||
if (empty($webfinger) && $uri != $addr) {
|
||||
$detected = $uri;
|
||||
$path = str_replace('{uri}', urlencode($uri), $template);
|
||||
$detected = $uri;
|
||||
$path = str_replace('{uri}', urlencode($uri), $template);
|
||||
$webfinger = self::webfinger($path, $type);
|
||||
if (is_null($webfinger)) {
|
||||
return null;
|
||||
|
@ -734,7 +733,7 @@ class Probe
|
|||
|
||||
$parts = parse_url($uri);
|
||||
if (empty($parts['scheme']) && empty($parts['host']) && (empty($parts['path']) || strpos($parts['path'], '@') === false)) {
|
||||
Logger::info('URI was not detectable, probe for AT Protocol now', ['uri' => $uri]);
|
||||
DI::logger()->info('URI was not detectable, probe for AT Protocol now', ['uri' => $uri]);
|
||||
return self::atProtocol($uri);
|
||||
}
|
||||
|
||||
|
@ -748,7 +747,7 @@ class Probe
|
|||
return self::mail($uri, $uid);
|
||||
}
|
||||
|
||||
Logger::info('Probing start', ['uri' => $uri]);
|
||||
DI::logger()->info('Probing start', ['uri' => $uri]);
|
||||
|
||||
if (!empty($ap_profile['addr']) && ($ap_profile['addr'] != $uri)) {
|
||||
$data = self::getWebfingerArray($ap_profile['addr']);
|
||||
|
@ -773,9 +772,9 @@ class Probe
|
|||
}
|
||||
|
||||
$webfinger = $data['webfinger'];
|
||||
$nick = $data['nick'] ?? '';
|
||||
$addr = $data['addr'] ?? '';
|
||||
$baseurl = $data['baseurl'] ?? '';
|
||||
$nick = $data['nick'] ?? '';
|
||||
$addr = $data['addr'] ?? '';
|
||||
$baseurl = $data['baseurl'] ?? '';
|
||||
|
||||
$result = [];
|
||||
|
||||
|
@ -821,7 +820,7 @@ class Probe
|
|||
$result['url'] = $uri;
|
||||
}
|
||||
|
||||
Logger::info('Probing done', ['uri' => $uri, 'network' => $result['network']]);
|
||||
DI::logger()->info('Probing done', ['uri' => $uri, 'network' => $result['network']]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -906,7 +905,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($url, 'application/x-zot+json', [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return $data;
|
||||
}
|
||||
if ($curlResult->isTimeout()) {
|
||||
|
@ -963,7 +962,7 @@ class Probe
|
|||
$data['hide'] = !$json['searchable'];
|
||||
}
|
||||
if (!empty($json['public_forum'])) {
|
||||
$data['community'] = $json['public_forum'];
|
||||
$data['community'] = $json['public_forum'];
|
||||
$data['account-type'] = User::ACCOUNT_TYPE_COMMUNITY;
|
||||
} elseif (($json['channel_type'] ?? '') == 'normal') {
|
||||
$data['account-type'] = User::ACCOUNT_TYPE_PERSON;
|
||||
|
@ -1017,7 +1016,7 @@ class Probe
|
|||
[HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout', 20), HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
Logger::notice($e->getMessage(), ['url' => $url, 'type' => $type, 'class' => get_class($e)]);
|
||||
DI::logger()->notice($e->getMessage(), ['url' => $url, 'type' => $type, 'class' => get_class($e)]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1029,7 @@ class Probe
|
|||
$webfinger = json_decode($data, true);
|
||||
if (!empty($webfinger)) {
|
||||
if (!isset($webfinger['links'])) {
|
||||
Logger::info('No json webfinger links', ['url' => $url]);
|
||||
DI::logger()->info('No json webfinger links', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
return $webfinger;
|
||||
|
@ -1039,13 +1038,13 @@ class Probe
|
|||
// If it is not JSON, maybe it is XML
|
||||
$xrd = XML::parseString($data, true);
|
||||
if (!is_object($xrd)) {
|
||||
Logger::info('No webfinger data retrievable', ['url' => $url]);
|
||||
DI::logger()->info('No webfinger data retrievable', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
$xrd_arr = XML::elementToArray($xrd);
|
||||
if (!isset($xrd_arr['xrd']['link'])) {
|
||||
Logger::info('No XML webfinger links', ['url' => $url]);
|
||||
DI::logger()->info('No XML webfinger links', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1091,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($noscrape_url, HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return $data;
|
||||
}
|
||||
if ($curlResult->isTimeout()) {
|
||||
|
@ -1101,13 +1100,13 @@ class Probe
|
|||
}
|
||||
$content = $curlResult->getBodyString();
|
||||
if (!$content) {
|
||||
Logger::info('Empty body', ['url' => $noscrape_url]);
|
||||
DI::logger()->info('Empty body', ['url' => $noscrape_url]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
$json = json_decode($content, true);
|
||||
if (!is_array($json)) {
|
||||
Logger::info('No json data', ['url' => $noscrape_url]);
|
||||
DI::logger()->info('No json data', ['url' => $noscrape_url]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1189,7 @@ class Probe
|
|||
private static function dfrn(array $webfinger): array
|
||||
{
|
||||
$hcard_url = '';
|
||||
$data = [];
|
||||
$data = [];
|
||||
// The array is reversed to take into account the order of preference for same-rel links
|
||||
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
||||
foreach (array_reverse($webfinger['links']) as $link) {
|
||||
|
@ -1257,7 +1256,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($hcard_url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
if ($curlResult->isTimeout()) {
|
||||
|
@ -1381,7 +1380,7 @@ class Probe
|
|||
private static function diaspora(array $webfinger): array
|
||||
{
|
||||
$hcard_url = '';
|
||||
$data = [];
|
||||
$data = [];
|
||||
|
||||
// The array is reversed to take into account the order of preference for same-rel links
|
||||
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
||||
|
@ -1447,7 +1446,7 @@ class Probe
|
|||
&& !empty($data['pubkey'])
|
||||
&& $hcard_url !== ''
|
||||
) {
|
||||
$data['network'] = Protocol::DIASPORA;
|
||||
$data['network'] = Protocol::DIASPORA;
|
||||
$data['manually-approve'] = false;
|
||||
|
||||
// The Diaspora handle must always be lowercase
|
||||
|
@ -1521,7 +1520,7 @@ class Probe
|
|||
self::$isTimeout = true;
|
||||
return $short ? false : [];
|
||||
}
|
||||
Logger::debug('Fetched public key', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $pubkey]);
|
||||
DI::logger()->debug('Fetched public key', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $pubkey]);
|
||||
$pubkey = $curlResult->getBodyString();
|
||||
}
|
||||
|
||||
|
@ -1538,7 +1537,7 @@ class Probe
|
|||
&& isset($data['poll'])
|
||||
&& isset($data['url'])
|
||||
) {
|
||||
$data['network'] = Protocol::OSTATUS;
|
||||
$data['network'] = Protocol::OSTATUS;
|
||||
$data['manually-approve'] = false;
|
||||
} else {
|
||||
return $short ? false : [];
|
||||
|
@ -1552,14 +1551,14 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return [];
|
||||
}
|
||||
if ($curlResult->isTimeout()) {
|
||||
self::$isTimeout = true;
|
||||
return [];
|
||||
}
|
||||
$feed = $curlResult->getBodyString();
|
||||
$feed = $curlResult->getBodyString();
|
||||
$feed_data = Feed::import($feed);
|
||||
if (!$feed_data) {
|
||||
return [];
|
||||
|
@ -1669,10 +1668,12 @@ class Probe
|
|||
|
||||
// Resolve arbitrary relative path
|
||||
// Lifted from https://www.php.net/manual/en/function.realpath.php#84012
|
||||
$parts = array_filter(explode('/', $path), 'strlen');
|
||||
$parts = array_filter(explode('/', $path), 'strlen');
|
||||
$absolutes = [];
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part) continue;
|
||||
if ('.' == $part) {
|
||||
continue;
|
||||
}
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
|
@ -1716,30 +1717,30 @@ class Probe
|
|||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
$profile = DI::atProtocol()->XRPCGet('app.bsky.actor.getProfile', ['actor' => $did]);
|
||||
if (empty($profile) || empty($profile->did)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$nick = $profile->handle ?? $profile->did;
|
||||
$nick = $profile->handle ?? $profile->did;
|
||||
$name = $profile->displayName ?? $nick;
|
||||
|
||||
$data = [
|
||||
'network' => Protocol::BLUESKY,
|
||||
'url' => $profile->did,
|
||||
'alias' => ATProtocol::WEB . '/profile/' . $nick,
|
||||
'name' => $name ?: $nick,
|
||||
'nick' => $nick,
|
||||
'addr' => $nick,
|
||||
'poll' => ATProtocol::WEB . '/profile/' . $profile->did . '/rss',
|
||||
'photo' => $profile->avatar ?? '',
|
||||
'network' => Protocol::BLUESKY,
|
||||
'url' => $profile->did,
|
||||
'alias' => ATProtocol::WEB . '/profile/' . $nick,
|
||||
'name' => $name ?: $nick,
|
||||
'nick' => $nick,
|
||||
'addr' => $nick,
|
||||
'poll' => ATProtocol::WEB . '/profile/' . $profile->did . '/rss',
|
||||
'photo' => $profile->avatar ?? '',
|
||||
];
|
||||
|
||||
|
||||
if (!empty($profile->description)) {
|
||||
$data['about'] = HTML::toBBCode($profile->description);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($profile->banner)) {
|
||||
$data['header'] = $profile->banner;
|
||||
}
|
||||
|
@ -1820,7 +1821,7 @@ class Probe
|
|||
$data['alias'] = $feed_data['header']['author-id'];
|
||||
}
|
||||
|
||||
$data['url'] = $url;
|
||||
$data['url'] = $url;
|
||||
$data['poll'] = $url;
|
||||
|
||||
$data['network'] = Protocol::FEED;
|
||||
|
@ -1850,14 +1851,14 @@ class Probe
|
|||
$user = DBA::selectFirst('user', ['prvkey'], ['uid' => $uid]);
|
||||
|
||||
$condition = ["`uid` = ? AND `server` != ''", $uid];
|
||||
$fields = ['pass', 'user', 'server', 'port', 'ssltype', 'mailbox'];
|
||||
$mailacct = DBA::selectFirst('mailacct', $fields, $condition);
|
||||
$fields = ['pass', 'user', 'server', 'port', 'ssltype', 'mailbox'];
|
||||
$mailacct = DBA::selectFirst('mailacct', $fields, $condition);
|
||||
|
||||
if (!DBA::isResult($user) || !DBA::isResult($mailacct)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$mailbox = Email::constructMailboxName($mailacct);
|
||||
$mailbox = Email::constructMailboxName($mailacct);
|
||||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($mailacct['pass']), $password, $user['prvkey']);
|
||||
$mbox = Email::connect($mailbox, $mailacct['user'], $password);
|
||||
|
@ -1866,7 +1867,7 @@ class Probe
|
|||
}
|
||||
|
||||
$msgs = Email::poll($mbox, $uri);
|
||||
Logger::info('Messages found', ['uri' => $uri, 'count' => count($msgs)]);
|
||||
DI::logger()->info('Messages found', ['uri' => $uri, 'count' => count($msgs)]);
|
||||
|
||||
if (!count($msgs)) {
|
||||
return [];
|
||||
|
@ -1884,7 +1885,7 @@ class Probe
|
|||
'poll' => 'email ' . Strings::getRandomHex(),
|
||||
];
|
||||
|
||||
$data['nick'] = $data['name'];
|
||||
$data['nick'] = $data['name'];
|
||||
|
||||
$x = Email::messageMeta($mbox, $msgs[0]);
|
||||
|
||||
|
@ -1900,7 +1901,7 @@ class Probe
|
|||
&& (strcasecmp($feadr->host, $phost) == 0)
|
||||
&& !empty($feadr->personal)
|
||||
) {
|
||||
$personal = imap_mime_header_decode($feadr->personal);
|
||||
$personal = imap_mime_header_decode($feadr->personal);
|
||||
$data['name'] = '';
|
||||
foreach ($personal as $perspart) {
|
||||
if ($perspart->charset != 'default') {
|
||||
|
@ -1953,7 +1954,7 @@ class Probe
|
|||
|
||||
$fixed = $scheme . $host . $port . $path . $query . $fragment;
|
||||
|
||||
Logger::debug('Avatar fixed', ['base' => $base, 'avatar' => $avatar, 'fixed' => $fixed]);
|
||||
DI::logger()->debug('Avatar fixed', ['base' => $base, 'avatar' => $avatar, 'fixed' => $fixed]);
|
||||
|
||||
return $fixed;
|
||||
}
|
||||
|
@ -2015,7 +2016,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($gserver['noscrape'] . '/' . $data['nick'], HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -2055,7 +2056,7 @@ class Probe
|
|||
if (is_string($outbox['first']) && ($outbox['first'] != $feed)) {
|
||||
return self::updateFromOutbox($outbox['first'], $data);
|
||||
} else {
|
||||
Logger::warning('Unexpected data', ['outbox' => $outbox]);
|
||||
DI::logger()->warning('Unexpected data', ['outbox' => $outbox]);
|
||||
}
|
||||
return '';
|
||||
} else {
|
||||
|
@ -2065,9 +2066,9 @@ class Probe
|
|||
$last_updated = '';
|
||||
foreach ($items as $activity) {
|
||||
if (!empty($activity['published'])) {
|
||||
$published = DateTimeFormat::utc($activity['published']);
|
||||
$published = DateTimeFormat::utc($activity['published']);
|
||||
} elseif (!empty($activity['object']['published'])) {
|
||||
$published = DateTimeFormat::utc($activity['object']['published']);
|
||||
$published = DateTimeFormat::utc($activity['object']['published']);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -2096,7 +2097,7 @@ class Probe
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($data['poll'], HttpClientAccept::ATOM_XML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return '';
|
||||
}
|
||||
if (!$curlResult->isSuccess() || !$curlResult->getBodyString()) {
|
||||
|
@ -2120,7 +2121,7 @@ class Probe
|
|||
$updated = !empty($updated_item->nodeValue) ? DateTimeFormat::utc($updated_item->nodeValue) : null;
|
||||
|
||||
if (empty($published) || empty($updated)) {
|
||||
Logger::notice('Invalid entry for XPath.', ['entry' => $entry, 'url' => $data['url']]);
|
||||
DI::logger()->notice('Invalid entry for XPath.', ['entry' => $entry, 'url' => $data['url']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2183,7 +2184,7 @@ class Probe
|
|||
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
|
||||
'pubkey' => $owner['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $owner['gsid'],
|
||||
'manually-approve' => in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP, User::PAGE_FLAGS_COMM_MAN]),
|
||||
'networks' => [
|
||||
'networks' => [
|
||||
Protocol::DIASPORA => [
|
||||
'name' => $owner['name'],
|
||||
'given_name' => $split_name['first'],
|
||||
|
@ -2208,7 +2209,7 @@ class Probe
|
|||
} catch (Exception $e) {
|
||||
// Default values for nonexistent targets
|
||||
$data = [
|
||||
'name' => $url, 'nick' => $url, 'url' => $url, 'network' => Protocol::PHANTOM,
|
||||
'name' => $url, 'nick' => $url, 'url' => $url, 'network' => Protocol::PHANTOM,
|
||||
'photo' => DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO
|
||||
];
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue