Mark posts that arrived in your network stream via tag

This commit is contained in:
Michael 2020-08-23 17:48:44 +00:00
parent 1493875ec9
commit 6139f5883b
3 changed files with 19 additions and 4 deletions

View file

@ -728,6 +728,10 @@ function conversation_fetch_comments($thread_items, $pinned) {
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;
}
@ -810,7 +814,7 @@ function conversation_fetch_items(array $parent, array $items, array $condition,
$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);

View file

@ -40,7 +40,6 @@ use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Network;
use Friendica\Util\Security;
use Friendica\Util\Strings;
use Friendica\Worker\Delivery;
use Text_LanguageDetect;
@ -57,6 +56,7 @@ class Item
const PT_VIDEO = 18;
const PT_DOCUMENT = 19;
const PT_EVENT = 32;
const PT_TAG = 64;
const PT_PERSONAL_NOTE = 128;
// Field list that is used to display the items
@ -2046,7 +2046,13 @@ class Item
$uids = Tag::getUIDListByURIId($item['uri-id']);
foreach ($uids as $uid) {
$stored = self::storeForUserByUriId($item['uri-id'], $uid);
if (Contact::isSharing($item['author-id'], $uid)) {
$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, 'stored' => $stored]);
}
}
@ -2215,9 +2221,10 @@ class Item
*
* @param integer $uri_id URI-ID of the given item
* @param integer $uid The user that will receive the item entry
* @param array $fields Additional fields to be stored
* @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]);
if (!DBA::isResult($item)) {
@ -2229,6 +2236,8 @@ class Item
return 0;
}
$item = array_merge($item, $fields);
$stored = self::storeForUser($item, $uid);
Logger::info('Public item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
return $stored;

View file

@ -7,6 +7,8 @@
<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}}
</span>
{{/if}}