Skip to content

feat: allow exact UID lookup through Nextcloud global search - #219

Open
vitormattos wants to merge 2 commits into
mainfrom
feat/profile-fields-directory-uid-search-20261114
Open

vitormattos wants to merge 2 commits into
mainfrom
feat/profile-fields-directory-uid-search-20261114

Conversation

@vitormattos

Copy link
Copy Markdown
Member

Objective

Allow the connected Nextcloud MCP to inspect Profile Fields through its existing unified search tool. No MCP Connector changes are required.

Changes

  • profile_fields.directory recognizes uid:<nextcloud_uid> for a Nextcloud instance administrator.
  • Each populated active field is returned as a separate paginated search hit, avoiding the current three-match preview limit.
  • Ordinary users and group-only administrators get no results for exact-UID lookups; other directory searches retain their visibility behavior.
  • Correctly stringify boolean false as false, not an empty value.
  • Unit and Nextcloud OCS/Behat regressions, plus README documentation.

Validation

  • PHP 8.4 syntax: pass on four changed PHP files.
  • Isolated runtime smoke test: pass (admin, paging, boolean, non-admin, unknown UID).
  • PHPUnit and Nextcloud Behat: not executed locally (Nextcloud runtime not available in the isolated worktree); CI pending.
  • No production changes or account imports.

Security

  • Explicitly relies on IGroupManager::isAdmin for exact-UID inspection.
  • Hidden fields are disclosed only under Nextcloud instance-administrator permissions.
  • No credentials or secrets imported, no mailbox provisioning, no new external services.

This PR is independent from changes in any upstream MCP Connector repository.

Expose populated administrative profile fields through Nextcloud search using uid:<user>. Return paginated field results and deny private lookups to non-admins.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>

@YvesCesar YvesCesar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vitormattos!

I made a few revisions. Could you take a look?

Comment thread README.md Resolved
Comment thread README.md Resolved
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>

@YvesCesar YvesCesar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vitormattos! The previous points are resolved. I left one more comment, could you take a look?

}

return trim((string)$scalar);
return is_bool($scalar) ? ($scalar ? 'true' : 'false') : trim((string)$scalar);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this in my first comment: rendering booleans as words makes the regular search match them by substring. Since the minimum term length is 2, terms like al, se, ru or ue now match every visible boolean field. Searching for al (looking for "Alice") returns every user with a boolean set to false, with subline Enabled: false. Before this PR booleans never matched in the regular search, because false was '' and true was '1'.

Could boolean fields match only the whole word in search() (line 81)? Something like:

$scalarValue = $this->extractScalarValue($value);
if ($scalarValue === null) {
	continue;
}

$normalizedValue = mb_strtolower($scalarValue);
$matches = $definition->getType() === FieldType::BOOLEAN->value
	? $normalizedValue === $normalizedTerm
	: str_contains($normalizedValue, $normalizedTerm);
if (!$matches) {
	continue;
}

testRegularSearchMatchesBooleanWords (line 249) would then search for false instead of fal, and could also assert that al returns no boolean match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants