use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Model\Tag;
+use Friendica\Model\Verb;
use Friendica\Object\Post;
use Friendica\Object\Thread;
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
return [];
}
- $str_blocked = DI::pConfig()->get(local_user(), 'system', 'blocked');
+ $str_blocked = str_replace(["\n", "\r"], ",", DI::pConfig()->get(local_user(), 'system', 'blocked'));
if (empty($str_blocked)) {
return [];
}
foreach (explode(',', $str_blocked) as $entry) {
// The 4th parameter guarantees that there always will be a public contact entry
- $cid = Contact::getIdForURL(trim($entry), 0, true, ['url' => trim($entry)]);
+ $cid = Contact::getIdForURL(trim($entry), 0, false, ['url' => trim($entry)]);
if (!empty($cid)) {
$blocklist[] = $cid;
}
. "<script> var profile_uid = " . $_SESSION['uid']
. "; var netargs = '" . substr(DI::args()->getCommand(), 8)
. '?f='
- . (!empty($_GET['cid']) ? '&cid=' . rawurlencode($_GET['cid']) : '')
- . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
- . (!empty($_GET['star']) ? '&star=' . rawurlencode($_GET['star']) : '')
- . (!empty($_GET['order']) ? '&order=' . rawurlencode($_GET['order']) : '')
- . (!empty($_GET['bmark']) ? '&bmark=' . rawurlencode($_GET['bmark']) : '')
- . (!empty($_GET['liked']) ? '&liked=' . rawurlencode($_GET['liked']) : '')
- . (!empty($_GET['conv']) ? '&conv=' . rawurlencode($_GET['conv']) : '')
- . (!empty($_GET['nets']) ? '&nets=' . rawurlencode($_GET['nets']) : '')
- . (!empty($_GET['cmin']) ? '&cmin=' . rawurlencode($_GET['cmin']) : '')
- . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
- . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
+ . (!empty($_GET['contactid']) ? '&contactid=' . rawurlencode($_GET['contactid']) : '')
+ . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
+ . (!empty($_GET['star']) ? '&star=' . rawurlencode($_GET['star']) : '')
+ . (!empty($_GET['order']) ? '&order=' . rawurlencode($_GET['order']) : '')
+ . (!empty($_GET['bmark']) ? '&bmark=' . rawurlencode($_GET['bmark']) : '')
+ . (!empty($_GET['liked']) ? '&liked=' . rawurlencode($_GET['liked']) : '')
+ . (!empty($_GET['conv']) ? '&conv=' . rawurlencode($_GET['conv']) : '')
+ . (!empty($_GET['nets']) ? '&nets=' . rawurlencode($_GET['nets']) : '')
+ . (!empty($_GET['cmin']) ? '&cmin=' . rawurlencode($_GET['cmin']) : '')
+ . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
+ . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
. "'; </script>\r\n";
}
$profile_name = $item['author-link'];
}
- $tags = Tag::populateTagsFromItem($item);
+ $tags = Tag::populateFromItem($item);
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
'name' => $profile_name,
'sparkle' => $sparkle,
'lock' => $lock,
- 'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
+ 'thumb' => DI::baseUrl()->remove($item['author-avatar']),
'title' => $title,
'body' => $body,
'tags' => $tags['tags'],
'indent' => '',
'owner_name' => $owner_name,
'owner_url' => $owner_url,
- 'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
+ 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']),
'plink' => Item::getPlink($item),
'edpost' => false,
'isstarred' => $isstarred,
$item['pagedrop'] = $page_dropping;
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$item_object = new Post($item);
$conv->addParent($item_object);
}
$comments = [];
$parentlines = [];
$lineno = 0;
+ $direction = [];
$actor = [];
$received = '';
while ($row = Item::fetch($thread_items)) {
- if (($row['verb'] == Activity::ANNOUNCE) && !empty($row['contact-uid']) && ($row['received'] > $received) && ($row['thr-parent'] == $row['parent-uri'])) {
+ if (!empty($parentlines) && ($row['verb'] == Activity::ANNOUNCE)
+ && ($row['thr-parent'] == $row['parent-uri']) && ($row['received'] > $received)
+ && Contact::isSharing($row['author-id'], $row['uid'])) {
+ $direction = ['direction' => 3, 'title' => DI::l10n()->t('%s reshared this.', $row['author-name'])];
$actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
$received = $row['received'];
}
- if ((($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && !in_array($row['network'], [Protocol::DIASPORA])) &&
- (empty($row['contact-uid']) || !in_array($row['network'], Protocol::NATIVE_SUPPORT))) {
+ if (!empty($parentlines) && empty($direction) && ($row['gravity'] == GRAVITY_COMMENT)
+ && Contact::isSharing($row['author-id'], $row['uid'])) {
+ $direction = ['direction' => 2, 'title' => DI::l10n()->t('%s commented this.', $row['author-name'])];
+ }
+
+ if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id'])
+ && !Contact::isSharing($row['author-id'], $row['uid'])) {
+ if ($row['post-type'] == Item::PT_TAG) {
+ $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
+ }
+
$parentlines[] = $lineno;
}
DBA::close($thread_items);
- if (!empty($actor)) {
+ if (!empty($direction)) {
foreach ($parentlines as $line) {
- $comments[$line]['owner-link'] = $actor['link'];
- $comments[$line]['owner-avatar'] = $actor['avatar'];
- $comments[$line]['owner-name'] = $actor['name'];
+ $comments[$line]['direction'] = $direction;
+ if (!empty($actor) && DI::pConfig()->get(local_user(), 'system', 'display_resharer') ) {
+ $comments[$line]['owner-link'] = $actor['link'];
+ $comments[$line]['owner-avatar'] = $actor['avatar'];
+ $comments[$line]['owner-name'] = $actor['name'];
+ }
}
}
return $comments;
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function conversation_add_children(array $parents, $block_authors, $order, $uid) {
- $max_comments = DI::config()->get('system', 'max_comments', 100);
+ if (count($parents) > 1) {
+ $max_comments = DI::config()->get('system', 'max_comments', 100);
+ } else {
+ $max_comments = DI::config()->get('system', 'max_display_comments', 1000);
+ }
- $params = ['order' => ['uid', 'commented' => true]];
+ $params = ['order' => ['gravity', 'uid', 'commented' => true]];
if ($max_comments > 0) {
$params['limit'] = $max_comments;
$items = [];
foreach ($parents AS $parent) {
- $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ",
- $parent['uri'], $uid];
- if ($block_authors) {
- $condition[0] .= "AND NOT `author`.`hidden`";
- }
-
- $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
-
- $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
-
- if (count($comments) != 0) {
- $items = array_merge($items, $comments);
- }
+ $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+ $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)];
+ $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
}
foreach ($items as $index => $item) {
return $items;
}
+/**
+ * Fetch conversation items
+ *
+ * @param array $parent
+ * @param array $items
+ * @param array $condition
+ * @param boolean $block_authors
+ * @param array $params
+ * @return array
+ */
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+ if ($block_authors) {
+ $condition[0] .= " AND NOT `author`.`hidden`";
+ }
+
+ $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params);
+
+ $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+
+ if (count($comments) != 0) {
+ $items = array_merge($items, $comments);
+ }
+ return $items;
+}
+
function item_photo_menu($item) {
$sub_link = '';
$poke_link = '';
$block_link = '';
$ignore_link = '';
- if (local_user() && local_user() == $item['uid'] && $item['parent'] == $item['id'] && !$item['self']) {
+ if (local_user() && local_user() == $item['uid'] && $item['gravity'] == GRAVITY_PARENT && !$item['self']) {
$sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
}
$sparkle = (strpos($profile_link, 'redir/') === 0);
$cid = 0;
- $pcid = Contact::getIdForURL($item['author-link'], 0, true);
+ $pcid = Contact::getIdForURL($item['author-link'], 0, false);
$network = '';
$rel = 0;
$condition = ['uid' => local_user(), 'nurl' => Strings::normaliseLink($item['author-link'])];
return;
}
- if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
+ if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['gravity'] != GRAVITY_PARENT)) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author);
{
$children = [];
foreach ($item_list as $i => $item) {
- if ($item['id'] != $item['parent']) {
+ if ($item['gravity'] != GRAVITY_PARENT) {
if ($recursive) {
// Fallback to parent-uri if thr-parent is not set
$thr_parent = $item['thr-parent'];
// Extract the top level items
foreach ($item_array as $item) {
- if ($item['id'] == $item['parent']) {
+ if ($item['gravity'] == GRAVITY_PARENT) {
$parents[] = $item;
}
}