`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`,
`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`,
`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`,
`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`,
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')) {
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);
$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)) {
'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.")],
"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"],
"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"],
"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"],
"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"],