Merge pull request #9062 from annando/show-reshared
Display a symbol when a post had been reshared
This commit is contained in:
commit
96ffe95949
5 changed files with 56 additions and 6 deletions
|
@ -708,17 +708,48 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
||||||
*/
|
*/
|
||||||
function conversation_fetch_comments($thread_items, $pinned) {
|
function conversation_fetch_comments($thread_items, $pinned) {
|
||||||
$comments = [];
|
$comments = [];
|
||||||
|
$parentlines = [];
|
||||||
|
$lineno = 0;
|
||||||
|
$direction = [];
|
||||||
|
$received = '';
|
||||||
|
|
||||||
while ($row = Item::fetch($thread_items)) {
|
while ($row = Item::fetch($thread_items)) {
|
||||||
|
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'])];
|
||||||
|
$received = $row['received'];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if ($row['gravity'] == GRAVITY_PARENT) {
|
if ($row['gravity'] == GRAVITY_PARENT) {
|
||||||
$row['pinned'] = $pinned;
|
$row['pinned'] = $pinned;
|
||||||
}
|
}
|
||||||
|
|
||||||
$comments[] = $row;
|
$comments[] = $row;
|
||||||
|
$lineno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::close($thread_items);
|
DBA::close($thread_items);
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
foreach ($parentlines as $line) {
|
||||||
|
$comments[$line]['direction'] = $direction;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +814,7 @@ function conversation_fetch_items(array $parent, array $items, array $condition,
|
||||||
$condition[0] .= " AND NOT `author`.`hidden`";
|
$condition[0] .= " AND NOT `author`.`hidden`";
|
||||||
}
|
}
|
||||||
|
|
||||||
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
|
$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);
|
$comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Security;
|
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
use Text_LanguageDetect;
|
use Text_LanguageDetect;
|
||||||
|
@ -57,6 +56,7 @@ class Item
|
||||||
const PT_VIDEO = 18;
|
const PT_VIDEO = 18;
|
||||||
const PT_DOCUMENT = 19;
|
const PT_DOCUMENT = 19;
|
||||||
const PT_EVENT = 32;
|
const PT_EVENT = 32;
|
||||||
|
const PT_TAG = 64;
|
||||||
const PT_PERSONAL_NOTE = 128;
|
const PT_PERSONAL_NOTE = 128;
|
||||||
|
|
||||||
// Field list that is used to display the items
|
// Field list that is used to display the items
|
||||||
|
@ -2046,8 +2046,14 @@ class Item
|
||||||
|
|
||||||
$uids = Tag::getUIDListByURIId($item['uri-id']);
|
$uids = Tag::getUIDListByURIId($item['uri-id']);
|
||||||
foreach ($uids as $uid) {
|
foreach ($uids as $uid) {
|
||||||
$stored = self::storeForUserByUriId($item['uri-id'], $uid);
|
if (Contact::isSharing($item['author-id'], $uid)) {
|
||||||
Logger::info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
$fields = [];
|
||||||
|
} else {
|
||||||
|
$fields = ['post-type' => self::PT_TAG];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stored = self::storeForUserByUriId($item['uri-id'], $uid, $fields);
|
||||||
|
Logger::info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'fields' => $fields, 'stored' => $stored]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2215,9 +2221,10 @@ class Item
|
||||||
*
|
*
|
||||||
* @param integer $uri_id URI-ID of the given item
|
* @param integer $uri_id URI-ID of the given item
|
||||||
* @param integer $uid The user that will receive the item entry
|
* @param integer $uid The user that will receive the item entry
|
||||||
|
* @param array $fields Additional fields to be stored
|
||||||
* @return integer stored item id
|
* @return integer stored item id
|
||||||
*/
|
*/
|
||||||
public static function storeForUserByUriId(int $uri_id, int $uid)
|
public static function storeForUserByUriId(int $uri_id, int $uid, array $fields = [])
|
||||||
{
|
{
|
||||||
$item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $uri_id, 'uid' => 0]);
|
$item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $uri_id, 'uid' => 0]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
|
@ -2229,6 +2236,8 @@ class Item
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item = array_merge($item, $fields);
|
||||||
|
|
||||||
$stored = self::storeForUser($item, $uid);
|
$stored = self::storeForUser($item, $uid);
|
||||||
Logger::info('Public item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
Logger::info('Public item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
|
||||||
return $stored;
|
return $stored;
|
||||||
|
|
|
@ -409,7 +409,9 @@ class Post
|
||||||
}
|
}
|
||||||
|
|
||||||
$direction = [];
|
$direction = [];
|
||||||
if (DI::config()->get('debug', 'show_direction')) {
|
if (!empty($item['direction'])) {
|
||||||
|
$direction = $item['direction'];
|
||||||
|
} elseif (DI::config()->get('debug', 'show_direction')) {
|
||||||
$conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]);
|
$conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]);
|
||||||
if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) {
|
if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) {
|
||||||
$title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
|
$title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
<i class="fa fa-inbox" aria-hidden="true" title="{{$direction.title}}"></i>
|
<i class="fa fa-inbox" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
{{elseif $direction.direction == 2}}
|
{{elseif $direction.direction == 2}}
|
||||||
<i class="fa fa-download" aria-hidden="true" title="{{$direction.title}}"></i>
|
<i class="fa fa-download" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
|
{{elseif $direction.direction == 3}}
|
||||||
|
<i class="fa fa-share-alt" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
|
{{elseif $direction.direction == 4}}
|
||||||
|
<i class="fa fa-hashtag" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
<i class="icon-inbox" aria-hidden="true" title="{{$direction.title}}"></i>
|
<i class="icon-inbox" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
{{elseif $direction.direction == 2}}
|
{{elseif $direction.direction == 2}}
|
||||||
<i class="icon-download" aria-hidden="true" title="{{$direction.title}}"></i>
|
<i class="icon-download" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
|
{{elseif $direction.direction == 3}}
|
||||||
|
<i class="icon-share" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
|
{{elseif $direction.direction == 4}}
|
||||||
|
<i class="icon-tag" aria-hidden="true" title="{{$direction.title}}"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Reference in a new issue