Merge pull request #13717 from annando/contacts-posts
Fix uddate issues and improve speed when displaying contact posts
This commit is contained in:
commit
c2e4c0e1fa
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2023.09-rc (Giant Rhubarb)
|
-- Friendica 2023.09-rc (Giant Rhubarb)
|
||||||
-- DB_UPDATE_VERSION 1540
|
-- DB_UPDATE_VERSION 1541
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -1534,7 +1534,8 @@ CREATE TABLE IF NOT EXISTS `post-user` (
|
||||||
INDEX `event-id` (`event-id`),
|
INDEX `event-id` (`event-id`),
|
||||||
INDEX `psid` (`psid`),
|
INDEX `psid` (`psid`),
|
||||||
INDEX `author-id_uid` (`author-id`,`uid`),
|
INDEX `author-id_uid` (`author-id`,`uid`),
|
||||||
INDEX `author-id_received` (`author-id`,`received`),
|
INDEX `author-id_created` (`author-id`,`created`),
|
||||||
|
INDEX `owner-id_created` (`owner-id`,`created`),
|
||||||
INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
|
INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
|
||||||
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
|
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
|
||||||
INDEX `uid_contactid` (`uid`,`contact-id`),
|
INDEX `uid_contactid` (`uid`,`contact-id`),
|
||||||
|
@ -1595,6 +1596,8 @@ CREATE TABLE IF NOT EXISTS `post-thread-user` (
|
||||||
INDEX `post-user-id` (`post-user-id`),
|
INDEX `post-user-id` (`post-user-id`),
|
||||||
INDEX `commented` (`commented`),
|
INDEX `commented` (`commented`),
|
||||||
INDEX `received` (`received`),
|
INDEX `received` (`received`),
|
||||||
|
INDEX `author-id_created` (`author-id`,`created`),
|
||||||
|
INDEX `owner-id_created` (`owner-id`,`created`),
|
||||||
INDEX `uid_received` (`uid`,`received`),
|
INDEX `uid_received` (`uid`,`received`),
|
||||||
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
|
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
|
||||||
INDEX `uid_commented` (`uid`,`commented`),
|
INDEX `uid_commented` (`uid`,`commented`),
|
||||||
|
|
|
@ -50,6 +50,8 @@ Indexes
|
||||||
| post-user-id | post-user-id |
|
| post-user-id | post-user-id |
|
||||||
| commented | commented |
|
| commented | commented |
|
||||||
| received | received |
|
| received | received |
|
||||||
|
| author-id_created | author-id, created |
|
||||||
|
| owner-id_created | owner-id, created |
|
||||||
| uid_received | uid, received |
|
| uid_received | uid, received |
|
||||||
| uid_wall_received | uid, wall, received |
|
| uid_wall_received | uid, wall, received |
|
||||||
| uid_commented | uid, commented |
|
| uid_commented | uid, commented |
|
||||||
|
|
|
@ -58,7 +58,8 @@ Indexes
|
||||||
| event-id | event-id |
|
| event-id | event-id |
|
||||||
| psid | psid |
|
| psid | psid |
|
||||||
| author-id_uid | author-id, uid |
|
| author-id_uid | author-id, uid |
|
||||||
| author-id_received | author-id, received |
|
| author-id_created | author-id, created |
|
||||||
|
| owner-id_created | owner-id, created |
|
||||||
| parent-uri-id_uid | parent-uri-id, uid |
|
| parent-uri-id_uid | parent-uri-id, uid |
|
||||||
| uid_wall_received | uid, wall, received |
|
| uid_wall_received | uid, wall, received |
|
||||||
| uid_contactid | uid, contact-id |
|
| uid_contactid | uid, contact-id |
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Friendica\Model\Contact;
|
||||||
function update_contact_content(App $a)
|
function update_contact_content(App $a)
|
||||||
{
|
{
|
||||||
if (!empty(DI::args()->get(1)) && !empty($_GET['force'])) {
|
if (!empty(DI::args()->get(1)) && !empty($_GET['force'])) {
|
||||||
$contact = Contact::getById(DI::args()->get(1), ['id', 'deleted']);
|
$contact = DBA::selectFirst('account-user-view', ['pid', 'deleted'], ['id' => DI::args()->get(1)]);
|
||||||
if (DBA::isResult($contact) && empty($contact['deleted'])) {
|
if (DBA::isResult($contact) && empty($contact['deleted'])) {
|
||||||
DI::page()['aside'] = '';
|
DI::page()['aside'] = '';
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ function update_contact_content(App $a)
|
||||||
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
|
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = Contact::getPostsFromId($contact['id'], true, true, $item['parent'] ?? 0);
|
$text = Contact::getThreadsFromId($contact['pid'], DI::userSession()->getLocalUserId(), true, $item['parent'] ?? 0, $_GET['last_received'] ?? '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1298,6 +1298,8 @@ class Conversation
|
||||||
usort($parents, [$this, 'sortThrFeaturedReceived']);
|
usort($parents, [$this, 'sortThrFeaturedReceived']);
|
||||||
} elseif (stristr($order, 'pinned_commented')) {
|
} elseif (stristr($order, 'pinned_commented')) {
|
||||||
usort($parents, [$this, 'sortThrFeaturedCommented']);
|
usort($parents, [$this, 'sortThrFeaturedCommented']);
|
||||||
|
} elseif (stristr($order, 'pinned_created')) {
|
||||||
|
usort($parents, [$this, 'sortThrFeaturedCreated']);
|
||||||
} elseif (stristr($order, 'received')) {
|
} elseif (stristr($order, 'received')) {
|
||||||
usort($parents, [$this, 'sortThrReceived']);
|
usort($parents, [$this, 'sortThrReceived']);
|
||||||
} elseif (stristr($order, 'commented')) {
|
} elseif (stristr($order, 'commented')) {
|
||||||
|
@ -1375,6 +1377,24 @@ class Conversation
|
||||||
return strcmp($b['commented'], $a['commented']);
|
return strcmp($b['commented'], $a['commented']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* usort() callback to sort item arrays by featured and the created key
|
||||||
|
*
|
||||||
|
* @param array $a
|
||||||
|
* @param array $b
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function sortThrFeaturedCreated(array $a, array $b): int
|
||||||
|
{
|
||||||
|
if ($b['featured'] && !$a['featured']) {
|
||||||
|
return 1;
|
||||||
|
} elseif (!$b['featured'] && $a['featured']) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strcmp($b['created'], $a['created']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* usort() callback to sort item arrays by the received key
|
* usort() callback to sort item arrays by the received key
|
||||||
*
|
*
|
||||||
|
|
|
@ -1566,23 +1566,20 @@ class Contact
|
||||||
* @return string posts in HTML
|
* @return string posts in HTML
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getPostsFromUrl(string $contact_url, bool $thread_mode = false, int $update = 0, int $parent = 0, bool $only_media = false): string
|
public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false): string
|
||||||
{
|
{
|
||||||
return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update, $parent, $only_media);
|
return self::getPostsFromId(self::getIdForURL($contact_url), $uid, $only_media);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns posts from a given contact id
|
* Returns posts from a given contact id
|
||||||
*
|
*
|
||||||
* @param int $cid Contact ID
|
* @param int $cid Contact ID
|
||||||
* @param bool $thread_mode
|
|
||||||
* @param int $update Update mode
|
|
||||||
* @param int $parent Item parent ID for the update mode
|
|
||||||
* @param bool $only_media Only display media content
|
* @param bool $only_media Only display media content
|
||||||
* @return string posts in HTML
|
* @return string posts in HTML
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getPostsFromId(int $cid, bool $thread_mode = false, int $update = 0, int $parent = 0, bool $only_media = false): string
|
public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
|
$contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
|
@ -1590,32 +1587,17 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($contact["network"]) || in_array($contact["network"], Protocol::FEDERATED)) {
|
if (empty($contact["network"]) || in_array($contact["network"], Protocol::FEDERATED)) {
|
||||||
$sql = "(`uid` = 0 OR (`uid` = ? AND NOT `global`))";
|
$condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`))", $uid];
|
||||||
} else {
|
} else {
|
||||||
$sql = "`uid` = ?";
|
$condition = ["`uid` = ?", $uid];
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id');
|
$contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id');
|
||||||
|
|
||||||
if ($thread_mode) {
|
$condition = DBA::mergeConditions($condition, ["`$contact_field` = ? AND `gravity` IN (?, ?)", $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT]);
|
||||||
$condition = [
|
|
||||||
"((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `protocol` != ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
|
|
||||||
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA, DI::userSession()->getLocalUserId()
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$condition = [
|
|
||||||
"`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
|
|
||||||
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($parent)) {
|
if (!empty($last_created)) {
|
||||||
$condition = DBA::mergeConditions($condition, ['parent' => $parent]);
|
$condition = DBA::mergeConditions($condition, ["`created` < ?", $last_created]);
|
||||||
} else {
|
|
||||||
$last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
|
|
||||||
if (!empty($last_received)) {
|
|
||||||
$condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($only_media) {
|
if ($only_media) {
|
||||||
|
@ -1626,66 +1608,108 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::mode()->isMobile()) {
|
if (DI::mode()->isMobile()) {
|
||||||
$itemsPerPage = DI::pConfig()->get(
|
$itemsPerPage = DI::pConfig()->get($uid, 'system', 'itemspage_mobile_network', DI::config()->get('system', 'itemspage_network_mobile'));
|
||||||
DI::userSession()->getLocalUserId(),
|
|
||||||
'system',
|
|
||||||
'itemspage_mobile_network',
|
|
||||||
DI::config()->get('system', 'itemspage_network_mobile')
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$itemsPerPage = DI::pConfig()->get(
|
$itemsPerPage = DI::pConfig()->get($uid, 'system', 'itemspage_network', DI::config()->get('system', 'itemspage_network'));
|
||||||
DI::userSession()->getLocalUserId(),
|
|
||||||
'system',
|
|
||||||
'itemspage_network',
|
|
||||||
DI::config()->get('system', 'itemspage_network')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||||
|
|
||||||
$params = ['order' => ['received' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
$params = ['order' => ['created' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||||
|
|
||||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
|
||||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||||
} else {
|
} else {
|
||||||
$o = '';
|
$o = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($thread_mode) {
|
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
|
||||||
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'commented'];
|
$items = Post::toArray(Post::selectForUser($uid, $fields, $condition, $params));
|
||||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
|
||||||
|
|
||||||
if ($pager->getStart() == 0) {
|
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACT_POSTS);
|
||||||
$cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
|
|
||||||
if (!empty($cdata['public'])) {
|
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
|
||||||
$pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, $fields);
|
$o .= HTML::scrollLoader();
|
||||||
|
} else {
|
||||||
|
$o .= $pager->renderMinimal(count($items));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns threads from a given contact id
|
||||||
|
*
|
||||||
|
* @param int $cid Contact ID
|
||||||
|
* @param int $update Update mode
|
||||||
|
* @param int $parent Item parent ID for the update mode
|
||||||
|
* @return string posts in HTML
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string
|
||||||
|
{
|
||||||
|
$contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
|
||||||
|
if (!DBA::isResult($contact)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($contact["network"]) || in_array($contact["network"], Protocol::FEDERATED)) {
|
||||||
|
$condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`))", $uid];
|
||||||
|
} else {
|
||||||
|
$condition = ["`uid` = ?", $uid];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($parent)) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ['parent' => $parent]);
|
||||||
|
} elseif (!empty($last_created)) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ["`created` < ?", $last_created]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id');
|
||||||
|
|
||||||
|
if (DI::mode()->isMobile()) {
|
||||||
|
$itemsPerPage = DI::pConfig()->get($uid, 'system', 'itemspage_mobile_network', DI::config()->get('system', 'itemspage_network_mobile'));
|
||||||
|
} else {
|
||||||
|
$itemsPerPage = DI::pConfig()->get($uid, 'system', 'itemspage_network', DI::config()->get('system', 'itemspage_network'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||||
|
|
||||||
|
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
|
||||||
|
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||||
|
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||||
|
} else {
|
||||||
|
$o = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition1 = DBA::mergeConditions($condition, ["`$contact_field` = ? AND `gravity` = ?", $cid, Item::GRAVITY_PARENT]);
|
||||||
|
|
||||||
|
$condition2 = DBA::mergeConditions($condition, [
|
||||||
|
"`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `protocol` != ? AND `thr-parent-id` = `parent-uri-id`",
|
||||||
|
$cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sql1 = "SELECT `uri-id`, `created` FROM `post-thread-user-view` WHERE " . array_shift($condition1);
|
||||||
|
$sql2 = "SELECT `thr-parent-id` AS `uri-id`, `created` FROM `post-user-view` WHERE " . array_shift($condition2);
|
||||||
|
|
||||||
|
$union = array_merge($condition1, $condition2);
|
||||||
|
$sql = $sql1 . " UNION " . $sql2;
|
||||||
|
|
||||||
|
$sql .= " ORDER BY `created` DESC LIMIT ?, ?";
|
||||||
|
$union = array_merge($union, [$pager->getStart(), $pager->getItemsPerPage()]);
|
||||||
|
$items = Post::toArray(DBA::p($sql, $union));
|
||||||
|
|
||||||
|
if (empty($last_created) && ($pager->getStart() == 0)) {
|
||||||
|
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'created'];
|
||||||
|
$pinned = Post\Collection::selectToArrayForContact($cid, Post\Collection::FEATURED, $fields);
|
||||||
$items = array_merge($items, $pinned);
|
$items = array_merge($items, $pinned);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACTS, $update, false, 'pinned_commented', DI::userSession()->getLocalUserId());
|
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACTS, $update, false, 'pinned_created', $uid);
|
||||||
} else {
|
|
||||||
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
|
|
||||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
|
||||||
|
|
||||||
if ($pager->getStart() == 0) {
|
|
||||||
$cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
|
|
||||||
if (!empty($cdata['public'])) {
|
|
||||||
$condition = [
|
|
||||||
"`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
|
||||||
$cdata['public'], Post\Collection::FEATURED
|
|
||||||
];
|
|
||||||
$pinned = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
|
||||||
$items = array_merge($pinned, $items);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACT_POSTS, $update);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
|
||||||
$o .= HTML::scrollLoader();
|
$o .= HTML::scrollLoader();
|
||||||
} else {
|
} else {
|
||||||
$o .= $pager->renderMinimal(count($items));
|
$o .= $pager->renderMinimal(count($items));
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Conversations extends BaseModule
|
||||||
$o = $this->conversation->statusEditor([], 0, true);
|
$o = $this->conversation->statusEditor([], 0, true);
|
||||||
|
|
||||||
$o .= Contact::getTabsHTML($contact, Contact::TAB_CONVERSATIONS);
|
$o .= Contact::getTabsHTML($contact, Contact::TAB_CONVERSATIONS);
|
||||||
$o .= Model\Contact::getPostsFromId($contact['id'], true);
|
$o .= Model\Contact::getThreadsFromId($contact['id'], $this->userSession->getLocalUserId(), 0, 0, $request['last_created'] ?? '');
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ class Follow extends BaseModule
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show last public posts
|
// Show last public posts
|
||||||
$output .= Contact::getPostsFromUrl($contact['url']);
|
$output .= Contact::getPostsFromUrl($contact['url'], $this->session->getLocalUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
|
@ -21,19 +21,37 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Contact;
|
namespace Friendica\Module\Contact;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Model\Contact as ModelContact;
|
use Friendica\Model\Contact as ModelContact;
|
||||||
use Friendica\Module\Contact;
|
use Friendica\Module\Contact;
|
||||||
|
use Friendica\Module\Response;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
|
use Friendica\Util\Profiler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GUI for media posts of a contact
|
* GUI for media posts of a contact
|
||||||
*/
|
*/
|
||||||
class Media extends BaseModule
|
class Media extends BaseModule
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var IHandleUserSessions
|
||||||
|
*/
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
|
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
}
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
$cid = $this->parameters['id'];
|
$cid = $this->parameters['id'];
|
||||||
|
@ -47,7 +65,7 @@ class Media extends BaseModule
|
||||||
|
|
||||||
$o = Contact::getTabsHTML($contact, Contact::TAB_MEDIA);
|
$o = Contact::getTabsHTML($contact, Contact::TAB_MEDIA);
|
||||||
|
|
||||||
$o .= ModelContact::getPostsFromUrl($contact['url'], false, 0, 0, true);
|
$o .= ModelContact::getPostsFromUrl($contact['url'], $this->userSession->getLocalUserId(), true);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class Posts extends BaseModule
|
||||||
|
|
||||||
$o = Contact::getTabsHTML($contact, Contact::TAB_POSTS);
|
$o = Contact::getTabsHTML($contact, Contact::TAB_POSTS);
|
||||||
|
|
||||||
$o .= Model\Contact::getPostsFromId($contact['id']);
|
$o .= Model\Contact::getPostsFromId($contact['id'], $this->userSession->getLocalUserId(), false, $request['last_created'] ?? '');
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ class Unfollow extends \Friendica\BaseModule
|
||||||
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => $this->t('Posts and Replies')]);
|
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => $this->t('Posts and Replies')]);
|
||||||
|
|
||||||
// Show last public posts
|
// Show last public posts
|
||||||
$o .= Contact::getPostsFromUrl($contact['url']);
|
$o .= Contact::getPostsFromUrl($contact['url'], $this->userSession->getLocalUserId());
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,32 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Profile;
|
namespace Friendica\Module\Profile;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Profile as ProfileModel;
|
use Friendica\Model\Profile as ProfileModel;
|
||||||
use Friendica\Module\BaseProfile;
|
use Friendica\Module\BaseProfile;
|
||||||
|
use Friendica\Module\Response;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
use Friendica\Util\Profiler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Media extends BaseProfile
|
class Media extends BaseProfile
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var IHandleUserSessions
|
||||||
|
*/
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
|
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
}
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
@ -46,7 +64,7 @@ class Media extends BaseProfile
|
||||||
|
|
||||||
$o = self::getTabsHTML('media', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
$o = self::getTabsHTML('media', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||||
|
|
||||||
$o .= Contact::getPostsFromUrl($profile['url'], false, 0, 0, true);
|
$o .= Contact::getPostsFromUrl($profile['url'], $this->userSession->getLocalUserId(), true);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ use Friendica\Database\DBA;
|
||||||
|
|
||||||
// This file is required several times during the test in DbaDefinition which justifies this condition
|
// This file is required several times during the test in DbaDefinition which justifies this condition
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1540);
|
define('DB_UPDATE_VERSION', 1541);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1551,7 +1551,8 @@ return [
|
||||||
"event-id" => ["event-id"],
|
"event-id" => ["event-id"],
|
||||||
"psid" => ["psid"],
|
"psid" => ["psid"],
|
||||||
"author-id_uid" => ["author-id", "uid"],
|
"author-id_uid" => ["author-id", "uid"],
|
||||||
"author-id_received" => ["author-id", "received"],
|
"author-id_created" => ["author-id", "created"],
|
||||||
|
"owner-id_created" => ["owner-id", "created"],
|
||||||
"parent-uri-id_uid" => ["parent-uri-id", "uid"],
|
"parent-uri-id_uid" => ["parent-uri-id", "uid"],
|
||||||
"uid_wall_received" => ["uid", "wall", "received"],
|
"uid_wall_received" => ["uid", "wall", "received"],
|
||||||
"uid_contactid" => ["uid", "contact-id"],
|
"uid_contactid" => ["uid", "contact-id"],
|
||||||
|
@ -1601,6 +1602,8 @@ return [
|
||||||
"post-user-id" => ["post-user-id"],
|
"post-user-id" => ["post-user-id"],
|
||||||
"commented" => ["commented"],
|
"commented" => ["commented"],
|
||||||
"received" => ["received"],
|
"received" => ["received"],
|
||||||
|
"author-id_created" => ["author-id", "created"],
|
||||||
|
"owner-id_created" => ["owner-id", "created"],
|
||||||
"uid_received" => ["uid", "received"],
|
"uid_received" => ["uid", "received"],
|
||||||
"uid_wall_received" => ["uid", "wall", "received"],
|
"uid_wall_received" => ["uid", "wall", "received"],
|
||||||
"uid_commented" => ["uid", "commented"],
|
"uid_commented" => ["uid", "commented"],
|
||||||
|
|
Loading…
Reference in a new issue