mirror of
https://github.com/friendica/friendica
synced 2024-11-17 16:23:46 +00:00
Rewrite:
- moved constants GRAVITY_* from boot.php to Friendica\Model\Item - also rewrote some array initialization: From: ```` <?php $arr = []; $arr['foo'] = "FOO"; ```` To: ```` <?php $arr['foo'] = "FOO"; ```` - added a few type-hints
This commit is contained in:
parent
e5ae5c7e67
commit
da66730e4f
77 changed files with 547 additions and 513 deletions
12
boot.php
12
boot.php
|
@ -59,18 +59,6 @@ define('CP_USERS_AND_GLOBAL', 2);
|
|||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Gravity
|
||||
*
|
||||
* Item weight for query ordering
|
||||
* @{
|
||||
*/
|
||||
define('GRAVITY_PARENT', 0);
|
||||
define('GRAVITY_ACTIVITY', 3);
|
||||
define('GRAVITY_COMMENT', 6);
|
||||
define('GRAVITY_UNKNOWN', 9);
|
||||
/* @}*/
|
||||
|
||||
/**
|
||||
* @name Priority
|
||||
*
|
||||
|
|
|
@ -106,7 +106,7 @@ function display_init(App $a)
|
|||
displayShowFeed($item['uri-id'], $item['uid'], false);
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [0, $item_user], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid' => true]]);
|
||||
$item = $parent ?: $item;
|
||||
}
|
||||
|
|
23
mod/item.php
23
mod/item.php
|
@ -122,7 +122,7 @@ function item_post(App $a) {
|
|||
$thr_parent_uri = $parent_item['uri'];
|
||||
$toplevel_item = $parent_item;
|
||||
|
||||
if ($parent_item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ function item_post(App $a) {
|
|||
// Look for any tags and linkify them
|
||||
$item = [
|
||||
'uid' => local_user() ? local_user() : $profile_uid,
|
||||
'gravity' => $toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT,
|
||||
'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
|
||||
'network' => $network,
|
||||
'body' => $body,
|
||||
'postopts' => $postopts,
|
||||
|
@ -513,7 +513,7 @@ function item_post(App $a) {
|
|||
$network = Protocol::DFRN;
|
||||
}
|
||||
|
||||
$gravity = ($toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT);
|
||||
$gravity = ($toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
|
||||
|
||||
// even if the post arrived via API we are considering that it
|
||||
// originated on this site by default for determining relayability.
|
||||
|
@ -705,7 +705,7 @@ function item_post(App $a) {
|
|||
|
||||
Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
|
||||
|
||||
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == GRAVITY_COMMENT)) {
|
||||
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == Item::GRAVITY_COMMENT)) {
|
||||
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
|
||||
}
|
||||
|
||||
|
@ -833,15 +833,15 @@ function item_content(App $a)
|
|||
* @return string
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
function drop_item(int $id, string $return = '')
|
||||
function drop_item(int $id, string $return = ''): string
|
||||
{
|
||||
// locate item to be deleted
|
||||
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'];
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
||||
// Locate item to be deleted
|
||||
$item = Post::selectFirstForUser(local_user(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
notice(DI::l10n()->t('Item not found.'));
|
||||
DI::baseUrl()->redirect('network');
|
||||
//NOTREACHED
|
||||
}
|
||||
|
||||
if ($item['deleted']) {
|
||||
|
@ -860,6 +860,7 @@ function drop_item(int $id, string $return = '')
|
|||
Item::deleteForUser(['id' => $item['id']], local_user());
|
||||
|
||||
item_redirect_after_action($item, $return);
|
||||
//NOTREACHED
|
||||
} else {
|
||||
Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
|
||||
notice(DI::l10n()->t('Permission denied.'));
|
||||
|
@ -870,15 +871,15 @@ function drop_item(int $id, string $return = '')
|
|||
return '';
|
||||
}
|
||||
|
||||
function item_redirect_after_action($item, $returnUrlHex)
|
||||
function item_redirect_after_action(array $item, string $returnUrlHex)
|
||||
{
|
||||
$return_url = hex2bin($returnUrlHex);
|
||||
|
||||
// removes update_* from return_url to ignore Ajax refresh
|
||||
$return_url = str_replace("update_", "", $return_url);
|
||||
$return_url = str_replace('update_', '', $return_url);
|
||||
|
||||
// Check if delete a comment
|
||||
if ($item['gravity'] == GRAVITY_COMMENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
if (!empty($item['parent'])) {
|
||||
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
|
||||
}
|
||||
|
|
172
mod/message.php
172
mod/message.php
|
@ -43,23 +43,23 @@ function message_init(App $a)
|
|||
}
|
||||
|
||||
$new = [
|
||||
'label' => DI::l10n()->t('New Message'),
|
||||
'url' => 'message/new',
|
||||
'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
|
||||
'label' => DI::l10n()->t('New Message'),
|
||||
'url' => 'message/new',
|
||||
'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
|
||||
'accesskey' => 'm',
|
||||
];
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('message_side.tpl');
|
||||
DI::page()['aside'] = Renderer::replaceMacros($tpl, [
|
||||
'$tabs' => $tabs,
|
||||
'$new' => $new,
|
||||
'$new' => $new,
|
||||
]);
|
||||
$base = DI::baseUrl();
|
||||
|
||||
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$base' => $base
|
||||
'$base' => $base
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,15 @@ function message_post(App $a)
|
|||
notice(DI::l10n()->t('No recipient selected.'));
|
||||
$norecip = true;
|
||||
break;
|
||||
|
||||
case -2:
|
||||
notice(DI::l10n()->t('Unable to locate contact information.'));
|
||||
break;
|
||||
|
||||
case -3:
|
||||
notice(DI::l10n()->t('Message could not be sent.'));
|
||||
break;
|
||||
|
||||
case -4:
|
||||
notice(DI::l10n()->t('Message collection failure.'));
|
||||
break;
|
||||
|
@ -118,20 +121,20 @@ function message_content(App $a)
|
|||
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
|
||||
$button = [
|
||||
'label' => DI::l10n()->t('Discard'),
|
||||
'url' => '/message',
|
||||
'sel' => 'close',
|
||||
'url' => '/message',
|
||||
'sel' => 'close',
|
||||
];
|
||||
} else {
|
||||
$button = [
|
||||
'label' => DI::l10n()->t('New Message'),
|
||||
'url' => '/message/new',
|
||||
'sel' => 'new',
|
||||
'label' => DI::l10n()->t('New Message'),
|
||||
'url' => '/message/new',
|
||||
'sel' => 'new',
|
||||
'accesskey' => 'm',
|
||||
];
|
||||
}
|
||||
$header = Renderer::replaceMacros($tpl, [
|
||||
'$messages' => DI::l10n()->t('Messages'),
|
||||
'$button' => $button,
|
||||
'$button' => $button,
|
||||
]);
|
||||
|
||||
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) {
|
||||
|
@ -186,19 +189,19 @@ function message_content(App $a)
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('prv_message.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$header' => DI::l10n()->t('Send Private Message'),
|
||||
'$to' => DI::l10n()->t('To:'),
|
||||
'$subject' => DI::l10n()->t('Subject:'),
|
||||
'$subjtxt' => $_REQUEST['subject'] ?? '',
|
||||
'$text' => $_REQUEST['body'] ?? '',
|
||||
'$readonly' => '',
|
||||
'$yourmessage'=> DI::l10n()->t('Your message:'),
|
||||
'$select' => $select,
|
||||
'$parent' => '',
|
||||
'$upload' => DI::l10n()->t('Upload photo'),
|
||||
'$insert' => DI::l10n()->t('Insert web link'),
|
||||
'$wait' => DI::l10n()->t('Please wait'),
|
||||
'$submit' => DI::l10n()->t('Submit')
|
||||
'$header' => DI::l10n()->t('Send Private Message'),
|
||||
'$to' => DI::l10n()->t('To:'),
|
||||
'$subject' => DI::l10n()->t('Subject:'),
|
||||
'$subjtxt' => $_REQUEST['subject'] ?? '',
|
||||
'$text' => $_REQUEST['body'] ?? '',
|
||||
'$readonly' => '',
|
||||
'$yourmessage' => DI::l10n()->t('Your message:'),
|
||||
'$select' => $select,
|
||||
'$parent' => '',
|
||||
'$upload' => DI::l10n()->t('Upload photo'),
|
||||
'$insert' => DI::l10n()->t('Insert web link'),
|
||||
'$wait' => DI::l10n()->t('Please wait'),
|
||||
'$submit' => DI::l10n()->t('Submit')
|
||||
]);
|
||||
return $o;
|
||||
}
|
||||
|
@ -312,18 +315,18 @@ function message_content(App $a)
|
|||
$from_photo = Contact::getThumb($contact);
|
||||
|
||||
$mails[] = [
|
||||
'id' => $message['id'],
|
||||
'from_name' => $from_name_e,
|
||||
'from_url' => $from_url,
|
||||
'from_addr' => $contact['addr'] ?? $from_url,
|
||||
'sparkle' => $sparkle,
|
||||
'id' => $message['id'],
|
||||
'from_name' => $from_name_e,
|
||||
'from_url' => $from_url,
|
||||
'from_addr' => $contact['addr'] ?? $from_url,
|
||||
'sparkle' => $sparkle,
|
||||
'from_photo' => $from_photo,
|
||||
'subject' => $subject_e,
|
||||
'body' => $body_e,
|
||||
'delete' => DI::l10n()->t('Delete message'),
|
||||
'to_name' => $to_name_e,
|
||||
'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
|
||||
'ago' => Temporal::getRelativeDate($message['created']),
|
||||
'subject' => $subject_e,
|
||||
'body' => $body_e,
|
||||
'delete' => DI::l10n()->t('Delete message'),
|
||||
'to_name' => $to_name_e,
|
||||
'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
|
||||
'ago' => Temporal::getRelativeDate($message['created']),
|
||||
];
|
||||
|
||||
$seen = $message['seen'];
|
||||
|
@ -334,28 +337,27 @@ function message_content(App $a)
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('mail_display.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$thread_id' => DI::args()->getArgv()[1],
|
||||
'$thread_id' => DI::args()->getArgv()[1],
|
||||
'$thread_subject' => $message['title'],
|
||||
'$thread_seen' => $seen,
|
||||
'$delete' => DI::l10n()->t('Delete conversation'),
|
||||
'$canreply' => (($unknown) ? false : '1'),
|
||||
'$unknown_text' => DI::l10n()->t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
|
||||
'$mails' => $mails,
|
||||
|
||||
'$thread_seen' => $seen,
|
||||
'$delete' => DI::l10n()->t('Delete conversation'),
|
||||
'$canreply' => (($unknown) ? false : '1'),
|
||||
'$unknown_text' => DI::l10n()->t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
|
||||
'$mails' => $mails,
|
||||
// reply
|
||||
'$header' => DI::l10n()->t('Send Reply'),
|
||||
'$to' => DI::l10n()->t('To:'),
|
||||
'$subject' => DI::l10n()->t('Subject:'),
|
||||
'$subjtxt' => $message['title'],
|
||||
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
|
||||
'$yourmessage' => DI::l10n()->t('Your message:'),
|
||||
'$text' => '',
|
||||
'$select' => $select,
|
||||
'$parent' => $parent,
|
||||
'$upload' => DI::l10n()->t('Upload photo'),
|
||||
'$insert' => DI::l10n()->t('Insert web link'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$wait' => DI::l10n()->t('Please wait')
|
||||
'$header' => DI::l10n()->t('Send Reply'),
|
||||
'$to' => DI::l10n()->t('To:'),
|
||||
'$subject' => DI::l10n()->t('Subject:'),
|
||||
'$subjtxt' => $message['title'],
|
||||
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
|
||||
'$yourmessage' => DI::l10n()->t('Your message:'),
|
||||
'$text' => '',
|
||||
'$select' => $select,
|
||||
'$parent' => $parent,
|
||||
'$upload' => DI::l10n()->t('Upload photo'),
|
||||
'$insert' => DI::l10n()->t('Insert web link'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$wait' => DI::l10n()->t('Please wait')
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
@ -368,7 +370,7 @@ function message_content(App $a)
|
|||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
function get_messages(int $uid, int $start, int $limit)
|
||||
function get_messages(int $uid, int $start, int $limit): array
|
||||
{
|
||||
return DBA::toArray(DBA::p('SELECT
|
||||
m.`id`,
|
||||
|
@ -392,21 +394,21 @@ function get_messages(int $uid, int $start, int $limit)
|
|||
c.`url`,
|
||||
c.`thumb`,
|
||||
c.`network`,
|
||||
m2.`count`,
|
||||
m2.`mailcreated`,
|
||||
m2.`mailseen`
|
||||
FROM `mail` m
|
||||
JOIN (
|
||||
SELECT
|
||||
`parent-uri`,
|
||||
MIN(`id`) AS `id`,
|
||||
COUNT(*) AS `count`,
|
||||
MAX(`created`) AS `mailcreated`,
|
||||
MIN(`seen`) AS `mailseen`
|
||||
FROM `mail`
|
||||
WHERE `uid` = ?
|
||||
GROUP BY `parent-uri`
|
||||
) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
|
||||
m2.`count`,
|
||||
m2.`mailcreated`,
|
||||
m2.`mailseen`
|
||||
FROM `mail` m
|
||||
JOIN (
|
||||
SELECT
|
||||
`parent-uri`,
|
||||
MIN(`id`) AS `id`,
|
||||
COUNT(*) AS `count`,
|
||||
MAX(`created`) AS `mailcreated`,
|
||||
MIN(`seen`) AS `mailseen`
|
||||
FROM `mail`
|
||||
WHERE `uid` = ?
|
||||
GROUP BY `parent-uri`
|
||||
) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
|
||||
LEFT JOIN `contact` c ON m.`contact-id` = c.`id`
|
||||
WHERE m.`uid` = ?
|
||||
ORDER BY m2.`mailcreated` DESC
|
||||
|
@ -414,7 +416,7 @@ function get_messages(int $uid, int $start, int $limit)
|
|||
, $uid, $uid, $start, $limit));
|
||||
}
|
||||
|
||||
function render_messages(array $msg, $t)
|
||||
function render_messages(array $msg, string $t): string
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
|
@ -444,20 +446,20 @@ function render_messages(array $msg, $t)
|
|||
$from_photo = Contact::getThumb($contact);
|
||||
|
||||
$rslt .= Renderer::replaceMacros($tpl, [
|
||||
'$id' => $rr['id'],
|
||||
'$from_name' => $participants,
|
||||
'$from_url' => Contact::magicLink($rr['url']),
|
||||
'$from_addr' => $contact['addr'] ?? '',
|
||||
'$sparkle' => ' sparkle',
|
||||
'$id' => $rr['id'],
|
||||
'$from_name' => $participants,
|
||||
'$from_url' => Contact::magicLink($rr['url']),
|
||||
'$from_addr' => $contact['addr'] ?? '',
|
||||
'$sparkle' => ' sparkle',
|
||||
'$from_photo' => $from_photo,
|
||||
'$subject' => $rr['title'],
|
||||
'$delete' => DI::l10n()->t('Delete conversation'),
|
||||
'$body' => $body_e,
|
||||
'$to_name' => $to_name_e,
|
||||
'$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
|
||||
'$ago' => Temporal::getRelativeDate($rr['mailcreated']),
|
||||
'$seen' => $rr['mailseen'],
|
||||
'$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
|
||||
'$subject' => $rr['title'],
|
||||
'$delete' => DI::l10n()->t('Delete conversation'),
|
||||
'$body' => $body_e,
|
||||
'$to_name' => $to_name_e,
|
||||
'$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
|
||||
'$ago' => Temporal::getRelativeDate($rr['mailcreated']),
|
||||
'$seen' => $rr['mailseen'],
|
||||
'$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ function notes_init(App $a)
|
|||
}
|
||||
|
||||
|
||||
function notes_content(App $a, $update = false)
|
||||
function notes_content(App $a, bool $update = false)
|
||||
{
|
||||
if (!local_user()) {
|
||||
notice(DI::l10n()->t('Permission denied.'));
|
||||
|
@ -60,7 +60,7 @@ function notes_content(App $a, $update = false)
|
|||
$o .= DI::conversation()->statusEditor($x, $a->getContactId());
|
||||
}
|
||||
|
||||
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
|
||||
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
|
||||
'contact-id'=> $a->getContactId()];
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
|
|
|
@ -93,8 +93,8 @@ function oexchange_init(App $a)
|
|||
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
|
||||
}
|
||||
|
||||
function oexchange_content(App $a) {
|
||||
|
||||
function oexchange_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
$o = Login::form();
|
||||
return $o;
|
||||
|
@ -109,7 +109,7 @@ function oexchange_content(App $a) {
|
|||
$description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : '';
|
||||
$tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : '';
|
||||
|
||||
$s = \Friendica\Content\Text\BBCode::embedURL($url, true, $title, $description, $tags);
|
||||
$s = BBCode::embedURL($url, true, $title, $description, $tags);
|
||||
|
||||
if (!strlen($s)) {
|
||||
return;
|
||||
|
@ -119,9 +119,9 @@ function oexchange_content(App $a) {
|
|||
|
||||
$post['profile_uid'] = local_user();
|
||||
$post['return'] = '/oexchange/done';
|
||||
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
|
||||
$post['body'] = HTML::toBBCode($s);
|
||||
|
||||
$_REQUEST = $post;
|
||||
require_once('mod/item.php');
|
||||
require_once 'mod/item.php';
|
||||
item_post($a);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
function ostatus_subscribe_content(App $a)
|
||||
function ostatus_subscribe_content(App $a): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
notice(DI::l10n()->t('Permission denied.'));
|
||||
|
@ -42,7 +42,6 @@ function ostatus_subscribe_content(App $a)
|
|||
$counter = intval($_REQUEST['counter'] ?? 0);
|
||||
|
||||
if (DI::pConfig()->get($uid, 'ostatus', 'legacy_friends') == '') {
|
||||
|
||||
if ($_REQUEST['url'] == '') {
|
||||
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
|
||||
return $o . DI::l10n()->t('No contact provided.');
|
||||
|
|
|
@ -55,8 +55,8 @@ use Friendica\Util\Temporal;
|
|||
use Friendica\Util\XML;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
function photos_init(App $a) {
|
||||
|
||||
function photos_init(App $a)
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
@ -526,44 +526,40 @@ function photos_post(App $a)
|
|||
foreach ($taginfo as $tagged) {
|
||||
$uri = Item::newURI();
|
||||
|
||||
$arr = [];
|
||||
$arr['guid'] = System::createUUID();
|
||||
$arr['uid'] = $page_owner_uid;
|
||||
$arr['uri'] = $uri;
|
||||
$arr['wall'] = 1;
|
||||
$arr['contact-id'] = $owner_record['id'];
|
||||
$arr['owner-name'] = $owner_record['name'];
|
||||
$arr['owner-link'] = $owner_record['url'];
|
||||
$arr['owner-avatar'] = $owner_record['thumb'];
|
||||
$arr['author-name'] = $owner_record['name'];
|
||||
$arr['author-link'] = $owner_record['url'];
|
||||
$arr['author-avatar'] = $owner_record['thumb'];
|
||||
$arr['title'] = '';
|
||||
$arr['allow_cid'] = $photo['allow_cid'];
|
||||
$arr['allow_gid'] = $photo['allow_gid'];
|
||||
$arr['deny_cid'] = $photo['deny_cid'];
|
||||
$arr['deny_gid'] = $photo['deny_gid'];
|
||||
$arr['visible'] = 0;
|
||||
$arr['verb'] = Activity::TAG;
|
||||
$arr['gravity'] = GRAVITY_PARENT;
|
||||
$arr['object-type'] = Activity\ObjectType::PERSON;
|
||||
$arr['target-type'] = Activity\ObjectType::IMAGE;
|
||||
$arr['inform'] = $tagged[2];
|
||||
$arr['origin'] = 1;
|
||||
$arr['body'] = DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
|
||||
$arr['body'] .= "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
|
||||
$arr = [
|
||||
'guid' => System::createUUID(),
|
||||
'uid' => $page_owner_uid,
|
||||
'uri' => $uri,
|
||||
'wall' => 1,
|
||||
'contact-id' => $owner_record['id'],
|
||||
'owner-name' => $owner_record['name'],
|
||||
'owner-link' => $owner_record['url'],
|
||||
'owner-avatar' => $owner_record['thumb'],
|
||||
'author-name' => $owner_record['name'],
|
||||
'author-link' => $owner_record['url'],
|
||||
'author-avatar' => $owner_record['thumb'],
|
||||
'title' => '',
|
||||
'allow_cid' => $photo['allow_cid'],
|
||||
'allow_gid' => $photo['allow_gid'],
|
||||
'deny_cid' => $photo['deny_cid'],
|
||||
'deny_gid' => $photo['deny_gid'],
|
||||
'visible' => 0,
|
||||
'verb' => Activity::TAG,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'object-type' => Activity\ObjectType::PERSON,
|
||||
'target-type' => Activity\ObjectType::IMAGE,
|
||||
'inform' => $tagged[2],
|
||||
'origin' => 1,
|
||||
'body' => DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') . "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n",
|
||||
'object' => '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n"),
|
||||
'target' => '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>',
|
||||
];
|
||||
|
||||
$arr['object'] = '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
|
||||
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
|
||||
if ($tagged[3]) {
|
||||
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
|
||||
}
|
||||
$arr['object'] .= '</link></object>' . "\n";
|
||||
|
||||
$arr['target'] = '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
|
||||
. DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
|
||||
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
|
||||
|
||||
Item::insert($arr);
|
||||
}
|
||||
}
|
||||
|
@ -1233,7 +1229,7 @@ function photos_content(App $a)
|
|||
$link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]);
|
||||
|
||||
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
|
||||
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], GRAVITY_COMMENT];
|
||||
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
|
||||
$total = Post::count($condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
@ -1404,7 +1400,7 @@ function photos_content(App $a)
|
|||
|
||||
if (($activity->match($item['verb'], Activity::LIKE) ||
|
||||
$activity->match($item['verb'], Activity::DISLIKE)) &&
|
||||
($item['gravity'] != GRAVITY_PARENT)) {
|
||||
($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1421,25 +1417,25 @@ function photos_content(App $a)
|
|||
$drop = [
|
||||
'dropping' => $dropping,
|
||||
'pagedrop' => false,
|
||||
'select' => DI::l10n()->t('Select'),
|
||||
'delete' => DI::l10n()->t('Delete'),
|
||||
'select' => DI::l10n()->t('Select'),
|
||||
'delete' => DI::l10n()->t('Delete'),
|
||||
];
|
||||
|
||||
$title_e = $item['title'];
|
||||
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
|
||||
|
||||
$comments .= Renderer::replaceMacros($template,[
|
||||
'$id' => $item['id'],
|
||||
'$id' => $item['id'],
|
||||
'$profile_url' => $profile_url,
|
||||
'$name' => $item['author-name'],
|
||||
'$thumb' => $item['author-avatar'],
|
||||
'$sparkle' => $sparkle,
|
||||
'$title' => $title_e,
|
||||
'$body' => $body_e,
|
||||
'$ago' => Temporal::getRelativeDate($item['created']),
|
||||
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
|
||||
'$drop' => $drop,
|
||||
'$comment' => $comment
|
||||
'$name' => $item['author-name'],
|
||||
'$thumb' => $item['author-avatar'],
|
||||
'$sparkle' => $sparkle,
|
||||
'$title' => $title_e,
|
||||
'$body' => $body_e,
|
||||
'$ago' => Temporal::getRelativeDate($item['created']),
|
||||
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
|
||||
'$drop' => $drop,
|
||||
'$comment' => $comment
|
||||
]);
|
||||
|
||||
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
|
||||
|
|
|
@ -123,7 +123,7 @@ EOT;
|
|||
$arr['uid'] = $owner_uid;
|
||||
$arr['contact-id'] = $contact['id'];
|
||||
$arr['wall'] = $item['wall'];
|
||||
$arr['gravity'] = GRAVITY_COMMENT;
|
||||
$arr['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$arr['parent'] = $item['id'];
|
||||
$arr['thr-parent'] = $item['uri'];
|
||||
$arr['owner-name'] = $item['author-name'];
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Core\Session;
|
|||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item as ItemModel;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
|
@ -135,7 +135,7 @@ class Conversation
|
|||
return;
|
||||
}
|
||||
|
||||
if (!empty($activity['verb']) && $this->activity->match($activity['verb'], $verb) && ($activity['gravity'] != GRAVITY_PARENT)) {
|
||||
if (!empty($activity['verb']) && $this->activity->match($activity['verb'], $verb) && ($activity['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $activity['author-id'],
|
||||
|
@ -369,7 +369,7 @@ class Conversation
|
|||
'$permset' => $this->l10n->t('Permission settings'),
|
||||
'$shortpermset' => $this->l10n->t('Permissions'),
|
||||
'$wall' => $notes_cid ? 0 : 1,
|
||||
'$posttype' => $notes_cid ? ItemModel::PT_PERSONAL_NOTE : ItemModel::PT_ARTICLE,
|
||||
'$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE,
|
||||
'$content' => $x['content'] ?? '',
|
||||
'$post_id' => $x['post_id'] ?? '',
|
||||
'$baseurl' => $this->baseURL->get(true),
|
||||
|
@ -641,7 +641,7 @@ class Conversation
|
|||
unset($likebuttons['dislike']);
|
||||
}
|
||||
|
||||
$body_html = ItemModel::prepareBody($item, true, $preview);
|
||||
$body_html = Item::prepareBody($item, true, $preview);
|
||||
|
||||
[$categories, $folders] = $this->item->determineCategoriesTerms($item, local_user());
|
||||
|
||||
|
@ -698,7 +698,7 @@ class Conversation
|
|||
'owner_name' => '',
|
||||
'owner_url' => '',
|
||||
'owner_photo' => $this->baseURL->remove($this->item->getOwnerAvatar($item)),
|
||||
'plink' => ItemModel::getPlink($item),
|
||||
'plink' => Item::getPlink($item),
|
||||
'edpost' => false,
|
||||
'pinned' => $pinned,
|
||||
'isstarred' => 'unstarred',
|
||||
|
@ -755,7 +755,7 @@ class Conversation
|
|||
|
||||
$item['pagedrop'] = $page_dropping;
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$item_object = new PostObject($item);
|
||||
$conv->addParent($item_object);
|
||||
}
|
||||
|
@ -825,8 +825,8 @@ class Conversation
|
|||
}
|
||||
|
||||
if (!empty($activity)) {
|
||||
if (($row['gravity'] == GRAVITY_PARENT)) {
|
||||
$row['post-reason'] = ItemModel::PR_ANNOUNCEMENT;
|
||||
if (($row['gravity'] == Item::GRAVITY_PARENT)) {
|
||||
$row['post-reason'] = Item::PR_ANNOUNCEMENT;
|
||||
|
||||
$row = array_merge($row, $activity);
|
||||
$contact = Contact::getById($activity['causer-id'], ['url', 'name', 'thumb']);
|
||||
|
@ -834,32 +834,32 @@ class Conversation
|
|||
$row['causer-link'] = $contact['url'];
|
||||
$row['causer-avatar'] = $contact['thumb'];
|
||||
$row['causer-name'] = $contact['name'];
|
||||
} elseif (($row['gravity'] == GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
|
||||
} elseif (($row['gravity'] == Item::GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
|
||||
($row['author-id'] == $activity['causer-id'])) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($row['post-reason']) {
|
||||
case ItemModel::PR_TO:
|
||||
case Item::PR_TO:
|
||||
$row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'to')];
|
||||
break;
|
||||
case ItemModel::PR_CC:
|
||||
case Item::PR_CC:
|
||||
$row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'cc')];
|
||||
break;
|
||||
case ItemModel::PR_BTO:
|
||||
case Item::PR_BTO:
|
||||
$row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'bto')];
|
||||
break;
|
||||
case ItemModel::PR_BCC:
|
||||
case Item::PR_BCC:
|
||||
$row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'bcc')];
|
||||
break;
|
||||
case ItemModel::PR_FOLLOWER:
|
||||
case Item::PR_FOLLOWER:
|
||||
$row['direction'] = ['direction' => 6, 'title' => $this->l10n->t('You are following %s.', $row['causer-name'] ?: $row['author-name'])];
|
||||
break;
|
||||
case ItemModel::PR_TAG:
|
||||
case Item::PR_TAG:
|
||||
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
|
||||
break;
|
||||
case ItemModel::PR_ANNOUNCEMENT:
|
||||
case Item::PR_ANNOUNCEMENT:
|
||||
if (!empty($row['causer-id']) && $this->pConfig->get(local_user(), 'system', 'display_resharer')) {
|
||||
$row['owner-id'] = $row['causer-id'];
|
||||
$row['owner-link'] = $row['causer-link'];
|
||||
|
@ -867,41 +867,41 @@ class Conversation
|
|||
$row['owner-name'] = $row['causer-name'];
|
||||
}
|
||||
|
||||
if (in_array($row['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) && !empty($row['causer-id'])) {
|
||||
if (in_array($row['gravity'], [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]) && !empty($row['causer-id'])) {
|
||||
$causer = ['uid' => 0, 'id' => $row['causer-id'], 'network' => $row['causer-network'], 'url' => $row['causer-link']];
|
||||
|
||||
$row['reshared'] = $this->l10n->t('%s reshared this.', '<a href="'. htmlentities(Contact::magicLinkByContact($causer)) .'">' . htmlentities($row['causer-name']) . '</a>');
|
||||
}
|
||||
$row['direction'] = ['direction' => 3, 'title' => (empty($row['causer-id']) ? $this->l10n->t('Reshared') : $this->l10n->t('Reshared by %s <%s>', $row['causer-name'], $row['causer-link']))];
|
||||
break;
|
||||
case ItemModel::PR_COMMENT:
|
||||
case Item::PR_COMMENT:
|
||||
$row['direction'] = ['direction' => 5, 'title' => $this->l10n->t('%s is participating in this thread.', $row['author-name'])];
|
||||
break;
|
||||
case ItemModel::PR_STORED:
|
||||
case Item::PR_STORED:
|
||||
$row['direction'] = ['direction' => 8, 'title' => $this->l10n->t('Stored for general reasons')];
|
||||
break;
|
||||
case ItemModel::PR_GLOBAL:
|
||||
case Item::PR_GLOBAL:
|
||||
$row['direction'] = ['direction' => 9, 'title' => $this->l10n->t('Global post')];
|
||||
break;
|
||||
case ItemModel::PR_RELAY:
|
||||
case Item::PR_RELAY:
|
||||
$row['direction'] = ['direction' => 10, 'title' => (empty($row['causer-id']) ? $this->l10n->t('Sent via an relay server') : $this->l10n->t('Sent via the relay server %s <%s>', $row['causer-name'], $row['causer-link']))];
|
||||
break;
|
||||
case ItemModel::PR_FETCHED:
|
||||
case Item::PR_FETCHED:
|
||||
$row['direction'] = ['direction' => 2, 'title' => (empty($row['causer-id']) ? $this->l10n->t('Fetched') : $this->l10n->t('Fetched because of %s <%s>', $row['causer-name'], $row['causer-link']))];
|
||||
break;
|
||||
case ItemModel::PR_COMPLETION:
|
||||
case Item::PR_COMPLETION:
|
||||
$row['direction'] = ['direction' => 2, 'title' => $this->l10n->t('Stored because of a child post to complete this thread.')];
|
||||
break;
|
||||
case ItemModel::PR_DIRECT:
|
||||
case Item::PR_DIRECT:
|
||||
$row['direction'] = ['direction' => 6, 'title' => $this->l10n->t('Local delivery')];
|
||||
break;
|
||||
case ItemModel::PR_ACTIVITY:
|
||||
case Item::PR_ACTIVITY:
|
||||
$row['direction'] = ['direction' => 2, 'title' => $this->l10n->t('Stored because of your activity (like, comment, star, ...)')];
|
||||
break;
|
||||
case ItemModel::PR_DISTRIBUTE:
|
||||
case Item::PR_DISTRIBUTE:
|
||||
$row['direction'] = ['direction' => 6, 'title' => $this->l10n->t('Distributed')];
|
||||
break;
|
||||
case ItemModel::PR_PUSHED:
|
||||
case Item::PR_PUSHED:
|
||||
$row['direction'] = ['direction' => 1, 'title' => $this->l10n->t('Pushed to us')];
|
||||
break;
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ class Conversation
|
|||
$activitycounter = [];
|
||||
|
||||
foreach ($parents as $parent) {
|
||||
if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == GRAVITY_ACTIVITY)) {
|
||||
if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == Item::GRAVITY_ACTIVITY)) {
|
||||
$uriid = $parent['thr-parent-id'];
|
||||
if (!empty($parent['author-id'])) {
|
||||
$activities[$uriid] = ['causer-id' => $parent['author-id']];
|
||||
|
@ -979,7 +979,7 @@ class Conversation
|
|||
|
||||
$params = ['order' => ['uri-id' => true, 'uid' => true]];
|
||||
|
||||
$thread_items = Post::selectForUser($uid, array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params);
|
||||
$thread_items = Post::selectForUser($uid, array_merge(Item::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params);
|
||||
|
||||
$items = [];
|
||||
|
||||
|
@ -993,10 +993,10 @@ class Conversation
|
|||
}
|
||||
|
||||
if ($max_comments > 0) {
|
||||
if (($row['gravity'] == GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) {
|
||||
if (($row['gravity'] == Item::GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) {
|
||||
continue;
|
||||
}
|
||||
if (($row['gravity'] == GRAVITY_ACTIVITY) && (++$activitycounter[$row['parent-uri-id']] > $max_comments)) {
|
||||
if (($row['gravity'] == Item::GRAVITY_ACTIVITY) && (++$activitycounter[$row['parent-uri-id']] > $max_comments)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ class Conversation
|
|||
$this->profiler->startRecording('rendering');
|
||||
$children = [];
|
||||
foreach ($item_list as $i => $item) {
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
if ($recursive) {
|
||||
// Fallback to parent-uri if thr-parent is not set
|
||||
$thr_parent = $item['thr-parent-id'];
|
||||
|
@ -1182,7 +1182,7 @@ class Conversation
|
|||
|
||||
// Extract the top level items
|
||||
foreach ($item_array as $item) {
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$parents[] = $item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ class Item
|
|||
$sub_link = $contact_url = $pm_url = $status_link = '';
|
||||
$photos_link = $posts_link = $block_link = $ignore_link = '';
|
||||
|
||||
if (local_user() && local_user() == $item['uid'] && $item['gravity'] == GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||
if (local_user() && local_user() == $item['uid'] && $item['gravity'] == ModelItem::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ class Item
|
|||
}
|
||||
$item['inform'] .= 'cid:' . $contact['id'];
|
||||
|
||||
if (($item['gravity'] == GRAVITY_COMMENT) || empty($contact['cid']) || ($contact['contact-type'] != Contact::TYPE_COMMUNITY)) {
|
||||
if (($item['gravity'] == ModelItem::GRAVITY_COMMENT) || empty($contact['cid']) || ($contact['contact-type'] != Contact::TYPE_COMMUNITY)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ class Item
|
|||
}
|
||||
Logger::info('Got inform', ['inform' => $item['inform']]);
|
||||
|
||||
if (($item['gravity'] == GRAVITY_PARENT) && !empty($forum_contact) && ($private_forum || $only_to_forum)) {
|
||||
if (($item['gravity'] == ModelItem::GRAVITY_PARENT) && !empty($forum_contact) && ($private_forum || $only_to_forum)) {
|
||||
// we tagged a forum in a top level post. Now we change the post
|
||||
$item['private'] = $private_forum ? ModelItem::PRIVATE : ModelItem::UNLISTED;
|
||||
|
||||
|
@ -510,7 +510,7 @@ class Item
|
|||
$item['allow_cid'] = '';
|
||||
$item['allow_gid'] = '';
|
||||
}
|
||||
} elseif ($setPermissions && ($item['gravity'] == GRAVITY_PARENT)) {
|
||||
} elseif ($setPermissions && ($item['gravity'] == ModelItem::GRAVITY_PARENT)) {
|
||||
if (empty($receivers)) {
|
||||
// For security reasons direct posts without any receiver will be posts to yourself
|
||||
$self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -139,7 +140,7 @@ class Protocol
|
|||
// create a follow slap
|
||||
$item = [
|
||||
'verb' => Activity::FOLLOW,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'follow' => $contact['url'],
|
||||
'body' => '',
|
||||
'title' => '',
|
||||
|
@ -191,14 +192,16 @@ class Protocol
|
|||
|
||||
if (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||
// create an unfollow slap
|
||||
$item = [];
|
||||
$item['verb'] = Activity::O_UNFOLLOW;
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['follow'] = $contact['url'];
|
||||
$item['body'] = '';
|
||||
$item['title'] = '';
|
||||
$item['guid'] = '';
|
||||
$item['uri-id'] = 0;
|
||||
$item = [
|
||||
'verb' => Activity::O_UNFOLLOW,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'follow' => $contact['url'],
|
||||
'body' => '',
|
||||
'title' => '',
|
||||
'guid' => '',
|
||||
'uri-id' => 0,
|
||||
];
|
||||
|
||||
$slap = OStatus::salmon($item, $user);
|
||||
|
||||
if (empty($contact['notify'])) {
|
||||
|
|
|
@ -48,19 +48,19 @@ class Renderer
|
|||
* beyond are used.
|
||||
*/
|
||||
public static $theme = [
|
||||
'videowidth' => 425,
|
||||
'videoheight' => 350,
|
||||
'stylesheet' => '',
|
||||
'videowidth' => 425,
|
||||
'videoheight' => 350,
|
||||
'stylesheet' => '',
|
||||
'template_engine' => 'smarty3',
|
||||
];
|
||||
|
||||
private static $ldelim = [
|
||||
'internal' => '',
|
||||
'smarty3' => '{{'
|
||||
'smarty3' => '{{'
|
||||
];
|
||||
private static $rdelim = [
|
||||
'internal' => '',
|
||||
'smarty3' => '}}'
|
||||
'smarty3' => '}}'
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -101,10 +101,10 @@ class Renderer
|
|||
* @param string $file Template to load.
|
||||
* @param string $subDir Subdirectory (Optional)
|
||||
*
|
||||
* @return string template.
|
||||
* @return string Template
|
||||
* @throws ServiceUnavailableException
|
||||
*/
|
||||
public static function getMarkupTemplate($file, $subDir = '')
|
||||
public static function getMarkupTemplate(string $file, string $subDir = ''): string
|
||||
{
|
||||
DI::profiler()->startRecording('file');
|
||||
$t = self::getTemplateEngine();
|
||||
|
@ -128,9 +128,11 @@ class Renderer
|
|||
* Register template engine class
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return void
|
||||
* @throws ServiceUnavailableException
|
||||
*/
|
||||
public static function registerTemplateEngine($class)
|
||||
public static function registerTemplateEngine(string $class)
|
||||
{
|
||||
$v = get_class_vars($class);
|
||||
|
||||
|
@ -156,7 +158,7 @@ class Renderer
|
|||
* @return TemplateEngine Template Engine instance
|
||||
* @throws ServiceUnavailableException
|
||||
*/
|
||||
public static function getTemplateEngine()
|
||||
public static function getTemplateEngine(): TemplateEngine
|
||||
{
|
||||
$template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
|
||||
|
||||
|
@ -185,7 +187,7 @@ class Renderer
|
|||
*
|
||||
* @return string the active template engine
|
||||
*/
|
||||
public static function getActiveTemplateEngine()
|
||||
public static function getActiveTemplateEngine(): string
|
||||
{
|
||||
return self::$theme['template_engine'];
|
||||
}
|
||||
|
@ -194,8 +196,10 @@ class Renderer
|
|||
* sets the active template engine
|
||||
*
|
||||
* @param string $engine the template engine (default is Smarty3)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setActiveTemplateEngine($engine = 'smarty3')
|
||||
public static function setActiveTemplateEngine(string $engine = 'smarty3')
|
||||
{
|
||||
self::$theme['template_engine'] = $engine;
|
||||
}
|
||||
|
@ -211,7 +215,7 @@ class Renderer
|
|||
*
|
||||
* @return string the right delimiter
|
||||
*/
|
||||
public static function getTemplateLeftDelimiter($engine = 'smarty3')
|
||||
public static function getTemplateLeftDelimiter(string $engine = 'smarty3'): string
|
||||
{
|
||||
return self::$ldelim[$engine];
|
||||
}
|
||||
|
@ -227,7 +231,7 @@ class Renderer
|
|||
*
|
||||
* @return string the left delimiter
|
||||
*/
|
||||
public static function getTemplateRightDelimiter($engine = 'smarty3')
|
||||
public static function getTemplateRightDelimiter(string $engine = 'smarty3'): string
|
||||
{
|
||||
return self::$rdelim[$engine];
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ class PostUpdate
|
|||
$items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity`
|
||||
FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
|
||||
LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id` AND `item`.`gravity` = ?
|
||||
WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", GRAVITY_ACTIVITY, $id);
|
||||
WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", Item::GRAVITY_ACTIVITY, $id);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Factory\Api\Friendica;
|
|||
|
||||
use Friendica\BaseFactory;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -62,7 +63,7 @@ class Activities extends BaseFactory
|
|||
'announce' => [],
|
||||
];
|
||||
|
||||
$condition = ['uid' => $uid, 'thr-parent-id' => $uriId, 'gravity' => GRAVITY_ACTIVITY];
|
||||
$condition = ['uid' => $uid, 'thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_ACTIVITY];
|
||||
|
||||
$ret = Post::selectForUser($uid, ['author-id', 'verb'], $condition);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App\BaseURL;
|
|||
use Friendica\BaseFactory;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Factory\Api\Twitter\Status;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo as ModelPhoto;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -116,7 +117,7 @@ class Photo extends BaseFactory
|
|||
|
||||
// retrieve comments on photo
|
||||
$condition = ["`parent` = ? AND `uid` = ? AND `gravity` IN (?, ?)",
|
||||
$item['parent'], $uid, GRAVITY_PARENT, GRAVITY_COMMENT];
|
||||
$item['parent'], $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT];
|
||||
|
||||
$statuses = Post::selectForUser($uid, [], $condition);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Factory\Api\Mastodon;
|
|||
use Friendica\BaseFactory;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemURI;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -69,7 +70,7 @@ class ScheduledStatus extends BaseFactory
|
|||
$media_attachments[] = DI::mstdnAttachment()->createFromPhoto($id);
|
||||
}
|
||||
|
||||
if (isset($parameters['item']['thr-parent']) && ($parameters['item']['gravity'] ?? GRAVITY_PARENT != GRAVITY_PARENT)) {
|
||||
if (isset($parameters['item']['thr-parent']) && ($parameters['item']['gravity'] ?? Item::GRAVITY_PARENT != Item::GRAVITY_PARENT)) {
|
||||
$in_reply_to_id = ItemURI::getIdByURI($parameters['item']['thr-parent']);
|
||||
} else {
|
||||
$in_reply_to_id = null;
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Content\ContactSelector;
|
|||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag as TagModel;
|
||||
use Friendica\Model\Verb;
|
||||
|
@ -94,19 +95,19 @@ class Status extends BaseFactory
|
|||
|
||||
$count_announce = Post::countPosts([
|
||||
'thr-parent-id' => $uriId,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'vid' => Verb::getID(Activity::ANNOUNCE),
|
||||
'deleted' => false
|
||||
], []);
|
||||
$count_like = Post::countPosts([
|
||||
'thr-parent-id' => $uriId,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'vid' => Verb::getID(Activity::LIKE),
|
||||
'deleted' => false
|
||||
], []);
|
||||
|
||||
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
|
||||
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => GRAVITY_COMMENT, 'deleted' => false], []),
|
||||
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false], []),
|
||||
$count_announce,
|
||||
$count_like
|
||||
);
|
||||
|
@ -115,7 +116,7 @@ class Status extends BaseFactory
|
|||
'thr-parent-id' => $uriId,
|
||||
'uid' => $uid,
|
||||
'origin' => true,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'vid' => Verb::getID(Activity::LIKE),
|
||||
'deleted' => false
|
||||
]);
|
||||
|
@ -123,7 +124,7 @@ class Status extends BaseFactory
|
|||
'thr-parent-id' => $uriId,
|
||||
'uid' => $uid,
|
||||
'origin' => true,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'vid' => Verb::getID(Activity::ANNOUNCE),
|
||||
'deleted' => false
|
||||
]);
|
||||
|
@ -131,7 +132,7 @@ class Status extends BaseFactory
|
|||
$origin_like,
|
||||
$origin_announce,
|
||||
Post\ThreadUser::getIgnored($uriId, $uid),
|
||||
(bool)($item['starred'] && ($item['gravity'] == GRAVITY_PARENT)),
|
||||
(bool)($item['starred'] && ($item['gravity'] == Item::GRAVITY_PARENT)),
|
||||
$item['featured']
|
||||
);
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class Status extends BaseFactory
|
|||
$owner = $this->twitterUser->createFromContactId($item['owner-id'], $uid, true);
|
||||
}
|
||||
|
||||
$friendica_comments = Post::countPosts(['thr-parent-id' => $item['uri-id'], 'deleted' => false, 'gravity' => GRAVITY_COMMENT]);
|
||||
$friendica_comments = Post::countPosts(['thr-parent-id' => $item['uri-id'], 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
||||
|
||||
$text = '';
|
||||
$title = '';
|
||||
|
@ -162,7 +162,7 @@ class Status extends BaseFactory
|
|||
'thr-parent-id' => $item['uri-id'],
|
||||
'uid' => $uid,
|
||||
'origin' => true,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'vid' => Verb::getID(Activity::LIKE),
|
||||
'deleted' => false
|
||||
]);
|
||||
|
|
|
@ -69,7 +69,7 @@ class User extends BaseFactory
|
|||
|
||||
if (!$skip_status) {
|
||||
$post = Post::selectFirstPost(['uri-id'],
|
||||
['author-id' => $publicContact['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]],
|
||||
['author-id' => $publicContact['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]],
|
||||
['order' => ['uri-id' => true]]);
|
||||
if (!empty($post['uri-id'])) {
|
||||
$status = $this->status->createFromUriId($post['uri-id'], $uid)->toArray();
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe;
|
||||
|
@ -495,13 +496,13 @@ class APContact
|
|||
private static function getStatusesCount(array $owner): int
|
||||
{
|
||||
$condition = [
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'author-id' => Contact::getIdForURL($owner['url'], 0, false),
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
'network' => Protocol::DFRN,
|
||||
'parent-network' => Protocol::FEDERATED,
|
||||
'deleted' => false,
|
||||
'visible' => true
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
$count = Post::countPosts($condition);
|
||||
|
|
|
@ -1506,10 +1506,10 @@ class Contact
|
|||
|
||||
if ($thread_mode) {
|
||||
$condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
|
||||
$cid, GRAVITY_PARENT, $cid, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()];
|
||||
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()];
|
||||
} else {
|
||||
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
|
||||
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
|
||||
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, local_user()];
|
||||
}
|
||||
|
||||
if (!empty($parent)) {
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -105,27 +106,27 @@ class FContact
|
|||
|
||||
$interacted = DBA::count('contact-relation', ["`cid` = ? AND NOT `follows` AND `last-interaction` > ?", $contact['id'], $last_interaction]);
|
||||
$interacting = DBA::count('contact-relation', ["`relation-cid` = ? AND NOT `follows` AND `last-interaction` > ?", $contact['id'], $last_interaction]);
|
||||
$posts = DBA::count('post', ['author-id' => $contact['id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
|
||||
$posts = DBA::count('post', ['author-id' => $contact['id'], 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]]);
|
||||
}
|
||||
|
||||
$fields = [
|
||||
'name' => $arr['name'],
|
||||
'photo' => $arr['photo'],
|
||||
'request' => $arr['request'],
|
||||
'nick' => $arr['nick'],
|
||||
'addr' => strtolower($arr['addr']),
|
||||
'guid' => $arr['guid'],
|
||||
'batch' => $arr['batch'],
|
||||
'notify' => $arr['notify'],
|
||||
'poll' => $arr['poll'],
|
||||
'confirm' => $arr['confirm'],
|
||||
'alias' => $arr['alias'],
|
||||
'pubkey' => $arr['pubkey'],
|
||||
'uri-id' => $uriid,
|
||||
'name' => $arr['name'],
|
||||
'photo' => $arr['photo'],
|
||||
'request' => $arr['request'],
|
||||
'nick' => $arr['nick'],
|
||||
'addr' => strtolower($arr['addr']),
|
||||
'guid' => $arr['guid'],
|
||||
'batch' => $arr['batch'],
|
||||
'notify' => $arr['notify'],
|
||||
'poll' => $arr['poll'],
|
||||
'confirm' => $arr['confirm'],
|
||||
'alias' => $arr['alias'],
|
||||
'pubkey' => $arr['pubkey'],
|
||||
'uri-id' => $uriid,
|
||||
'interacting_count' => $interacting ?? 0,
|
||||
'interacted_count' => $interacted ?? 0,
|
||||
'post_count' => $posts ?? 0,
|
||||
'updated' => DateTimeFormat::utcNow(),
|
||||
'interacted_count' => $interacted ?? 0,
|
||||
'post_count' => $posts ?? 0,
|
||||
'updated' => DateTimeFormat::utcNow(),
|
||||
];
|
||||
|
||||
if (empty($fcontact['created'])) {
|
||||
|
|
|
@ -146,6 +146,12 @@ class Item
|
|||
const PRIVATE = 1;
|
||||
const UNLISTED = 2;
|
||||
|
||||
// Item weight for query ordering
|
||||
const GRAVITY_PARENT = 0;
|
||||
const GRAVITY_ACTIVITY = 3;
|
||||
const GRAVITY_COMMENT = 6;
|
||||
const GRAVITY_UNKNOWN = 9;
|
||||
|
||||
/**
|
||||
* Update existing item entries
|
||||
*
|
||||
|
@ -356,7 +362,7 @@ class Item
|
|||
Post\DeliveryData::delete($item['uri-id']);
|
||||
|
||||
// If it's the parent of a comment thread, kill all the kids
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
|
||||
}
|
||||
|
||||
|
@ -463,7 +469,7 @@ class Item
|
|||
}
|
||||
}
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
if (Contact::isSharingByURL($item['owner-link'], $item['uid'], true)) {
|
||||
$contact_id = Contact::getIdForURL($item['owner-link'], $item['uid']);
|
||||
} else {
|
||||
|
@ -714,7 +720,7 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($thread_parent['gravity'] == GRAVITY_PARENT) {
|
||||
if ($thread_parent['gravity'] == Item::GRAVITY_PARENT) {
|
||||
return $uriid;
|
||||
}
|
||||
|
||||
|
@ -791,17 +797,17 @@ class Item
|
|||
if (isset($item['gravity'])) {
|
||||
return intval($item['gravity']);
|
||||
} elseif ($item['parent-uri-id'] === $item['uri-id']) {
|
||||
return GRAVITY_PARENT;
|
||||
return self::GRAVITY_PARENT;
|
||||
} elseif ($activity->match($item['verb'], Activity::POST)) {
|
||||
return GRAVITY_COMMENT;
|
||||
return self::GRAVITY_COMMENT;
|
||||
} elseif ($activity->match($item['verb'], Activity::FOLLOW)) {
|
||||
return GRAVITY_ACTIVITY;
|
||||
return self::GRAVITY_ACTIVITY;
|
||||
} elseif ($activity->match($item['verb'], Activity::ANNOUNCE)) {
|
||||
return GRAVITY_ACTIVITY;
|
||||
return self::GRAVITY_ACTIVITY;
|
||||
}
|
||||
|
||||
Logger::info('Unknown gravity for verb', ['verb' => $item['verb']]);
|
||||
return GRAVITY_UNKNOWN; // Should not happen
|
||||
return self::GRAVITY_UNKNOWN; // Should not happen
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -965,7 +971,7 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($item['gravity'] !== GRAVITY_PARENT) {
|
||||
if ($item['gravity'] !== self::GRAVITY_PARENT) {
|
||||
$toplevel_parent = self::getTopLevelParent($item);
|
||||
if (empty($toplevel_parent)) {
|
||||
return 0;
|
||||
|
@ -1178,7 +1184,7 @@ class Item
|
|||
|
||||
Post::insert($item['uri-id'], $item);
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
Post\Thread::insert($item['uri-id'], $item);
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1193,7 @@ class Item
|
|||
}
|
||||
|
||||
// Create Diaspora signature
|
||||
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) {
|
||||
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != self::GRAVITY_PARENT)) {
|
||||
$signed = Diaspora::createCommentSignature($item);
|
||||
if (!empty($signed)) {
|
||||
$item['diaspora_signed_text'] = json_encode($signed);
|
||||
|
@ -1227,7 +1233,7 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
$item['post-user-id'] = $post_user_id;
|
||||
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
|
||||
}
|
||||
|
@ -1245,7 +1251,7 @@ class Item
|
|||
// update the commented timestamp on the parent
|
||||
if (DI::config()->get('system', 'like_no_comment')) {
|
||||
// Update when it is a comment
|
||||
$update_commented = in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]);
|
||||
$update_commented = in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]);
|
||||
} else {
|
||||
// Update when it isn't a follow or tag verb
|
||||
$update_commented = !in_array($posted_item['verb'], [Activity::FOLLOW, Activity::TAG]);
|
||||
|
@ -1269,7 +1275,7 @@ class Item
|
|||
}
|
||||
|
||||
if ($notify) {
|
||||
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) {
|
||||
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == self::GRAVITY_COMMENT)) {
|
||||
Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']);
|
||||
}
|
||||
Hook::callAll('post_local_end', $posted_item);
|
||||
|
@ -1277,7 +1283,7 @@ class Item
|
|||
Hook::callAll('post_remote_end', $posted_item);
|
||||
}
|
||||
|
||||
if ($posted_item['gravity'] === GRAVITY_PARENT) {
|
||||
if ($posted_item['gravity'] === self::GRAVITY_PARENT) {
|
||||
self::addShadow($post_user_id);
|
||||
} else {
|
||||
self::addShadowPost($post_user_id);
|
||||
|
@ -1312,7 +1318,7 @@ class Item
|
|||
}
|
||||
|
||||
// Fill the cache with the rendered content.
|
||||
if (in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) && ($posted_item['uid'] == 0)) {
|
||||
if (in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]) && ($posted_item['uid'] == 0)) {
|
||||
self::updateDisplayCache($posted_item['uri-id']);
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1334,7 @@ class Item
|
|||
*/
|
||||
public static function getPostReason(array $item): int
|
||||
{
|
||||
$actor = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
$actor = ($item['gravity'] == self::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
if (empty($item['origin']) && ($item['uid'] != 0) && Contact::isSharing($actor, $item['uid'])) {
|
||||
return self::PR_FOLLOWER;
|
||||
}
|
||||
|
@ -1409,7 +1415,7 @@ class Item
|
|||
*/
|
||||
private static function distributeByTags(array $item)
|
||||
{
|
||||
if (($item['uid'] != 0) || ($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], Protocol::FEDERATED)) {
|
||||
if (($item['uid'] != 0) || ($item['gravity'] != self::GRAVITY_PARENT) || !in_array($item['network'], Protocol::FEDERATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1535,7 +1541,7 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (($uid != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
|
||||
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 forum but is not mentioned here, thread will not be stored', ['uid' => $uid, 'uri-id' => $uri_id]);
|
||||
|
@ -1552,13 +1558,13 @@ class Item
|
|||
|
||||
$item = array_merge($item, $fields);
|
||||
|
||||
if (($uid != 0) && Contact::isSharing(($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'], $uid)) {
|
||||
if (($uid != 0) && Contact::isSharing(($item['gravity'] == Item::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'], $uid)) {
|
||||
$item['post-reason'] = self::PR_FOLLOWER;
|
||||
}
|
||||
|
||||
$is_reshare = ($item['gravity'] == GRAVITY_ACTIVITY) && ($item['verb'] == Activity::ANNOUNCE);
|
||||
$is_reshare = ($item['gravity'] == self::GRAVITY_ACTIVITY) && ($item['verb'] == Activity::ANNOUNCE);
|
||||
|
||||
if (($uid != 0) && (($item['gravity'] == GRAVITY_PARENT) || $is_reshare) &&
|
||||
if (($uid != 0) && (($item['gravity'] == self::GRAVITY_PARENT) || $is_reshare) &&
|
||||
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])) {
|
||||
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']]);
|
||||
|
@ -1567,7 +1573,7 @@ class Item
|
|||
|
||||
$causer = $item['causer-id'] ?: $item['author-id'];
|
||||
|
||||
if (($uri_id != $item['parent-uri-id']) && ($item['gravity'] == GRAVITY_COMMENT) && !Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) {
|
||||
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]);
|
||||
return 0;
|
||||
|
@ -1708,7 +1714,7 @@ class Item
|
|||
$item['contact-id'] = self::contactId($item);
|
||||
|
||||
$notify = false;
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
|
||||
if (DBA::isResult($contact)) {
|
||||
$notify = self::isRemoteSelf($contact, $item);
|
||||
|
@ -1738,7 +1744,7 @@ class Item
|
|||
private static function addShadow(int $itemid)
|
||||
{
|
||||
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
|
||||
$condition = ['id' => $itemid, 'gravity' => GRAVITY_PARENT];
|
||||
$condition = ['id' => $itemid, 'gravity' => self::GRAVITY_PARENT];
|
||||
$item = Post::selectFirst($fields, $condition);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
|
@ -1806,7 +1812,7 @@ class Item
|
|||
}
|
||||
|
||||
// Is it a toplevel post?
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
self::addShadow($itemid);
|
||||
return;
|
||||
}
|
||||
|
@ -1868,7 +1874,7 @@ class Item
|
|||
return $item['language'];
|
||||
}
|
||||
|
||||
if (!in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) || empty($item['body'])) {
|
||||
if (!in_array($item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]) || empty($item['body'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -2148,13 +2154,13 @@ class Item
|
|||
return false;
|
||||
}
|
||||
|
||||
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'origin' => 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]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
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']]);
|
||||
} else {
|
||||
|
@ -2199,7 +2205,7 @@ class Item
|
|||
*/
|
||||
private static function autoReshare(array $item)
|
||||
{
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != self::GRAVITY_PARENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2460,7 +2466,7 @@ class Item
|
|||
}
|
||||
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
|
||||
$uid, GRAVITY_PARENT];
|
||||
$uid, self::GRAVITY_PARENT];
|
||||
|
||||
/*
|
||||
* $expire_network_only = save your own wall posts
|
||||
|
@ -2667,7 +2673,7 @@ class Item
|
|||
$vids = Verb::getID($activity);
|
||||
}
|
||||
|
||||
$condition = ['vid' => $vids, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY,
|
||||
$condition = ['vid' => $vids, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'author-id' => $author_id, 'uid' => $item['uid'], 'thr-parent-id' => $uri_id];
|
||||
$like_item = Post::selectFirst(['id', 'guid', 'verb'], $condition);
|
||||
|
||||
|
@ -2721,7 +2727,7 @@ class Item
|
|||
'network' => Protocol::DFRN,
|
||||
'protocol' => Conversation::PARCEL_DIRECT,
|
||||
'direction' => Conversation::PUSH,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'parent' => $item['id'],
|
||||
'thr-parent' => $item['uri'],
|
||||
'owner-id' => $author_id,
|
||||
|
@ -2846,9 +2852,9 @@ class Item
|
|||
return $l10n->t('event');
|
||||
} elseif (!empty($item['resource-id'])) {
|
||||
return $l10n->t('photo');
|
||||
} elseif ($item['gravity'] == GRAVITY_ACTIVITY) {
|
||||
} elseif ($item['gravity'] == self::GRAVITY_ACTIVITY) {
|
||||
return $l10n->t('activity');
|
||||
} elseif ($item['gravity'] == GRAVITY_COMMENT) {
|
||||
} elseif ($item['gravity'] == self::GRAVITY_COMMENT) {
|
||||
return $l10n->t('comment');
|
||||
}
|
||||
|
||||
|
@ -3593,7 +3599,7 @@ class Item
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!empty($item['causer-id']) && ($item['gravity'] === GRAVITY_PARENT) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
|
||||
if (!empty($item['causer-id']) && ($item['gravity'] === self::GRAVITY_PARENT) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
|
||||
Logger::notice('Causer is ignored by user', ['causer-link' => $item['causer-link'] ?? $item['causer-id'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
|
@ -62,8 +63,8 @@ class Nodeinfo
|
|||
$logger->info('user statistics', $userStats);
|
||||
|
||||
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
|
||||
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", GRAVITY_COMMENT]);
|
||||
$config->set('nodeinfo', 'local_posts', $posts);
|
||||
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", Item::GRAVITY_COMMENT]);
|
||||
$config->set('nodeinfo', 'local_posts', $posts);
|
||||
$config->set('nodeinfo', 'local_comments', $comments);
|
||||
|
||||
$logger->info('User actitivy', ['posts' => $posts, 'comments' => $comments]);
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Database\Database;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
||||
class Post
|
||||
|
@ -405,7 +406,7 @@ class Post
|
|||
AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked`)
|
||||
AND NOT (`gravity` = ? AND `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored`))
|
||||
AND NOT (`gravity` = ? AND `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored`))",
|
||||
0, Contact::SHARING, Contact::FRIEND, GRAVITY_PARENT, 0, $uid, $uid, $uid, GRAVITY_PARENT, $uid, GRAVITY_PARENT, $uid]);
|
||||
0, Contact::SHARING, Contact::FRIEND, Item::GRAVITY_PARENT, 0, $uid, $uid, $uid, Item::GRAVITY_PARENT, $uid, Item::GRAVITY_PARENT, $uid]);
|
||||
|
||||
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
|
||||
|
||||
|
@ -520,7 +521,7 @@ class Post
|
|||
unset($fields['parent-uri']);
|
||||
unset($fields['parent-uri-id']);
|
||||
|
||||
$thread_condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$thread_condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
|
||||
// To ensure the data integrity we do it in an transaction
|
||||
DBA::transaction();
|
||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Subscription;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -288,7 +289,7 @@ class UserNotification
|
|||
}
|
||||
|
||||
// Only create notifications for posts and comments, not for activities
|
||||
if (($item['gravity'] == GRAVITY_ACTIVITY) && ($item['verb'] != Activity::ANNOUNCE)) {
|
||||
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($item['verb'] != Activity::ANNOUNCE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,7 +311,7 @@ class UserNotification
|
|||
*/
|
||||
private static function insertNotificationByItem(int $type, int $uid, array $item): void
|
||||
{
|
||||
if (($item['verb'] != Activity::ANNOUNCE) && ($item['gravity'] == GRAVITY_ACTIVITY) &&
|
||||
if (($item['verb'] != Activity::ANNOUNCE) && ($item['gravity'] == Item::GRAVITY_ACTIVITY) &&
|
||||
!in_array($type, [self::TYPE_DIRECT_COMMENT, self::TYPE_DIRECT_THREAD_COMMENT])) {
|
||||
// Activities are only stored when performed on the user's post or comment
|
||||
return;
|
||||
|
@ -321,7 +322,7 @@ class UserNotification
|
|||
$item['vid'],
|
||||
$type,
|
||||
$item['author-id'],
|
||||
$item['gravity'] == GRAVITY_ACTIVITY ? $item['thr-parent-id'] : $item['uri-id'],
|
||||
$item['gravity'] == Item::GRAVITY_ACTIVITY ? $item['thr-parent-id'] : $item['uri-id'],
|
||||
$item['parent-uri-id']
|
||||
);
|
||||
|
||||
|
@ -423,14 +424,14 @@ class UserNotification
|
|||
private static function checkShared(array $item, int $uid): bool
|
||||
{
|
||||
// Only check on original posts and reshare ("announce") activities, otherwise return
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && ($item['verb'] != Activity::ANNOUNCE)) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['verb'] != Activity::ANNOUNCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't notify about reshares by communities of our own posts or each time someone comments
|
||||
if (($item['verb'] == Activity::ANNOUNCE) && DBA::exists('contact', ['id' => $item['contact-id'], 'contact-type' => Contact::TYPE_COMMUNITY])) {
|
||||
$post = Post::selectFirst(['origin', 'gravity'], ['uri-id' => $item['thr-parent-id'], 'uid' => $uid]);
|
||||
if ($post['origin'] || ($post['gravity'] != GRAVITY_PARENT)) {
|
||||
if ($post['origin'] || ($post['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +498,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkCommentedThread(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_PARENT];
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_PARENT];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
|
||||
|
@ -511,7 +512,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkDirectComment(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_COMMENT];
|
||||
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
|
||||
|
@ -525,7 +526,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkDirectCommentedThread(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_PARENT];
|
||||
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_PARENT];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
|
||||
|
@ -539,7 +540,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkCommentedParticipation(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_COMMENT];
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
|
||||
|
@ -553,7 +554,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkFollowParticipation(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::FOLLOW];
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::FOLLOW];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
|
||||
|
@ -567,7 +568,7 @@ class UserNotification
|
|||
*/
|
||||
private static function checkActivityParticipation(array $item, array $contacts): bool
|
||||
{
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY];
|
||||
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_ACTIVITY];
|
||||
return Post::exists($condition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ class Objects extends BaseModule
|
|||
$last_modified = $item['changed'];
|
||||
Network::checkEtagModified($etag, $last_modified);
|
||||
|
||||
if (empty($this->parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
|
||||
if (empty($this->parameters['activity']) && ($item['gravity'] != Item::GRAVITY_ACTIVITY)) {
|
||||
$activity = ActivityPub\Transmitter::createCachedActivityFromItem($item['id'], false, true);
|
||||
if (empty($activity['type'])) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
|
@ -69,7 +70,7 @@ class Conversation extends BaseApi
|
|||
$id = $parent['id'];
|
||||
|
||||
$condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `uri-id` > ?",
|
||||
$id, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
$id, $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `uri-id` <= ?";
|
||||
|
|
|
@ -78,7 +78,7 @@ class Statuses extends BaseApi
|
|||
|
||||
if (!$request['pinned']) {
|
||||
$condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ?))",
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]);
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]);
|
||||
}
|
||||
|
||||
if ($request['only_media']) {
|
||||
|
@ -100,7 +100,7 @@ class Statuses extends BaseApi
|
|||
}
|
||||
|
||||
if ($request['exclude_replies']) {
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
if ($request['pinned']) {
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -51,7 +52,7 @@ class Favourited extends BaseApi
|
|||
|
||||
$params = ['order' => ['thr-parent-id' => true], 'limit' => $request['limit']];
|
||||
|
||||
$condition = ['gravity' => GRAVITY_ACTIVITY, 'origin' => true, 'verb' => Activity::LIKE, 'uid' => $uid];
|
||||
$condition = ['gravity' => Item::GRAVITY_ACTIVITY, 'origin' => true, 'verb' => Activity::LIKE, 'uid' => $uid];
|
||||
|
||||
if (!empty($request['max_id'])) {
|
||||
$condition = DBA::mergeConditions($condition, ["`thr-parent-id` < ?", $request['max_id']]);
|
||||
|
|
|
@ -151,13 +151,13 @@ class Statuses extends BaseApi
|
|||
$parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_id'], 'uid' => [0, $uid]]);
|
||||
|
||||
$item['thr-parent'] = $parent['uri'];
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
|
||||
} else {
|
||||
self::checkThrottleLimit();
|
||||
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
$item['title'] = $request['spoiler_text'];
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class Bookmark extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
|
@ -55,7 +56,7 @@ class Context extends BaseApi
|
|||
$parent = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$posts = Post::selectPosts(['uri-id', 'thr-parent-id'],
|
||||
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
|
||||
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]]);
|
||||
while ($post = Post::fetch($posts)) {
|
||||
if ($post['uri-id'] == $post['thr-parent-id']) {
|
||||
continue;
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
|
|||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -48,7 +49,7 @@ class FavouritedBy extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::LIKE]);
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE]);
|
||||
|
||||
$accounts = [];
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
|
@ -46,7 +47,7 @@ class Mute extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
|
|||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -48,7 +49,7 @@ class RebloggedBy extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
|
||||
|
||||
$accounts = [];
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class Unbookmark extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
|
@ -46,7 +47,7 @@ class Unmute extends BaseApi
|
|||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Timelines;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -55,7 +56,7 @@ class Home extends BaseApi
|
|||
|
||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||
|
||||
$condition = ['gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'uid' => $uid];
|
||||
$condition = ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'uid' => $uid];
|
||||
|
||||
if ($request['local']) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
||||
|
@ -85,7 +86,7 @@ class Home extends BaseApi
|
|||
}
|
||||
|
||||
if ($request['exclude_replies']) {
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Timelines;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -60,7 +61,7 @@ class ListTimeline extends BaseApi
|
|||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)",
|
||||
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $this->parameters['id']];
|
||||
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $this->parameters['id']];
|
||||
|
||||
if (!empty($request['max_id'])) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);
|
||||
|
@ -82,7 +83,7 @@ class ListTimeline extends BaseApi
|
|||
}
|
||||
|
||||
if ($request['exclude_replies']) {
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
if ($request['local']) {
|
||||
|
|
|
@ -57,7 +57,7 @@ class PublicTimeline extends BaseApi
|
|||
|
||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||
|
||||
$condition = ['gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => Item::PUBLIC,
|
||||
$condition = ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'private' => Item::PUBLIC,
|
||||
'network' => Protocol::FEDERATED, 'parent-author-blocked' => false, 'parent-author-hidden' => false];
|
||||
|
||||
if ($request['local']) {
|
||||
|
@ -87,7 +87,7 @@ class PublicTimeline extends BaseApi
|
|||
}
|
||||
|
||||
if ($request['exclude_replies']) {
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
if (!empty($uid)) {
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -85,7 +86,7 @@ class Tag extends BaseApi
|
|||
}
|
||||
|
||||
if ($request['exclude_replies']) {
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
if (!empty($request['max_id'])) {
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter;
|
|||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -54,7 +55,7 @@ class Favorites extends BaseApi
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ? AND `starred`",
|
||||
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
|
||||
|
||||
$params = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];
|
||||
|
||||
|
|
|
@ -26,10 +26,11 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Factory\Api\Twitter\Status as TwitterStatus;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -77,7 +78,7 @@ class Statuses extends BaseApi
|
|||
|
||||
$groups = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
@ -86,7 +87,7 @@ class Statuses extends BaseApi
|
|||
}
|
||||
if ($exclude_replies) {
|
||||
$condition[0] .= ' AND `gravity` = ?';
|
||||
$condition[] = GRAVITY_PARENT;
|
||||
$condition[] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
if ($conversation_id > 0) {
|
||||
$condition[0] .= " AND `parent-uri-id` = ?";
|
||||
|
|
|
@ -78,13 +78,13 @@ class Tweets extends BaseApi
|
|||
|
||||
$condition = ['uri-id' => $uriids];
|
||||
if ($exclude_replies) {
|
||||
$condition['gravity'] = GRAVITY_PARENT;
|
||||
$condition['gravity'] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
|
||||
$params['group_by'] = ['uri-id'];
|
||||
} else {
|
||||
$condition = ["`uri-id` > ?
|
||||
" . ($exclude_replies ? " AND `gravity` = " . GRAVITY_PARENT : ' ') . "
|
||||
" . ($exclude_replies ? " AND `gravity` = " . Item::GRAVITY_PARENT : ' ') . "
|
||||
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
|
||||
AND `body` LIKE CONCAT('%',?,'%')",
|
||||
$since_id, $uid, $_REQUEST['q']];
|
||||
|
|
|
@ -54,7 +54,7 @@ class HomeTimeline extends BaseApi
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ?",
|
||||
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
|
||||
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `uri-id` <= ?";
|
||||
|
@ -62,7 +62,7 @@ class HomeTimeline extends BaseApi
|
|||
}
|
||||
if ($exclude_replies) {
|
||||
$condition[0] .= ' AND `gravity` = ?';
|
||||
$condition[] = GRAVITY_PARENT;
|
||||
$condition[] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
if ($conversation_id > 0) {
|
||||
$condition[0] .= " AND `parent-uri-id` = ?";
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Twitter\Statuses;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Post;
|
||||
|
||||
|
@ -55,7 +56,7 @@ class Mentions extends BaseApi
|
|||
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `uri-id` > ?";
|
||||
|
||||
$condition = [
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT,
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
||||
$uid,
|
||||
Post\UserNotification::TYPE_EXPLICIT_TAGGED | Post\UserNotification::TYPE_IMPLICIT_TAGGED |
|
||||
Post\UserNotification::TYPE_THREAD_COMMENT | Post\UserNotification::TYPE_DIRECT_COMMENT |
|
||||
|
|
|
@ -47,7 +47,7 @@ class NetworkPublicTimeline extends BaseApi
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ?",
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, Item::PUBLIC];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `uri-id` <= ?";
|
||||
|
|
|
@ -53,7 +53,7 @@ class PublicTimeline extends BaseApi
|
|||
|
||||
if ($exclude_replies && !$conversation_id) {
|
||||
$condition = ["`gravity` = ? AND `uri-id` > ? AND `private` = ? AND `wall` AND NOT `author-hidden`",
|
||||
GRAVITY_PARENT, $since_id, Item::PUBLIC];
|
||||
Item::GRAVITY_PARENT, $since_id, Item::PUBLIC];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `uri-id` <= ?";
|
||||
|
@ -64,7 +64,7 @@ class PublicTimeline extends BaseApi
|
|||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
} else {
|
||||
$condition = ["`gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ? AND `wall` AND `origin` AND NOT `author-hidden`",
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, Item::PUBLIC];
|
||||
|
||||
if ($max_id > 0) {
|
||||
$condition[0] .= " AND `uri-id` <= ?";
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
|
@ -60,10 +61,10 @@ class Show extends BaseApi
|
|||
$item_id = $item['id'];
|
||||
|
||||
if ($conversation) {
|
||||
$condition = ['parent' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||
$condition = ['parent' => $item_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]];
|
||||
$params = ['order' => ['uri-id' => true]];
|
||||
} else {
|
||||
$condition = ['id' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||
$condition = ['id' => $item_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]];
|
||||
$params = [];
|
||||
}
|
||||
|
||||
|
|
|
@ -113,12 +113,12 @@ class Update extends BaseApi
|
|||
$parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_status_id'], 'uid' => [0, $uid]]);
|
||||
|
||||
$item['thr-parent'] = $parent['uri'];
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
} else {
|
||||
self::checkThrottleLimit();
|
||||
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@ namespace Friendica\Module\Api\Twitter\Statuses;
|
|||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
* Returns the most recent statuses posted by the user.
|
||||
|
@ -54,11 +55,11 @@ class UserTimeline extends BaseApi
|
|||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`)) AND `gravity` IN (?, ?) AND `uri-id` > ? AND `author-id` = ?",
|
||||
0, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $cid];
|
||||
0, $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, $cid];
|
||||
|
||||
if ($exclude_replies) {
|
||||
$condition[0] .= ' AND `gravity` = ?';
|
||||
$condition[] = GRAVITY_PARENT;
|
||||
$condition[] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
|
||||
if ($conversation_id > 0) {
|
||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
|
@ -233,7 +234,7 @@ class BaseApi extends BaseModule
|
|||
if ($throttle_day > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_day = Post::countThread($condition);
|
||||
|
||||
if ($posts_day > $throttle_day) {
|
||||
|
@ -249,7 +250,7 @@ class BaseApi extends BaseModule
|
|||
if ($throttle_week > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_week = Post::countThread($condition);
|
||||
|
||||
if ($posts_week > $throttle_week) {
|
||||
|
@ -265,7 +266,7 @@ class BaseApi extends BaseModule
|
|||
if ($throttle_month > 0) {
|
||||
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
|
||||
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
|
||||
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
|
||||
$posts_month = Post::countThread($condition);
|
||||
|
||||
if ($posts_month > $throttle_month) {
|
||||
|
|
|
@ -414,7 +414,7 @@ class Network extends BaseModule
|
|||
} elseif (self::$forumContactId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings,
|
||||
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
|
||||
self::$forumContactId, self::$forumContactId, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
|
||||
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
|
||||
}
|
||||
|
||||
// Currently only the order modes "received" and "commented" are in use
|
||||
|
|
|
@ -49,7 +49,7 @@ class Fetch extends BaseModule
|
|||
|
||||
// Fetch the item
|
||||
$condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid,
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$item = Post::selectFirst([], $condition);
|
||||
if (empty($item)) {
|
||||
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
|
@ -76,7 +76,7 @@ class Fetch extends BaseModule
|
|||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$status = Diaspora::buildStatus($item, $user);
|
||||
} else {
|
||||
$status = ['type' => 'comment', 'message' => Diaspora::createCommentSignature($item)];
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
|
@ -49,7 +50,7 @@ class Ignore extends BaseModule
|
|||
|
||||
$dba = DI::dba();
|
||||
|
||||
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => GRAVITY_PARENT]);
|
||||
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => Item::GRAVITY_PARENT]);
|
||||
if (!$dba->isResult($thread)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ class Status extends BaseProfile
|
|||
$condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR
|
||||
(`gravity` = ? AND `vid` = ? AND `origin`
|
||||
AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? AND `network` = ?)))",
|
||||
GRAVITY_PARENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), GRAVITY_PARENT, Protocol::ACTIVITYPUB]);
|
||||
GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB]);
|
||||
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
|
||||
'visible' => true, 'deleted' => false]);
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Update;
|
|||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\Conversation\Network as NetworkModule;
|
||||
|
||||
|
@ -55,7 +56,7 @@ class Network extends NetworkModule
|
|||
} elseif (self::$order === 'received') {
|
||||
// Only load new toplevel posts
|
||||
$conditionFields['unseen'] = true;
|
||||
$conditionFields['gravity'] = GRAVITY_PARENT;
|
||||
$conditionFields['gravity'] = Item::GRAVITY_PARENT;
|
||||
} else {
|
||||
// Load all unseen items
|
||||
$conditionFields['unseen'] = true;
|
||||
|
|
|
@ -72,7 +72,7 @@ class Profile extends BaseModule
|
|||
|
||||
$condition = ["`uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
|
||||
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
|
||||
AND `wall` " . $sql_extra, $a->getProfileOwner(), GRAVITY_ACTIVITY];
|
||||
AND `wall` " . $sql_extra, $a->getProfileOwner(), Item::GRAVITY_ACTIVITY];
|
||||
|
||||
if ($_GET['force'] && !empty($_GET['item'])) {
|
||||
// When the parent is provided, we only fetch this
|
||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\BaseNotifications;
|
||||
use Friendica\Navigation\Notifications\Collection\FormattedNotifies;
|
||||
|
@ -363,13 +364,13 @@ class FormattedNotify extends BaseFactory
|
|||
$item['author-avatar'] = $item['contact-avatar'];
|
||||
}
|
||||
|
||||
$item['label'] = (($item['gravity'] == GRAVITY_PARENT) ? 'post' : 'comment');
|
||||
$item['label'] = (($item['gravity'] == Item::GRAVITY_PARENT) ? 'post' : 'comment');
|
||||
$item['link'] = $this->baseUrl->get(true) . '/display/' . $item['parent-guid'];
|
||||
$item['image'] = $item['author-avatar'];
|
||||
$item['url'] = $item['author-link'];
|
||||
$item['when'] = DateTimeFormat::local($item['created'], 'r');
|
||||
$item['ago'] = Temporal::getRelativeDate($item['created']);
|
||||
$item['text'] = (($item['gravity'] == GRAVITY_PARENT)
|
||||
$item['text'] = (($item['gravity'] == Item::GRAVITY_PARENT)
|
||||
? $this->l10n->t("%s created a new post", $item['author-name'])
|
||||
: $this->l10n->t("%s commented on %s's post", $item['author-name'], $item['parent-author-name']));
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Object\Api\Mastodon;
|
|||
|
||||
use Friendica\BaseDataTransferObject;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Object\Api\Mastodon\Status\Counts;
|
||||
use Friendica\Object\Api\Mastodon\Status\UserAttributes;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -102,7 +103,7 @@ class Status extends BaseDataTransferObject
|
|||
$this->id = (string)$item['uri-id'];
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
|
||||
|
||||
if ($item['gravity'] == GRAVITY_COMMENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
$this->in_reply_to_id = (string)$item['thr-parent-id'];
|
||||
$this->in_reply_to_account_id = (string)$item['parent-author-id'];
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class Status extends BaseDataTransferObject
|
|||
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::API);
|
||||
|
||||
if ($item['gravity'] == GRAVITY_COMMENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
$this->in_reply_to_status_id = (int)$item['thr-parent-id'];
|
||||
$this->in_reply_to_status_id_str = (string)$item['thr-parent-id'];
|
||||
$this->in_reply_to_user_id = (int)$item['parent-author-id'];
|
||||
|
|
|
@ -210,7 +210,7 @@ class Post
|
|||
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
|
||||
|
||||
// On Diaspora only toplevel posts can be reshared
|
||||
if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != GRAVITY_PARENT)) {
|
||||
if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
$announceable = false;
|
||||
}
|
||||
|
||||
|
@ -915,7 +915,7 @@ class Post
|
|||
return $text;
|
||||
}
|
||||
|
||||
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
|
||||
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != Item::GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
|
||||
$text .= '@' . $item['author-addr'] . ' ';
|
||||
}
|
||||
|
||||
|
|
|
@ -308,10 +308,10 @@ class Processor
|
|||
$item['thr-parent'] = $activity['reply-to-id'];
|
||||
|
||||
if ($activity['reply-to-id'] == $activity['id']) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
} else {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ class Processor
|
|||
|
||||
$item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
|
||||
|
||||
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
|
||||
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
|
||||
Logger::notice('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]);
|
||||
if (!$fetch_parents) {
|
||||
Queue::remove($activity);
|
||||
|
@ -663,7 +663,7 @@ class Processor
|
|||
|
||||
$item['verb'] = $verb;
|
||||
$item['thr-parent'] = $activity['object_id'];
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
unset($item['post-type']);
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
|
@ -833,7 +833,7 @@ class Processor
|
|||
$item['body'] = Item::improveSharedDataInBody($item);
|
||||
} else {
|
||||
$parent_uri = $item['parent-uri'] ?? $item['thr-parent'];
|
||||
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
|
||||
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
|
||||
$parent = Post::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $parent_uri]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
Logger::warning('Unknown parent item.', ['uri' => $parent_uri]);
|
||||
|
@ -937,7 +937,7 @@ class Processor
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
// We cannot reliably check at this point if a comment or activity belongs to an accepted post or needs to be fetched
|
||||
// This can possibly be improved in the future.
|
||||
Logger::debug('Message is no parent - accepted', ['uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'url' => $item['uri']]);
|
||||
|
@ -1035,7 +1035,7 @@ class Processor
|
|||
// When a post arrives via a relay and we follow the author, we have to override the causer.
|
||||
// Otherwise the system assumes that we follow the relay. (See "addRowInformation")
|
||||
Logger::debug('Relay post for follower', ['receiver' => $receiver, 'guid' => $item['guid'], 'relay' => $activity['from-relay']]);
|
||||
$item['causer-id'] = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
$item['causer-id'] = ($item['gravity'] == Item::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
|
||||
}
|
||||
|
||||
if ($item['isForum'] ?? false) {
|
||||
|
@ -1053,7 +1053,7 @@ class Processor
|
|||
continue;
|
||||
}
|
||||
|
||||
if (($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
|
||||
if (($receiver != 0) && ($item['gravity'] == Item::GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
|
||||
if (!($item['isForum'] ?? false)) {
|
||||
if ($item['post-reason'] == Item::PR_BCC) {
|
||||
Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id'], 'url' => $item['uri']]);
|
||||
|
@ -1088,7 +1088,7 @@ class Processor
|
|||
continue;
|
||||
}
|
||||
|
||||
if (($item['gravity'] != GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
|
||||
if (($item['gravity'] != Item::GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
|
||||
$event_id = self::createEvent($activity, $item);
|
||||
|
||||
$item = Event::getItemArrayForImportedId($event_id, $item);
|
||||
|
@ -1118,7 +1118,7 @@ class Processor
|
|||
}
|
||||
|
||||
// Store send a follow request for every reshare - but only when the item had been stored
|
||||
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
|
||||
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == Item::GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
|
||||
$author = APContact::getByURL($item['owner-link'], false);
|
||||
// We send automatic follow requests for reshared messages. (We don't need though for forum posts)
|
||||
if ($author['type'] != 'Group') {
|
||||
|
@ -1138,7 +1138,7 @@ class Processor
|
|||
*/
|
||||
private static function hasParents(array $item, int $receiver)
|
||||
{
|
||||
if (($receiver == 0) || ($item['gravity'] == GRAVITY_PARENT)) {
|
||||
if (($receiver == 0) || ($item['gravity'] == Item::GRAVITY_PARENT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1149,7 @@ class Processor
|
|||
if ($item['verb'] != Activity::ANNOUNCE) {
|
||||
switch (DI::pConfig()->get($receiver, 'system', 'accept_only_sharer')) {
|
||||
case Item::COMPLETION_COMMENT:
|
||||
$add_parent = ($item['gravity'] != GRAVITY_ACTIVITY);
|
||||
$add_parent = ($item['gravity'] != Item::GRAVITY_ACTIVITY);
|
||||
break;
|
||||
|
||||
case Item::COMPLETION_NONE:
|
||||
|
@ -1283,7 +1283,7 @@ class Processor
|
|||
*/
|
||||
private static function postMail(array $activity, array $item)
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
|
||||
Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
|
||||
return false;
|
||||
}
|
||||
|
@ -1859,7 +1859,7 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => GRAVITY_ACTIVITY]);
|
||||
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => Item::GRAVITY_ACTIVITY]);
|
||||
Queue::remove($activity);
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ class Receiver
|
|||
}
|
||||
}
|
||||
|
||||
if (Post::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
|
||||
if (Post::exists(['uri' => $object_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]])) {
|
||||
// We just assume "note" since it doesn't make a difference for the further processing
|
||||
return 'as:Note';
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ class Transmitter
|
|||
$condition = array_merge($condition, [
|
||||
'uid' => $owner['uid'],
|
||||
'author-id' => Contact::getIdForURL($owner['url'], 0, false),
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
'network' => Protocol::FEDERATED,
|
||||
'parent-network' => Protocol::FEDERATED,
|
||||
'origin' => true,
|
||||
|
@ -351,7 +351,7 @@ class Transmitter
|
|||
'uid' => $owner['uid'],
|
||||
'author-id' => $owner_cid,
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
'network' => Protocol::FEDERATED,
|
||||
'parent-network' => Protocol::FEDERATED,
|
||||
'origin' => true,
|
||||
|
@ -577,7 +577,7 @@ class Transmitter
|
|||
$item_profile = APContact::getByURL($item['author-link']);
|
||||
$exclude[] = $item['author-link'];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$exclude[] = $item['owner-link'];
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ class Transmitter
|
|||
|
||||
$data = ['to' => [], 'cc' => [], 'bcc' => []];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$actor_profile = APContact::getByURL($item['owner-link']);
|
||||
} else {
|
||||
$actor_profile = APContact::getByURL($item['author-link']);
|
||||
|
@ -753,10 +753,10 @@ class Transmitter
|
|||
if (!empty($item['parent'])) {
|
||||
$parents = Post::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']], ['order' => ['id']]);
|
||||
while ($parent = Post::fetch($parents)) {
|
||||
if ($parent['gravity'] == GRAVITY_PARENT) {
|
||||
if ($parent['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$profile = APContact::getByURL($parent['owner-link'], false);
|
||||
if (!empty($profile)) {
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
// Comments to forums are directed to the forum
|
||||
// But comments to forums aren't directed to the followers collection
|
||||
// This rule is only valid when the actor isn't the forum.
|
||||
|
@ -971,7 +971,7 @@ class Transmitter
|
|||
|
||||
$inboxes = [];
|
||||
|
||||
if ($item['gravity'] == GRAVITY_ACTIVITY) {
|
||||
if ($item['gravity'] == Item::GRAVITY_ACTIVITY) {
|
||||
$item_profile = APContact::getByURL($item['author-link'], false);
|
||||
} else {
|
||||
$item_profile = APContact::getByURL($item['owner-link'], false);
|
||||
|
@ -1060,7 +1060,7 @@ class Transmitter
|
|||
$mail['parent-uri'] = $reply['uri'];
|
||||
$mail['parent-uri-id'] = $reply['uri-id'];
|
||||
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
|
||||
$mail['gravity'] = ($mail['reply'] ? GRAVITY_COMMENT: GRAVITY_PARENT);
|
||||
$mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT: Item::GRAVITY_PARENT);
|
||||
$mail['event-type'] = '';
|
||||
$mail['language'] = '';
|
||||
$mail['parent'] = 0;
|
||||
|
@ -1245,7 +1245,7 @@ class Transmitter
|
|||
if (!$object_mode) {
|
||||
$data = ['@context' => $context ?? ActivityPub::CONTEXT];
|
||||
|
||||
if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
|
||||
if ($item['deleted'] && ($item['gravity'] == Item::GRAVITY_ACTIVITY)) {
|
||||
$type = 'Undo';
|
||||
} elseif ($item['deleted']) {
|
||||
$type = 'Delete';
|
||||
|
@ -1256,7 +1256,7 @@ class Transmitter
|
|||
|
||||
if ($type == 'Delete') {
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;;
|
||||
} elseif (($item['gravity'] == GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
} elseif (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
$data['id'] = $item['uri'];
|
||||
} else {
|
||||
$data['id'] = $item['uri'] . '/' . $type;
|
||||
|
@ -1264,7 +1264,7 @@ class Transmitter
|
|||
|
||||
$data['type'] = $type;
|
||||
|
||||
if (($type != 'Announce') || ($item['gravity'] != GRAVITY_PARENT)) {
|
||||
if (($type != 'Announce') || ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
$data['actor'] = $item['author-link'];
|
||||
} else {
|
||||
$data['actor'] = $item['owner-link'];
|
||||
|
@ -1557,7 +1557,7 @@ class Transmitter
|
|||
// We are treating posts differently when they are directed to a community.
|
||||
// This is done to better support Lemmy. Most of the changes should work with other systems as well.
|
||||
// But to not risk compatibility issues we currently perform the changes only for communities.
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$isCommunityPost = !empty(Tag::getByURIId($item['uri-id'], [Tag::EXCLUSIVE_MENTION]));
|
||||
$links = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||
if ($isCommunityPost && (count($links) == 1)) {
|
||||
|
|
|
@ -799,7 +799,7 @@ class DFRN
|
|||
$dfrnowner = self::addEntryAuthor($doc, "dfrn:owner", $item["owner-link"], $item);
|
||||
$entry->appendChild($dfrnowner);
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
|
||||
|
@ -888,7 +888,7 @@ class DFRN
|
|||
|
||||
if ($item['object-type'] != '') {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', $item['object-type']);
|
||||
} elseif ($item['gravity'] == GRAVITY_PARENT) {
|
||||
} elseif ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::NOTE);
|
||||
} else {
|
||||
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::COMMENT);
|
||||
|
@ -1612,21 +1612,21 @@ class DFRN
|
|||
|| ($item['verb'] == Activity::ATTENDMAYBE)
|
||||
|| ($item['verb'] == Activity::ANNOUNCE)
|
||||
) {
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
// only one like or dislike per person
|
||||
// split into two queries for performance issues
|
||||
$condition = [
|
||||
'uid' => $item['uid'],
|
||||
'author-id' => $item['author-id'],
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'],
|
||||
'uid' => $item['uid'],
|
||||
'author-id' => $item['author-id'],
|
||||
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'],
|
||||
'parent-uri' => $item['thr-parent'],
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => GRAVITY_ACTIVITY,
|
||||
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
|
||||
if (Post::exists($condition)) {
|
||||
return false;
|
||||
|
@ -1938,7 +1938,7 @@ class DFRN
|
|||
|
||||
// Now assign the rest of the values that depend on the type of the message
|
||||
if (in_array($entrytype, [self::REPLY, self::REPLY_RC])) {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
if (!isset($item['object-type'])) {
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
|
@ -1964,7 +1964,7 @@ class DFRN
|
|||
if ($entrytype == self::REPLY_RC) {
|
||||
$item['wall'] = 1;
|
||||
} elseif ($entrytype == self::TOP_LEVEL) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
if (!isset($item['object-type'])) {
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -2034,7 +2034,7 @@ class DFRN
|
|||
Logger::info('Contact is not sharing with the user', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
|
||||
return;
|
||||
}
|
||||
if (($item['gravity'] == GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
|
||||
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
|
||||
Logger::info('Completion is set to "comment", but this is an activity. so we stop here.', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
|
||||
return;
|
||||
}
|
||||
|
@ -2119,13 +2119,13 @@ class DFRN
|
|||
}
|
||||
|
||||
// When it is a starting post it has to belong to the person that wants to delete it
|
||||
if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
if (($item['gravity'] == Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
Logger::info('Item with URI ' . $uri . ' do not belong to contact ' . $importer['id'] . ' - ignoring deletion.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Comments can be deleted by the thread owner or comment owner
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
|
||||
$condition = ['id' => $item['parent'], 'contact-id' => $importer['id']];
|
||||
if (!Post::exists($condition)) {
|
||||
Logger::info('Item with URI ' . $uri . ' was not found or must not be deleted by contact ' . $importer['id'] . ' - ignoring deletion.');
|
||||
|
|
|
@ -83,7 +83,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
|
||||
['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
|
||||
['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
||||
while ($item = Post::fetch($items)) {
|
||||
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
|
||||
['id' => $item['author-id']]);
|
||||
|
@ -1548,7 +1548,7 @@ class Diaspora
|
|||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_COMMENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
|
||||
|
||||
|
@ -1801,7 +1801,7 @@ class Diaspora
|
|||
$datarray['uri'] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray['verb'] = $verb;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -1812,7 +1812,7 @@ class Diaspora
|
|||
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = DateTimeFormat::utcNow();
|
||||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($toplevel_parent_item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$toplevel = Post::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
|
||||
$origin = $toplevel['origin'];
|
||||
} else {
|
||||
|
@ -1981,7 +1981,7 @@ class Diaspora
|
|||
$datarray['uri'] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray['verb'] = Activity::FOLLOW;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -2002,9 +2002,9 @@ class Diaspora
|
|||
|
||||
// Send all existing comments and likes to the requesting server
|
||||
$comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
|
||||
['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
|
||||
['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
|
||||
while ($comment = Post::fetch($comments)) {
|
||||
if (($comment['gravity'] == GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
|
||||
continue;
|
||||
}
|
||||
|
@ -2302,7 +2302,7 @@ class Diaspora
|
|||
$datarray['thr-parent'] = $parent['uri'];
|
||||
|
||||
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
$datarray['protocol'] = $item['protocol'];
|
||||
|
@ -2387,7 +2387,7 @@ class Diaspora
|
|||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_PARENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
|
@ -2706,7 +2706,7 @@ class Diaspora
|
|||
$datarray['owner-id'] = $datarray['author-id'];
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = GRAVITY_PARENT;
|
||||
$datarray['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
|
@ -3596,7 +3596,7 @@ class Diaspora
|
|||
// - Implicit mentions are enabled
|
||||
if (
|
||||
$item['author-id'] != $thread_parent_item['author-id']
|
||||
&& ($thread_parent_item['gravity'] != GRAVITY_PARENT)
|
||||
&& ($thread_parent_item['gravity'] != Item::GRAVITY_PARENT)
|
||||
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
|
||||
&& !DI::config()->get('system', 'disable_implicit_mentions')
|
||||
) {
|
||||
|
@ -3729,7 +3729,7 @@ class Diaspora
|
|||
|
||||
$msg_type = 'retraction';
|
||||
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$target_type = 'Post';
|
||||
} elseif (in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$target_type = 'Like';
|
||||
|
@ -4069,12 +4069,12 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
if (($parent_post['gravity'] == GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
|
||||
if (($parent_post['gravity'] == Item::GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
|
||||
Logger::info('Parent comment has got no Diaspora signature.', ['parent-id' => $parent_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($parent_post['gravity'] == GRAVITY_COMMENT) {
|
||||
if ($parent_post['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
return self::parentSupportDiaspora($parent_post['thr-parent-id']);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,20 +252,21 @@ class Feed
|
|||
$author['owner-avatar'] = $contact['thumb'];
|
||||
}
|
||||
|
||||
$header = [];
|
||||
$header['uid'] = $importer['uid'] ?? 0;
|
||||
$header['network'] = Protocol::FEED;
|
||||
$header = [
|
||||
'uid' => $importer['uid'] ?? 0,
|
||||
'network' => Protocol::FEED,
|
||||
'wall' => 0,
|
||||
'origin' => 0,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'private' => Item::PUBLIC,
|
||||
'verb' => Activity::POST,
|
||||
'object-type' => Activity\ObjectType::NOTE,
|
||||
'post-type' => Item::PT_ARTICLE,
|
||||
'contact-id' => $contact['id'] ?? 0,
|
||||
];
|
||||
|
||||
$datarray['protocol'] = $protocol;
|
||||
$datarray['direction'] = Conversation::PULL;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header['gravity'] = GRAVITY_PARENT;
|
||||
$header['private'] = Item::PUBLIC;
|
||||
$header['verb'] = Activity::POST;
|
||||
$header['object-type'] = Activity\ObjectType::NOTE;
|
||||
$header['post-type'] = Item::PT_ARTICLE;
|
||||
|
||||
$header['contact-id'] = $contact['id'] ?? 0;
|
||||
|
||||
if (!is_object($entries)) {
|
||||
Logger::info("There are no entries in this feed.");
|
||||
|
@ -954,13 +955,13 @@ class Feed
|
|||
|
||||
$condition = ["`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
|
||||
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
|
||||
$owner['uid'], $check_date, GRAVITY_PARENT, GRAVITY_COMMENT,
|
||||
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
|
||||
Item::PRIVATE, Protocol::ACTIVITYPUB,
|
||||
Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
|
||||
|
||||
if ($filter === 'comments') {
|
||||
$condition[0] .= " AND `gravity` = ? ";
|
||||
$condition[] = GRAVITY_COMMENT;
|
||||
$condition[] = Item::GRAVITY_COMMENT;
|
||||
}
|
||||
|
||||
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
|
@ -1087,7 +1088,7 @@ class Feed
|
|||
*/
|
||||
private static function noteEntry(DOMDocument $doc, array $item, array $owner): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('Feed entry author does not match feed owner', ['owner' => $owner['url'], 'author' => $item['author-link']]);
|
||||
}
|
||||
|
||||
|
@ -1151,7 +1152,7 @@ class Feed
|
|||
{
|
||||
$mentioned = [];
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||
|
||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||
|
|
|
@ -391,7 +391,7 @@ class OStatus
|
|||
$header['network'] = Protocol::OSTATUS;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header['gravity'] = GRAVITY_COMMENT;
|
||||
$header['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
|
||||
return false;
|
||||
|
@ -499,7 +499,7 @@ class OStatus
|
|||
|
||||
$item['verb'] = Activity::LIKE;
|
||||
$item['thr-parent'] = $orig_uri;
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ class OStatus
|
|||
}
|
||||
} else {
|
||||
$item['thr-parent'] = $item['uri'];
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
}
|
||||
|
||||
self::$itemlist[] = $item;
|
||||
|
@ -1359,7 +1359,7 @@ class OStatus
|
|||
*/
|
||||
private static function likeEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
|
||||
}
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ class OStatus
|
|||
*/
|
||||
private static function noteEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
|
||||
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
|
||||
}
|
||||
|
||||
|
@ -1639,7 +1639,7 @@ class OStatus
|
|||
{
|
||||
$mentioned = [];
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||
|
||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||
|
|
|
@ -25,18 +25,21 @@ use Friendica\Contact\FriendSuggest\Collection\FriendSuggests;
|
|||
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\FContact;
|
||||
use Friendica\Model\GServer;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\Email;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Model\FContact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
class Delivery
|
||||
{
|
||||
|
@ -75,7 +78,7 @@ class Delivery
|
|||
$uid = $post_uriid;
|
||||
$target_item = [];
|
||||
} else {
|
||||
$item = Model\Post::selectFirst(['id', 'parent'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
$item = Post::selectFirst(['id', 'parent'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($item) || empty($item['parent'])) {
|
||||
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
return;
|
||||
|
@ -85,9 +88,9 @@ class Delivery
|
|||
|
||||
$condition = ['id' => [$target_id, $parent_id], 'visible' => true];
|
||||
$params = ['order' => ['id']];
|
||||
$itemdata = Model\Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
|
||||
$itemdata = Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
|
||||
|
||||
while ($item = Model\Post::fetch($itemdata)) {
|
||||
while ($item = Post::fetch($itemdata)) {
|
||||
if ($item['verb'] == Activity::ANNOUNCE) {
|
||||
continue;
|
||||
}
|
||||
|
@ -124,14 +127,14 @@ class Delivery
|
|||
}
|
||||
|
||||
$condition = ['uri' => $target_item['thr-parent'], 'uid' => $target_item['uid']];
|
||||
$thr_parent = Model\Post::selectFirst(['network', 'object'], $condition);
|
||||
$thr_parent = Post::selectFirst(['network', 'object'], $condition);
|
||||
if (!DBA::isResult($thr_parent)) {
|
||||
// Shouldn't happen. But when this does, we just take the parent as thread parent.
|
||||
// That's totally okay for what we use this variable here.
|
||||
$thr_parent = $parent;
|
||||
}
|
||||
|
||||
if (!empty($contact_id) && Model\Contact::isArchived($contact_id)) {
|
||||
if (!empty($contact_id) && Contact::isArchived($contact_id)) {
|
||||
Logger::info('Contact is archived', ['id' => $contact_id, 'cmd' => $cmd, 'item' => $target_item['id']]);
|
||||
self::setFailedQueue($cmd, $target_item);
|
||||
return;
|
||||
|
@ -144,7 +147,7 @@ class Delivery
|
|||
}
|
||||
}
|
||||
|
||||
$top_level = $target_item['gravity'] == GRAVITY_PARENT;
|
||||
$top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
|
||||
|
||||
// This is IMPORTANT!!!!
|
||||
|
||||
|
@ -176,7 +179,7 @@ class Delivery
|
|||
&& empty($parent['allow_gid'])
|
||||
&& empty($parent['deny_cid'])
|
||||
&& empty($parent['deny_gid'])
|
||||
&& ($parent["private"] != Model\Item::PRIVATE)) {
|
||||
&& ($parent['private'] != Item::PRIVATE)) {
|
||||
$public_message = true;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +188,7 @@ class Delivery
|
|||
Logger::warning('No delivery data', ['command' => $cmd, 'uri-id' => $post_uriid, 'cid' => $contact_id]);
|
||||
}
|
||||
|
||||
$owner = Model\User::getOwnerDataById($uid);
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (!DBA::isResult($owner)) {
|
||||
self::setFailedQueue($cmd, $target_item);
|
||||
return;
|
||||
|
@ -205,7 +208,7 @@ class Delivery
|
|||
return;
|
||||
}
|
||||
|
||||
$protocol = Model\GServer::getProtocol($contact['gsid'] ?? 0);
|
||||
$protocol = GServer::getProtocol($contact['gsid'] ?? 0);
|
||||
|
||||
// Transmit via Diaspora if the thread had started as Diaspora post.
|
||||
// Also transmit via Diaspora if this is a direct answer to a Diaspora comment.
|
||||
|
@ -250,7 +253,7 @@ class Delivery
|
|||
return;
|
||||
}
|
||||
|
||||
Model\Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
|
||||
Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,7 +284,7 @@ class Delivery
|
|||
|
||||
if ($cmd == self::MAIL) {
|
||||
$item = $target_item;
|
||||
$item['body'] = Model\Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
|
||||
$item['body'] = Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
|
||||
$atom = DFRN::mail($item, $owner);
|
||||
} elseif ($cmd == self::SUGGESTION) {
|
||||
$item = $target_item;
|
||||
|
@ -311,13 +314,13 @@ class Delivery
|
|||
|
||||
Logger::debug('Notifier entry: ' . $contact["url"] . ' ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' entry: ' . $atom);
|
||||
|
||||
$protocol = Model\Post\DeliveryData::DFRN;
|
||||
$protocol = Post\DeliveryData::DFRN;
|
||||
|
||||
// We don't have a relationship with contacts on a public post.
|
||||
// Se we transmit with the new method and via Diaspora as a fallback
|
||||
if (!empty($items) && (($items[0]['uid'] == 0) || ($contact['uid'] == 0))) {
|
||||
// Transmit in public if it's a relay post
|
||||
$public_dfrn = ($contact['contact-type'] == Model\Contact::TYPE_RELAY);
|
||||
$public_dfrn = ($contact['contact-type'] == Contact::TYPE_RELAY);
|
||||
|
||||
$deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn);
|
||||
|
||||
|
@ -327,17 +330,17 @@ class Delivery
|
|||
|
||||
if ($cmd == Delivery::POST) {
|
||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
|
||||
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
|
||||
|
||||
Model\GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
|
||||
GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
|
||||
} else {
|
||||
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((($deliver_status < 200) || ($deliver_status > 299)) && (empty($server_protocol) || ($server_protocol == Model\Post\DeliveryData::LEGACY_DFRN))) {
|
||||
if ((($deliver_status < 200) || ($deliver_status > 299)) && (empty($server_protocol) || ($server_protocol == Post\DeliveryData::LEGACY_DFRN))) {
|
||||
// Transmit via Diaspora if not possible via Friendica
|
||||
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||
return;
|
||||
|
@ -351,20 +354,20 @@ class Delivery
|
|||
|
||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||
// We successfully delivered a message, the contact is alive
|
||||
Model\Contact::unmarkForArchival($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
|
||||
Model\GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
|
||||
GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
|
||||
|
||||
if ($cmd == Delivery::POST) {
|
||||
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
|
||||
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
|
||||
}
|
||||
} else {
|
||||
// The message could not be delivered. We mark the contact as "dead"
|
||||
Model\Contact::markForArchival($contact);
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
|
||||
if (!Worker::defer() && $cmd == Delivery::POST) {
|
||||
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +389,7 @@ class Delivery
|
|||
private static function deliverDiaspora(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup)
|
||||
{
|
||||
// We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
|
||||
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Model\User::ACCOUNT_TYPE_COMMUNITY);
|
||||
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY);
|
||||
|
||||
if ($public_message) {
|
||||
$loc = 'public batch ' . $contact['batch'];
|
||||
|
@ -438,30 +441,30 @@ class Delivery
|
|||
|
||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||
// We successfully delivered a message, the contact is alive
|
||||
Model\Contact::unmarkForArchival($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
|
||||
Model\GServer::setProtocol($contact['gsid'] ?? 0, Model\Post\DeliveryData::DIASPORA);
|
||||
GServer::setProtocol($contact['gsid'] ?? 0, Post\DeliveryData::DIASPORA);
|
||||
|
||||
if ($cmd == Delivery::POST) {
|
||||
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::DIASPORA);
|
||||
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Post\DeliveryData::DIASPORA);
|
||||
}
|
||||
} else {
|
||||
// The message could not be delivered. We mark the contact as "dead"
|
||||
Model\Contact::markForArchival($contact);
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
// When it is delivered to the public endpoint, we do mark the relay contact for archival as well
|
||||
if ($public_message) {
|
||||
Relay::markForArchival($contact);
|
||||
}
|
||||
|
||||
if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {
|
||||
if (empty($contact['contact-type']) || ($contact['contact-type'] != Contact::TYPE_RELAY)) {
|
||||
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
|
||||
// defer message for redelivery
|
||||
if (!Worker::defer() && $cmd == Delivery::POST) {
|
||||
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
}
|
||||
} elseif ($cmd == Delivery::POST) {
|
||||
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +528,7 @@ class Delivery
|
|||
|
||||
// only expose our real email address to true friends
|
||||
|
||||
if (($contact['rel'] == Model\Contact::FRIEND) && !$contact['blocked']) {
|
||||
if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
|
||||
if ($reply_to) {
|
||||
$headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to . '>' . "\n";
|
||||
$headers .= 'Sender: ' . $local_user['email'] . "\n";
|
||||
|
@ -551,13 +554,13 @@ class Delivery
|
|||
|
||||
if (empty($target_item['title'])) {
|
||||
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
||||
$title = Model\Post::selectFirst(['title'], $condition);
|
||||
$title = Post::selectFirst(['title'], $condition);
|
||||
|
||||
if (DBA::isResult($title) && ($title['title'] != '')) {
|
||||
$subject = $title['title'];
|
||||
} else {
|
||||
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
||||
$title = Model\Post::selectFirst(['title'], $condition);
|
||||
$title = Post::selectFirst(['title'], $condition);
|
||||
|
||||
if (DBA::isResult($title) && ($title['title'] != '')) {
|
||||
$subject = $title['title'];
|
||||
|
@ -575,7 +578,7 @@ class Delivery
|
|||
|
||||
if ($success) {
|
||||
// Success
|
||||
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::MAIL);
|
||||
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Post\DeliveryData::MAIL);
|
||||
Logger::info('Delivered via mail', ['guid' => $target_item['guid'], 'to' => $addr, 'subject' => $subject]);
|
||||
} else {
|
||||
// Failed
|
||||
|
|
|
@ -68,7 +68,7 @@ class ExpirePosts
|
|||
{
|
||||
Logger::notice('Delete expired posts');
|
||||
// physically remove anything that has been deleted for more than two months
|
||||
$condition = ["`gravity` = ? AND `deleted` AND `changed` < ?", GRAVITY_PARENT, DateTimeFormat::utc('now - 60 days')];
|
||||
$condition = ["`gravity` = ? AND `deleted` AND `changed` < ?", Item::GRAVITY_PARENT, DateTimeFormat::utc('now - 60 days')];
|
||||
$rows = Post::select(['guid', 'uri-id', 'uid'], $condition);
|
||||
while ($row = Post::fetch($rows)) {
|
||||
Logger::info('Delete expired item', ['uri-id' => $row['uri-id'], 'guid' => $row['guid']]);
|
||||
|
@ -134,7 +134,7 @@ class ExpirePosts
|
|||
}
|
||||
|
||||
$rows = 0;
|
||||
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT]);
|
||||
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", Item::GRAVITY_PARENT]);
|
||||
while ($fields = DBA::fetch($userposts)) {
|
||||
$post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $fields);
|
||||
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
|
||||
|
@ -149,7 +149,7 @@ class ExpirePosts
|
|||
}
|
||||
|
||||
$rows = 0;
|
||||
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", GRAVITY_PARENT]);
|
||||
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", Item::GRAVITY_PARENT]);
|
||||
while ($fields = DBA::fetch($userposts)) {
|
||||
$post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $fields);
|
||||
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
|
||||
|
@ -264,7 +264,7 @@ class ExpirePosts
|
|||
AND `i`.`parent-uri-id` = `post-user`.`uri-id`)
|
||||
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user` AS `i` WHERE `i`.`uid` = ?
|
||||
AND `i`.`parent-uri-id` = `post-user`.`uri-id` AND `i`.`received` > ?))",
|
||||
GRAVITY_PARENT, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days'), 0, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days')]);
|
||||
Item::GRAVITY_PARENT, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days'), 0, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days')]);
|
||||
|
||||
Logger::notice('Start deleting unclaimed public items');
|
||||
$affected_count = 0;
|
||||
|
|
|
@ -143,7 +143,7 @@ class Notifier
|
|||
}
|
||||
}
|
||||
|
||||
$top_level = $target_item['gravity'] == GRAVITY_PARENT;
|
||||
$top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
|
|
@ -387,7 +387,7 @@ return [
|
|||
'uri-id' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -402,7 +402,7 @@ return [
|
|||
'uri-id' => 2,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -417,7 +417,7 @@ return [
|
|||
'uri-id' => 3,
|
||||
'parent-uri-id' => 3,
|
||||
'thr-parent-id' => 3,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 43,
|
||||
|
@ -432,7 +432,7 @@ return [
|
|||
'uri-id' => 4,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -447,7 +447,7 @@ return [
|
|||
'uri-id' => 5,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -462,7 +462,7 @@ return [
|
|||
'uri-id' => 6,
|
||||
'parent-uri-id' => 6,
|
||||
'thr-parent-id' => 6,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -477,7 +477,7 @@ return [
|
|||
'uri-id' => 7,
|
||||
'parent-uri-id' => 7,
|
||||
'thr-parent-id' => 7,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -505,7 +505,7 @@ return [
|
|||
'thr-parent-id' => 1,
|
||||
'private' => Item::PUBLIC,
|
||||
'global' => true,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'wall' => 1,
|
||||
'origin' => 1,
|
||||
|
@ -519,7 +519,7 @@ return [
|
|||
'origin' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -540,7 +540,7 @@ return [
|
|||
'origin' => 1,
|
||||
'parent-uri-id' => 3,
|
||||
'thr-parent-id' => 3,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 43,
|
||||
|
@ -561,7 +561,7 @@ return [
|
|||
'origin' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -582,7 +582,7 @@ return [
|
|||
'origin' => 1,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -603,7 +603,7 @@ return [
|
|||
'origin' => 1,
|
||||
'parent-uri-id' => 6,
|
||||
'thr-parent-id' => 6,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -624,7 +624,7 @@ return [
|
|||
'origin' => 0,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -645,7 +645,7 @@ return [
|
|||
'origin' => 0,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -666,7 +666,7 @@ return [
|
|||
'origin' => 0,
|
||||
'parent-uri-id' => 3,
|
||||
'thr-parent-id' => 3,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 43,
|
||||
|
@ -687,7 +687,7 @@ return [
|
|||
'origin' => 0,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 44,
|
||||
|
@ -708,7 +708,7 @@ return [
|
|||
'origin' => 0,
|
||||
'parent-uri-id' => 1,
|
||||
'thr-parent-id' => 1,
|
||||
'gravity' => GRAVITY_COMMENT,
|
||||
'gravity' => Item::GRAVITY_COMMENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'owner-id' => 42,
|
||||
'author-id' => 42,
|
||||
|
@ -735,7 +735,7 @@ return [
|
|||
'thr-parent-id' => 6,
|
||||
'private' => Item::PUBLIC,
|
||||
'global' => true,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'origin' => 0,
|
||||
'deleted' => 0,
|
||||
|
@ -756,7 +756,7 @@ return [
|
|||
'thr-parent-id' => 7,
|
||||
'private' => Item::PUBLIC,
|
||||
'global' => true,
|
||||
'gravity' => GRAVITY_PARENT,
|
||||
'gravity' => Item::GRAVITY_PARENT,
|
||||
'network' => Protocol::DFRN,
|
||||
'origin' => 0,
|
||||
'deleted' => 0,
|
||||
|
|
|
@ -299,7 +299,7 @@ function update_1349()
|
|||
}
|
||||
|
||||
if (!DBA::e("UPDATE `item` INNER JOIN `item-activity` ON `item`.`uri-id` = `item-activity`.`uri-id`
|
||||
SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", GRAVITY_ACTIVITY)) {
|
||||
SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", Item::GRAVITY_ACTIVITY)) {
|
||||
return Update::FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ use Friendica\Core\Session;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Module;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -203,7 +205,7 @@ function frio_remote_nav(App $a, array &$nav_info)
|
|||
{
|
||||
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
|
||||
// get the homelink from $_SESSION
|
||||
$homelink = Model\Profile::getMyURL();
|
||||
$homelink = Profile::getMyURL();
|
||||
if (!$homelink) {
|
||||
$homelink = Session::get('visitor_home', '');
|
||||
}
|
||||
|
@ -216,7 +218,7 @@ function frio_remote_nav(App $a, array &$nav_info)
|
|||
} elseif (!local_user() && remote_user()) {
|
||||
$remoteUser = Contact::getById(remote_user(), $fields);
|
||||
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
|
||||
} elseif (Model\Profile::getMyURL()) {
|
||||
} elseif (Profile::getMyURL()) {
|
||||
$remoteUser = Contact::getByURL($homelink, null, $fields);
|
||||
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
|
||||
} else {
|
||||
|
@ -257,7 +259,7 @@ function frio_display_item(App $a, &$arr)
|
|||
if (
|
||||
local_user()
|
||||
&& in_array($arr['item']['uid'], [0, local_user()])
|
||||
&& $arr['item']['gravity'] == GRAVITY_PARENT
|
||||
&& $arr['item']['gravity'] == Item::GRAVITY_PARENT
|
||||
&& !$arr['item']['self']
|
||||
&& !$arr['item']['mention']
|
||||
) {
|
||||
|
|
Loading…
Reference in a new issue