mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 09:34:26 +02:00
Replace Logger with DI::logger() in Model classes
This commit is contained in:
parent
5b4faf811f
commit
a0e2c82c62
12 changed files with 253 additions and 266 deletions
|
@ -16,7 +16,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
|
@ -215,7 +214,7 @@ class Item
|
|||
return $rows;
|
||||
}
|
||||
|
||||
Logger::info('Updating per single row method', ['fields' => $fields, 'condition' => $condition]);
|
||||
DI::logger()->info('Updating per single row method', ['fields' => $fields, 'condition' => $condition]);
|
||||
|
||||
$items = Post::select(['id', 'origin', 'uri-id', 'uid', 'author-network', 'quote-uri-id'], $condition);
|
||||
|
||||
|
@ -236,7 +235,7 @@ class Item
|
|||
if ($item['origin'] && empty($item['quote-uri-id'])) {
|
||||
$quote_id = Post\Media::getActivityUriId($item['uri-id']);
|
||||
if (!empty($quote_id)) {
|
||||
Logger::notice('Found attached post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->notice('Found attached post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
$content_fields['quote-uri-id'] = $quote_id;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +331,7 @@ class Item
|
|||
if ($item['uid'] == $uid) {
|
||||
self::markForDeletionById($item['id'], Worker::PRIORITY_HIGH);
|
||||
} elseif ($item['uid'] != 0) {
|
||||
Logger::warning('Wrong ownership. Not deleting item', ['id' => $item['id']]);
|
||||
DI::logger()->warning('Wrong ownership. Not deleting item', ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
DBA::close($items);
|
||||
|
@ -348,7 +347,7 @@ class Item
|
|||
*/
|
||||
public static function markForDeletionById(int $item_id, int $priority = Worker::PRIORITY_HIGH): bool
|
||||
{
|
||||
Logger::info('Mark item for deletion by id', ['id' => $item_id]);
|
||||
DI::logger()->info('Mark item for deletion by id', ['id' => $item_id]);
|
||||
// locate item to be deleted
|
||||
$fields = [
|
||||
'id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri-id', 'origin',
|
||||
|
@ -357,12 +356,12 @@ class Item
|
|||
];
|
||||
$item = Post::selectFirst($fields, ['id' => $item_id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::info('Item not found.', ['id' => $item_id]);
|
||||
DI::logger()->info('Item not found.', ['id' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item['deleted']) {
|
||||
Logger::info('Item has already been marked for deletion.', ['id' => $item_id]);
|
||||
DI::logger()->info('Item has already been marked for deletion.', ['id' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -444,7 +443,7 @@ class Item
|
|||
Post\Counts::update($item['thr-parent-id'], $item['parent-uri-id'], $item['vid'], $item['verb'], $item['body']);
|
||||
}
|
||||
|
||||
Logger::info('Item has been marked for deletion.', ['id' => $item_id]);
|
||||
DI::logger()->info('Item has been marked for deletion.', ['id' => $item_id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -554,7 +553,7 @@ class Item
|
|||
return $contact_id;
|
||||
}
|
||||
|
||||
Logger::warning('contact-id could not be fetched, using self contact instead.', ['uid' => $item['uid'], 'item' => $item]);
|
||||
DI::logger()->warning('contact-id could not be fetched, using self contact instead.', ['uid' => $item['uid'], 'item' => $item]);
|
||||
$self = Contact::selectFirst(['id'], ['self' => true, 'uid' => $item['uid']]);
|
||||
return $self['id'];
|
||||
}
|
||||
|
@ -577,7 +576,7 @@ class Item
|
|||
$spool = $spoolpath . '/' . $file;
|
||||
|
||||
file_put_contents($spool, json_encode($item));
|
||||
Logger::warning("Item wasn't stored - Item was spooled into file", ['file' => $file]);
|
||||
DI::logger()->warning("Item wasn't stored - Item was spooled into file", ['file' => $file]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +591,7 @@ class Item
|
|||
// Checking if there is already an item with the same guid
|
||||
$condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
|
||||
if (Post::exists($condition)) {
|
||||
Logger::notice('Found already existing item', $condition);
|
||||
DI::logger()->notice('Found already existing item', $condition);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -601,7 +600,7 @@ class Item
|
|||
'network' => [$item['network'], Protocol::DFRN]
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
Logger::notice('duplicated item with the same uri found.', $condition);
|
||||
DI::logger()->notice('duplicated item with the same uri found.', $condition);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -609,7 +608,7 @@ class Item
|
|||
if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
|
||||
$condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
|
||||
if (Post::exists($condition)) {
|
||||
Logger::notice('duplicated item with the same guid found.', $condition);
|
||||
DI::logger()->notice('duplicated item with the same guid found.', $condition);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +619,7 @@ class Item
|
|||
* An unique index would help - but the limitations of MySQL (maximum size of index values) prevent this.
|
||||
*/
|
||||
if (($item['uid'] == 0) && Post::exists(['uri-id' => $item['uri-id'], 'uid' => 0])) {
|
||||
Logger::notice('Global item already stored.', ['uri-id' => $item['uri-id'], 'network' => $item['network']]);
|
||||
DI::logger()->notice('Global item already stored.', ['uri-id' => $item['uri-id'], 'network' => $item['network']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -637,47 +636,47 @@ class Item
|
|||
{
|
||||
// When there is no content then we don't post it
|
||||
if (($item['body'] . $item['title'] == '') && empty($item['quote-uri-id']) && empty($item['attachments']) && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
|
||||
Logger::notice('No body, no title.');
|
||||
DI::logger()->notice('No body, no title.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['uid'])) {
|
||||
$owner = User::getOwnerDataById($item['uid'], false);
|
||||
if (!$owner) {
|
||||
Logger::warning('Missing item user owner data', ['uid' => $item['uid']]);
|
||||
DI::logger()->warning('Missing item user owner data', ['uid' => $item['uid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($owner['account_expired'] || $owner['account_removed']) {
|
||||
Logger::notice('Item user has been deleted/expired/removed', ['uid' => $item['uid'], 'deleted' => $owner['deleted'], 'account_expired' => $owner['account_expired'], 'account_removed' => $owner['account_removed']]);
|
||||
DI::logger()->notice('Item user has been deleted/expired/removed', ['uid' => $item['uid'], 'deleted' => $owner['deleted'], 'account_expired' => $owner['account_expired'], 'account_removed' => $owner['account_removed']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['author-id']) && Contact::isBlocked($item['author-id'])) {
|
||||
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||
DI::logger()->notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['author-link']) && Network::isUrlBlocked($item['author-link'])) {
|
||||
Logger::notice('Author server is blocked', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||
DI::logger()->notice('Author server is blocked', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['owner-id']) && Contact::isBlocked($item['owner-id'])) {
|
||||
Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
||||
DI::logger()->notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['owner-link']) && Network::isUrlBlocked($item['owner-link'])) {
|
||||
Logger::notice('Owner server is blocked', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
||||
DI::logger()->notice('Owner server is blocked', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item['verb'] == Activity::FOLLOW) {
|
||||
if (!$item['origin'] && ($item['author-id'] == Contact::getPublicIdByUserId($item['uid']))) {
|
||||
// Our own follow request can be relayed to us. We don't store it to avoid notification chaos.
|
||||
Logger::info("Follow: Don't store not origin follow request", ['parent-uri' => $item['parent-uri']]);
|
||||
DI::logger()->info("Follow: Don't store not origin follow request", ['parent-uri' => $item['parent-uri']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -687,7 +686,7 @@ class Item
|
|||
];
|
||||
if (Post::exists($condition)) {
|
||||
// It happens that we receive multiple follow requests by the same author - we only store one.
|
||||
Logger::info('Follow: Found existing follow request from author', ['author-id' => $item['author-id'], 'parent-uri' => $item['parent-uri']]);
|
||||
DI::logger()->info('Follow: Found existing follow request from author', ['author-id' => $item['author-id'], 'parent-uri' => $item['parent-uri']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -716,7 +715,7 @@ class Item
|
|||
if (DBA::isResult($existing)) {
|
||||
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
|
||||
if ($item['uid'] != 0) {
|
||||
Logger::notice('Item already existed for user', [
|
||||
DI::logger()->notice('Item already existed for user', [
|
||||
'uri-id' => $item['uri-id'],
|
||||
'uid' => $item['uid'],
|
||||
'network' => $item['network'],
|
||||
|
@ -776,18 +775,18 @@ class Item
|
|||
$stored = Item::storeForUserByUriId($item['parent-uri-id'], $item['uid'], ['post-reason' => Item::PR_COMPLETION]);
|
||||
}
|
||||
if ($stored) {
|
||||
Logger::info('Stored thread parent item for user', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'stored' => $stored]);
|
||||
DI::logger()->info('Stored thread parent item for user', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'stored' => $stored]);
|
||||
$parent = Post::selectFirst($fields, $condition, $params);
|
||||
}
|
||||
}
|
||||
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::notice('item parent was not found - ignoring item', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->notice('item parent was not found - ignoring item', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (self::hasRestrictions($item, $parent['author-id'], $parent['restrictions'])) {
|
||||
Logger::notice('Restrictions apply - ignoring item', ['restrictions' => $parent['restrictions'], 'verb' => $parent['verb'], 'uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->notice('Restrictions apply - ignoring item', ['restrictions' => $parent['restrictions'], 'verb' => $parent['verb'], 'uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -805,12 +804,12 @@ class Item
|
|||
|
||||
if (!DBA::isResult($toplevel_parent) && $item['origin']) {
|
||||
$stored = Item::storeForUserByUriId($item['parent-uri-id'], $item['uid'], ['post-reason' => Item::PR_COMPLETION]);
|
||||
Logger::info('Stored parent item for user', ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'stored' => $stored]);
|
||||
DI::logger()->info('Stored parent item for user', ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'stored' => $stored]);
|
||||
$toplevel_parent = Post::selectFirst($fields, $condition, $params);
|
||||
}
|
||||
|
||||
if (!DBA::isResult($toplevel_parent)) {
|
||||
Logger::notice('item top level parent was not found - ignoring item', ['parent-uri-id' => $parent['parent-uri-id'], 'uid' => $parent['uid']]);
|
||||
DI::logger()->notice('item top level parent was not found - ignoring item', ['parent-uri-id' => $parent['parent-uri-id'], 'uid' => $parent['uid']]);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -839,7 +838,7 @@ class Item
|
|||
return self::GRAVITY_ACTIVITY;
|
||||
}
|
||||
|
||||
Logger::info('Unknown gravity for verb', ['verb' => $item['verb']]);
|
||||
DI::logger()->info('Unknown gravity for verb', ['verb' => $item['verb']]);
|
||||
return self::GRAVITY_UNKNOWN; // Should not happen
|
||||
}
|
||||
|
||||
|
@ -971,7 +970,7 @@ class Item
|
|||
if (($uid != 0) && ($item['network'] == Protocol::DIASPORA)) {
|
||||
$user = User::getById($uid, ['account-type']);
|
||||
if ($user['account-type'] == Contact::TYPE_COMMUNITY) {
|
||||
Logger::info('Community posts are not supported via Diaspora');
|
||||
DI::logger()->info('Community posts are not supported via Diaspora');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1014,7 +1013,7 @@ class Item
|
|||
!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
|
||||
empty($item['origin']) && DI::contentItem()->isTooOld($item['created'], $item['uid'])
|
||||
) {
|
||||
Logger::info('Item is too old', ['item' => $item]);
|
||||
DI::logger()->info('Item is too old', ['item' => $item]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1066,7 @@ class Item
|
|||
// If its a post that originated here then tag the thread as "mention"
|
||||
if ($item['origin'] && $item['uid']) {
|
||||
DBA::update('post-thread-user', ['mention' => true], ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
|
||||
Logger::info('tagged thread as mention', ['parent' => $parent_id, 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->info('tagged thread as mention', ['parent' => $parent_id, 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
// Update the contact relations
|
||||
|
@ -1149,7 +1148,7 @@ class Item
|
|||
}
|
||||
|
||||
if (!empty($item['cancel'])) {
|
||||
Logger::notice('post cancelled by addon.');
|
||||
DI::logger()->notice('post cancelled by addon.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1193,13 +1192,13 @@ class Item
|
|||
if (!empty($quote_id)) {
|
||||
// This is one of these "should not happen" situations.
|
||||
// The protocol implementations should already have done this job.
|
||||
Logger::notice('Quote-uri-id detected in post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->notice('Quote-uri-id detected in post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
$item['quote-uri-id'] = $quote_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] == $item['uri-id'])) {
|
||||
Logger::info('Quote-Uri-Id is identical to Uri-Id', ['uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Quote-Uri-Id is identical to Uri-Id', ['uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
unset($item['quote-uri-id']);
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1231,7 @@ class Item
|
|||
if ($item['origin'] && empty($item['quote-uri-id'])) {
|
||||
$quote_id = Post\Media::getActivityUriId($item['uri-id']);
|
||||
if (!empty($quote_id)) {
|
||||
Logger::notice('Found attached post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->notice('Found attached post', ['id' => $quote_id, 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
$item['quote-uri-id'] = $quote_id;
|
||||
}
|
||||
}
|
||||
|
@ -1242,7 +1241,7 @@ class Item
|
|||
|
||||
$ev = Event::fromBBCode($item['body']);
|
||||
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
||||
Logger::info('Event found.');
|
||||
DI::logger()->info('Event found.');
|
||||
$ev['cid'] = $item['contact-id'];
|
||||
$ev['uid'] = $item['uid'];
|
||||
$ev['uri'] = $item['uri'];
|
||||
|
@ -1263,7 +1262,7 @@ class Item
|
|||
$event_id = Event::store($ev);
|
||||
$item = Event::getItemArrayForImportedId($event_id, $item);
|
||||
|
||||
Logger::info('Event was stored', ['id' => $event_id]);
|
||||
DI::logger()->info('Event was stored', ['id' => $event_id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1328,13 +1327,13 @@ class Item
|
|||
|
||||
$condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid']];
|
||||
if (Post::exists($condition)) {
|
||||
Logger::notice('Item is already inserted - aborting', $condition);
|
||||
DI::logger()->notice('Item is already inserted - aborting', $condition);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$post_user_id = Post\User::insert($item['uri-id'], $item['uid'], $item);
|
||||
if (!$post_user_id) {
|
||||
Logger::notice('Post-User is already inserted - aborting', ['uid' => $item['uid'], 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->notice('Post-User is already inserted - aborting', ['uid' => $item['uid'], 'uri-id' => $item['uri-id']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1343,12 +1342,12 @@ class Item
|
|||
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
||||
}
|
||||
|
||||
Logger::notice('created item', ['post-id' => $post_user_id, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->notice('created item', ['post-id' => $post_user_id, 'uid' => $item['uid'], 'network' => $item['network'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
|
||||
$posted_item = Post::selectFirst(self::ITEM_FIELDLIST, ['post-user-id' => $post_user_id]);
|
||||
if (!DBA::isResult($posted_item)) {
|
||||
// On failure store the data into a spool file so that the "SpoolPost" worker can try again later.
|
||||
Logger::warning('Could not store item. it will be spooled', ['id' => $post_user_id]);
|
||||
DI::logger()->warning('Could not store item. it will be spooled', ['id' => $post_user_id]);
|
||||
self::spool($orig_item);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1385,7 +1384,7 @@ class Item
|
|||
// Get the user information for the logging
|
||||
$user = User::getById($uid);
|
||||
|
||||
Logger::notice('Item had been deleted', ['id' => $post_user_id, 'user' => $uid, 'account-type' => $user['account-type']]);
|
||||
DI::logger()->notice('Item had been deleted', ['id' => $post_user_id, 'user' => $uid, 'account-type' => $user['account-type']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1418,15 +1417,15 @@ class Item
|
|||
|
||||
if ($transmit) {
|
||||
if ($posted_item['uid'] && Contact\User::isBlocked($posted_item['author-id'], $posted_item['uid'])) {
|
||||
Logger::info('Message from blocked author will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['author-id']]);
|
||||
DI::logger()->info('Message from blocked author will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['author-id']]);
|
||||
$transmit = false;
|
||||
}
|
||||
if ($transmit && $posted_item['uid'] && Contact\User::isBlocked($posted_item['owner-id'], $posted_item['uid'])) {
|
||||
Logger::info('Message from blocked owner will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['owner-id']]);
|
||||
DI::logger()->info('Message from blocked owner will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['owner-id']]);
|
||||
$transmit = false;
|
||||
}
|
||||
if ($transmit && !empty($posted_item['causer-id']) && $posted_item['uid'] && Contact\User::isBlocked($posted_item['causer-id'], $posted_item['uid'])) {
|
||||
Logger::info('Message from blocked causer will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['causer-id']]);
|
||||
DI::logger()->info('Message from blocked causer will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['causer-id']]);
|
||||
$transmit = false;
|
||||
}
|
||||
|
||||
|
@ -1434,7 +1433,7 @@ class Item
|
|||
if (($posted_item['verb'] == Activity::FOLLOW) &&
|
||||
(!$posted_item['origin'] || ($posted_item['author-id'] != Contact::getPublicIdByUserId($uid)))
|
||||
) {
|
||||
Logger::info('Participation messages will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'verb' => $posted_item['verb']]);
|
||||
DI::logger()->info('Participation messages will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'verb' => $posted_item['verb']]);
|
||||
$transmit = false;
|
||||
}
|
||||
}
|
||||
|
@ -1520,25 +1519,25 @@ class Item
|
|||
|
||||
$item = Post::selectFirst(['id', 'private', 'network', 'language', 'owner-id'], ['uri-id' => $uri_id, 'uid' => 0]);
|
||||
if (empty($item['id'])) {
|
||||
Logger::debug('Post not found', ['uri-id' => $uri_id]);
|
||||
DI::logger()->debug('Post not found', ['uri-id' => $uri_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (($item['private'] != self::PUBLIC) || !in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
|
||||
Logger::debug('Not a public post or no AP or DFRN post', ['uri-id' => $uri_id]);
|
||||
DI::logger()->debug('Not a public post or no AP or DFRN post', ['uri-id' => $uri_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$engagement = DBA::selectFirst('post-engagement', ['searchtext', 'media-type'], ['uri-id' => $uri_id]);
|
||||
if (empty($engagement['searchtext'])) {
|
||||
Logger::debug('No engagement found', ['uri-id' => $uri_id]);
|
||||
DI::logger()->debug('No engagement found', ['uri-id' => $uri_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$language = !empty($item['language']) ? array_key_first(json_decode($item['language'], true)) : '';
|
||||
$tags = array_column(Tag::getByURIId($uri_id, [Tag::HASHTAG]), 'name');
|
||||
|
||||
Logger::debug('Prepare check', ['uri-id' => $uri_id, 'language' => $language, 'tags' => $tags, 'searchtext' => $engagement['searchtext'], 'media_type' => $engagement['media-type'], 'owner' => $item['owner-id'], 'reshare' => $reshare_id]);
|
||||
DI::logger()->debug('Prepare check', ['uri-id' => $uri_id, 'language' => $language, 'tags' => $tags, 'searchtext' => $engagement['searchtext'], 'media_type' => $engagement['media-type'], 'owner' => $item['owner-id'], 'reshare' => $reshare_id]);
|
||||
|
||||
$count = 0;
|
||||
foreach (DI::userDefinedChannel()->getMatchingChannelUsers($engagement['searchtext'], $language, $tags, $engagement['media-type'], $item['owner-id'], $reshare_id) as $uid) {
|
||||
|
@ -1547,19 +1546,19 @@ class Item
|
|||
'author-id' => Contact::getPublicIdByUserId($uid), 'uid' => $uid, 'thr-parent-id' => $uri_id
|
||||
];
|
||||
if (!Post::exists($condition)) {
|
||||
Logger::debug('Reshare post', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
DI::logger()->debug('Reshare post', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
$allow_cid = '';
|
||||
$allow_gid = '<' . Circle::FOLLOWERS . '>';
|
||||
$deny_cid = '';
|
||||
$deny_gid = '';
|
||||
self::performActivity($item['id'], 'announce', $uid, $allow_cid, $allow_gid, $deny_cid, $deny_gid);
|
||||
} else {
|
||||
Logger::debug('Reshare already exists', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
DI::logger()->debug('Reshare already exists', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
Logger::debug('Check done', ['uri-id' => $uri_id, 'count' => $count]);
|
||||
DI::logger()->debug('Check done', ['uri-id' => $uri_id, 'count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1622,13 +1621,13 @@ class Item
|
|||
['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]
|
||||
);
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::error('Parent not found', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->error('Parent not found', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
$author = Contact::selectFirst(['url', 'contact-type', 'network'], ['id' => $item['author-id']]);
|
||||
if (!DBA::isResult($author)) {
|
||||
Logger::error('Author not found', ['id' => $item['author-id']]);
|
||||
DI::logger()->error('Author not found', ['id' => $item['author-id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1637,24 +1636,24 @@ class Item
|
|||
|
||||
$cid = Contact::getIdForURL($author['url'], $item['uid']);
|
||||
if (empty($cid) || (!Contact::isSharing($cid, $item['uid']) && ($cid != $self))) {
|
||||
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid'], 'cid' => $cid]);
|
||||
DI::logger()->info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid'], 'cid' => $cid]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($author['contact-type'] != Contact::TYPE_COMMUNITY) {
|
||||
if ($parent['post-reason'] == self::PR_ANNOUNCEMENT) {
|
||||
Logger::info('The parent is already marked as announced: quit', ['causer' => $parent['causer-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->info('The parent is already marked as announced: quit', ['causer' => $parent['causer-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contact::isSharing($parent['owner-id'], $item['uid'])) {
|
||||
Logger::info('The resharer is no group: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->info('The resharer is no group: quit', ['resharer' => $item['author-id'], 'owner' => $parent['owner-id'], 'author' => $parent['author-id'], 'uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self::update(['post-reason' => self::PR_ANNOUNCEMENT, 'causer-id' => $item['author-id']], ['id' => $parent['id']]);
|
||||
Logger::info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
DI::logger()->info('Set announcement post-reason', ['uri-id' => $item['uri-id'], 'thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1680,18 +1679,18 @@ class Item
|
|||
}
|
||||
}
|
||||
if ($keep) {
|
||||
Logger::debug('Wanted languages found', ['uid' => $uid, 'user-languages' => $user_languages, 'item-languages' => $languages]);
|
||||
DI::logger()->debug('Wanted languages found', ['uid' => $uid, 'user-languages' => $user_languages, 'item-languages' => $languages]);
|
||||
} else {
|
||||
Logger::debug('No wanted languages found', ['uid' => $uid, 'user-languages' => $user_languages, 'item-languages' => $languages]);
|
||||
DI::logger()->debug('No wanted languages found', ['uid' => $uid, 'user-languages' => $user_languages, 'item-languages' => $languages]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$stored = self::storeForUserByUriId($item['uri-id'], $uid, ['post-reason' => self::PR_TAG]);
|
||||
Logger::info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
||||
DI::logger()->info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
||||
foreach ($tags as $tag) {
|
||||
$stored = Category::storeFileByURIId($item['uri-id'], $uid, Category::SUBCRIPTION, $tag);
|
||||
Logger::debug('Stored tag subscription for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, $tag, 'stored' => $stored]);
|
||||
DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, $tag, 'stored' => $stored]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1708,7 +1707,7 @@ class Item
|
|||
$condition = ["`id` IN (SELECT `parent` FROM `post-user-view` WHERE `id` = ?)", $itemid];
|
||||
$parent = Post::selectFirst(['owner-id'], $condition);
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::warning('Item not found', ['condition' => $condition]);
|
||||
DI::logger()->warning('Item not found', ['condition' => $condition]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1720,7 +1719,7 @@ class Item
|
|||
];
|
||||
$item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), $condition);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::warning('Item not found', ['condition' => $condition]);
|
||||
DI::logger()->warning('Item not found', ['condition' => $condition]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1803,26 +1802,26 @@ class Item
|
|||
public static function storeForUserByUriId(int $uri_id, int $uid, array $fields = [], int $source_uid = 0): int
|
||||
{
|
||||
if ($uid == $source_uid) {
|
||||
Logger::warning('target UID must not be be equal to the source UID', ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
DI::logger()->warning('target UID must not be be equal to the source UID', ['uri-id' => $uri_id, 'uid' => $uid]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), ['uri-id' => $uri_id, 'uid' => $source_uid]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::warning('Item could not be fetched', ['uri-id' => $uri_id, 'uid' => $source_uid]);
|
||||
DI::logger()->warning('Item could not be fetched', ['uri-id' => $uri_id, 'uid' => $source_uid]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (($uid != 0) && ($item['gravity'] == self::GRAVITY_PARENT)) {
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (($owner['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY) && !Tag::isMentioned($uri_id, $owner['url'])) {
|
||||
Logger::info('Target user is a group but is not mentioned here, thread will not be stored', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
DI::logger()->info('Target user is a group but is not mentioned here, thread will not be stored', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (($source_uid == 0) && (($item['private'] == self::PRIVATE) || !in_array($item['network'], array_merge(Protocol::FEDERATED, [Protocol::BLUESKY])))) {
|
||||
Logger::notice('Item is private or not from a federated network. It will not be stored for the user.', ['uri-id' => $uri_id, 'uid' => $uid, 'private' => $item['private'], 'network' => $item['network']]);
|
||||
DI::logger()->notice('Item is private or not from a federated network. It will not be stored for the user.', ['uri-id' => $uri_id, 'uid' => $uid, 'private' => $item['private'], 'network' => $item['network']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1840,7 +1839,7 @@ class Item
|
|||
DI::pConfig()->get($uid, 'system', 'accept_only_sharer') == self::COMPLETION_NONE &&
|
||||
!in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY, self::PR_AUDIENCE])
|
||||
) {
|
||||
Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
|
||||
DI::logger()->info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1848,20 +1847,20 @@ class Item
|
|||
|
||||
if (($uri_id != $item['parent-uri-id']) && ($item['gravity'] == self::GRAVITY_COMMENT) && !Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) {
|
||||
if (!self::fetchParent($item['parent-uri-id'], $uid, $causer)) {
|
||||
Logger::info('Parent post had not been added', ['uri-id' => $item['parent-uri-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
DI::logger()->info('Parent post had not been added', ['uri-id' => $item['parent-uri-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
return 0;
|
||||
}
|
||||
Logger::info('Fetched parent post', ['uri-id' => $item['parent-uri-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
DI::logger()->info('Fetched parent post', ['uri-id' => $item['parent-uri-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
} elseif (($uri_id != $item['thr-parent-id']) && $is_reshare && !Post::exists(['uri-id' => $item['thr-parent-id'], 'uid' => $uid])) {
|
||||
if (!self::fetchParent($item['thr-parent-id'], $uid, $causer)) {
|
||||
Logger::info('Thread parent had not been added', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
DI::logger()->info('Thread parent had not been added', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
return 0;
|
||||
}
|
||||
Logger::info('Fetched thread parent', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
DI::logger()->info('Fetched thread parent', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'causer' => $causer]);
|
||||
}
|
||||
|
||||
$stored = self::storeForUser($item, $uid);
|
||||
Logger::info('Item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'causer' => $causer, 'source-uid' => $source_uid, 'stored' => $stored]);
|
||||
DI::logger()->info('Item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'causer' => $causer, 'source-uid' => $source_uid, 'stored' => $stored]);
|
||||
return $stored;
|
||||
}
|
||||
|
||||
|
@ -1879,7 +1878,7 @@ class Item
|
|||
// Fetch the origin user for the post
|
||||
$origin_uid = self::GetOriginUidForUriId($uri_id, $uid);
|
||||
if (is_null($origin_uid)) {
|
||||
Logger::info('Origin item was not found', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
DI::logger()->info('Origin item was not found', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1955,11 +1954,11 @@ class Item
|
|||
if (!empty($event)) {
|
||||
// We aren't using "Event::store" here, since we don't want to trigger any further action
|
||||
$ret = DBA::update('event', $event, ['id' => $event_post['event-id']]);
|
||||
Logger::info('Event updated', ['uid' => $uid, 'source-event' => $item['event-id'], 'target-event' => $event_post['event-id'], 'ret' => $ret]);
|
||||
DI::logger()->info('Event updated', ['uid' => $uid, 'source-event' => $item['event-id'], 'target-event' => $event_post['event-id'], 'ret' => $ret]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger::info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'id' => $post['id']]);
|
||||
DI::logger()->info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'id' => $post['id']]);
|
||||
return $post['id'];
|
||||
}
|
||||
|
||||
|
@ -1997,9 +1996,9 @@ class Item
|
|||
$distributed = self::insert($item, $notify);
|
||||
|
||||
if (!$distributed) {
|
||||
Logger::info("Distributed item wasn't stored", ['uri-id' => $item['uri-id'], 'user' => $uid]);
|
||||
DI::logger()->info("Distributed item wasn't stored", ['uri-id' => $item['uri-id'], 'user' => $uid]);
|
||||
} else {
|
||||
Logger::info('Distributed item was stored', ['uri-id' => $item['uri-id'], 'user' => $uid, 'stored' => $distributed]);
|
||||
DI::logger()->info('Distributed item was stored', ['uri-id' => $item['uri-id'], 'user' => $uid, 'stored' => $distributed]);
|
||||
}
|
||||
return $distributed;
|
||||
}
|
||||
|
@ -2065,7 +2064,7 @@ class Item
|
|||
|
||||
$public_shadow = self::insert($item);
|
||||
|
||||
Logger::info('Stored public shadow', ['thread' => $itemid, 'id' => $public_shadow]);
|
||||
DI::logger()->info('Stored public shadow', ['thread' => $itemid, 'id' => $public_shadow]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2124,7 +2123,7 @@ class Item
|
|||
|
||||
$public_shadow = self::insert($item);
|
||||
|
||||
Logger::info('Stored public shadow', ['uri-id' => $item['uri-id'], 'id' => $public_shadow]);
|
||||
DI::logger()->info('Stored public shadow', ['uri-id' => $item['uri-id'], 'id' => $public_shadow]);
|
||||
|
||||
// If this was a comment to a Diaspora post we don't get our comment back.
|
||||
// This means that we have to distribute the comment by ourselves.
|
||||
|
@ -2194,7 +2193,7 @@ class Item
|
|||
$author = Contact::selectFirst(['about'], ['id' => $author_id]);
|
||||
if (!empty($author['about'])) {
|
||||
$about = BBCode::toSearchText($author['about'], 0);
|
||||
Logger::debug('About field added', ['author' => $author_id, 'body' => $searchtext, 'about' => $about]);
|
||||
DI::logger()->debug('About field added', ['author' => $author_id, 'body' => $searchtext, 'about' => $about]);
|
||||
$searchtext .= ' ' . $about;
|
||||
}
|
||||
}
|
||||
|
@ -2375,7 +2374,7 @@ class Item
|
|||
|
||||
$hostPart = $host ?: $parsed['host'] ?? '';
|
||||
if (!$hostPart) {
|
||||
Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed]);
|
||||
DI::logger()->warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed]);
|
||||
}
|
||||
|
||||
// Glue it together to be able to make a hash from it
|
||||
|
@ -2560,26 +2559,26 @@ class Item
|
|||
{
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (!DBA::isResult($owner)) {
|
||||
Logger::warning('User not found, quitting here.', ['uid' => $uid]);
|
||||
DI::logger()->warning('User not found, quitting here.', ['uid' => $uid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($owner['contact-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
Logger::debug('Owner is no community, quitting here.', ['uid' => $uid, 'id' => $item_id]);
|
||||
DI::logger()->debug('Owner is no community, quitting here.', ['uid' => $uid, 'id' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id, 'gravity' => [self::GRAVITY_PARENT, self::GRAVITY_COMMENT], 'origin' => false]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::debug('Post is an activity or origin or not found at all, quitting here.', ['id' => $item_id]);
|
||||
DI::logger()->debug('Post is an activity or origin or not found at all, quitting here.', ['id' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
if (Tag::isMentioned($item['uri-id'], $owner['url'])) {
|
||||
Logger::info('Mention found in tag.', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Mention found in tag.', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
} else {
|
||||
Logger::info('Top-level post without mention is deleted.', ['uri' => $item['uri'], $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Top-level post without mention is deleted.', ['uri' => $item['uri'], $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
Post\User::delete(['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
|
||||
return true;
|
||||
}
|
||||
|
@ -2589,14 +2588,14 @@ class Item
|
|||
Hook::callAll('tagged', $arr);
|
||||
} else {
|
||||
if (Tag::isMentioned($item['parent-uri-id'], $owner['url'])) {
|
||||
Logger::info('Mention found in parent tag.', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Mention found in parent tag.', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
} else {
|
||||
Logger::debug('No mentions found in parent, quitting here.', ['id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->debug('No mentions found in parent, quitting here.', ['id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Logger::info('Community post will be distributed', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Community post will be distributed', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
|
||||
if ($owner['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
|
||||
$allow_cid = '';
|
||||
|
@ -2608,7 +2607,7 @@ class Item
|
|||
self::performActivity($item['id'], 'announce', $uid);
|
||||
}
|
||||
|
||||
Logger::info('Community post had been distributed', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
DI::logger()->info('Community post had been distributed', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2641,7 +2640,7 @@ class Item
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::info('Automatically reshare item', ['uid' => $item['uid'], 'id' => $item['id'], 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
DI::logger()->info('Automatically reshare item', ['uid' => $item['uid'], 'id' => $item['id'], 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
|
||||
|
||||
self::performActivity($item['id'], 'announce', $item['uid']);
|
||||
}
|
||||
|
@ -2654,34 +2653,34 @@ class Item
|
|||
|
||||
// Prevent the forwarding of posts that are forwarded
|
||||
if (!empty($datarray['extid']) && ($datarray['extid'] == Protocol::DFRN)) {
|
||||
Logger::info('Already forwarded');
|
||||
DI::logger()->info('Already forwarded');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Prevent to forward already forwarded posts
|
||||
if ($datarray['app'] == DI::baseUrl()->getHost()) {
|
||||
Logger::info('Already forwarded (second test)');
|
||||
DI::logger()->info('Already forwarded (second test)');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only forward posts
|
||||
if ($datarray['verb'] != Activity::POST) {
|
||||
Logger::info('No post');
|
||||
DI::logger()->info('No post');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (($contact['network'] != Protocol::FEED) && ($datarray['private'] == self::PRIVATE)) {
|
||||
Logger::info('Not public');
|
||||
DI::logger()->info('Not public');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (User::getById($contact['uid'], ['blocked'])['blocked'] ?? false) {
|
||||
Logger::info('User is blocked', ['contact' => $contact]);
|
||||
DI::logger()->info('User is blocked', ['contact' => $contact]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$datarray2 = $datarray;
|
||||
Logger::info('remote-self start', ['contact' => $contact['url'], 'remote_self' => $contact['remote_self'], 'item' => $datarray]);
|
||||
DI::logger()->info('remote-self start', ['contact' => $contact['url'], 'remote_self' => $contact['remote_self'], 'item' => $datarray]);
|
||||
|
||||
$self = DBA::selectFirst(
|
||||
'contact',
|
||||
|
@ -2689,7 +2688,7 @@ class Item
|
|||
['uid' => $contact['uid'], 'self' => true]
|
||||
);
|
||||
if (!DBA::isResult($self)) {
|
||||
Logger::error('Self contact not found', ['uid' => $contact['uid']]);
|
||||
DI::logger()->error('Self contact not found', ['uid' => $contact['uid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2723,7 +2722,7 @@ class Item
|
|||
|
||||
// Store the original post
|
||||
$result = self::insert($datarray2);
|
||||
Logger::info('remote-self post original item', ['contact' => $contact['url'], 'result' => $result, 'item' => $datarray2]);
|
||||
DI::logger()->info('remote-self post original item', ['contact' => $contact['url'], 'result' => $result, 'item' => $datarray2]);
|
||||
} else {
|
||||
$datarray['app'] = 'Feed';
|
||||
$result = true;
|
||||
|
@ -2752,7 +2751,7 @@ class Item
|
|||
return $s;
|
||||
}
|
||||
|
||||
Logger::info('check for photos');
|
||||
DI::logger()->info('check for photos');
|
||||
$site = substr(DI::baseUrl(), strpos(DI::baseUrl(), '://'));
|
||||
|
||||
$orig_body = $s;
|
||||
|
@ -2766,7 +2765,7 @@ class Item
|
|||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
$image = substr($orig_body, $img_start + $img_st_close, $img_len);
|
||||
|
||||
Logger::info('found photo', ['image' => $image]);
|
||||
DI::logger()->info('found photo', ['image' => $image]);
|
||||
|
||||
if (stristr($image, $site . '/photo/')) {
|
||||
// Only embed locally hosted photos
|
||||
|
@ -2805,7 +2804,7 @@ class Item
|
|||
$photo_img = Photo::getImageForPhoto($photo);
|
||||
// If a custom width and height were specified, apply before embedding
|
||||
if (preg_match("/\[img\=([0-9]*)x([0-9]*)\]/is", substr($orig_body, $img_start, $img_st_close), $match)) {
|
||||
Logger::info('scaling photo');
|
||||
DI::logger()->info('scaling photo');
|
||||
|
||||
$width = intval($match[1]);
|
||||
$height = intval($match[2]);
|
||||
|
@ -2816,9 +2815,9 @@ class Item
|
|||
$data = $photo_img->asString();
|
||||
$type = $photo_img->getType();
|
||||
|
||||
Logger::info('replacing photo');
|
||||
DI::logger()->info('replacing photo');
|
||||
$image = 'data:' . $type . ';base64,' . base64_encode($data);
|
||||
Logger::debug('replaced', ['image' => $image]);
|
||||
DI::logger()->debug('replaced', ['image' => $image]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2968,7 +2967,7 @@ class Item
|
|||
++$expired;
|
||||
}
|
||||
DBA::close($items);
|
||||
Logger::notice('Expired', ['user' => $uid, 'days' => $days, 'network' => $network, 'force' => $force, 'expired' => $expired, 'expire items' => $expire_items, 'expire notes' => $expire_notes, 'expire starred' => $expire_starred, 'expire photos' => $expire_photos, 'condition' => $condition]);
|
||||
DI::logger()->notice('Expired', ['user' => $uid, 'days' => $days, 'network' => $network, 'force' => $force, 'expired' => $expired, 'expire items' => $expire_items, 'expire notes' => $expire_notes, 'expire starred' => $expire_starred, 'expire photos' => $expire_photos, 'condition' => $condition]);
|
||||
return $expired;
|
||||
}
|
||||
|
||||
|
@ -3021,11 +3020,11 @@ class Item
|
|||
return false;
|
||||
}
|
||||
|
||||
Logger::notice('Start create activity', ['verb' => $verb, 'item' => $item_id, 'user' => $uid]);
|
||||
DI::logger()->notice('Start create activity', ['verb' => $verb, 'item' => $item_id, 'user' => $uid]);
|
||||
|
||||
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::warning('Post had not been fetched', ['id' => $item_id]);
|
||||
DI::logger()->warning('Post had not been fetched', ['id' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3040,7 +3039,7 @@ class Item
|
|||
if (($item['parent-uri-id'] == $item['uri-id']) && !empty($stored)) {
|
||||
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::info('Could not fetch just created item - should not happen', ['stored' => $stored, 'uid' => $uid, 'uri-id' => $uri_id]);
|
||||
DI::logger()->info('Could not fetch just created item - should not happen', ['stored' => $stored, 'uid' => $uid, 'uri-id' => $uri_id]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3049,14 +3048,14 @@ class Item
|
|||
// Retrieves the local post owner
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (empty($owner)) {
|
||||
Logger::info('Empty owner for user', ['uid' => $uid]);
|
||||
DI::logger()->info('Empty owner for user', ['uid' => $uid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retrieve the current logged in user's public contact
|
||||
$author_id = Contact::getPublicIdByUserId($uid);
|
||||
if (empty($author_id)) {
|
||||
Logger::info('Empty public contact');
|
||||
DI::logger()->info('Empty public contact');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3091,7 +3090,7 @@ class Item
|
|||
$activity = Activity::ANNOUNCE;
|
||||
break;
|
||||
default:
|
||||
Logger::warning('unknown verb', ['verb' => $verb, 'item' => $item_id]);
|
||||
DI::logger()->warning('unknown verb', ['verb' => $verb, 'item' => $item_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4196,10 +4195,10 @@ class Item
|
|||
*/
|
||||
public static function fetchByLink(string $uri, int $uid = 0, int $completion = ActivityPub\Receiver::COMPLETION_MANUAL, string $mimetype = ''): int
|
||||
{
|
||||
Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]);
|
||||
DI::logger()->info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]);
|
||||
$item_id = self::searchByLink($uri, $uid);
|
||||
if (!empty($item_id)) {
|
||||
Logger::info('Link found', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
DI::logger()->info('Link found', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
return $item_id;
|
||||
}
|
||||
|
||||
|
@ -4216,7 +4215,7 @@ class Item
|
|||
Hook::callAll('item_by_link', $hookData);
|
||||
|
||||
if (isset($hookData['item_id'])) {
|
||||
Logger::info('Hook link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $hookData['item_id']]);
|
||||
DI::logger()->info('Hook link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $hookData['item_id']]);
|
||||
return is_numeric($hookData['item_id']) ? $hookData['item_id'] : 0;
|
||||
}
|
||||
|
||||
|
@ -4225,7 +4224,7 @@ class Item
|
|||
$curlResult = DI::httpClient()->head($uri, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON_AS, HttpClientOptions::REQUEST => HttpClientRequest::ACTIVITYPUB]);
|
||||
$mimetype = $curlResult->getContentType();
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Error while fetching HTTP link via HEAD', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->info('Error while fetching HTTP link via HEAD', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -4236,7 +4235,7 @@ class Item
|
|||
$curlResult = HTTPSignature::fetchRaw($uri, $uid);
|
||||
$mimetype = $curlResult->getContentType();
|
||||
} catch (\Throwable $th) {
|
||||
Logger::info('Error while fetching HTTP link via signed GET', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
DI::logger()->info('Error while fetching HTTP link via signed GET', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -4246,7 +4245,7 @@ class Item
|
|||
if (!empty($fetched_uri)) {
|
||||
$item_id = self::searchByLink($fetched_uri, $uid);
|
||||
if ($item_id) {
|
||||
Logger::info('ActivityPub link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
DI::logger()->info('ActivityPub link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
return $item_id;
|
||||
}
|
||||
}
|
||||
|
@ -4254,18 +4253,18 @@ class Item
|
|||
|
||||
$item_id = Diaspora::fetchByURL($uri);
|
||||
if ($item_id) {
|
||||
Logger::info('Diaspora link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
DI::logger()->info('Diaspora link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
|
||||
return $item_id;
|
||||
}
|
||||
|
||||
Logger::info('This is not an item link', ['uid' => $uid, 'uri' => $uri]);
|
||||
DI::logger()->info('This is not an item link', ['uid' => $uid, 'uri' => $uri]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the uri-id of a quoted post by searching for data in the body or attached media
|
||||
*
|
||||
* @param string $body The body of the
|
||||
* @param string $body The body of the
|
||||
* @param int $uid The id of the user
|
||||
* @return integer
|
||||
*/
|
||||
|
@ -4277,14 +4276,14 @@ class Item
|
|||
}
|
||||
|
||||
if (empty($shared['link']) && empty($shared['message_id'])) {
|
||||
Logger::notice('Invalid share block.', ['share' => $shared]);
|
||||
DI::logger()->notice('Invalid share block.', ['share' => $shared]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!empty($shared['guid'])) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['guid' => $shared['guid'], 'uid' => [0, $uid]]);
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
Logger::debug('Found post by guid', ['guid' => $shared['guid'], 'uid' => $uid]);
|
||||
DI::logger()->debug('Found post by guid', ['guid' => $shared['guid'], 'uid' => $uid]);
|
||||
return $shared_item['uri-id'];
|
||||
}
|
||||
}
|
||||
|
@ -4292,7 +4291,7 @@ class Item
|
|||
if (!empty($shared['message_id'])) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['uri' => $shared['message_id'], 'uid' => [0, $uid]]);
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
Logger::debug('Found post by message_id', ['message_id' => $shared['message_id'], 'uid' => $uid]);
|
||||
DI::logger()->debug('Found post by message_id', ['message_id' => $shared['message_id'], 'uid' => $uid]);
|
||||
return $shared_item['uri-id'];
|
||||
}
|
||||
}
|
||||
|
@ -4300,7 +4299,7 @@ class Item
|
|||
if (!empty($shared['link'])) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['plink' => $shared['link'], 'uid' => [0, $uid]]);
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
Logger::debug('Found post by link', ['link' => $shared['link'], 'uid' => $uid]);
|
||||
DI::logger()->debug('Found post by link', ['link' => $shared['link'], 'uid' => $uid]);
|
||||
return $shared_item['uri-id'];
|
||||
}
|
||||
}
|
||||
|
@ -4308,17 +4307,17 @@ class Item
|
|||
$url = $shared['message_id'] ?: $shared['link'];
|
||||
$id = self::fetchByLink($url, 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
if (!$id) {
|
||||
Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
|
||||
DI::logger()->notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
Logger::debug('Fetched shared post', ['id' => $id, 'url' => $url, 'uid' => $uid]);
|
||||
DI::logger()->debug('Fetched shared post', ['id' => $id, 'url' => $url, 'uid' => $uid]);
|
||||
return $shared_item['uri-id'];
|
||||
}
|
||||
|
||||
Logger::warning('Post does not exist although it was supposed to had been fetched.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
|
||||
DI::logger()->warning('Post does not exist although it was supposed to had been fetched.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue