Special search keywords added
This commit is contained in:
parent
c66e841c38
commit
a8a9f93e09
|
@ -2090,6 +2090,7 @@ CREATE VIEW `post-user-view` AS SELECT
|
|||
`author`.`blocked` AS `author-blocked`,
|
||||
`author`.`hidden` AS `author-hidden`,
|
||||
`author`.`updated` AS `author-updated`,
|
||||
`author`.`contact-type` AS `author-contact-type`,
|
||||
`author`.`gsid` AS `author-gsid`,
|
||||
`author`.`baseurl` AS `author-baseurl`,
|
||||
`post-user`.`owner-id` AS `owner-id`,
|
||||
|
@ -2274,6 +2275,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
|
|||
`author`.`blocked` AS `author-blocked`,
|
||||
`author`.`hidden` AS `author-hidden`,
|
||||
`author`.`updated` AS `author-updated`,
|
||||
`author`.`contact-type` AS `author-contact-type`,
|
||||
`author`.`gsid` AS `author-gsid`,
|
||||
`post-thread-user`.`owner-id` AS `owner-id`,
|
||||
`owner`.`uri-id` AS `owner-uri-id`,
|
||||
|
@ -2442,6 +2444,7 @@ CREATE VIEW `post-view` AS SELECT
|
|||
`author`.`blocked` AS `author-blocked`,
|
||||
`author`.`hidden` AS `author-hidden`,
|
||||
`author`.`updated` AS `author-updated`,
|
||||
`author`.`contact-type` AS `author-contact-type`,
|
||||
`author`.`gsid` AS `author-gsid`,
|
||||
`post`.`owner-id` AS `owner-id`,
|
||||
`owner`.`uri-id` AS `owner-uri-id`,
|
||||
|
@ -2587,6 +2590,7 @@ CREATE VIEW `post-thread-view` AS SELECT
|
|||
`author`.`blocked` AS `author-blocked`,
|
||||
`author`.`hidden` AS `author-hidden`,
|
||||
`author`.`updated` AS `author-updated`,
|
||||
`author`.`contact-type` AS `author-contact-type`,
|
||||
`author`.`gsid` AS `author-gsid`,
|
||||
`post-thread`.`owner-id` AS `owner-id`,
|
||||
`owner`.`uri-id` AS `owner-uri-id`,
|
||||
|
|
|
@ -53,8 +53,8 @@ class Engagement
|
|||
return;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['uri-id', 'created', 'owner-id', 'uid', 'private', 'contact-contact-type', 'language',
|
||||
'title', 'content-warning', 'body', 'author-name', 'author-nick', 'author-addr', 'owner-name', 'owner-nick', 'owner-addr'],
|
||||
$parent = Post::selectFirst(['uri-id', 'created', 'author-id', 'owner-id', 'uid', 'private', 'contact-contact-type', 'language', 'network',
|
||||
'title', 'content-warning', 'body', 'author-contact-type', 'author-nick', 'author-addr', 'owner-contact-type', 'owner-nick', 'owner-addr'],
|
||||
['uri-id' => $item['parent-uri-id']]);
|
||||
|
||||
if ($parent['created'] < DateTimeFormat::utc('now - ' . DI::config()->get('channel', 'engagement_hours') . ' hour')) {
|
||||
|
@ -110,9 +110,52 @@ class Engagement
|
|||
|
||||
private static function getSearchText(array $item): string
|
||||
{
|
||||
$body = $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'] . ' ' .
|
||||
$item['author-name'] . ' ' . $item['author-nick'] . ' ' . $item['author-addr'] . ' ' .
|
||||
$item['owner-name'] . ' ' . $item['owner-nick'] . ' ' . $item['owner-addr'];
|
||||
$body = '[nosmile]network:' . $item['network'];
|
||||
|
||||
switch ($item['private']) {
|
||||
case Item::PUBLIC:
|
||||
$body .= ' visibility:public';
|
||||
break;
|
||||
case Item::UNLISTED:
|
||||
$body .= ' visibility:unlisted';
|
||||
break;
|
||||
case Item::PRIVATE:
|
||||
$body .= ' visibility:private';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['author-contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$body .= ' group:' . $item['author-nick'] . ' group:' . $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'];
|
||||
}
|
||||
|
||||
if ($item['author-id'] != $item['owner-id']) {
|
||||
if ($item['owner-contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$body .= ' group:' . $item['owner-nick'] . ' group:' . $item['owner-addr'];
|
||||
} elseif (in_array($item['owner-contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
|
||||
$body .= ' from:' . $item['owner-nick'] . ' from:' . $item['owner-addr'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION, Tag::AUDIENCE]) as $tag) {
|
||||
$contact = Contact::getByURL($tag['name'], false, ['nick', 'addr', 'contact-type']);
|
||||
if (empty($contact)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($contact['contact-type'] == Contact::TYPE_COMMUNITY) && !strpos($body, 'group:' . $contact['addr'])) {
|
||||
$body .= ' group:' . $contact['nick'] . ' group:' . $contact['addr'];
|
||||
} elseif (in_array($contact['contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
|
||||
$body .= ' to:' . $contact['nick'] . ' to:' . $contact['addr'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Tag::getByURIId($item['uri-id'], [Tag::HASHTAG]) as $tag) {
|
||||
$body .= ' tag:' . $tag['name'];
|
||||
}
|
||||
|
||||
$body .= ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
|
||||
|
||||
$body = Post\Media::addAttachmentsToBody($item['uri-id'], $body);
|
||||
$text = BBCode::toPlaintext($body, false);
|
||||
|
|
|
@ -376,7 +376,11 @@ class Timeline extends BaseModule
|
|||
$condition = [];
|
||||
|
||||
if (!empty($channel->fullTextSearch)) {
|
||||
$condition = DBA::mergeConditions($condition, ["MATCH (`searchtext`) AGAINST (? IN BOOLEAN MODE)", $channel->fullTextSearch]);
|
||||
$search = $channel->fullTextSearch;
|
||||
foreach (['from', 'to', 'group', 'tag', 'network', 'visibility'] as $keyword) {
|
||||
$search = preg_replace('~(' . $keyword . ':.[\w@\.-]+)~', '"$1"', $search);
|
||||
}
|
||||
$condition = DBA::mergeConditions($condition, ["MATCH (`searchtext`) AGAINST (? IN BOOLEAN MODE)", $search]);
|
||||
}
|
||||
|
||||
if (!empty($channel->includeTags)) {
|
||||
|
|
|
@ -134,7 +134,7 @@ class Channels extends BaseSettings
|
|||
'access_key' => ["new_access_key", $this->t("Access Key"), '', $this->t('When you want to access this channel via an access key, you can define it here. Pay attentioon to not use an already used one.')],
|
||||
'include_tags' => ["new_include_tags", $this->t("Include Tags"), '', $this->t('Comma separated list of tags. A post will be used when it contains any of the listed tags.')],
|
||||
'exclude_tags' => ["new_exclude_tags", $this->t("Exclude Tags"), '', $this->t('Comma separated list of tags. If a post contain any of these tags, then it will not be part of nthis channel.')],
|
||||
'text_search' => ["new_text_search", $this->t("Full Text Search"), '', $this->t('Search terms for the body.')],
|
||||
'text_search' => ["new_text_search", $this->t("Full Text Search"), '', $this->t('Search terms for the body.')], // @todo Add dcumentation for the keywords
|
||||
'image' => ['new_image', $this->t("Images"), false, $this->t("Check to display images in the channel.")],
|
||||
'video' => ["new_video", $this->t("Videos"), false, $this->t("Check to display videos in the channel.")],
|
||||
'audio' => ["new_audio", $this->t("Audio"), false, $this->t("Check to display audio in the channel.")],
|
||||
|
|
|
@ -184,6 +184,7 @@
|
|||
"author-blocked" => ["author", "blocked"],
|
||||
"author-hidden" => ["author", "hidden"],
|
||||
"author-updated" => ["author", "updated"],
|
||||
"author-contact-type" => ["author", "contact-type"],
|
||||
"author-gsid" => ["author", "gsid"],
|
||||
"author-baseurl" => ["author", "baseurl"],
|
||||
"owner-id" => ["post-user", "owner-id"],
|
||||
|
@ -366,6 +367,7 @@
|
|||
"author-blocked" => ["author", "blocked"],
|
||||
"author-hidden" => ["author", "hidden"],
|
||||
"author-updated" => ["author", "updated"],
|
||||
"author-contact-type" => ["author", "contact-type"],
|
||||
"author-gsid" => ["author", "gsid"],
|
||||
"owner-id" => ["post-thread-user", "owner-id"],
|
||||
"owner-uri-id" => ["owner", "uri-id"],
|
||||
|
@ -532,6 +534,7 @@
|
|||
"author-blocked" => ["author", "blocked"],
|
||||
"author-hidden" => ["author", "hidden"],
|
||||
"author-updated" => ["author", "updated"],
|
||||
"author-contact-type" => ["author", "contact-type"],
|
||||
"author-gsid" => ["author", "gsid"],
|
||||
"owner-id" => ["post", "owner-id"],
|
||||
"owner-uri-id" => ["owner", "uri-id"],
|
||||
|
@ -675,6 +678,7 @@
|
|||
"author-blocked" => ["author", "blocked"],
|
||||
"author-hidden" => ["author", "hidden"],
|
||||
"author-updated" => ["author", "updated"],
|
||||
"author-contact-type" => ["author", "contact-type"],
|
||||
"author-gsid" => ["author", "gsid"],
|
||||
"owner-id" => ["post-thread", "owner-id"],
|
||||
"owner-uri-id" => ["owner", "uri-id"],
|
||||
|
|
Loading…
Reference in New Issue
Block a user