mirror of
https://github.com/friendica/friendica
synced 2025-02-05 16:58:51 +00:00
Fix code style
This commit is contained in:
parent
d4697a17a3
commit
0e59dba914
102 changed files with 3038 additions and 2764 deletions
|
@ -1026,7 +1026,7 @@ function photos_content()
|
|||
}
|
||||
|
||||
|
||||
$edit = Null;
|
||||
$edit = null;
|
||||
if ($cmd === 'edit' && $can_post) {
|
||||
$edit_tpl = Renderer::getMarkupTemplate('photo_edit.tpl');
|
||||
|
||||
|
|
|
@ -215,8 +215,11 @@ class PageInfo
|
|||
|
||||
$taglist = [];
|
||||
foreach ($data['keywords'] as $keyword) {
|
||||
$hashtag = str_replace([' ', '+', '/', '.', '#', "'"],
|
||||
['', '', '', '', '', ''], $keyword);
|
||||
$hashtag = str_replace(
|
||||
[' ', '+', '/', '.', '#', "'"],
|
||||
['', '', '', '', '', ''],
|
||||
$keyword
|
||||
);
|
||||
|
||||
$taglist[] = $hashtag;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ class BBCode
|
|||
$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;
|
||||
|
|
|
@ -24,7 +24,8 @@ 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();
|
||||
|
|
|
@ -203,8 +203,11 @@ class Update
|
|||
// run the pre_update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $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));
|
||||
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) {
|
||||
DI::logger()->warning('Pre update failed', ['version' => $version]);
|
||||
|
@ -245,8 +248,11 @@ class Update
|
|||
// run the update_nnnn functions in update.php
|
||||
for ($version = $stored + 1; $version <= $current; $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));
|
||||
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) {
|
||||
DI::logger()->warning('Post update failed', ['version' => $version]);
|
||||
|
@ -359,12 +365,14 @@ class Update
|
|||
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));
|
||||
$update_id
|
||||
));
|
||||
$body = $l10n->t('The error message is\n[pre]%s[/pre]', $error_message);
|
||||
|
||||
$email = DI::emailer()
|
||||
|
@ -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()
|
||||
|
|
|
@ -112,7 +112,10 @@ 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 {
|
||||
DI::logger()->info('Process runtime is okay', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
|
||||
|
|
|
@ -73,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.');
|
||||
|
@ -143,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 />';
|
||||
}
|
||||
|
@ -522,21 +528,27 @@ 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'],
|
||||
["`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 = [];
|
||||
|
@ -731,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]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -174,12 +174,19 @@ class PostUpdate
|
|||
|
||||
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)) {
|
||||
DI::logger()->info('Remove duplicates', ['nurl' => $contact['nurl'], 'uid' => $contact['uid']]);
|
||||
|
@ -331,12 +338,18 @@ class PostUpdate
|
|||
|
||||
$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) {
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
|
@ -490,9 +503,12 @@ class PostUpdate
|
|||
|
||||
$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) {
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
|
@ -632,9 +648,11 @@ class PostUpdate
|
|||
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;
|
||||
}
|
||||
|
@ -685,9 +703,11 @@ class PostUpdate
|
|||
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;
|
||||
}
|
||||
|
@ -1053,10 +1073,14 @@ class PostUpdate
|
|||
$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) {
|
||||
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
|
@ -1217,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;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ 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;
|
||||
|
|
|
@ -163,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`
|
||||
|
|
|
@ -300,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();
|
||||
}
|
||||
|
@ -311,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;
|
||||
|
@ -334,7 +334,7 @@ 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]];
|
||||
|
@ -355,7 +355,7 @@ 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 [];
|
||||
|
@ -371,7 +371,10 @@ class Relation
|
|||
|
||||
// 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`)
|
||||
|
@ -381,7 +384,8 @@ class Relation
|
|||
0,
|
||||
$uid, Contact::FRIEND, Contact::SHARING,
|
||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid
|
||||
], [
|
||||
],
|
||||
[
|
||||
'order' => ['last-item' => true],
|
||||
'limit' => $totallimit,
|
||||
]
|
||||
|
@ -401,7 +405,9 @@ 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
|
||||
|
@ -425,7 +431,9 @@ class Relation
|
|||
}
|
||||
|
||||
// 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` = ?)",
|
||||
|
@ -446,7 +454,9 @@ class Relation
|
|||
}
|
||||
|
||||
// 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` = ?)",
|
||||
|
@ -712,7 +722,8 @@ class Relation
|
|||
*/
|
||||
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = []): int
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
$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]
|
||||
|
@ -735,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,
|
||||
$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]
|
||||
);
|
||||
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
return DI::dba()->selectToArray(
|
||||
'contact',
|
||||
[],
|
||||
$condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
}
|
||||
|
@ -757,7 +772,8 @@ class Relation
|
|||
*/
|
||||
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = []): int
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
$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]
|
||||
|
@ -780,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,
|
||||
$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]
|
||||
);
|
||||
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
return DI::dba()->selectToArray(
|
||||
'contact',
|
||||
[],
|
||||
$condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
}
|
||||
|
@ -810,67 +830,145 @@ class Relation
|
|||
|
||||
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
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
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')
|
||||
);
|
||||
|
||||
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']]);
|
||||
|
|
|
@ -29,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)) {
|
||||
|
@ -654,7 +653,7 @@ class 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']);
|
||||
|
|
|
@ -450,9 +450,11 @@ 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(),
|
||||
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]);
|
||||
['nurl' => $nurl]
|
||||
);
|
||||
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
||||
if (self::isDefunct($gserver)) {
|
||||
self::archiveContacts($gserver['id']);
|
||||
|
@ -2501,9 +2503,12 @@ 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)) {
|
||||
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
|
|
|
@ -2329,7 +2329,7 @@ class Item
|
|||
|
||||
public static function getLanguageMessage(array $item): string
|
||||
{
|
||||
$iso639 = new \Matriphe\ISO639\ISO639;
|
||||
$iso639 = new \Matriphe\ISO639\ISO639();
|
||||
|
||||
$used_languages = '';
|
||||
foreach (json_decode($item['language'], true) as $language => $reliability) {
|
||||
|
|
|
@ -447,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`
|
||||
|
@ -456,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));
|
||||
|
||||
|
|
|
@ -51,11 +51,13 @@ class Engagement
|
|||
return 0;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['uri-id', 'created', 'uid', 'private', 'quote-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']]);
|
||||
['uri-id' => $item['parent-uri-id']]
|
||||
);
|
||||
|
||||
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
||||
DI::logger()->debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
||||
|
@ -314,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 = '';
|
||||
|
||||
|
@ -392,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -305,11 +305,9 @@ class Profile
|
|||
|
||||
$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()) : '';
|
||||
|
||||
|
|
|
@ -1496,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
|
||||
|
@ -1946,10 +1946,13 @@ 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;
|
||||
}
|
||||
|
|
|
@ -96,9 +96,11 @@ 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();
|
||||
|
|
|
@ -63,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);
|
||||
|
@ -131,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()),
|
||||
]);
|
||||
|
|
|
@ -566,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;
|
||||
|
||||
|
|
|
@ -57,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']);
|
||||
|
|
|
@ -344,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 {
|
||||
|
|
|
@ -59,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);
|
||||
|
@ -146,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;
|
||||
|
|
|
@ -1671,7 +1671,9 @@ class Probe
|
|||
$parts = array_filter(explode('/', $path), 'strlen');
|
||||
$absolutes = [];
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part) continue;
|
||||
if ('.' == $part) {
|
||||
continue;
|
||||
}
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
|
|
|
@ -322,8 +322,10 @@ class ClientToServer
|
|||
if (!empty($requester_id)) {
|
||||
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $owner['uid']);
|
||||
if (count($permissionSets) > 0) {
|
||||
$condition = ['psid' => array_merge($permissionSets->column('id'),
|
||||
[DI::permissionSet()->selectPublicForUser($owner['uid'])])];
|
||||
$condition = ['psid' => array_merge(
|
||||
$permissionSets->column('id'),
|
||||
[DI::permissionSet()->selectPublicForUser($owner['uid'])]
|
||||
)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1194,8 +1194,10 @@ class Processor
|
|||
|
||||
if ((DI::pConfig()->get($receiver, 'system', 'accept_only_sharer') != Item::COMPLETION_LIKE)
|
||||
&& in_array($activity['thread-children-type'] ?? '', Receiver::ACTIVITY_TYPES)) {
|
||||
DI::logger()->info('Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
|
||||
['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]);
|
||||
DI::logger()->info(
|
||||
'Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
|
||||
['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -2053,7 +2055,7 @@ class Processor
|
|||
return [];
|
||||
}
|
||||
|
||||
$iso639 = new \Matriphe\ISO639\ISO639;
|
||||
$iso639 = new \Matriphe\ISO639\ISO639();
|
||||
|
||||
$result = [];
|
||||
foreach ($languages as $language) {
|
||||
|
|
|
@ -1403,7 +1403,8 @@ class Transmitter
|
|||
}
|
||||
|
||||
if ($type == 'Delete') {
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;;
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;
|
||||
;
|
||||
} elseif (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
$data['id'] = $item['uri'];
|
||||
} else {
|
||||
|
|
|
@ -45,7 +45,6 @@ use GuzzleHttp\Psr7\Uri;
|
|||
*/
|
||||
class DFRN
|
||||
{
|
||||
|
||||
const TOP_LEVEL = 0; // Top level posting
|
||||
const REPLY = 1; // Regular reply that is stored locally
|
||||
const REPLY_RC = 2; // Reply that will be relayed
|
||||
|
@ -489,9 +488,11 @@ class DFRN
|
|||
}
|
||||
|
||||
// Only show contact details when we are allowed to
|
||||
$profile = DBA::selectFirst('owner-view',
|
||||
$profile = DBA::selectFirst(
|
||||
'owner-view',
|
||||
['about', 'name', 'homepage', 'nickname', 'timezone', 'locality', 'region', 'country-name', 'pub_keywords', 'xmpp', 'dob'],
|
||||
['uid' => $owner['uid'], 'hidewall' => false]);
|
||||
['uid' => $owner['uid'], 'hidewall' => false]
|
||||
);
|
||||
if (DBA::isResult($profile)) {
|
||||
XML::addElement($doc, $author, 'poco:displayName', $profile['name']);
|
||||
XML::addElement($doc, $author, 'poco:updated', $namdate);
|
||||
|
@ -1662,11 +1663,16 @@ class DFRN
|
|||
foreach ($links as $link) {
|
||||
foreach ($link->attributes as $attributes) {
|
||||
switch ($attributes->name) {
|
||||
case 'href' : $href = $attributes->textContent; break;
|
||||
case 'rel' : $rel = $attributes->textContent; break;
|
||||
case 'type' : $type = $attributes->textContent; break;
|
||||
case 'length': $length = $attributes->textContent; break;
|
||||
case 'title' : $title = $attributes->textContent; break;
|
||||
case 'href': $href = $attributes->textContent;
|
||||
break;
|
||||
case 'rel': $rel = $attributes->textContent;
|
||||
break;
|
||||
case 'type': $type = $attributes->textContent;
|
||||
break;
|
||||
case 'length': $length = $attributes->textContent;
|
||||
break;
|
||||
case 'title': $title = $attributes->textContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($rel != '') && ($href != '')) {
|
||||
|
@ -1745,7 +1751,8 @@ class DFRN
|
|||
|
||||
$item['edited'] = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry);
|
||||
|
||||
$current = Post::selectFirst(['id', 'uid', 'edited', 'body'],
|
||||
$current = Post::selectFirst(
|
||||
['id', 'uid', 'edited', 'body'],
|
||||
['uri' => $item['uri'], 'uid' => $importer['importer_uid']]
|
||||
);
|
||||
// Is there an existing item?
|
||||
|
|
|
@ -185,7 +185,9 @@ class Delivery
|
|||
}
|
||||
|
||||
// We don't deliver our items to blocked, archived or pending contacts, and not to ourselves either
|
||||
$contact = DBA::selectFirst('contact', [],
|
||||
$contact = DBA::selectFirst(
|
||||
'contact',
|
||||
[],
|
||||
['id' => $contact_id, 'archive' => false, 'blocked' => false, 'pending' => false, 'self' => false]
|
||||
);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Delivery;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
|
@ -648,8 +647,9 @@ class Diaspora
|
|||
|
||||
// All retractions are handled identically from now on.
|
||||
// In the new version there will only be "retraction".
|
||||
if (in_array($type, ['signed_retraction', 'relayable_retraction']))
|
||||
if (in_array($type, ['signed_retraction', 'relayable_retraction'])) {
|
||||
$type = 'retraction';
|
||||
}
|
||||
|
||||
if ($type == 'request') {
|
||||
$type = 'contact';
|
||||
|
@ -3366,8 +3366,9 @@ class Diaspora
|
|||
|
||||
$location = [];
|
||||
|
||||
if ($item['location'] != '')
|
||||
if ($item['location'] != '') {
|
||||
$location['address'] = $item['location'];
|
||||
}
|
||||
|
||||
if ($item['coord'] != '') {
|
||||
$coord = explode(' ', $item['coord']);
|
||||
|
@ -3912,7 +3913,7 @@ class Diaspora
|
|||
$data['birthday'] = '';
|
||||
|
||||
if ($profile['dob'] && ($profile['dob'] > '0000-00-00')) {
|
||||
[$year, $month, $day] = sscanf($profile['dob'], '%4d-%2d-%2d');
|
||||
list($year, $month, $day) = sscanf($profile['dob'], '%4d-%2d-%2d');
|
||||
if ($year < 1004) {
|
||||
$year = 1004;
|
||||
}
|
||||
|
@ -4003,7 +4004,8 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (!in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
DI::logger()->warning('Item is neither a like nor a dislike', ['uid' => $uid, 'item[verb]' => $item['verb']]);;
|
||||
DI::logger()->warning('Item is neither a like nor a dislike', ['uid' => $uid, 'item[verb]' => $item['verb']]);
|
||||
;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -672,8 +672,9 @@ class Email
|
|||
|
||||
while ((strlen($quoteline) > 0) and ((substr($quoteline, 0, 1) == '>')
|
||||
|| (substr($quoteline, 0, 1) == ' '))) {
|
||||
if (substr($quoteline, 0, 1) == '>')
|
||||
if (substr($quoteline, 0, 1) == '>') {
|
||||
$quotelevel++;
|
||||
}
|
||||
|
||||
$quoteline = ltrim(substr($quoteline, 1));
|
||||
}
|
||||
|
@ -773,9 +774,10 @@ class Email
|
|||
foreach ($quotes as $index => $quote) {
|
||||
$quotelevel += $quote;
|
||||
|
||||
if (($quotelevel == 0) and ($quotestart == 0))
|
||||
if (($quotelevel == 0) and ($quotestart == 0)) {
|
||||
$quotestart = $index;
|
||||
}
|
||||
}
|
||||
|
||||
if ($quotestart != 0) {
|
||||
$message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart + 7, -8) . '[/spoiler]';
|
||||
|
|
|
@ -376,8 +376,11 @@ class Relay
|
|||
*/
|
||||
public static function getList(array $fields = []): array
|
||||
{
|
||||
return DBA::selectToArray('apcontact', $fields,
|
||||
["`type` IN (?, ?) AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)", 'Application', 'Service', 0, Contact::FRIEND]);
|
||||
return DBA::selectToArray(
|
||||
'apcontact',
|
||||
$fields,
|
||||
["`type` IN (?, ?) AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)", 'Application', 'Service', 0, Contact::FRIEND]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ class DateTimeFormat
|
|||
const JSON = 'Y-m-d\TH:i:s.v\Z';
|
||||
const API = 'D M d H:i:s +0000 Y';
|
||||
|
||||
static $localTimezone = 'UTC';
|
||||
public static $localTimezone = 'UTC';
|
||||
|
||||
public static function setLocalTimeZone(string $timezone)
|
||||
{
|
||||
|
|
|
@ -387,7 +387,7 @@ class HTTPSignature
|
|||
* @param int $gsid Server ID
|
||||
* @throws \Exception
|
||||
*/
|
||||
static public function setInboxStatus(string $url, bool $success, bool $shared = false, int $gsid = null)
|
||||
public static function setInboxStatus(string $url, bool $success, bool $shared = false, int $gsid = null)
|
||||
{
|
||||
$now = DateTimeFormat::utcNow();
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class JsonLD
|
|||
break;
|
||||
default:
|
||||
switch (parse_url($url, PHP_URL_PATH)) {
|
||||
case '/schemas/litepub-0.1.jsonld';
|
||||
case '/schemas/litepub-0.1.jsonld':
|
||||
$url = DI::basePath() . '/static/litepub-0.1.jsonld';
|
||||
break;
|
||||
case '/apschema/v1.2':
|
||||
|
@ -117,7 +117,7 @@ class JsonLD
|
|||
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
|
||||
try {
|
||||
$normalized = jsonld_normalize($jsonobj, array('algorithm' => 'URDNA2015', 'format' => 'application/nquads'));
|
||||
$normalized = jsonld_normalize($jsonobj, ['algorithm' => 'URDNA2015', 'format' => 'application/nquads']);
|
||||
} catch (Exception $e) {
|
||||
$normalized = false;
|
||||
$messages = [];
|
||||
|
|
|
@ -20,7 +20,6 @@ use Psr\Http\Message\UriInterface;
|
|||
|
||||
class Network
|
||||
{
|
||||
|
||||
/**
|
||||
* Return raw post data from a post request
|
||||
*
|
||||
|
|
|
@ -115,7 +115,9 @@ class ParseUrl
|
|||
|
||||
$urlHash = hash('sha256', $url);
|
||||
|
||||
$parsed_url = DBA::selectFirst('parsed_url', ['content'],
|
||||
$parsed_url = DBA::selectFirst(
|
||||
'parsed_url',
|
||||
['content'],
|
||||
['url_hash' => $urlHash, 'oembed' => false]
|
||||
);
|
||||
if (!empty($parsed_url['content'])) {
|
||||
|
@ -259,7 +261,8 @@ class ParseUrl
|
|||
if (isset($mediaType->parameters['charset'])) {
|
||||
$charset = $mediaType->parameters['charset'];
|
||||
}
|
||||
} catch(\InvalidArgumentException $e) {}
|
||||
} catch(\InvalidArgumentException $e) {
|
||||
}
|
||||
|
||||
$siteinfo['charset'] = $charset;
|
||||
|
||||
|
@ -810,7 +813,7 @@ class ParseUrl
|
|||
case 'Person':
|
||||
case 'Patient':
|
||||
case 'PerformingGroup':
|
||||
case 'DanceGroup';
|
||||
case 'DanceGroup':
|
||||
case 'MusicGroup':
|
||||
case 'TheaterGroup':
|
||||
return self::parseJsonLdWebPerson($siteinfo, $jsonld);
|
||||
|
|
|
@ -37,7 +37,8 @@ class Proxy
|
|||
/**
|
||||
* Private constructor
|
||||
*/
|
||||
private function __construct () {
|
||||
private function __construct()
|
||||
{
|
||||
// No instances from utilities classes
|
||||
}
|
||||
|
||||
|
|
|
@ -544,8 +544,10 @@ class Strings
|
|||
switch ($last) {
|
||||
case 'g':
|
||||
$shorthand *= 1024;
|
||||
// no break
|
||||
case 'm':
|
||||
$shorthand *= 1024;
|
||||
// no break
|
||||
case 'k':
|
||||
$shorthand *= 1024;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
class APDelivery
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -47,7 +47,8 @@ class Directory
|
|||
return;
|
||||
}
|
||||
|
||||
private static function updateAll() {
|
||||
private static function updateAll()
|
||||
{
|
||||
$users = DBA::select('owner-view', ['url'], ['net-publish' => true, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
Worker::add(Worker::PRIORITY_LOW, 'Directory', $user['url']);
|
||||
|
|
|
@ -47,16 +47,23 @@ class Expire
|
|||
$r = DBA::select('user', ['uid', 'username'], ["`expire` != ?", 0]);
|
||||
while ($row = DBA::fetch($r)) {
|
||||
DI::logger()->info('Calling expiry', ['user' => $row['uid'], 'username' => $row['username']]);
|
||||
Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'Expire', (int)$row['uid']);
|
||||
Worker::add(
|
||||
['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'Expire',
|
||||
(int)$row['uid']
|
||||
);
|
||||
}
|
||||
DBA::close($r);
|
||||
|
||||
DI::logger()->notice('calling hooks');
|
||||
foreach (Hook::getByName('expire') as $hook) {
|
||||
DI::logger()->info('Calling expire', ['hook' => $hook[1]]);
|
||||
Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'Expire', 'hook', $hook[1]);
|
||||
Worker::add(
|
||||
['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'Expire',
|
||||
'hook',
|
||||
$hook[1]
|
||||
);
|
||||
}
|
||||
|
||||
DI::logger()->notice('calling hooks done');
|
||||
|
|
|
@ -70,8 +70,16 @@ class Notifier
|
|||
foreach ($inboxes as $inbox => $receivers) {
|
||||
$ap_contacts = array_merge($ap_contacts, $receivers);
|
||||
DI::logger()->info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
|
||||
Worker::add(['priority' => Worker::PRIORITY_HIGH, 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
|
||||
Worker::add(
|
||||
['priority' => Worker::PRIORITY_HIGH, 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'APDelivery',
|
||||
$cmd,
|
||||
$target_id,
|
||||
$inbox,
|
||||
$uid,
|
||||
$receivers,
|
||||
$post_uriid
|
||||
);
|
||||
}
|
||||
} elseif ($cmd == Delivery::SUGGESTION) {
|
||||
$suggest = DI::fsuggest()->selectOneById($target_id);
|
||||
|
@ -343,9 +351,12 @@ class Notifier
|
|||
if ($diaspora_delivery && !$unlisted) {
|
||||
$batch_delivery = true;
|
||||
|
||||
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'baseurl', 'gsid', 'id', 'url', 'name'],
|
||||
$participants = DBA::selectToArray(
|
||||
'contact',
|
||||
['batch', 'network', 'protocol', 'baseurl', 'gsid', 'id', 'url', 'name'],
|
||||
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
||||
['group_by' => ['batch', 'network', 'protocol']]);
|
||||
['group_by' => ['batch', 'network', 'protocol']]
|
||||
);
|
||||
|
||||
// Fetch the participation list
|
||||
// The function will ensure that there are no duplicates
|
||||
|
@ -617,8 +628,15 @@ class Notifier
|
|||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($self_user_id);
|
||||
foreach ($inboxes as $inbox => $receivers) {
|
||||
DI::logger()->info('Account removal via ActivityPub', ['uid' => $self_user_id, 'inbox' => $inbox]);
|
||||
Worker::add(['priority' => Worker::PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery', Delivery::REMOVAL, 0, $inbox, $self_user_id, $receivers);
|
||||
Worker::add(
|
||||
['priority' => Worker::PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery',
|
||||
Delivery::REMOVAL,
|
||||
0,
|
||||
$inbox,
|
||||
$self_user_id,
|
||||
$receivers
|
||||
);
|
||||
Worker::coolDown();
|
||||
}
|
||||
|
||||
|
@ -763,8 +781,16 @@ class Notifier
|
|||
Post\Delivery::add($target_item['uri-id'], $uid, $inbox, $target_item['created'], $cmd, $receivers);
|
||||
Worker::add([Worker::PRIORITY_HIGH, 'dont_fork' => true], 'APDelivery', '', 0, $inbox, 0);
|
||||
} else {
|
||||
if (Worker::add(['priority' => $priority, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery', $cmd, $target_item['id'], $inbox, $uid, $receivers, $target_item['uri-id'])) {
|
||||
if (Worker::add(
|
||||
['priority' => $priority, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery',
|
||||
$cmd,
|
||||
$target_item['id'],
|
||||
$inbox,
|
||||
$uid,
|
||||
$receivers,
|
||||
$target_item['uri-id']
|
||||
)) {
|
||||
$delivery_queue_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,11 +285,12 @@ class OnePoll
|
|||
DI::logger()->info('Mail: Seen before ' . $msg_uid . ' for ' . $mailconf['user'] . ' UID: ' . $importer_uid . ' URI: ' . $datarray['uri']);
|
||||
|
||||
// Only delete when mails aren't automatically moved or deleted
|
||||
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
|
||||
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) {
|
||||
if ($meta->deleted && ! $item['deleted']) {
|
||||
$fields = ['deleted' => true, 'changed' => $updated];
|
||||
Item::update($fields, ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($mailconf['action']) {
|
||||
case 0:
|
||||
|
|
|
@ -29,11 +29,15 @@ class PollContacts
|
|||
$condition = ['network' => [Protocol::FEED, Protocol::MAIL], 'self' => false, 'blocked' => false, 'archive' => false];
|
||||
|
||||
if (!empty($abandon_days)) {
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]);
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]
|
||||
);
|
||||
} else {
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`)", 0]);
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`)", 0]
|
||||
);
|
||||
}
|
||||
|
||||
$contacts = DBA::select('contact', ['id', 'nick', 'name', 'network', 'archive', 'last-update', 'priority', 'rating'], $condition);
|
||||
|
|
|
@ -16,7 +16,8 @@ use Friendica\Protocol\ActivityPub;
|
|||
/**
|
||||
* Send updated profile data to Diaspora and ActivityPub
|
||||
*/
|
||||
class ProfileUpdate {
|
||||
class ProfileUpdate
|
||||
{
|
||||
/**
|
||||
* Sends updated profile data to Diaspora and ActivityPub
|
||||
*
|
||||
|
@ -35,7 +36,8 @@ class ProfileUpdate {
|
|||
|
||||
foreach ($inboxes as $inbox => $receivers) {
|
||||
DI::logger()->info('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub');
|
||||
Worker::add(['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
Worker::add(
|
||||
['priority' => $appHelper->getQueueValue('priority'), 'created' => $appHelper->getQueueValue('created'), 'dont_fork' => true],
|
||||
'APDelivery',
|
||||
Delivery::PROFILEUPDATE,
|
||||
0,
|
||||
|
|
|
@ -14,8 +14,10 @@ use Friendica\Model\Item;
|
|||
/**
|
||||
* Posts items that where spooled because they couldn't be posted.
|
||||
*/
|
||||
class SpoolPost {
|
||||
public static function execute() {
|
||||
class SpoolPost
|
||||
{
|
||||
public static function execute()
|
||||
{
|
||||
$path = System::getSpoolPath();
|
||||
|
||||
if (($path != '') && is_writable($path)) {
|
||||
|
|
|
@ -63,7 +63,8 @@ class AutomaticInstallationConsoleTest extends ConsoleTestCase
|
|||
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpVfsDir();;
|
||||
$this->setUpVfsDir();
|
||||
;
|
||||
|
||||
if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
$this->root->getChild('config')
|
||||
|
|
14
update.php
14
update.php
|
@ -650,13 +650,19 @@ function pre_update_1377()
|
|||
|
||||
function update_1380()
|
||||
{
|
||||
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
|
||||
Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
|
||||
if (!DBA::e(
|
||||
"UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
|
||||
Notification\ObjectType::ITEM,
|
||||
Notification\ObjectType::PERSON
|
||||
)) {
|
||||
return Update::FAILED;
|
||||
}
|
||||
|
||||
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
|
||||
Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
|
||||
if (!DBA::e(
|
||||
"UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
|
||||
Notification\ObjectType::ITEM,
|
||||
Notification\ObjectType::PERSON
|
||||
)) {
|
||||
return Update::FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,11 @@ header('Last-Modified: '.$modified);
|
|||
|
||||
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||
$cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
|
||||
$cached_etag = str_replace(['"', "-gzip"], ['', ''],
|
||||
stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
|
||||
$cached_etag = str_replace(
|
||||
['"', "-gzip"],
|
||||
['', ''],
|
||||
stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
|
||||
);
|
||||
|
||||
if (($cached_modified == $modified) && ($cached_etag == $etag)) {
|
||||
throw new NotModifiedException();
|
||||
|
|
Loading…
Add table
Reference in a new issue