review/refactor federated search

This commit is contained in:
Mike Macgirvin 2023-01-21 08:22:35 +11:00
parent 195ce4e5ee
commit e1b9a29d87
3 changed files with 24 additions and 26 deletions

View file

@ -453,10 +453,6 @@ class Activity
$ret[] = ['ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((str_starts_with($t['name'], '#')) ? substr($t['name'], 1) : $t['name'])];
break;
case 'topicalCollection':
$ret[] = ['ttype' => TERM_PCATEGORY, 'url' => $t['href'], 'term' => escape_tags($t['name'])];
break;
case 'Category':
$ret[] = ['ttype' => TERM_CATEGORY, 'url' => $t['href'], 'term' => escape_tags($t['name'])];
break;
@ -505,12 +501,6 @@ class Activity
}
break;
case TERM_PCATEGORY:
if ($t['url'] && $t['term']) {
$ret[] = ['type' => 'topicalCollection', 'href' => $t['url'], 'name' => $t['term']];
}
break;
case TERM_CATEGORY:
if ($t['url'] && $t['term']) {
$ret[] = ['type' => 'Category', 'href' => $t['url'], 'name' => $t['term']];
@ -801,8 +791,10 @@ class Activity
}
}
if ($item['mid'] !== $item['parent_mid']) {
if ($item['mid'] === $item['parent_mid']) {
$activity['isContainedConversation'] = true;
}
else {
// inReplyTo needs to be set in the activity for followup actions (Like, Dislike, Announce, etc.),
// but *not* for comments and RSVPs, where it should only be present in the object
@ -827,11 +819,12 @@ class Activity
$cnv = $item['parent_mid'];
}
}
if (isset($cnv) && $cnv) {
if (!empty($cnv)) {
if (is_string($cnv) && str_starts_with($cnv, z_root())) {
$cnv = str_replace(['/item/', '/activity/'], ['/conversation/', '/conversation/'], $cnv);
}
$activity['context'] = $cnv;
$activity['conversation'] = $cnv;
}
if (intval($item['item_private']) === 2) {
@ -1174,6 +1167,7 @@ class Activity
$activity['attributedTo'] = self::encode_person($item['author'],false);
if ($item['mid'] === $item['parent_mid']) {
$activity['isContainedConversation'] = true;
if (in_array($activity['commentPolicy'], ['public', 'authenticated'])) {
$activity['canReply'] = ACTIVITY_PUBLIC_INBOX;
} elseif (in_array($activity['commentPolicy'], ['contacts', 'specific'])) {
@ -1199,11 +1193,12 @@ class Activity
$cnv = $item['parent_mid'];
}
}
if (isset($cnv) && $cnv) {
if (!empty($cnv)) {
if (is_string($cnv) && str_starts_with($cnv, z_root())) {
$cnv = str_replace(['/item/', '/activity/'], ['/conversation/', '/conversation/'], $cnv);
}
$activity['context'] = $cnv;
$activity['conversation'] = $cnv;
}
// provide ocap access token for private media.
@ -4573,17 +4568,8 @@ class Activity
'oauthRegistrationEndpoint' => 'litepub:oauthRegistrationEndpoint',
'sensitive' => 'as:sensitive',
'movedTo' => 'as:movedTo',
'copiedTo' => 'as:copiedTo',
'alsoKnownAs' => 'as:alsoKnownAs',
'EmojiReact' => 'as:EmojiReact',
'commentPolicy' => 'nomad:commentPolicy',
'topicalCollection' => 'nomad:topicalCollection',
'eventRepeat' => 'nomad:eventRepeat',
'emojiReaction' => 'nomad:emojiReaction',
'expires' => 'nomad:expires',
'directMessage' => 'nomad:directMessage',
'Category' => 'nomad:Category',
'replyTo' => 'nomad:replyTo',
'PropertyValue' => 'schema:PropertyValue',
'value' => 'schema:value',
'discoverable' => 'toot:discoverable',
@ -4594,6 +4580,16 @@ class Activity
'canReply' => 'toot:canReply',
'approval' => 'toot:approval',
'Identity' => 'fep:Identity',
'isContainedConversation' => 'nomad:isContainedConversation',
'conversation' => 'nomad:conversation',
'commentPolicy' => 'nomad:commentPolicy',
'eventRepeat' => 'nomad:eventRepeat',
'emojiReaction' => 'nomad:emojiReaction',
'expires' => 'nomad:expires',
'directMessage' => 'nomad:directMessage',
'Category' => 'nomad:Category',
'replyTo' => 'nomad:replyTo',
'copiedTo' => 'as:copiedTo',
];
}

View file

@ -53,11 +53,13 @@ class Search extends Controller
}
Navbar::set_selected('Search');
$format = (($_REQUEST['module_format']) ? $_REQUEST['module_format'] : '');
$format = (($_REQUEST['module_format']) ?: '');
if (ActivityStreams::is_as_request()) {
$format = 'json';
}
if ($format !== '') {
$this->updating = $this->loading = 1;
}
$observer = App::get_observer();
$observer_hash = (($observer) ? $observer['xchan_hash'] : '');

View file

@ -19,7 +19,7 @@ The URL endpoints are:
Direct Messages
Direct Messages (DM) are differentiated from other private messaging using the zot:directMessage flag (boolean). This is compatible with the same facility provided by other projects in other namespaces and is not prefixed within activities so that these may potentially be aggregated.
Direct Messages (DM) are differentiated from other private messaging using the nomad:directMessage flag (boolean). This is compatible with the same facility provided by other projects in other namespaces and is not prefixed within activities so that these may potentially be aggregated.
Events