Searchtext functionality added
This commit is contained in:
parent
36313fe35b
commit
7c43b41f0b
|
@ -38,7 +38,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
|
||||
class Engagement
|
||||
{
|
||||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'tag', 'network', 'platform', 'visibility', 'language'];
|
||||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language'];
|
||||
|
||||
/**
|
||||
* Store engagement data from an item array
|
||||
|
@ -230,6 +230,8 @@ class Engagement
|
|||
|
||||
if ($item['author-contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$body .= ' group_' . $item['author-nick'] . ' group_' . $item['author-addr'];
|
||||
} elseif ($item['author-contact-type'] == Contact::TYPE_RELAY) {
|
||||
$body .= ' application_' . $item['author-nick'] . ' application_' . $item['author-addr'];
|
||||
} elseif (in_array($item['author-contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
|
||||
$body .= ' from_' . $item['author-nick'] . ' from_' . $item['author-addr'];
|
||||
}
|
||||
|
@ -242,6 +244,8 @@ class Engagement
|
|||
}
|
||||
}
|
||||
|
||||
$body = self::addResharers($body, $item['uri-id']);
|
||||
|
||||
foreach ($receivers as $receiver) {
|
||||
$contact = Contact::getByURL($receiver, false, ['nick', 'addr', 'contact-type']);
|
||||
if (empty($contact)) {
|
||||
|
@ -269,6 +273,31 @@ class Engagement
|
|||
return BBCode::toSearchText($body, $item['uri-id']);
|
||||
}
|
||||
|
||||
private static function addResharers(string $text, int $uri_id): string
|
||||
{
|
||||
$result = Post::selectPosts(['author-addr', 'author-nick', 'author-contact-type'],
|
||||
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]);
|
||||
while ($reshare = Post::fetch($result)) {
|
||||
switch ($reshare['author-contact-type']) {
|
||||
case Contact::TYPE_RELAY:
|
||||
$prefix = ' application_';
|
||||
break;
|
||||
case Contact::TYPE_COMMUNITY:
|
||||
$prefix = ' group_';
|
||||
break;
|
||||
}
|
||||
$nick = $prefix . $reshare['author-nick'];
|
||||
$addr = $prefix . $reshare['author-addr'];
|
||||
|
||||
if (stripos($text, $addr) === false) {
|
||||
$text .= $nick . $addr;
|
||||
}
|
||||
}
|
||||
DBA::close($result);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
private static function getMediaType(int $uri_id): int
|
||||
{
|
||||
$media = Post\Media::getByURIId($uri_id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user