* @}
*/
-/**
- * @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
*
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;
}
$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']]);
}
}
// 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,
$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.
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']);
}
* @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']) {
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.'));
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']]);
}
}
$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
]);
}
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;
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')) {
$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;
}
$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'];
$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;
* @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`,
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
, $uid, $uid, $start, $limit));
}
-function render_messages(array $msg, $t)
+function render_messages(array $msg, string $t): string
{
$a = DI::app();
$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']),
]);
}
}
-function notes_content(App $a, $update = false)
+function notes_content(App $a, bool $update = false)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
$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()) {
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;
$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;
$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);
}
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.'));
$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.');
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;
}
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['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");
+ $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>',
+ ];
+
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);
}
}
$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());
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
- ($item['gravity'] != GRAVITY_PARENT)) {
+ ($item['gravity'] != Item::GRAVITY_PARENT)) {
continue;
}
$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))) {
$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'];
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;
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'],
'$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),
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());
'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',
$item['pagedrop'] = $page_dropping;
- if ($item['gravity'] == GRAVITY_PARENT) {
+ if ($item['gravity'] == Item::GRAVITY_PARENT) {
$item_object = new PostObject($item);
$conv->addParent($item_object);
}
}
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']);
$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'];
$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;
}
$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']];
$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 = [];
}
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;
}
}
$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'];
// Extract the top level items
foreach ($item_array as $item) {
- if ($item['gravity'] == GRAVITY_PARENT) {
+ if ($item['gravity'] == Item::GRAVITY_PARENT) {
$parents[] = $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;';
}
}
$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;
}
}
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;
$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]);
namespace Friendica\Core;
use Friendica\Database\DBA;
+use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity;
// create a follow slap
$item = [
'verb' => Activity::FOLLOW,
- 'gravity' => GRAVITY_ACTIVITY,
+ 'gravity' => Item::GRAVITY_ACTIVITY,
'follow' => $contact['url'],
'body' => '',
'title' => '',
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'])) {
* 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' => '}}'
];
/**
* @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();
* 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);
* @return TemplateEngine Template Engine instance
* @throws ServiceUnavailableException
*/
- public static function getTemplateEngine()
+ public static function getTemplateEngine(): TemplateEngine
{
$template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
*
* @return string the active template engine
*/
- public static function getActiveTemplateEngine()
+ public static function getActiveTemplateEngine(): string
{
return self::$theme['template_engine'];
}
* 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;
}
*
* @return string the right delimiter
*/
- public static function getTemplateLeftDelimiter($engine = 'smarty3')
+ public static function getTemplateLeftDelimiter(string $engine = 'smarty3'): string
{
return self::$ldelim[$engine];
}
*
* @return string the left delimiter
*/
- public static function getTemplateRightDelimiter($engine = 'smarty3')
+ public static function getTemplateRightDelimiter(string $engine = 'smarty3'): string
{
return self::$rdelim[$engine];
}
$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()]);
use Friendica\BaseFactory;
use Friendica\Database\DBA;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity;
'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);
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;
// 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);
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;
$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;
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;
$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
);
'thr-parent-id' => $uriId,
'uid' => $uid,
'origin' => true,
- 'gravity' => GRAVITY_ACTIVITY,
+ 'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::LIKE),
'deleted' => false
]);
'thr-parent-id' => $uriId,
'uid' => $uid,
'origin' => true,
- 'gravity' => GRAVITY_ACTIVITY,
+ 'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::ANNOUNCE),
'deleted' => false
]);
$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']
);
$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 = '';
'thr-parent-id' => $item['uri-id'],
'uid' => $uid,
'origin' => true,
- 'gravity' => GRAVITY_ACTIVITY,
+ 'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::LIKE),
'deleted' => false
]);
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();
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;
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);
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)) {
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;
$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'])) {
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
*
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);
}
}
}
- 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 {
return 0;
}
- if ($thread_parent['gravity'] == GRAVITY_PARENT) {
+ if ($thread_parent['gravity'] == Item::GRAVITY_PARENT) {
return $uriid;
}
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
}
/**
return 0;
}
- if ($item['gravity'] !== GRAVITY_PARENT) {
+ if ($item['gravity'] !== self::GRAVITY_PARENT) {
$toplevel_parent = self::getTopLevelParent($item);
if (empty($toplevel_parent)) {
return 0;
Post::insert($item['uri-id'], $item);
- if ($item['gravity'] == GRAVITY_PARENT) {
+ if ($item['gravity'] == self::GRAVITY_PARENT) {
Post\Thread::insert($item['uri-id'], $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);
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);
}
// 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]);
}
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);
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);
}
// 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']);
}
*/
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;
}
*/
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;
}
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]);
$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']]);
$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;
$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);
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)) {
}
// Is it a toplevel post?
- if ($item['gravity'] == GRAVITY_PARENT) {
+ if ($item['gravity'] == self::GRAVITY_PARENT) {
self::addShadow($itemid);
return;
}
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 '';
}
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 {
*/
private static function autoReshare(array $item)
{
- if ($item['gravity'] != GRAVITY_PARENT) {
+ if ($item['gravity'] != self::GRAVITY_PARENT) {
return;
}
}
$condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
- $uid, GRAVITY_PARENT];
+ $uid, self::GRAVITY_PARENT];
/*
* $expire_network_only = save your own wall posts
$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);
'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,
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');
}
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;
}
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\Item;
use stdClass;
/**
$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]);
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Protocol\Activity;
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));
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();
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;
}
// 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;
}
*/
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;
$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']
);
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;
}
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
}
$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();
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException\BadRequestException;
$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` <= ?";
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']) {
}
if ($request['exclude_replies']) {
- $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
+ $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if ($request['pinned']) {
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;
$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']]);
$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'];
}
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'));
}
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\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;
use Friendica\Core\System;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Protocol\Activity;
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 = [];
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\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'));
}
use Friendica\Core\System;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Protocol\Activity;
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 = [];
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'));
}
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\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'));
}
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;
$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`)"]);
}
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);
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;
$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']]);
}
if ($request['exclude_replies']) {
- $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
+ $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if ($request['local']) {
$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']) {
}
if ($request['exclude_replies']) {
- $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
+ $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if (!empty($uid)) {
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;
}
if ($request['exclude_replies']) {
- $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
+ $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if (!empty($request['max_id'])) {
use Friendica\Core\Logger;
use Friendica\Database\DBA;
+use Friendica\Model\Item;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
$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]];
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;
$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) {
}
if ($exclude_replies) {
$condition[0] .= ' AND `gravity` = ?';
- $condition[] = GRAVITY_PARENT;
+ $condition[] = Item::GRAVITY_PARENT;
}
if ($conversation_id > 0) {
$condition[0] .= " AND `parent-uri-id` = ?";
$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']];
$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` <= ?";
}
if ($exclude_replies) {
$condition[0] .= ' AND `gravity` = ?';
- $condition[] = GRAVITY_PARENT;
+ $condition[] = Item::GRAVITY_PARENT;
}
if ($conversation_id > 0) {
$condition[0] .= " AND `parent-uri-id` = ?";
use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Contact;
use Friendica\Model\Post;
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 |
$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` <= ?";
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` <= ?";
$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` <= ?";
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException\BadRequestException;
$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 = [];
}
$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;
}
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.
$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) {
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;
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) {
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) {
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) {
} 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
// 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]];
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)];
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
$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();
}
$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]);
use Friendica\Core\System;
use Friendica\DI;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\Conversation\Network as 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;
$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
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;
$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']));
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;
$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'];
}
$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'];
$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;
}
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'] . ' ';
}
$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;
}
$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);
$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;
$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]);
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']]);
// 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) {
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']]);
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);
}
// 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') {
*/
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;
}
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:
*/
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;
}
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);
}
}
}
- 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';
}
$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,
'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,
$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'];
}
$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']);
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.
$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);
$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;
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';
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;
$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'];
// 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)) {
$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",
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);
|| ($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;
// 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;
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;
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;
}
}
// 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.');
}
$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']]);
$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'];
$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;
$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 {
$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;
// 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;
}
$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'];
$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;
$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;
// - 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')
) {
$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';
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']);
}
$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.");
$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) {
*/
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']]);
}
{
$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']]);
$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;
$item['verb'] = Activity::LIKE;
$item['thr-parent'] = $orig_uri;
- $item['gravity'] = GRAVITY_ACTIVITY;
+ $item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['object-type'] = Activity\ObjectType::NOTE;
}
}
} else {
$item['thr-parent'] = $item['uri'];
- $item['gravity'] = GRAVITY_PARENT;
+ $item['gravity'] = Item::GRAVITY_PARENT;
}
self::$itemlist[] = $item;
*/
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.');
}
*/
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.');
}
{
$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']]);
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
{
$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;
$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;
}
}
$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;
}
}
- $top_level = $target_item['gravity'] == GRAVITY_PARENT;
+ $top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
// This is IMPORTANT!!!!
&& empty($parent['allow_gid'])
&& empty($parent['deny_cid'])
&& empty($parent['deny_gid'])
- && ($parent["private"] != Model\Item::PRIVATE)) {
+ && ($parent['private'] != Item::PRIVATE)) {
$public_message = true;
}
}
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;
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.
return;
}
- Model\Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
+ Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
}
/**
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;
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);
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;
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']);
}
}
}
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'];
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']);
}
}
}
// 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";
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'];
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
{
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']]);
}
$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'];
}
$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'];
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;
}
}
- $top_level = $target_item['gravity'] == GRAVITY_PARENT;
+ $top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
}
$owner = User::getOwnerDataById($uid);
'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,
'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,
'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,
'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,
'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,
'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,
'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,
'thr-parent-id' => 1,
'private' => Item::PUBLIC,
'global' => true,
- 'gravity' => GRAVITY_PARENT,
+ 'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'wall' => 1,
'origin' => 1,
'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,
'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,
'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,
'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,
'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,
'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,
'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,
'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,
'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,
'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,
'thr-parent-id' => 6,
'private' => Item::PUBLIC,
'global' => true,
- 'gravity' => GRAVITY_PARENT,
+ 'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,
'thr-parent-id' => 7,
'private' => Item::PUBLIC,
'global' => true,
- 'gravity' => GRAVITY_PARENT,
+ 'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,
}
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;
}
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;
{
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', '');
}
} 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 {
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']
) {