Merge pull request #11997 from Quix0r/rewrite/gravity-constants

Moved GRAVITY_* constants to Item model class
This commit is contained in:
Hypolite Petovan 2022-10-18 11:31:51 -04:00 committed by GitHub
commit bbe05f523f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 658 additions and 623 deletions

View File

@ -29,18 +29,6 @@
use Friendica\Core\Session;
/**
* @name Gravity
*
* Item weight for query ordering
* @{
*/
define('GRAVITY_PARENT', 0);
define('GRAVITY_ACTIVITY', 3);
define('GRAVITY_COMMENT', 6);
define('GRAVITY_UNKNOWN', 9);
/* @}*/
/**
* Returns the user id of locally logged in user or false.
*

View File

@ -106,7 +106,7 @@ function display_init(App $a)
displayShowFeed($item['uri-id'], $item['uid'], false);
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [0, $item_user], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid' => true]]);
$item = $parent ?: $item;
}

View File

@ -173,22 +173,23 @@ function events_post(App $a)
$private_event = true;
}
$datarray = [];
$datarray['start'] = $start;
$datarray['finish'] = $finish;
$datarray['summary'] = $summary;
$datarray['desc'] = $desc;
$datarray['location'] = $location;
$datarray['type'] = $type;
$datarray['nofinish'] = $nofinish;
$datarray['uid'] = $uid;
$datarray['cid'] = $cid;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private_event;
$datarray['id'] = $event_id;
$datarray = [
'start' => $start,
'finish' => $finish,
'summary' => $summary,
'desc' => $desc,
'location' => $location,
'type' => $type,
'nofinish' => $nofinish,
'uid' => $uid,
'cid' => $cid,
'allow_cid' => $str_contact_allow,
'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny,
'deny_gid' => $str_group_deny,
'private' => $private_event,
'id' => $event_id,
];
if (intval($_REQUEST['preview'])) {
System::httpExit(Event::getHTML($datarray));

View File

@ -123,7 +123,7 @@ function item_post(App $a) {
$thr_parent_uri = $parent_item['uri'];
$toplevel_item = $parent_item;
if ($parent_item['gravity'] != GRAVITY_PARENT) {
if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
}
}
@ -308,7 +308,7 @@ function item_post(App $a) {
// for non native networks use the network of the original post as network of the item
if (($toplevel_item['network'] != Protocol::DIASPORA)
&& ($toplevel_item['network'] != Protocol::OSTATUS)
&& ($network == "")) {
&& ($network == '')) {
$network = $toplevel_item['network'];
}
@ -386,7 +386,7 @@ function item_post(App $a) {
// Look for any tags and linkify them
$item = [
'uid' => local_user() ? local_user() : $profile_uid,
'gravity' => $toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT,
'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
'network' => $network,
'body' => $body,
'postopts' => $postopts,
@ -463,7 +463,7 @@ function item_post(App $a) {
$data = BBCode::getAttachmentData($body);
$match = [];
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data['type']))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
$objecttype = Activity\ObjectType::BOOKMARK;
@ -478,11 +478,11 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::NOTE; // Default value
$objectdata = BBCode::getAttachedData($body);
if ($objectdata["type"] == "link") {
if ($objectdata['type'] == 'link') {
$objecttype = Activity\ObjectType::BOOKMARK;
} elseif ($objectdata["type"] == "video") {
} elseif ($objectdata['type'] == 'video') {
$objecttype = Activity\ObjectType::VIDEO;
} elseif ($objectdata["type"] == "photo") {
} elseif ($objectdata['type'] == 'photo') {
$objecttype = Activity\ObjectType::IMAGE;
}
@ -510,11 +510,11 @@ function item_post(App $a) {
$verb = Activity::POST;
}
if ($network == "") {
if ($network == '') {
$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.
@ -533,68 +533,65 @@ function item_post(App $a) {
$thr_parent_uri = $uri;
}
$datarray = [];
$datarray['uid'] = $profile_uid;
$datarray['wall'] = $wall;
$datarray['gravity'] = $gravity;
$datarray['network'] = $network;
$datarray['contact-id'] = $contact_id;
$datarray['owner-name'] = $contact_record['name'] ?? '';
$datarray['owner-link'] = $contact_record['url'] ?? '';
$datarray['owner-avatar'] = $contact_record['thumb'] ?? '';
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-name'] = $author['name'];
$datarray['author-link'] = $author['url'];
$datarray['author-avatar'] = $author['thumb'];
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['created'] = empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'];
$datarray['edited'] = $datarray['created'];
$datarray['commented'] = $datarray['created'];
$datarray['changed'] = $datarray['created'];
$datarray['received'] = DateTimeFormat::utcNow();
$datarray['extid'] = $extid;
$datarray['guid'] = $guid;
$datarray['uri'] = $uri;
$datarray['title'] = $title;
$datarray['body'] = $body;
$datarray['app'] = $app;
$datarray['location'] = $location;
$datarray['coord'] = $coord;
$datarray['file'] = $categories;
$datarray['inform'] = $inform;
$datarray['verb'] = $verb;
$datarray['post-type'] = $posttype;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enabled;
$datarray['attach'] = $attachments;
$datarray['thr-parent'] = $thr_parent_uri;
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['object'] = $object;
$datarray['attachments'] = $_REQUEST['attachments'] ?? [];
$datarray = [
'uid' => $profile_uid,
'wall' => $wall,
'gravity' => $gravity,
'network' => $network,
'contact-id' => $contact_id,
'owner-name' => $contact_record['name'] ?? '',
'owner-link' => $contact_record['url'] ?? '',
'owner-avatar' => $contact_record['thumb'] ?? '',
'author-name' => $author['name'],
'author-link' => $author['url'],
'author-avatar' => $author['thumb'],
'created' => empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'],
'received' => DateTimeFormat::utcNow(),
'extid' => $extid,
'guid' => $guid,
'uri' => $uri,
'title' => $title,
'body' => $body,
'app' => $app,
'location' => $location,
'coord' => $coord,
'file' => $categories,
'inform' => $inform,
'verb' => $verb,
'post-type' => $posttype,
'object-type' => $objecttype,
'allow_cid' => $str_contact_allow,
'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny,
'deny_gid' => $str_group_deny,
'private' => $private,
'pubmail' => $pubmail_enabled,
'attach' => $attachments,
'thr-parent' => $thr_parent_uri,
'postopts' => $postopts,
'origin' => $origin,
'object' => $object,
'attachments' => $_REQUEST['attachments'] ?? [],
/*
* These fields are for the convenience of addons...
* 'self' if true indicates the owner is posting on their own wall
* If parent is 0 it is a top-level post.
*/
$datarray['parent'] = $toplevel_item_id;
$datarray['self'] = $self;
'parent' => $toplevel_item_id,
'self' => $self,
// This triggers posts via API and the mirror functions
$datarray['api_source'] = $api_source;
'api_source' => $api_source,
// This field is for storing the raw conversation data
$datarray['protocol'] = Conversation::PARCEL_DIRECT;
$datarray['direction'] = Conversation::PUSH;
'protocol' => Conversation::PARCEL_DIRECT,
'direction' => Conversation::PUSH,
];
// These cannot be part of above initialization ...
$datarray['edited'] = $datarray['created'];
$datarray['commented'] = $datarray['created'];
$datarray['changed'] = $datarray['created'];
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['edit'] = $orig_post;
@ -607,14 +604,14 @@ function item_post(App $a) {
if ($preview) {
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
$datarray["id"] = -1;
$datarray["uri-id"] = -1;
$datarray["author-network"] = Protocol::DFRN;
$datarray["author-updated"] = '';
$datarray["author-gsid"] = 0;
$datarray["author-uri-id"] = ItemURI::getIdByURI($datarray["author-link"]);
$datarray["owner-updated"] = '';
$datarray["has-media"] = false;
$datarray['id'] = -1;
$datarray['uri-id'] = -1;
$datarray['author-network'] = Protocol::DFRN;
$datarray['author-updated'] = '';
$datarray['author-gsid'] = 0;
$datarray['author-uri-id'] = ItemURI::getIdByURI($datarray['author-link']);
$datarray['owner-updated'] = '';
$datarray['has-media'] = false;
$datarray['body'] = Item::improveSharedDataInBody($datarray);
$o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
@ -706,7 +703,7 @@ function item_post(App $a) {
Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == GRAVITY_COMMENT)) {
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == Item::GRAVITY_COMMENT)) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
}
@ -808,6 +805,7 @@ function item_content(App $a)
}
}
break;
case 'block':
$item = Post::selectFirstForUser(local_user(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
if (empty($item['author-id'])) {
@ -834,15 +832,15 @@ function item_content(App $a)
* @return string
* @throws HTTPException\InternalServerErrorException
*/
function drop_item(int $id, string $return = '')
function drop_item(int $id, string $return = ''): string
{
// locate item to be deleted
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'];
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
// Locate item to be deleted
$item = Post::selectFirstForUser(local_user(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network');
//NOTREACHED
}
if ($item['deleted']) {
@ -861,6 +859,7 @@ function drop_item(int $id, string $return = '')
Item::deleteForUser(['id' => $item['id']], local_user());
item_redirect_after_action($item, $return);
//NOTREACHED
} else {
Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@ -871,15 +870,15 @@ function drop_item(int $id, string $return = '')
return '';
}
function item_redirect_after_action($item, $returnUrlHex)
function item_redirect_after_action(array $item, string $returnUrlHex)
{
$return_url = hex2bin($returnUrlHex);
// removes update_* from return_url to ignore Ajax refresh
$return_url = str_replace("update_", "", $return_url);
$return_url = str_replace('update_', '', $return_url);
// Check if delete a comment
if ($item['gravity'] == GRAVITY_COMMENT) {
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
if (!empty($item['parent'])) {
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
}

View File

@ -83,12 +83,15 @@ function message_post(App $a)
DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.'));
$norecip = true;
break;
case -2:
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.'));
break;
case -3:
DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.'));
break;
case -4:
DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.'));
break;
@ -192,7 +195,7 @@ function message_content(App $a)
'$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> DI::l10n()->t('Your message:'),
'$yourmessage' => DI::l10n()->t('Your message:'),
'$select' => $select,
'$parent' => '',
'$upload' => DI::l10n()->t('Upload photo'),
@ -341,7 +344,6 @@ function message_content(App $a)
'$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:'),
@ -368,7 +370,7 @@ function message_content(App $a)
* @param int $limit
* @return array
*/
function get_messages(int $uid, int $start, int $limit)
function get_messages(int $uid, int $start, int $limit): array
{
return DBA::toArray(DBA::p('SELECT
m.`id`,
@ -414,7 +416,7 @@ function get_messages(int $uid, int $start, int $limit)
, $uid, $uid, $start, $limit));
}
function render_messages(array $msg, $t)
function render_messages(array $msg, string $t): string
{
$a = DI::app();

View File

@ -38,7 +38,7 @@ function notes_init(App $a)
}
function notes_content(App $a, $update = false)
function notes_content(App $a, bool $update = false)
{
if (!local_user()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@ -60,7 +60,7 @@ function notes_content(App $a, $update = false)
$o .= DI::conversation()->statusEditor($x, $a->getContactId());
}
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
'contact-id'=> $a->getContactId()];
if (DI::mode()->isMobile()) {

View File

@ -20,6 +20,8 @@
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Response;
@ -93,8 +95,8 @@ function oexchange_init(App $a)
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
function oexchange_content(App $a) {
function oexchange_content(App $a)
{
if (!local_user()) {
$o = Login::form();
return $o;
@ -109,7 +111,7 @@ function oexchange_content(App $a) {
$description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : '';
$tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : '';
$s = \Friendica\Content\Text\BBCode::embedURL($url, true, $title, $description, $tags);
$s = BBCode::embedURL($url, true, $title, $description, $tags);
if (!strlen($s)) {
return;
@ -119,9 +121,9 @@ function oexchange_content(App $a) {
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done';
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
$post['body'] = HTML::toBBCode($s);
$_REQUEST = $post;
require_once('mod/item.php');
require_once 'mod/item.php';
item_post($a);
}

View File

@ -27,7 +27,7 @@ use Friendica\Model\Contact;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\ActivityPub;
function ostatus_subscribe_content(App $a)
function ostatus_subscribe_content(App $a): string
{
if (!local_user()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@ -42,7 +42,6 @@ function ostatus_subscribe_content(App $a)
$counter = intval($_REQUEST['counter'] ?? 0);
if (DI::pConfig()->get($uid, 'ostatus', 'legacy_friends') == '') {
if ($_REQUEST['url'] == '') {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('No contact provided.');

View File

@ -55,8 +55,8 @@ use Friendica\Util\Temporal;
use Friendica\Util\XML;
use Friendica\Network\HTTPException;
function photos_init(App $a) {
function photos_init(App $a)
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
@ -526,44 +526,40 @@ function photos_post(App $a)
foreach ($taginfo as $tagged) {
$uri = Item::newURI();
$arr = [];
$arr['guid'] = System::createUUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['wall'] = 1;
$arr['contact-id'] = $owner_record['id'];
$arr['owner-name'] = $owner_record['name'];
$arr['owner-link'] = $owner_record['url'];
$arr['owner-avatar'] = $owner_record['thumb'];
$arr['author-name'] = $owner_record['name'];
$arr['author-link'] = $owner_record['url'];
$arr['author-avatar'] = $owner_record['thumb'];
$arr['title'] = '';
$arr['allow_cid'] = $photo['allow_cid'];
$arr['allow_gid'] = $photo['allow_gid'];
$arr['deny_cid'] = $photo['deny_cid'];
$arr['deny_gid'] = $photo['deny_gid'];
$arr['visible'] = 0;
$arr['verb'] = Activity::TAG;
$arr['gravity'] = GRAVITY_PARENT;
$arr['object-type'] = Activity\ObjectType::PERSON;
$arr['target-type'] = Activity\ObjectType::IMAGE;
$arr['inform'] = $tagged[2];
$arr['origin'] = 1;
$arr['body'] = DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
$arr['body'] .= "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
$arr = [
'guid' => System::createUUID(),
'uid' => $page_owner_uid,
'uri' => $uri,
'wall' => 1,
'contact-id' => $owner_record['id'],
'owner-name' => $owner_record['name'],
'owner-link' => $owner_record['url'],
'owner-avatar' => $owner_record['thumb'],
'author-name' => $owner_record['name'],
'author-link' => $owner_record['url'],
'author-avatar' => $owner_record['thumb'],
'title' => '',
'allow_cid' => $photo['allow_cid'],
'allow_gid' => $photo['allow_gid'],
'deny_cid' => $photo['deny_cid'],
'deny_gid' => $photo['deny_gid'],
'visible' => 0,
'verb' => Activity::TAG,
'gravity' => Item::GRAVITY_PARENT,
'object-type' => Activity\ObjectType::PERSON,
'target-type' => Activity\ObjectType::IMAGE,
'inform' => $tagged[2],
'origin' => 1,
'body' => DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') . "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n",
'object' => '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n"),
'target' => '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>',
];
$arr['object'] = '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
if ($tagged[3]) {
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
}
$arr['object'] .= '</link></object>' . "\n";
$arr['target'] = '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
. DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
Item::insert($arr);
}
}
@ -1233,7 +1229,7 @@ function photos_content(App $a)
$link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]);
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], GRAVITY_COMMENT];
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
$total = Post::count($condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
@ -1404,7 +1400,7 @@ function photos_content(App $a)
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
($item['gravity'] != GRAVITY_PARENT)) {
($item['gravity'] != Item::GRAVITY_PARENT)) {
continue;
}

View File

@ -35,8 +35,8 @@ use Friendica\Protocol\Activity;
use Friendica\Util\XML;
use Friendica\Worker\Delivery;
function tagger_content(App $a) {
function tagger_content(App $a)
{
if (!Session::isAuthenticated()) {
return;
}
@ -116,41 +116,41 @@ EOT;
$termlink = html_entity_decode('&#x2317;') . '[url=' . DI::baseUrl() . '/search?tag=' . $term . ']'. $term . '[/url]';
$arr = [];
$arr['guid'] = System::createUUID();
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr['wall'] = $item['wall'];
$arr['gravity'] = GRAVITY_COMMENT;
$arr['parent'] = $item['id'];
$arr['thr-parent'] = $item['uri'];
$arr['owner-name'] = $item['author-name'];
$arr['owner-link'] = $item['author-link'];
$arr['owner-avatar'] = $item['author-avatar'];
$arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink );
$arr['verb'] = Activity::TAG;
$arr['target-type'] = $targettype;
$arr['target'] = $target;
$arr['object-type'] = $objtype;
$arr['object'] = $obj;
$arr['private'] = $item['private'];
$arr['allow_cid'] = $item['allow_cid'];
$arr['allow_gid'] = $item['allow_gid'];
$arr['deny_cid'] = $item['deny_cid'];
$arr['deny_gid'] = $item['deny_gid'];
$arr['visible'] = 1;
$arr['unseen'] = 1;
$arr['origin'] = 1;
$arr = [
'guid' => System::createUUID(),
'uri' => $uri,
'uid' => $owner_uid,
'contact-id' => $contact['id'],
'wall' => $item['wall'],
'gravity' => Item::GRAVITY_COMMENT,
'parent' => $item['id'],
'thr-parent' => $item['uri'],
'owner-name' => $item['author-name'],
'owner-link' => $item['author-link'],
'owner-avatar' => $item['author-avatar'],
'author-name' => $contact['name'],
'author-link' => $contact['url'],
'author-avatar' => $contact['thumb'],
'body' => sprintf($bodyverb, $ulink, $alink, $plink, $termlink),
'verb' => Activity::TAG,
'target-type' => $targettype,
'target' => $target,
'object-type' => $objtype,
'object' => $obj,
'private' => $item['private'],
'allow_cid' => $item['allow_cid'],
'allow_gid' => $item['allow_gid'],
'deny_cid' => $item['deny_cid'],
'deny_gid' => $item['deny_gid'],
'visible' => 1,
'unseen' => 1,
'origin' => 1,
];
$post_id = Item::insert($arr);

View File

@ -135,7 +135,7 @@ class Conversation
return;
}
if (!empty($activity['verb']) && $this->activity->match($activity['verb'], $verb) && ($activity['gravity'] != GRAVITY_PARENT)) {
if (!empty($activity['verb']) && $this->activity->match($activity['verb'], $verb) && ($activity['gravity'] != ItemModel::GRAVITY_PARENT)) {
$author = [
'uid' => 0,
'id' => $activity['author-id'],
@ -756,7 +756,7 @@ class Conversation
$item['pagedrop'] = $page_dropping;
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == ItemModel::GRAVITY_PARENT) {
$item_object = new PostObject($item);
$conv->addParent($item_object);
}
@ -826,7 +826,7 @@ class Conversation
}
if (!empty($activity)) {
if (($row['gravity'] == GRAVITY_PARENT)) {
if (($row['gravity'] == ItemModel::GRAVITY_PARENT)) {
$row['post-reason'] = ItemModel::PR_ANNOUNCEMENT;
$row = array_merge($row, $activity);
@ -835,7 +835,7 @@ class Conversation
$row['causer-link'] = $contact['url'];
$row['causer-avatar'] = $contact['thumb'];
$row['causer-name'] = $contact['name'];
} elseif (($row['gravity'] == GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
} elseif (($row['gravity'] == ItemModel::GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
($row['author-id'] == $activity['causer-id'])) {
return $row;
}
@ -868,7 +868,7 @@ class Conversation
$row['owner-name'] = $row['causer-name'];
}
if (in_array($row['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) && !empty($row['causer-id'])) {
if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::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>');
@ -942,7 +942,7 @@ class Conversation
$activitycounter = [];
foreach ($parents as $parent) {
if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == GRAVITY_ACTIVITY)) {
if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == ItemModel::GRAVITY_ACTIVITY)) {
$uriid = $parent['thr-parent-id'];
if (!empty($parent['author-id'])) {
$activities[$uriid] = ['causer-id' => $parent['author-id']];
@ -994,10 +994,10 @@ class Conversation
}
if ($max_comments > 0) {
if (($row['gravity'] == GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) {
if (($row['gravity'] == ItemModel::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'] == ItemModel::GRAVITY_ACTIVITY) && (++$activitycounter[$row['parent-uri-id']] > $max_comments)) {
continue;
}
}
@ -1026,7 +1026,7 @@ class Conversation
$this->profiler->startRecording('rendering');
$children = [];
foreach ($item_list as $i => $item) {
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != ItemModel::GRAVITY_PARENT) {
if ($recursive) {
// Fallback to parent-uri if thr-parent is not set
$thr_parent = $item['thr-parent-id'];
@ -1183,7 +1183,7 @@ class Conversation
// Extract the top level items
foreach ($item_array as $item) {
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == ItemModel::GRAVITY_PARENT) {
$parents[] = $item;
}
}

View File

@ -31,7 +31,7 @@ use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item as ModelItem;
use Friendica\Model\Item as ItemModel;
use Friendica\Model\Photo;
use Friendica\Model\Tag;
use Friendica\Model\Post;
@ -331,7 +331,7 @@ class Item
$sub_link = $contact_url = $pm_url = $status_link = '';
$photos_link = $posts_link = $block_link = $ignore_link = '';
if (local_user() && local_user() == $item['uid'] && $item['gravity'] == GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
if (local_user() && local_user() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
}
@ -392,7 +392,7 @@ class Item
];
if (!empty($item['language'])) {
$menu[$this->l10n->t('Languages')] = 'javascript:alert(\'' . ModelItem::getLanguageMessage($item) . '\');';
$menu[$this->l10n->t('Languages')] = 'javascript:alert(\'' . ItemModel::getLanguageMessage($item) . '\');';
}
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
@ -470,7 +470,7 @@ class Item
}
$item['inform'] .= 'cid:' . $contact['id'];
if (($item['gravity'] == GRAVITY_COMMENT) || empty($contact['cid']) || ($contact['contact-type'] != Contact::TYPE_COMMUNITY)) {
if (($item['gravity'] == ItemModel::GRAVITY_COMMENT) || empty($contact['cid']) || ($contact['contact-type'] != Contact::TYPE_COMMUNITY)) {
continue;
}
@ -492,9 +492,9 @@ class Item
}
Logger::info('Got inform', ['inform' => $item['inform']]);
if (($item['gravity'] == GRAVITY_PARENT) && !empty($forum_contact) && ($private_forum || $only_to_forum)) {
if (($item['gravity'] == ItemModel::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['private'] = $private_forum ? ItemModel::PRIVATE : ItemModel::UNLISTED;
if ($only_to_forum) {
$item['postopts'] = '';
@ -510,14 +510,14 @@ class Item
$item['allow_cid'] = '';
$item['allow_gid'] = '';
}
} elseif ($setPermissions && ($item['gravity'] == GRAVITY_PARENT)) {
} elseif ($setPermissions && ($item['gravity'] == ItemModel::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]);
$receivers[] = $self['id'];
}
$item['private'] = ModelItem::PRIVATE;
$item['private'] = ItemModel::PRIVATE;
$item['allow_cid'] = '';
$item['allow_gid'] = '';
$item['deny_cid'] = '';

View File

@ -22,6 +22,7 @@
namespace Friendica\Core;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity;
@ -139,7 +140,7 @@ class Protocol
// create a follow slap
$item = [
'verb' => Activity::FOLLOW,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'follow' => $contact['url'],
'body' => '',
'title' => '',
@ -191,14 +192,16 @@ class Protocol
if (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
// create an unfollow slap
$item = [];
$item['verb'] = Activity::O_UNFOLLOW;
$item['gravity'] = GRAVITY_ACTIVITY;
$item['follow'] = $contact['url'];
$item['body'] = '';
$item['title'] = '';
$item['guid'] = '';
$item['uri-id'] = 0;
$item = [
'verb' => Activity::O_UNFOLLOW,
'gravity' => Item::GRAVITY_ACTIVITY,
'follow' => $contact['url'],
'body' => '',
'title' => '',
'guid' => '',
'uri-id' => 0,
];
$slap = OStatus::salmon($item, $user);
if (empty($contact['notify'])) {

View File

@ -101,10 +101,10 @@ class Renderer
* @param string $file Template to load.
* @param string $subDir Subdirectory (Optional)
*
* @return string template.
* @return string Template
* @throws ServiceUnavailableException
*/
public static function getMarkupTemplate($file, $subDir = '')
public static function getMarkupTemplate(string $file, string $subDir = ''): string
{
DI::profiler()->startRecording('file');
$t = self::getTemplateEngine();
@ -128,9 +128,11 @@ class Renderer
* Register template engine class
*
* @param string $class
*
* @return void
* @throws ServiceUnavailableException
*/
public static function registerTemplateEngine($class)
public static function registerTemplateEngine(string $class)
{
$v = get_class_vars($class);
@ -156,7 +158,7 @@ class Renderer
* @return TemplateEngine Template Engine instance
* @throws ServiceUnavailableException
*/
public static function getTemplateEngine()
public static function getTemplateEngine(): TemplateEngine
{
$template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
@ -185,7 +187,7 @@ class Renderer
*
* @return string the active template engine
*/
public static function getActiveTemplateEngine()
public static function getActiveTemplateEngine(): string
{
return self::$theme['template_engine'];
}
@ -194,8 +196,10 @@ class Renderer
* sets the active template engine
*
* @param string $engine the template engine (default is Smarty3)
*
* @return void
*/
public static function setActiveTemplateEngine($engine = 'smarty3')
public static function setActiveTemplateEngine(string $engine = 'smarty3')
{
self::$theme['template_engine'] = $engine;
}
@ -211,7 +215,7 @@ class Renderer
*
* @return string the right delimiter
*/
public static function getTemplateLeftDelimiter($engine = 'smarty3')
public static function getTemplateLeftDelimiter(string $engine = 'smarty3'): string
{
return self::$ldelim[$engine];
}
@ -227,7 +231,7 @@ class Renderer
*
* @return string the left delimiter
*/
public static function getTemplateRightDelimiter($engine = 'smarty3')
public static function getTemplateRightDelimiter(string $engine = 'smarty3'): string
{
return self::$rdelim[$engine];
}

View File

@ -563,7 +563,7 @@ class PostUpdate
$items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity`
FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id` AND `item`.`gravity` = ?
WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", GRAVITY_ACTIVITY, $id);
WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", Item::GRAVITY_ACTIVITY, $id);
if (DBA::errorNo() != 0) {
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);

View File

@ -23,6 +23,7 @@ namespace Friendica\Factory\Api\Friendica;
use Friendica\BaseFactory;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Activity;
@ -62,7 +63,7 @@ class Activities extends BaseFactory
'announce' => [],
];
$condition = ['uid' => $uid, 'thr-parent-id' => $uriId, 'gravity' => GRAVITY_ACTIVITY];
$condition = ['uid' => $uid, 'thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_ACTIVITY];
$ret = Post::selectForUser($uid, ['author-id', 'verb'], $condition);

View File

@ -25,6 +25,7 @@ use Friendica\App\BaseURL;
use Friendica\BaseFactory;
use Friendica\Database\DBA;
use Friendica\Factory\Api\Twitter\Status;
use Friendica\Model\Item;
use Friendica\Model\Photo as ModelPhoto;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
@ -116,7 +117,7 @@ class Photo extends BaseFactory
// retrieve comments on photo
$condition = ["`parent` = ? AND `uid` = ? AND `gravity` IN (?, ?)",
$item['parent'], $uid, GRAVITY_PARENT, GRAVITY_COMMENT];
$item['parent'], $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT];
$statuses = Post::selectForUser($uid, [], $condition);

View File

@ -24,6 +24,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -69,7 +70,7 @@ class ScheduledStatus extends BaseFactory
$media_attachments[] = DI::mstdnAttachment()->createFromPhoto($id);
}
if (isset($parameters['item']['thr-parent']) && ($parameters['item']['gravity'] ?? GRAVITY_PARENT != GRAVITY_PARENT)) {
if (isset($parameters['item']['thr-parent']) && ($parameters['item']['gravity'] ?? Item::GRAVITY_PARENT != Item::GRAVITY_PARENT)) {
$in_reply_to_id = ItemURI::getIdByURI($parameters['item']['thr-parent']);
} else {
$in_reply_to_id = null;

View File

@ -26,6 +26,7 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Text\BBCode;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag as TagModel;
use Friendica\Model\Verb;
@ -94,19 +95,19 @@ class Status extends BaseFactory
$count_announce = Post::countPosts([
'thr-parent-id' => $uriId,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::ANNOUNCE),
'deleted' => false
], []);
$count_like = Post::countPosts([
'thr-parent-id' => $uriId,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::LIKE),
'deleted' => false
], []);
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => GRAVITY_COMMENT, 'deleted' => false], []),
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false], []),
$count_announce,
$count_like
);
@ -115,7 +116,7 @@ class Status extends BaseFactory
'thr-parent-id' => $uriId,
'uid' => $uid,
'origin' => true,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::LIKE),
'deleted' => false
]);
@ -123,7 +124,7 @@ class Status extends BaseFactory
'thr-parent-id' => $uriId,
'uid' => $uid,
'origin' => true,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::ANNOUNCE),
'deleted' => false
]);
@ -131,7 +132,7 @@ class Status extends BaseFactory
$origin_like,
$origin_announce,
Post\ThreadUser::getIgnored($uriId, $uid),
(bool)($item['starred'] && ($item['gravity'] == GRAVITY_PARENT)),
(bool)($item['starred'] && ($item['gravity'] == Item::GRAVITY_PARENT)),
$item['featured']
);

View File

@ -128,7 +128,7 @@ class Status extends BaseFactory
$owner = $this->twitterUser->createFromContactId($item['owner-id'], $uid, true);
}
$friendica_comments = Post::countPosts(['thr-parent-id' => $item['uri-id'], 'deleted' => false, 'gravity' => GRAVITY_COMMENT]);
$friendica_comments = Post::countPosts(['thr-parent-id' => $item['uri-id'], 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
$text = '';
$title = '';
@ -162,7 +162,7 @@ class Status extends BaseFactory
'thr-parent-id' => $item['uri-id'],
'uid' => $uid,
'origin' => true,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'vid' => Verb::getID(Activity::LIKE),
'deleted' => false
]);

View File

@ -69,7 +69,7 @@ class User extends BaseFactory
if (!$skip_status) {
$post = Post::selectFirstPost(['uri-id'],
['author-id' => $publicContact['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]],
['author-id' => $publicContact['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]],
['order' => ['uri-id' => true]]);
if (!empty($post['uri-id'])) {
$status = $this->status->createFromUriId($post['uri-id'], $uid)->toArray();

View File

@ -28,6 +28,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe;
@ -497,11 +498,11 @@ class APContact
$condition = [
'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);

View File

@ -1506,10 +1506,10 @@ class Contact
if ($thread_mode) {
$condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
$cid, GRAVITY_PARENT, $cid, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()];
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()];
} else {
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, local_user()];
}
if (!empty($parent)) {

View File

@ -26,6 +26,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
@ -105,7 +106,7 @@ class FContact
$interacted = DBA::count('contact-relation', ["`cid` = ? AND NOT `follows` AND `last-interaction` > ?", $contact['id'], $last_interaction]);
$interacting = DBA::count('contact-relation', ["`relation-cid` = ? AND NOT `follows` AND `last-interaction` > ?", $contact['id'], $last_interaction]);
$posts = DBA::count('post', ['author-id' => $contact['id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
$posts = DBA::count('post', ['author-id' => $contact['id'], 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]]);
}
$fields = [

View File

@ -146,6 +146,12 @@ class Item
const PRIVATE = 1;
const UNLISTED = 2;
// Item weight for query ordering
const GRAVITY_PARENT = 0;
const GRAVITY_ACTIVITY = 3;
const GRAVITY_COMMENT = 6;
const GRAVITY_UNKNOWN = 9;
/**
* Update existing item entries
*
@ -356,7 +362,7 @@ class Item
Post\DeliveryData::delete($item['uri-id']);
// If it's the parent of a comment thread, kill all the kids
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
}
@ -463,7 +469,7 @@ class Item
}
}
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
if (Contact::isSharingByURL($item['owner-link'], $item['uid'], true)) {
$contact_id = Contact::getIdForURL($item['owner-link'], $item['uid']);
} else {
@ -714,7 +720,7 @@ class Item
return 0;
}
if ($thread_parent['gravity'] == GRAVITY_PARENT) {
if ($thread_parent['gravity'] == Item::GRAVITY_PARENT) {
return $uriid;
}
@ -791,17 +797,17 @@ class Item
if (isset($item['gravity'])) {
return intval($item['gravity']);
} elseif ($item['parent-uri-id'] === $item['uri-id']) {
return GRAVITY_PARENT;
return self::GRAVITY_PARENT;
} elseif ($activity->match($item['verb'], Activity::POST)) {
return GRAVITY_COMMENT;
return self::GRAVITY_COMMENT;
} elseif ($activity->match($item['verb'], Activity::FOLLOW)) {
return GRAVITY_ACTIVITY;
return self::GRAVITY_ACTIVITY;
} elseif ($activity->match($item['verb'], Activity::ANNOUNCE)) {
return GRAVITY_ACTIVITY;
return self::GRAVITY_ACTIVITY;
}
Logger::info('Unknown gravity for verb', ['verb' => $item['verb']]);
return GRAVITY_UNKNOWN; // Should not happen
return self::GRAVITY_UNKNOWN; // Should not happen
}
/**
@ -965,7 +971,7 @@ class Item
return 0;
}
if ($item['gravity'] !== GRAVITY_PARENT) {
if ($item['gravity'] !== self::GRAVITY_PARENT) {
$toplevel_parent = self::getTopLevelParent($item);
if (empty($toplevel_parent)) {
return 0;
@ -1185,7 +1191,7 @@ class Item
Post::insert($item['uri-id'], $item);
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
Post\Thread::insert($item['uri-id'], $item);
}
@ -1194,7 +1200,7 @@ class Item
}
// Create Diaspora signature
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) {
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != self::GRAVITY_PARENT)) {
$signed = Diaspora::createCommentSignature($item);
if (!empty($signed)) {
$item['diaspora_signed_text'] = json_encode($signed);
@ -1234,7 +1240,7 @@ class Item
return 0;
}
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
$item['post-user-id'] = $post_user_id;
Post\ThreadUser::insert($item['uri-id'], $item['uid'], $item);
}
@ -1252,7 +1258,7 @@ class Item
// update the commented timestamp on the parent
if (DI::config()->get('system', 'like_no_comment')) {
// Update when it is a comment
$update_commented = in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]);
$update_commented = in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]);
} else {
// Update when it isn't a follow or tag verb
$update_commented = !in_array($posted_item['verb'], [Activity::FOLLOW, Activity::TAG]);
@ -1276,7 +1282,7 @@ class Item
}
if ($notify) {
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) {
if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == self::GRAVITY_COMMENT)) {
Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']);
}
Hook::callAll('post_local_end', $posted_item);
@ -1284,7 +1290,7 @@ class Item
Hook::callAll('post_remote_end', $posted_item);
}
if ($posted_item['gravity'] === GRAVITY_PARENT) {
if ($posted_item['gravity'] === self::GRAVITY_PARENT) {
self::addShadow($post_user_id);
} else {
self::addShadowPost($post_user_id);
@ -1319,7 +1325,7 @@ class Item
}
// Fill the cache with the rendered content.
if (in_array($posted_item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) && ($posted_item['uid'] == 0)) {
if (in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]) && ($posted_item['uid'] == 0)) {
self::updateDisplayCache($posted_item['uri-id']);
}
@ -1335,7 +1341,7 @@ class Item
*/
public static function getPostReason(array $item): int
{
$actor = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
$actor = ($item['gravity'] == self::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
if (empty($item['origin']) && ($item['uid'] != 0) && Contact::isSharing($actor, $item['uid'])) {
return self::PR_FOLLOWER;
}
@ -1416,7 +1422,7 @@ class Item
*/
private static function distributeByTags(array $item)
{
if (($item['uid'] != 0) || ($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], Protocol::FEDERATED)) {
if (($item['uid'] != 0) || ($item['gravity'] != self::GRAVITY_PARENT) || !in_array($item['network'], Protocol::FEDERATED)) {
return;
}
@ -1542,7 +1548,7 @@ class Item
return 0;
}
if (($uid != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
if (($uid != 0) && ($item['gravity'] == self::GRAVITY_PARENT)) {
$owner = User::getOwnerDataById($uid);
if (($owner['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY) && !Tag::isMentioned($uri_id, $owner['url'])) {
Logger::info('Target user is a forum but is not mentioned here, thread will not be stored', ['uid' => $uid, 'uri-id' => $uri_id]);
@ -1559,13 +1565,13 @@ class Item
$item = array_merge($item, $fields);
if (($uid != 0) && Contact::isSharing(($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'], $uid)) {
if (($uid != 0) && Contact::isSharing(($item['gravity'] == Item::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'], $uid)) {
$item['post-reason'] = self::PR_FOLLOWER;
}
$is_reshare = ($item['gravity'] == GRAVITY_ACTIVITY) && ($item['verb'] == Activity::ANNOUNCE);
$is_reshare = ($item['gravity'] == self::GRAVITY_ACTIVITY) && ($item['verb'] == Activity::ANNOUNCE);
if (($uid != 0) && (($item['gravity'] == GRAVITY_PARENT) || $is_reshare) &&
if (($uid != 0) && (($item['gravity'] == self::GRAVITY_PARENT) || $is_reshare) &&
DI::pConfig()->get($uid, 'system', 'accept_only_sharer') == self::COMPLETION_NONE &&
!in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC])) {
Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
@ -1574,7 +1580,7 @@ class Item
$causer = $item['causer-id'] ?: $item['author-id'];
if (($uri_id != $item['parent-uri-id']) && ($item['gravity'] == GRAVITY_COMMENT) && !Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) {
if (($uri_id != $item['parent-uri-id']) && ($item['gravity'] == self::GRAVITY_COMMENT) && !Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) {
if (!self::fetchParent($item['parent-uri-id'], $uid, $causer)) {
Logger::info('Parent post had not been added', ['uri-id' => $item['parent-uri-id'], 'uid' => $uid, 'causer' => $causer]);
return 0;
@ -1715,7 +1721,7 @@ class Item
$item['contact-id'] = self::contactId($item);
$notify = false;
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
if (DBA::isResult($contact)) {
$notify = self::isRemoteSelf($contact, $item);
@ -1745,7 +1751,7 @@ class Item
private static function addShadow(int $itemid)
{
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
$condition = ['id' => $itemid, 'gravity' => GRAVITY_PARENT];
$condition = ['id' => $itemid, 'gravity' => self::GRAVITY_PARENT];
$item = Post::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
@ -1813,7 +1819,7 @@ class Item
}
// Is it a toplevel post?
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
self::addShadow($itemid);
return;
}
@ -1875,7 +1881,7 @@ class Item
return $item['language'];
}
if (!in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) || empty($item['body'])) {
if (!in_array($item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT]) || empty($item['body'])) {
return '';
}
@ -2155,13 +2161,13 @@ class Item
return false;
}
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'origin' => false]);
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id, 'gravity' => [self::GRAVITY_PARENT, self::GRAVITY_COMMENT], 'origin' => false]);
if (!DBA::isResult($item)) {
Logger::debug('Post is an activity or origin or not found at all, quitting here.', ['id' => $item_id]);
return false;
}
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == self::GRAVITY_PARENT) {
if (Tag::isMentioned($item['uri-id'], $owner['url'])) {
Logger::info('Mention found in tag.', ['uri' => $item['uri'], 'uid' => $uid, 'id' => $item_id, 'uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
} else {
@ -2206,7 +2212,7 @@ class Item
*/
private static function autoReshare(array $item)
{
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != self::GRAVITY_PARENT) {
return;
}
@ -2467,7 +2473,7 @@ class Item
}
$condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
$uid, GRAVITY_PARENT];
$uid, self::GRAVITY_PARENT];
/*
* $expire_network_only = save your own wall posts
@ -2674,7 +2680,7 @@ class Item
$vids = Verb::getID($activity);
}
$condition = ['vid' => $vids, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY,
$condition = ['vid' => $vids, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
'author-id' => $author_id, 'uid' => $item['uid'], 'thr-parent-id' => $uri_id];
$like_item = Post::selectFirst(['id', 'guid', 'verb'], $condition);
@ -2728,7 +2734,7 @@ class Item
'network' => Protocol::DFRN,
'protocol' => Conversation::PARCEL_DIRECT,
'direction' => Conversation::PUSH,
'gravity' => GRAVITY_ACTIVITY,
'gravity' => self::GRAVITY_ACTIVITY,
'parent' => $item['id'],
'thr-parent' => $item['uri'],
'owner-id' => $author_id,
@ -2853,9 +2859,9 @@ class Item
return $l10n->t('event');
} elseif (!empty($item['resource-id'])) {
return $l10n->t('photo');
} elseif ($item['gravity'] == GRAVITY_ACTIVITY) {
} elseif ($item['gravity'] == self::GRAVITY_ACTIVITY) {
return $l10n->t('activity');
} elseif ($item['gravity'] == GRAVITY_COMMENT) {
} elseif ($item['gravity'] == self::GRAVITY_COMMENT) {
return $l10n->t('comment');
}
@ -3627,7 +3633,7 @@ class Item
return false;
}
if (!empty($item['causer-id']) && ($item['gravity'] === GRAVITY_PARENT) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
if (!empty($item['causer-id']) && ($item['gravity'] === self::GRAVITY_PARENT) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
Logger::notice('Causer is ignored by user', ['causer-link' => $item['causer-link'] ?? $item['causer-id'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
return false;
}

View File

@ -25,6 +25,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use stdClass;
/**
@ -62,7 +63,7 @@ class Nodeinfo
$logger->info('user statistics', $userStats);
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", GRAVITY_COMMENT]);
$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);

View File

@ -28,6 +28,7 @@ use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Protocol\Activity;
class Post
@ -405,7 +406,7 @@ class Post
AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked`)
AND NOT (`gravity` = ? AND `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored`))
AND NOT (`gravity` = ? AND `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored`))",
0, Contact::SHARING, Contact::FRIEND, GRAVITY_PARENT, 0, $uid, $uid, $uid, GRAVITY_PARENT, $uid, GRAVITY_PARENT, $uid]);
0, Contact::SHARING, Contact::FRIEND, Item::GRAVITY_PARENT, 0, $uid, $uid, $uid, Item::GRAVITY_PARENT, $uid, Item::GRAVITY_PARENT, $uid]);
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
@ -520,7 +521,7 @@ class Post
unset($fields['parent-uri']);
unset($fields['parent-uri-id']);
$thread_condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$thread_condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
// To ensure the data integrity we do it in an transaction
DBA::transaction();

View File

@ -30,6 +30,7 @@ use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Subscription;
use Friendica\Model\Tag;
@ -288,7 +289,7 @@ class UserNotification
}
// Only create notifications for posts and comments, not for activities
if (($item['gravity'] == GRAVITY_ACTIVITY) && ($item['verb'] != Activity::ANNOUNCE)) {
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($item['verb'] != Activity::ANNOUNCE)) {
return;
}
@ -310,7 +311,7 @@ class UserNotification
*/
private static function insertNotificationByItem(int $type, int $uid, array $item): void
{
if (($item['verb'] != Activity::ANNOUNCE) && ($item['gravity'] == GRAVITY_ACTIVITY) &&
if (($item['verb'] != Activity::ANNOUNCE) && ($item['gravity'] == Item::GRAVITY_ACTIVITY) &&
!in_array($type, [self::TYPE_DIRECT_COMMENT, self::TYPE_DIRECT_THREAD_COMMENT])) {
// Activities are only stored when performed on the user's post or comment
return;
@ -321,7 +322,7 @@ class UserNotification
$item['vid'],
$type,
$item['author-id'],
$item['gravity'] == GRAVITY_ACTIVITY ? $item['thr-parent-id'] : $item['uri-id'],
$item['gravity'] == Item::GRAVITY_ACTIVITY ? $item['thr-parent-id'] : $item['uri-id'],
$item['parent-uri-id']
);
@ -423,14 +424,14 @@ class UserNotification
private static function checkShared(array $item, int $uid): bool
{
// Only check on original posts and reshare ("announce") activities, otherwise return
if (($item['gravity'] != GRAVITY_PARENT) && ($item['verb'] != Activity::ANNOUNCE)) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['verb'] != Activity::ANNOUNCE)) {
return false;
}
// Don't notify about reshares by communities of our own posts or each time someone comments
if (($item['verb'] == Activity::ANNOUNCE) && DBA::exists('contact', ['id' => $item['contact-id'], 'contact-type' => Contact::TYPE_COMMUNITY])) {
$post = Post::selectFirst(['origin', 'gravity'], ['uri-id' => $item['thr-parent-id'], 'uid' => $uid]);
if ($post['origin'] || ($post['gravity'] != GRAVITY_PARENT)) {
if ($post['origin'] || ($post['gravity'] != Item::GRAVITY_PARENT)) {
return false;
}
}
@ -497,7 +498,7 @@ class UserNotification
*/
private static function checkCommentedThread(array $item, array $contacts): bool
{
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_PARENT];
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_PARENT];
return Post::exists($condition);
}
@ -511,7 +512,7 @@ class UserNotification
*/
private static function checkDirectComment(array $item, array $contacts): bool
{
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_COMMENT];
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT];
return Post::exists($condition);
}
@ -525,7 +526,7 @@ class UserNotification
*/
private static function checkDirectCommentedThread(array $item, array $contacts): bool
{
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_PARENT];
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_PARENT];
return Post::exists($condition);
}
@ -539,7 +540,7 @@ class UserNotification
*/
private static function checkCommentedParticipation(array $item, array $contacts): bool
{
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_COMMENT];
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_COMMENT];
return Post::exists($condition);
}
@ -553,7 +554,7 @@ class UserNotification
*/
private static function checkFollowParticipation(array $item, array $contacts): bool
{
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::FOLLOW];
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::FOLLOW];
return Post::exists($condition);
}
@ -567,7 +568,7 @@ class UserNotification
*/
private static function checkActivityParticipation(array $item, array $contacts): bool
{
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_ACTIVITY];
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => Item::GRAVITY_ACTIVITY];
return Post::exists($condition);
}
}

View File

@ -97,7 +97,7 @@ class Objects extends BaseModule
$last_modified = $item['changed'];
Network::checkEtagModified($etag, $last_modified);
if (empty($this->parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
if (empty($this->parameters['activity']) && ($item['gravity'] != Item::GRAVITY_ACTIVITY)) {
$activity = ActivityPub\Transmitter::createCachedActivityFromItem($item['id'], false, true);
if (empty($activity['type'])) {
throw new HTTPException\NotFoundException();

View File

@ -26,6 +26,7 @@ use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException\BadRequestException;
@ -69,7 +70,7 @@ class Conversation extends BaseApi
$id = $parent['id'];
$condition = ["`parent` = ? AND `uid` IN (0, ?) AND `gravity` IN (?, ?) AND `uri-id` > ?",
$id, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
$id, $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `uri-id` <= ?";

View File

@ -78,7 +78,7 @@ class Statuses extends BaseApi
if (!$request['pinned']) {
$condition = DBA::mergeConditions($condition, ["(`gravity` IN (?, ?) OR (`gravity` = ? AND `vid` = ?))",
GRAVITY_PARENT, GRAVITY_COMMENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]);
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE)]);
}
if ($request['only_media']) {
@ -100,7 +100,7 @@ class Statuses extends BaseApi
}
if ($request['exclude_replies']) {
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if ($request['pinned']) {

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
@ -51,7 +52,7 @@ class Favourited extends BaseApi
$params = ['order' => ['thr-parent-id' => true], 'limit' => $request['limit']];
$condition = ['gravity' => GRAVITY_ACTIVITY, 'origin' => true, 'verb' => Activity::LIKE, 'uid' => $uid];
$condition = ['gravity' => Item::GRAVITY_ACTIVITY, 'origin' => true, 'verb' => Activity::LIKE, 'uid' => $uid];
if (!empty($request['max_id'])) {
$condition = DBA::mergeConditions($condition, ["`thr-parent-id` < ?", $request['max_id']]);

View File

@ -152,13 +152,13 @@ class Statuses extends BaseApi
$parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_id'], 'uid' => [0, $uid]]);
$item['thr-parent'] = $parent['uri'];
$item['gravity'] = GRAVITY_COMMENT;
$item['gravity'] = Item::GRAVITY_COMMENT;
$item['object-type'] = Activity\ObjectType::COMMENT;
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
} else {
self::checkThrottleLimit();
$item['gravity'] = GRAVITY_PARENT;
$item['gravity'] = Item::GRAVITY_PARENT;
$item['object-type'] = Activity\ObjectType::NOTE;
$item['title'] = $request['spoiler_text'];
}

View File

@ -47,7 +47,7 @@ class Bookmark extends BaseApi
DI::mstdnError()->RecordNotFound();
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
}

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
@ -55,7 +56,7 @@ class Context extends BaseApi
$parent = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
if (DBA::isResult($parent)) {
$posts = Post::selectPosts(['uri-id', 'thr-parent-id'],
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]]);
while ($post = Post::fetch($posts)) {
if ($post['uri-id'] == $post['thr-parent-id']) {
continue;

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Protocol\Activity;
@ -48,7 +49,7 @@ class FavouritedBy extends BaseApi
DI::mstdnError()->RecordNotFound();
}
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::LIKE]);
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE]);
$accounts = [];

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
@ -46,7 +47,7 @@ class Mute extends BaseApi
DI::mstdnError()->RecordNotFound();
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
}

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Protocol\Activity;
@ -48,7 +49,7 @@ class RebloggedBy extends BaseApi
DI::mstdnError()->RecordNotFound();
}
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
$accounts = [];

View File

@ -47,7 +47,7 @@ class Unbookmark extends BaseApi
DI::mstdnError()->RecordNotFound();
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
}

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
@ -46,7 +47,7 @@ class Unmute extends BaseApi
DI::mstdnError()->RecordNotFound();
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
}

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Timelines;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
@ -55,7 +56,7 @@ class Home extends BaseApi
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
$condition = ['gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'uid' => $uid];
$condition = ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'uid' => $uid];
if ($request['local']) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
@ -85,7 +86,7 @@ class Home extends BaseApi
}
if ($request['exclude_replies']) {
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Timelines;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
@ -60,7 +61,7 @@ class ListTimeline extends BaseApi
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)",
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $this->parameters['id']];
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $this->parameters['id']];
if (!empty($request['max_id'])) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);
@ -82,7 +83,7 @@ class ListTimeline extends BaseApi
}
if ($request['exclude_replies']) {
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if ($request['local']) {

View File

@ -57,7 +57,7 @@ class PublicTimeline extends BaseApi
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
$condition = ['gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => Item::PUBLIC,
$condition = ['gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'private' => Item::PUBLIC,
'network' => Protocol::FEDERATED, 'parent-author-blocked' => false, 'parent-author-hidden' => false];
if ($request['local']) {
@ -87,7 +87,7 @@ class PublicTimeline extends BaseApi
}
if ($request['exclude_replies']) {
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if (!empty($uid)) {

View File

@ -25,6 +25,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
@ -85,7 +86,7 @@ class Tag extends BaseApi
}
if ($request['exclude_replies']) {
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
}
if (!empty($request['max_id'])) {

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
@ -54,7 +55,7 @@ class Favorites extends BaseApi
$start = max(0, ($page - 1) * $count);
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ? AND `starred`",
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
$params = ['order' => ['uri-id' => true], 'limit' => [$start, $count]];

View File

@ -26,10 +26,11 @@ use Friendica\Core\L10n;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Factory\Api\Twitter\Status as TwitterStatus;
use Friendica\Module\BaseApi;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\Api\ApiResponse;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
@ -77,7 +78,7 @@ class Statuses extends BaseApi
$groups = $this->dba->selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
$gids = array_column($groups, 'contact-id');
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
$condition = ['uid' => $uid, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'contact-id' => $gids];
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
if ($max_id > 0) {
@ -86,7 +87,7 @@ class Statuses extends BaseApi
}
if ($exclude_replies) {
$condition[0] .= ' AND `gravity` = ?';
$condition[] = GRAVITY_PARENT;
$condition[] = Item::GRAVITY_PARENT;
}
if ($conversation_id > 0) {
$condition[0] .= " AND `parent-uri-id` = ?";

View File

@ -78,13 +78,13 @@ class Tweets extends BaseApi
$condition = ['uri-id' => $uriids];
if ($exclude_replies) {
$condition['gravity'] = GRAVITY_PARENT;
$condition['gravity'] = Item::GRAVITY_PARENT;
}
$params['group_by'] = ['uri-id'];
} else {
$condition = ["`uri-id` > ?
" . ($exclude_replies ? " AND `gravity` = " . GRAVITY_PARENT : ' ') . "
" . ($exclude_replies ? " AND `gravity` = " . Item::GRAVITY_PARENT : ' ') . "
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`))
AND `body` LIKE CONCAT('%',?,'%')",
$since_id, $uid, $_REQUEST['q']];

View File

@ -54,7 +54,7 @@ class HomeTimeline extends BaseApi
$start = max(0, ($page - 1) * $count);
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `uri-id` > ?",
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id];
$uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id];
if ($max_id > 0) {
$condition[0] .= " AND `uri-id` <= ?";
@ -62,7 +62,7 @@ class HomeTimeline extends BaseApi
}
if ($exclude_replies) {
$condition[0] .= ' AND `gravity` = ?';
$condition[] = GRAVITY_PARENT;
$condition[] = Item::GRAVITY_PARENT;
}
if ($conversation_id > 0) {
$condition[0] .= " AND `parent-uri-id` = ?";

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Contact;
use Friendica\Model\Post;
@ -55,7 +56,7 @@ class Mentions extends BaseApi
AND (`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `uri-id` > ?";
$condition = [
GRAVITY_PARENT, GRAVITY_COMMENT,
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
$uid,
Post\UserNotification::TYPE_EXPLICIT_TAGGED | Post\UserNotification::TYPE_IMPLICIT_TAGGED |
Post\UserNotification::TYPE_THREAD_COMMENT | Post\UserNotification::TYPE_DIRECT_COMMENT |

View File

@ -47,7 +47,7 @@ class NetworkPublicTimeline extends BaseApi
$start = max(0, ($page - 1) * $count);
$condition = ["`uid` = 0 AND `gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ?",
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, Item::PUBLIC];
if ($max_id > 0) {
$condition[0] .= " AND `uri-id` <= ?";

View File

@ -53,7 +53,7 @@ class PublicTimeline extends BaseApi
if ($exclude_replies && !$conversation_id) {
$condition = ["`gravity` = ? AND `uri-id` > ? AND `private` = ? AND `wall` AND NOT `author-hidden`",
GRAVITY_PARENT, $since_id, Item::PUBLIC];
Item::GRAVITY_PARENT, $since_id, Item::PUBLIC];
if ($max_id > 0) {
$condition[0] .= " AND `uri-id` <= ?";
@ -64,7 +64,7 @@ class PublicTimeline extends BaseApi
$statuses = Post::selectForUser($uid, [], $condition, $params);
} else {
$condition = ["`gravity` IN (?, ?) AND `uri-id` > ? AND `private` = ? AND `wall` AND `origin` AND NOT `author-hidden`",
GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, Item::PUBLIC];
Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, Item::PUBLIC];
if ($max_id > 0) {
$condition[0] .= " AND `uri-id` <= ?";

View File

@ -26,6 +26,7 @@ use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException\BadRequestException;
@ -60,10 +61,10 @@ class Show extends BaseApi
$item_id = $item['id'];
if ($conversation) {
$condition = ['parent' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$condition = ['parent' => $item_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]];
$params = ['order' => ['uri-id' => true]];
} else {
$condition = ['id' => $item_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
$condition = ['id' => $item_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]];
$params = [];
}

View File

@ -113,12 +113,12 @@ class Update extends BaseApi
$parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_status_id'], 'uid' => [0, $uid]]);
$item['thr-parent'] = $parent['uri'];
$item['gravity'] = GRAVITY_COMMENT;
$item['gravity'] = Item::GRAVITY_COMMENT;
$item['object-type'] = Activity\ObjectType::COMMENT;
} else {
self::checkThrottleLimit();
$item['gravity'] = GRAVITY_PARENT;
$item['gravity'] = Item::GRAVITY_PARENT;
$item['object-type'] = Activity\ObjectType::NOTE;
}

View File

@ -23,10 +23,11 @@ namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseApi;
/**
* Returns the most recent statuses posted by the user.
@ -54,11 +55,11 @@ class UserTimeline extends BaseApi
$start = max(0, ($page - 1) * $count);
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`)) AND `gravity` IN (?, ?) AND `uri-id` > ? AND `author-id` = ?",
0, $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $since_id, $cid];
0, $uid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, $since_id, $cid];
if ($exclude_replies) {
$condition[0] .= ' AND `gravity` = ?';
$condition[] = GRAVITY_PARENT;
$condition[] = Item::GRAVITY_PARENT;
}
if ($conversation_id > 0) {

View File

@ -29,6 +29,7 @@ use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\Api\ApiResponse;
@ -233,7 +234,7 @@ class BaseApi extends BaseModule
if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_day = Post::countThread($condition);
if ($posts_day > $throttle_day) {
@ -249,7 +250,7 @@ class BaseApi extends BaseModule
if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_week = Post::countThread($condition);
if ($posts_week > $throttle_week) {
@ -265,7 +266,7 @@ class BaseApi extends BaseModule
if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_month = Post::countThread($condition);
if ($posts_month > $throttle_month) {

View File

@ -414,7 +414,7 @@ class Network extends BaseModule
} elseif (self::$forumContactId) {
$conditionStrings = DBA::mergeConditions($conditionStrings,
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
self::$forumContactId, self::$forumContactId, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
}
// Currently only the order modes "received" and "commented" are in use

View File

@ -49,7 +49,7 @@ class Fetch extends BaseModule
// Fetch the item
$condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid,
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Post::selectFirst([], $condition);
if (empty($item)) {
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
@ -76,7 +76,7 @@ class Fetch extends BaseModule
throw new HTTPException\NotFoundException();
}
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == Item::GRAVITY_PARENT) {
$status = Diaspora::buildStatus($item, $user);
} else {
$status = ['type' => 'comment', 'message' => Diaspora::createCommentSignature($item)];

View File

@ -25,6 +25,7 @@ use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
@ -49,7 +50,7 @@ class Ignore extends BaseModule
$dba = DI::dba();
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => GRAVITY_PARENT]);
$thread = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId, 'gravity' => Item::GRAVITY_PARENT]);
if (!$dba->isResult($thread)) {
throw new HTTPException\NotFoundException();
}

View File

@ -176,7 +176,7 @@ class Status extends BaseProfile
$condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR
(`gravity` = ? AND `vid` = ? AND `origin`
AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? AND `network` = ?)))",
GRAVITY_PARENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), GRAVITY_PARENT, Protocol::ACTIVITYPUB]);
GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB]);
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
'visible' => true, 'deleted' => false]);

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Update;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\Conversation\Network as NetworkModule;
@ -55,7 +56,7 @@ class Network extends NetworkModule
} elseif (self::$order === 'received') {
// Only load new toplevel posts
$conditionFields['unseen'] = true;
$conditionFields['gravity'] = GRAVITY_PARENT;
$conditionFields['gravity'] = Item::GRAVITY_PARENT;
} else {
// Load all unseen items
$conditionFields['unseen'] = true;

View File

@ -72,7 +72,7 @@ class Profile extends BaseModule
$condition = ["`uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
AND `wall` " . $sql_extra, $a->getProfileOwner(), GRAVITY_ACTIVITY];
AND `wall` " . $sql_extra, $a->getProfileOwner(), Item::GRAVITY_ACTIVITY];
if ($_GET['force'] && !empty($_GET['item'])) {
// When the parent is provided, we only fetch this

View File

@ -29,6 +29,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\BaseNotifications;
use Friendica\Navigation\Notifications\Collection\FormattedNotifies;
@ -363,13 +364,13 @@ class FormattedNotify extends BaseFactory
$item['author-avatar'] = $item['contact-avatar'];
}
$item['label'] = (($item['gravity'] == GRAVITY_PARENT) ? 'post' : 'comment');
$item['label'] = (($item['gravity'] == Item::GRAVITY_PARENT) ? 'post' : 'comment');
$item['link'] = $this->baseUrl->get(true) . '/display/' . $item['parent-guid'];
$item['image'] = $item['author-avatar'];
$item['url'] = $item['author-link'];
$item['when'] = DateTimeFormat::local($item['created'], 'r');
$item['ago'] = Temporal::getRelativeDate($item['created']);
$item['text'] = (($item['gravity'] == GRAVITY_PARENT)
$item['text'] = (($item['gravity'] == Item::GRAVITY_PARENT)
? $this->l10n->t("%s created a new post", $item['author-name'])
: $this->l10n->t("%s commented on %s's post", $item['author-name'], $item['parent-author-name']));

View File

@ -23,6 +23,7 @@ namespace Friendica\Object\Api\Mastodon;
use Friendica\BaseDataTransferObject;
use Friendica\Content\Text\BBCode;
use Friendica\Model\Item;
use Friendica\Object\Api\Mastodon\Status\Counts;
use Friendica\Object\Api\Mastodon\Status\UserAttributes;
use Friendica\Util\DateTimeFormat;
@ -102,7 +103,7 @@ class Status extends BaseDataTransferObject
$this->id = (string)$item['uri-id'];
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
if ($item['gravity'] == GRAVITY_COMMENT) {
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
$this->in_reply_to_id = (string)$item['thr-parent-id'];
$this->in_reply_to_account_id = (string)$item['parent-author-id'];
}

View File

@ -106,7 +106,7 @@ class Status extends BaseDataTransferObject
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::API);
if ($item['gravity'] == GRAVITY_COMMENT) {
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
$this->in_reply_to_status_id = (int)$item['thr-parent-id'];
$this->in_reply_to_status_id_str = (string)$item['thr-parent-id'];
$this->in_reply_to_user_id = (int)$item['parent-author-id'];

View File

@ -210,7 +210,7 @@ class Post
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
// On Diaspora only toplevel posts can be reshared
if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != GRAVITY_PARENT)) {
if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
$announceable = false;
}
@ -915,7 +915,7 @@ class Post
return $text;
}
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != Item::GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
$text .= '@' . $item['author-addr'] . ' ';
}

View File

@ -308,10 +308,10 @@ class Processor
$item['thr-parent'] = $activity['reply-to-id'];
if ($activity['reply-to-id'] == $activity['id']) {
$item['gravity'] = GRAVITY_PARENT;
$item['gravity'] = Item::GRAVITY_PARENT;
$item['object-type'] = Activity\ObjectType::NOTE;
} else {
$item['gravity'] = GRAVITY_COMMENT;
$item['gravity'] = Item::GRAVITY_COMMENT;
$item['object-type'] = Activity\ObjectType::COMMENT;
}
@ -356,7 +356,7 @@ class Processor
$item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
if (empty($conversation) && empty($activity['directmessage']) && ($item['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['uri' => $item['thr-parent']])) {
Logger::notice('Parent not found, message will be discarded.', ['thr-parent' => $item['thr-parent']]);
if (!$fetch_parents) {
Queue::remove($activity);
@ -663,7 +663,7 @@ class Processor
$item['verb'] = $verb;
$item['thr-parent'] = $activity['object_id'];
$item['gravity'] = GRAVITY_ACTIVITY;
$item['gravity'] = Item::GRAVITY_ACTIVITY;
unset($item['post-type']);
$item['object-type'] = Activity\ObjectType::NOTE;
@ -833,7 +833,7 @@ class Processor
$item['body'] = Item::improveSharedDataInBody($item);
} else {
$parent_uri = $item['parent-uri'] ?? $item['thr-parent'];
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
if (empty($activity['directmessage']) && ($parent_uri != $item['uri']) && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
$parent = Post::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $parent_uri]);
if (!DBA::isResult($parent)) {
Logger::warning('Unknown parent item.', ['uri' => $parent_uri]);
@ -937,7 +937,7 @@ class Processor
return true;
}
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
// We cannot reliably check at this point if a comment or activity belongs to an accepted post or needs to be fetched
// This can possibly be improved in the future.
Logger::debug('Message is no parent - accepted', ['uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'url' => $item['uri']]);
@ -1035,7 +1035,7 @@ class Processor
// When a post arrives via a relay and we follow the author, we have to override the causer.
// Otherwise the system assumes that we follow the relay. (See "addRowInformation")
Logger::debug('Relay post for follower', ['receiver' => $receiver, 'guid' => $item['guid'], 'relay' => $activity['from-relay']]);
$item['causer-id'] = ($item['gravity'] == GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
$item['causer-id'] = ($item['gravity'] == Item::GRAVITY_PARENT) ? $item['owner-id'] : $item['author-id'];
}
if ($item['isForum'] ?? false) {
@ -1053,7 +1053,7 @@ class Processor
continue;
}
if (($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
if (($receiver != 0) && ($item['gravity'] == Item::GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
if (!($item['isForum'] ?? false)) {
if ($item['post-reason'] == Item::PR_BCC) {
Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id'], 'url' => $item['uri']]);
@ -1088,7 +1088,7 @@ class Processor
continue;
}
if (($item['gravity'] != GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
if (($item['gravity'] != Item::GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) {
$event_id = self::createEvent($activity, $item);
$item = Event::getItemArrayForImportedId($event_id, $item);
@ -1118,7 +1118,7 @@ class Processor
}
// Store send a follow request for every reshare - but only when the item had been stored
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
if ($stored && ($item['private'] != Item::PRIVATE) && ($item['gravity'] == Item::GRAVITY_PARENT) && !empty($item['author-link']) && ($item['author-link'] != $item['owner-link'])) {
$author = APContact::getByURL($item['owner-link'], false);
// We send automatic follow requests for reshared messages. (We don't need though for forum posts)
if ($author['type'] != 'Group') {
@ -1138,7 +1138,7 @@ class Processor
*/
private static function hasParents(array $item, int $receiver)
{
if (($receiver == 0) || ($item['gravity'] == GRAVITY_PARENT)) {
if (($receiver == 0) || ($item['gravity'] == Item::GRAVITY_PARENT)) {
return true;
}
@ -1149,7 +1149,7 @@ class Processor
if ($item['verb'] != Activity::ANNOUNCE) {
switch (DI::pConfig()->get($receiver, 'system', 'accept_only_sharer')) {
case Item::COMPLETION_COMMENT:
$add_parent = ($item['gravity'] != GRAVITY_ACTIVITY);
$add_parent = ($item['gravity'] != Item::GRAVITY_ACTIVITY);
break;
case Item::COMPLETION_NONE:
@ -1283,7 +1283,7 @@ class Processor
*/
private static function postMail(array $activity, array $item)
{
if (($item['gravity'] != GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
return false;
}
@ -1859,7 +1859,7 @@ class Processor
return;
}
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => GRAVITY_ACTIVITY]);
Item::markForDeletion(['uri' => $activity['object_id'], 'author-id' => $author_id, 'gravity' => Item::GRAVITY_ACTIVITY]);
Queue::remove($activity);
}

View File

@ -264,7 +264,7 @@ class Receiver
}
}
if (Post::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
if (Post::exists(['uri' => $object_id, 'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]])) {
// We just assume "note" since it doesn't make a difference for the further processing
return 'as:Note';
}

View File

@ -268,7 +268,7 @@ class Transmitter
$condition = array_merge($condition, [
'uid' => $owner['uid'],
'author-id' => Contact::getIdForURL($owner['url'], 0, false),
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
'network' => Protocol::FEDERATED,
'parent-network' => Protocol::FEDERATED,
'origin' => true,
@ -353,7 +353,7 @@ class Transmitter
'uid' => $owner['uid'],
'author-id' => $owner_cid,
'private' => [Item::PUBLIC, Item::UNLISTED],
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
'network' => Protocol::FEDERATED,
'parent-network' => Protocol::FEDERATED,
'origin' => true,
@ -579,7 +579,7 @@ class Transmitter
$item_profile = APContact::getByURL($item['author-link']);
$exclude[] = $item['author-link'];
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == Item::GRAVITY_PARENT) {
$exclude[] = $item['owner-link'];
}
@ -667,7 +667,7 @@ class Transmitter
$data = ['to' => [], 'cc' => [], 'bcc' => []];
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == Item::GRAVITY_PARENT) {
$actor_profile = APContact::getByURL($item['owner-link']);
} else {
$actor_profile = APContact::getByURL($item['author-link']);
@ -755,10 +755,10 @@ class Transmitter
if (!empty($item['parent'])) {
$parents = Post::select(['id', 'author-link', 'owner-link', 'gravity', 'uri'], ['parent' => $item['parent']], ['order' => ['id']]);
while ($parent = Post::fetch($parents)) {
if ($parent['gravity'] == GRAVITY_PARENT) {
if ($parent['gravity'] == Item::GRAVITY_PARENT) {
$profile = APContact::getByURL($parent['owner-link'], false);
if (!empty($profile)) {
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
// Comments to forums are directed to the forum
// But comments to forums aren't directed to the followers collection
// This rule is only valid when the actor isn't the forum.
@ -973,7 +973,7 @@ class Transmitter
$inboxes = [];
if ($item['gravity'] == GRAVITY_ACTIVITY) {
if ($item['gravity'] == Item::GRAVITY_ACTIVITY) {
$item_profile = APContact::getByURL($item['author-link'], false);
} else {
$item_profile = APContact::getByURL($item['owner-link'], false);
@ -1062,7 +1062,7 @@ class Transmitter
$mail['parent-uri'] = $reply['uri'];
$mail['parent-uri-id'] = $reply['uri-id'];
$mail['parent-author-id'] = Contact::getIdForURL($reply['from-url'], 0, false);
$mail['gravity'] = ($mail['reply'] ? GRAVITY_COMMENT: GRAVITY_PARENT);
$mail['gravity'] = ($mail['reply'] ? Item::GRAVITY_COMMENT: Item::GRAVITY_PARENT);
$mail['event-type'] = '';
$mail['language'] = '';
$mail['parent'] = 0;
@ -1247,7 +1247,7 @@ class Transmitter
if (!$object_mode) {
$data = ['@context' => $context ?? ActivityPub::CONTEXT];
if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
if ($item['deleted'] && ($item['gravity'] == Item::GRAVITY_ACTIVITY)) {
$type = 'Undo';
} elseif ($item['deleted']) {
$type = 'Delete';
@ -1258,7 +1258,7 @@ class Transmitter
if ($type == 'Delete') {
$data['id'] = Item::newURI($item['guid']) . '/' . $type;;
} elseif (($item['gravity'] == GRAVITY_ACTIVITY) && ($type != 'Undo')) {
} elseif (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($type != 'Undo')) {
$data['id'] = $item['uri'];
} else {
$data['id'] = $item['uri'] . '/' . $type;
@ -1266,7 +1266,7 @@ class Transmitter
$data['type'] = $type;
if (($type != 'Announce') || ($item['gravity'] != GRAVITY_PARENT)) {
if (($type != 'Announce') || ($item['gravity'] != Item::GRAVITY_PARENT)) {
$data['actor'] = $item['author-link'];
} else {
$data['actor'] = $item['owner-link'];
@ -1559,7 +1559,7 @@ class Transmitter
// We are treating posts differently when they are directed to a community.
// This is done to better support Lemmy. Most of the changes should work with other systems as well.
// But to not risk compatibility issues we currently perform the changes only for communities.
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == Item::GRAVITY_PARENT) {
$isCommunityPost = !empty(Tag::getByURIId($item['uri-id'], [Tag::EXCLUSIVE_MENTION]));
$links = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
if ($isCommunityPost && (count($links) == 1)) {

View File

@ -800,7 +800,7 @@ class DFRN
$dfrnowner = self::addEntryAuthor($doc, "dfrn:owner", $item["owner-link"], $item);
$entry->appendChild($dfrnowner);
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
if (DBA::isResult($parent)) {
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
@ -889,7 +889,7 @@ class DFRN
if ($item['object-type'] != '') {
XML::addElement($doc, $entry, 'activity:object-type', $item['object-type']);
} elseif ($item['gravity'] == GRAVITY_PARENT) {
} elseif ($item['gravity'] == Item::GRAVITY_PARENT) {
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::NOTE);
} else {
XML::addElement($doc, $entry, 'activity:object-type', Activity\ObjectType::COMMENT);
@ -1613,13 +1613,13 @@ class DFRN
|| ($item['verb'] == Activity::ATTENDMAYBE)
|| ($item['verb'] == Activity::ANNOUNCE)
) {
$item['gravity'] = GRAVITY_ACTIVITY;
$item['gravity'] = Item::GRAVITY_ACTIVITY;
// only one like or dislike per person
// split into two queries for performance issues
$condition = [
'uid' => $item['uid'],
'author-id' => $item['author-id'],
'gravity' => GRAVITY_ACTIVITY,
'gravity' => Item::GRAVITY_ACTIVITY,
'verb' => $item['verb'],
'parent-uri' => $item['thr-parent'],
];
@ -1627,7 +1627,7 @@ class DFRN
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;
@ -1939,7 +1939,7 @@ class DFRN
// Now assign the rest of the values that depend on the type of the message
if (in_array($entrytype, [self::REPLY, self::REPLY_RC])) {
$item['gravity'] = GRAVITY_COMMENT;
$item['gravity'] = Item::GRAVITY_COMMENT;
if (!isset($item['object-type'])) {
$item['object-type'] = Activity\ObjectType::COMMENT;
@ -1965,7 +1965,7 @@ class DFRN
if ($entrytype == self::REPLY_RC) {
$item['wall'] = 1;
} elseif ($entrytype == self::TOP_LEVEL) {
$item['gravity'] = GRAVITY_PARENT;
$item['gravity'] = Item::GRAVITY_PARENT;
if (!isset($item['object-type'])) {
$item['object-type'] = Activity\ObjectType::NOTE;
@ -2035,7 +2035,7 @@ class DFRN
Logger::info('Contact is not sharing with the user', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
return;
}
if (($item['gravity'] == GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
if (($item['gravity'] == Item::GRAVITY_ACTIVITY) && DI::pConfig()->get($item['uid'], 'system', 'accept_only_sharer') == Item::COMPLETION_COMMENT) {
Logger::info('Completion is set to "comment", but this is an activity. so we stop here.', ['uid' => $item['uid'], 'owner-id' => $item['owner-id'], 'author-id' => $item['author-id'], 'gravity' => $item['gravity'], 'uri' => $item['uri']]);
return;
}
@ -2120,13 +2120,13 @@ class DFRN
}
// When it is a starting post it has to belong to the person that wants to delete it
if (($item['gravity'] == GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
if (($item['gravity'] == Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
Logger::info('Item with URI ' . $uri . ' do not belong to contact ' . $importer['id'] . ' - ignoring deletion.');
return;
}
// Comments can be deleted by the thread owner or comment owner
if (($item['gravity'] != GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && ($item['contact-id'] != $importer['id'])) {
$condition = ['id' => $item['parent'], 'contact-id' => $importer['id']];
if (!Post::exists($condition)) {
Logger::info('Item with URI ' . $uri . ' was not found or must not be deleted by contact ' . $importer['id'] . ' - ignoring deletion.');

View File

@ -83,7 +83,7 @@ class Diaspora
}
$items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
['parent' => $item['parent'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
while ($item = Post::fetch($items)) {
$contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
['id' => $item['author-id']]);
@ -1548,7 +1548,7 @@ class Diaspora
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
$datarray['verb'] = Activity::POST;
$datarray['gravity'] = GRAVITY_COMMENT;
$datarray['gravity'] = Item::GRAVITY_COMMENT;
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
@ -1801,7 +1801,7 @@ class Diaspora
$datarray['uri'] = self::getUriFromGuid($author, $guid);
$datarray['verb'] = $verb;
$datarray['gravity'] = GRAVITY_ACTIVITY;
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
$datarray['object-type'] = Activity\ObjectType::NOTE;
@ -1812,7 +1812,7 @@ class Diaspora
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = DateTimeFormat::utcNow();
// like on comments have the comment as parent. So we need to fetch the toplevel parent
if ($toplevel_parent_item['gravity'] != GRAVITY_PARENT) {
if ($toplevel_parent_item['gravity'] != Item::GRAVITY_PARENT) {
$toplevel = Post::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
$origin = $toplevel['origin'];
} else {
@ -1981,7 +1981,7 @@ class Diaspora
$datarray['uri'] = self::getUriFromGuid($author, $guid);
$datarray['verb'] = Activity::FOLLOW;
$datarray['gravity'] = GRAVITY_ACTIVITY;
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
$datarray['object-type'] = Activity\ObjectType::NOTE;
@ -2002,9 +2002,9 @@ class Diaspora
// Send all existing comments and likes to the requesting server
$comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
while ($comment = Post::fetch($comments)) {
if (($comment['gravity'] == GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
continue;
}
@ -2302,7 +2302,7 @@ class Diaspora
$datarray['thr-parent'] = $parent['uri'];
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
$datarray['gravity'] = GRAVITY_ACTIVITY;
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
$datarray['object-type'] = Activity\ObjectType::NOTE;
$datarray['protocol'] = $item['protocol'];
@ -2387,7 +2387,7 @@ class Diaspora
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
$datarray['verb'] = Activity::POST;
$datarray['gravity'] = GRAVITY_PARENT;
$datarray['gravity'] = Item::GRAVITY_PARENT;
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
$datarray['source'] = $xml;
@ -2706,7 +2706,7 @@ class Diaspora
$datarray['owner-id'] = $datarray['author-id'];
$datarray['verb'] = Activity::POST;
$datarray['gravity'] = GRAVITY_PARENT;
$datarray['gravity'] = Item::GRAVITY_PARENT;
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
$datarray['source'] = $xml;
@ -3596,7 +3596,7 @@ class Diaspora
// - Implicit mentions are enabled
if (
$item['author-id'] != $thread_parent_item['author-id']
&& ($thread_parent_item['gravity'] != GRAVITY_PARENT)
&& ($thread_parent_item['gravity'] != Item::GRAVITY_PARENT)
&& (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions'))
&& !DI::config()->get('system', 'disable_implicit_mentions')
) {
@ -3729,7 +3729,7 @@ class Diaspora
$msg_type = 'retraction';
if ($item['gravity'] == GRAVITY_PARENT) {
if ($item['gravity'] == Item::GRAVITY_PARENT) {
$target_type = 'Post';
} elseif (in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
$target_type = 'Like';
@ -4069,12 +4069,12 @@ class Diaspora
return false;
}
if (($parent_post['gravity'] == GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
if (($parent_post['gravity'] == Item::GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
Logger::info('Parent comment has got no Diaspora signature.', ['parent-id' => $parent_id]);
return false;
}
if ($parent_post['gravity'] == GRAVITY_COMMENT) {
if ($parent_post['gravity'] == Item::GRAVITY_COMMENT) {
return self::parentSupportDiaspora($parent_post['thr-parent-id']);
}

View File

@ -254,20 +254,21 @@ class Feed
$author['owner-avatar'] = $contact['thumb'];
}
$header = [];
$header['uid'] = $importer['uid'] ?? 0;
$header['network'] = Protocol::FEED;
$header = [
'uid' => $importer['uid'] ?? 0,
'network' => Protocol::FEED,
'wall' => 0,
'origin' => 0,
'gravity' => Item::GRAVITY_PARENT,
'private' => Item::PUBLIC,
'verb' => Activity::POST,
'object-type' => Activity\ObjectType::NOTE,
'post-type' => Item::PT_ARTICLE,
'contact-id' => $contact['id'] ?? 0,
];
$datarray['protocol'] = $protocol;
$datarray['direction'] = Conversation::PULL;
$header['wall'] = 0;
$header['origin'] = 0;
$header['gravity'] = GRAVITY_PARENT;
$header['private'] = Item::PUBLIC;
$header['verb'] = Activity::POST;
$header['object-type'] = Activity\ObjectType::NOTE;
$header['post-type'] = Item::PT_ARTICLE;
$header['contact-id'] = $contact['id'] ?? 0;
if (!is_object($entries)) {
Logger::info("There are no entries in this feed.");
@ -956,13 +957,13 @@ class Feed
$condition = ["`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
$owner['uid'], $check_date, GRAVITY_PARENT, GRAVITY_COMMENT,
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
Item::PRIVATE, Protocol::ACTIVITYPUB,
Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
if ($filter === 'comments') {
$condition[0] .= " AND `gravity` = ? ";
$condition[] = GRAVITY_COMMENT;
$condition[] = Item::GRAVITY_COMMENT;
}
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
@ -1089,7 +1090,7 @@ class Feed
*/
private static function noteEntry(DOMDocument $doc, array $item, array $owner): DOMElement
{
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
Logger::info('Feed entry author does not match feed owner', ['owner' => $owner['url'], 'author' => $item['author-link']]);
}
@ -1153,7 +1154,7 @@ class Feed
{
$mentioned = [];
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);

View File

@ -392,7 +392,7 @@ class OStatus
$header['network'] = Protocol::OSTATUS;
$header['wall'] = 0;
$header['origin'] = 0;
$header['gravity'] = GRAVITY_COMMENT;
$header['gravity'] = Item::GRAVITY_COMMENT;
if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
return false;
@ -500,7 +500,7 @@ class OStatus
$item['verb'] = Activity::LIKE;
$item['thr-parent'] = $orig_uri;
$item['gravity'] = GRAVITY_ACTIVITY;
$item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['object-type'] = Activity\ObjectType::NOTE;
}
@ -715,7 +715,7 @@ class OStatus
}
} else {
$item['thr-parent'] = $item['uri'];
$item['gravity'] = GRAVITY_PARENT;
$item['gravity'] = Item::GRAVITY_PARENT;
}
self::$itemlist[] = $item;
@ -1360,7 +1360,7 @@ class OStatus
*/
private static function likeEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
{
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
}
@ -1510,7 +1510,7 @@ class OStatus
*/
private static function noteEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
{
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
}
@ -1640,7 +1640,7 @@ class OStatus
{
$mentioned = [];
if ($item['gravity'] != GRAVITY_PARENT) {
if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);

View File

@ -25,18 +25,21 @@ use Friendica\Contact\FriendSuggest\Collection\FriendSuggests;
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
use Friendica\Model\Contact;
use Friendica\Model\FContact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Protocol\Activity;
use Friendica\Util\Network;
use Friendica\Core\Worker;
use Friendica\Model\FContact;
use Friendica\Model\Item;
use Friendica\Protocol\Relay;
use Friendica\Util\Network;
class Delivery
{
@ -75,7 +78,7 @@ class Delivery
$uid = $post_uriid;
$target_item = [];
} else {
$item = Model\Post::selectFirst(['id', 'parent'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
$item = Post::selectFirst(['id', 'parent'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
if (!DBA::isResult($item) || empty($item['parent'])) {
Logger::warning('Post not found', ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
return;
@ -85,9 +88,9 @@ class Delivery
$condition = ['id' => [$target_id, $parent_id], 'visible' => true];
$params = ['order' => ['id']];
$itemdata = Model\Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
$itemdata = Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
while ($item = Model\Post::fetch($itemdata)) {
while ($item = Post::fetch($itemdata)) {
if ($item['verb'] == Activity::ANNOUNCE) {
continue;
}
@ -124,14 +127,14 @@ class Delivery
}
$condition = ['uri' => $target_item['thr-parent'], 'uid' => $target_item['uid']];
$thr_parent = Model\Post::selectFirst(['network', 'object'], $condition);
$thr_parent = Post::selectFirst(['network', 'object'], $condition);
if (!DBA::isResult($thr_parent)) {
// Shouldn't happen. But when this does, we just take the parent as thread parent.
// That's totally okay for what we use this variable here.
$thr_parent = $parent;
}
if (!empty($contact_id) && Model\Contact::isArchived($contact_id)) {
if (!empty($contact_id) && Contact::isArchived($contact_id)) {
Logger::info('Contact is archived', ['id' => $contact_id, 'cmd' => $cmd, 'item' => $target_item['id']]);
self::setFailedQueue($cmd, $target_item);
return;
@ -144,7 +147,7 @@ class Delivery
}
}
$top_level = $target_item['gravity'] == GRAVITY_PARENT;
$top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
// This is IMPORTANT!!!!
@ -176,7 +179,7 @@ class Delivery
&& empty($parent['allow_gid'])
&& empty($parent['deny_cid'])
&& empty($parent['deny_gid'])
&& ($parent["private"] != Model\Item::PRIVATE)) {
&& ($parent['private'] != Item::PRIVATE)) {
$public_message = true;
}
}
@ -185,7 +188,7 @@ class Delivery
Logger::warning('No delivery data', ['command' => $cmd, 'uri-id' => $post_uriid, 'cid' => $contact_id]);
}
$owner = Model\User::getOwnerDataById($uid);
$owner = User::getOwnerDataById($uid);
if (!DBA::isResult($owner)) {
self::setFailedQueue($cmd, $target_item);
return;
@ -205,7 +208,7 @@ class Delivery
return;
}
$protocol = Model\GServer::getProtocol($contact['gsid'] ?? 0);
$protocol = GServer::getProtocol($contact['gsid'] ?? 0);
// Transmit via Diaspora if the thread had started as Diaspora post.
// Also transmit via Diaspora if this is a direct answer to a Diaspora comment.
@ -250,7 +253,7 @@ class Delivery
return;
}
Model\Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
Post\DeliveryData::incrementQueueFailed($item['uri-id'] ?? $item['id']);
}
/**
@ -281,7 +284,7 @@ class Delivery
if ($cmd == self::MAIL) {
$item = $target_item;
$item['body'] = Model\Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
$item['body'] = Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
$atom = DFRN::mail($item, $owner);
} elseif ($cmd == self::SUGGESTION) {
$item = $target_item;
@ -311,13 +314,13 @@ class Delivery
Logger::debug('Notifier entry: ' . $contact["url"] . ' ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' entry: ' . $atom);
$protocol = Model\Post\DeliveryData::DFRN;
$protocol = Post\DeliveryData::DFRN;
// We don't have a relationship with contacts on a public post.
// Se we transmit with the new method and via Diaspora as a fallback
if (!empty($items) && (($items[0]['uid'] == 0) || ($contact['uid'] == 0))) {
// Transmit in public if it's a relay post
$public_dfrn = ($contact['contact-type'] == Model\Contact::TYPE_RELAY);
$public_dfrn = ($contact['contact-type'] == Contact::TYPE_RELAY);
$deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn);
@ -327,17 +330,17 @@ class Delivery
if ($cmd == Delivery::POST) {
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
Model\GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
} else {
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
return;
}
if ((($deliver_status < 200) || ($deliver_status > 299)) && (empty($server_protocol) || ($server_protocol == Model\Post\DeliveryData::LEGACY_DFRN))) {
if ((($deliver_status < 200) || ($deliver_status > 299)) && (empty($server_protocol) || ($server_protocol == Post\DeliveryData::LEGACY_DFRN))) {
// Transmit via Diaspora if not possible via Friendica
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
return;
@ -351,20 +354,20 @@ class Delivery
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
Contact::unmarkForArchival($contact);
Model\GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
GServer::setProtocol($contact['gsid'] ?? 0, $protocol);
if ($cmd == Delivery::POST) {
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], $protocol);
}
} else {
// The message could not be delivered. We mark the contact as "dead"
Model\Contact::markForArchival($contact);
Contact::markForArchival($contact);
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
if (!Worker::defer() && $cmd == Delivery::POST) {
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
}
@ -386,7 +389,7 @@ class Delivery
private static function deliverDiaspora(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup)
{
// We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Model\User::ACCOUNT_TYPE_COMMUNITY);
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY);
if ($public_message) {
$loc = 'public batch ' . $contact['batch'];
@ -438,30 +441,30 @@ class Delivery
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
Contact::unmarkForArchival($contact);
Model\GServer::setProtocol($contact['gsid'] ?? 0, Model\Post\DeliveryData::DIASPORA);
GServer::setProtocol($contact['gsid'] ?? 0, Post\DeliveryData::DIASPORA);
if ($cmd == Delivery::POST) {
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::DIASPORA);
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Post\DeliveryData::DIASPORA);
}
} else {
// The message could not be delivered. We mark the contact as "dead"
Model\Contact::markForArchival($contact);
Contact::markForArchival($contact);
// When it is delivered to the public endpoint, we do mark the relay contact for archival as well
if ($public_message) {
Relay::markForArchival($contact);
}
if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {
if (empty($contact['contact-type']) || ($contact['contact-type'] != Contact::TYPE_RELAY)) {
Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
// defer message for redelivery
if (!Worker::defer() && $cmd == Delivery::POST) {
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
} elseif ($cmd == Delivery::POST) {
Model\Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
Post\DeliveryData::incrementQueueFailed($target_item['uri-id']);
}
}
}
@ -525,7 +528,7 @@ class Delivery
// only expose our real email address to true friends
if (($contact['rel'] == Model\Contact::FRIEND) && !$contact['blocked']) {
if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
if ($reply_to) {
$headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to . '>' . "\n";
$headers .= 'Sender: ' . $local_user['email'] . "\n";
@ -551,13 +554,13 @@ class Delivery
if (empty($target_item['title'])) {
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
$title = Model\Post::selectFirst(['title'], $condition);
$title = Post::selectFirst(['title'], $condition);
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
} else {
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
$title = Model\Post::selectFirst(['title'], $condition);
$title = Post::selectFirst(['title'], $condition);
if (DBA::isResult($title) && ($title['title'] != '')) {
$subject = $title['title'];
@ -575,7 +578,7 @@ class Delivery
if ($success) {
// Success
Model\Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Model\Post\DeliveryData::MAIL);
Post\DeliveryData::incrementQueueDone($target_item['uri-id'], Post\DeliveryData::MAIL);
Logger::info('Delivered via mail', ['guid' => $target_item['guid'], 'to' => $addr, 'subject' => $subject]);
} else {
// Failed

View File

@ -68,7 +68,7 @@ class ExpirePosts
{
Logger::notice('Delete expired posts');
// physically remove anything that has been deleted for more than two months
$condition = ["`gravity` = ? AND `deleted` AND `changed` < ?", GRAVITY_PARENT, DateTimeFormat::utc('now - 60 days')];
$condition = ["`gravity` = ? AND `deleted` AND `changed` < ?", Item::GRAVITY_PARENT, DateTimeFormat::utc('now - 60 days')];
$rows = Post::select(['guid', 'uri-id', 'uid'], $condition);
while ($row = Post::fetch($rows)) {
Logger::info('Delete expired item', ['uri-id' => $row['uri-id'], 'guid' => $row['guid']]);
@ -134,7 +134,7 @@ class ExpirePosts
}
$rows = 0;
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT]);
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", Item::GRAVITY_PARENT]);
while ($fields = DBA::fetch($userposts)) {
$post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $fields);
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
@ -149,7 +149,7 @@ class ExpirePosts
}
$rows = 0;
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", GRAVITY_PARENT]);
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", Item::GRAVITY_PARENT]);
while ($fields = DBA::fetch($userposts)) {
$post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $fields);
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
@ -264,7 +264,7 @@ class ExpirePosts
AND `i`.`parent-uri-id` = `post-user`.`uri-id`)
AND NOT `uri-id` IN (SELECT `parent-uri-id` FROM `post-user` AS `i` WHERE `i`.`uid` = ?
AND `i`.`parent-uri-id` = `post-user`.`uri-id` AND `i`.`received` > ?))",
GRAVITY_PARENT, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days'), 0, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days')]);
Item::GRAVITY_PARENT, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days'), 0, 0, DateTimeFormat::utc('now - ' . (int)$expire_days_unclaimed . ' days')]);
Logger::notice('Start deleting unclaimed public items');
$affected_count = 0;

View File

@ -143,7 +143,7 @@ class Notifier
}
}
$top_level = $target_item['gravity'] == GRAVITY_PARENT;
$top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
}
$owner = User::getOwnerDataById($uid);

View File

@ -387,7 +387,7 @@ return [
'uri-id' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -402,7 +402,7 @@ return [
'uri-id' => 2,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -417,7 +417,7 @@ return [
'uri-id' => 3,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
@ -432,7 +432,7 @@ return [
'uri-id' => 4,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -447,7 +447,7 @@ return [
'uri-id' => 5,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -462,7 +462,7 @@ return [
'uri-id' => 6,
'parent-uri-id' => 6,
'thr-parent-id' => 6,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -477,7 +477,7 @@ return [
'uri-id' => 7,
'parent-uri-id' => 7,
'thr-parent-id' => 7,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -505,7 +505,7 @@ return [
'thr-parent-id' => 1,
'private' => Item::PUBLIC,
'global' => true,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'wall' => 1,
'origin' => 1,
@ -519,7 +519,7 @@ return [
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -540,7 +540,7 @@ return [
'origin' => 1,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
@ -561,7 +561,7 @@ return [
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -582,7 +582,7 @@ return [
'origin' => 1,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -603,7 +603,7 @@ return [
'origin' => 1,
'parent-uri-id' => 6,
'thr-parent-id' => 6,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -624,7 +624,7 @@ return [
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -645,7 +645,7 @@ return [
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -666,7 +666,7 @@ return [
'origin' => 0,
'parent-uri-id' => 3,
'thr-parent-id' => 3,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 43,
@ -687,7 +687,7 @@ return [
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
@ -708,7 +708,7 @@ return [
'origin' => 0,
'parent-uri-id' => 1,
'thr-parent-id' => 1,
'gravity' => GRAVITY_COMMENT,
'gravity' => Item::GRAVITY_COMMENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 42,
@ -735,7 +735,7 @@ return [
'thr-parent-id' => 6,
'private' => Item::PUBLIC,
'global' => true,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,
@ -756,7 +756,7 @@ return [
'thr-parent-id' => 7,
'private' => Item::PUBLIC,
'global' => true,
'gravity' => GRAVITY_PARENT,
'gravity' => Item::GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,

View File

@ -299,7 +299,7 @@ function update_1349()
}
if (!DBA::e("UPDATE `item` INNER JOIN `item-activity` ON `item`.`uri-id` = `item-activity`.`uri-id`
SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", GRAVITY_ACTIVITY)) {
SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", Item::GRAVITY_ACTIVITY)) {
return Update::FAILED;
}

View File

@ -33,7 +33,9 @@ use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
use Friendica\Model\Item;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module;
use Friendica\Util\Strings;
@ -203,7 +205,7 @@ function frio_remote_nav(App $a, array &$nav_info)
{
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
// get the homelink from $_SESSION
$homelink = Model\Profile::getMyURL();
$homelink = Profile::getMyURL();
if (!$homelink) {
$homelink = Session::get('visitor_home', '');
}
@ -216,7 +218,7 @@ function frio_remote_nav(App $a, array &$nav_info)
} elseif (!local_user() && remote_user()) {
$remoteUser = Contact::getById(remote_user(), $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
} elseif (Model\Profile::getMyURL()) {
} elseif (Profile::getMyURL()) {
$remoteUser = Contact::getByURL($homelink, null, $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
} else {
@ -257,7 +259,7 @@ function frio_display_item(App $a, &$arr)
if (
local_user()
&& in_array($arr['item']['uid'], [0, local_user()])
&& $arr['item']['gravity'] == GRAVITY_PARENT
&& $arr['item']['gravity'] == Item::GRAVITY_PARENT
&& !$arr['item']['self']
&& !$arr['item']['mention']
) {