Context
In the context of ActivityPub, we want to be able to use the user picker to suggest users from the fediverse.
In addition, we want to be able to use the user picker to suggest users, groups, and users from the fediverse when using the mention macro.
Hence, it is interesting to allow the user picker to propose results from different sources of groups or users, and to allow these sources to be contributed to by extension.
Overview
I propose to introduce an UIXP used to call specific documents dedicated to the search of actors of a given kind (e.g., users, groups…).
Current Architecture
The user picker (suggestUsersAndGroups.js
) calls uorgsuggest.vm
to get the list of suggestions.
Parameters
- exactMatch (boolean): if true, return only exact matches
- input (string): the string used for the search
- wiki (
'global'
or undeclared): if ‘global’, search for global users too - media (
'json'
or undeclared ): if ‘json’ returns the result in json, otherwise returns the result in xml. - uorg: (
'user'
or undeclared): if ‘user’ search for the users, otherwise search for the groups
Response
The result of the query is a data structure (json or xml). The number of results is limited to 10.
xml
The root is a result
tag containing multiple rs
tags. The rs
tag has multiple attributes:
- id: the url of the user or group
- icon: the url of the icon of the user of group
- info: the plain user name or the group name
The body of rs
tag is the compact serialized form of the user or group
json
The result is an array of objects.
Each object has the following fields:
- value: the compact serialized form of the user or group
- label: the plain user name or the group name
- icon: the url of the icon of the user or group
- url: the url of the user or group
Proposed Architecture Changes
The parameters of uorgsuggest.vm
stay the same but uorg
is used differently.
- if empty: returns the groups (for legacy reasons)
- if equals to ‘*’: returns the results of all the UIX.
- otherwise, the string is split and only the UIX with a parameter type contained in the split list are used to form the results.
For instance,
-
users,groups
returns the suggestions of users and groups -
groups
returns only the groups suggestions - the empty string returns the groups suggestions too
-
users,activitypub
returns the suggestions for the wiki users and activitypub users.
The result stays the same but a new key, named type
is introduced. The type indicates from which UIX the results comes from.
The result of all the selected UIXs are merged, sorted by label, limited to the 10 first results, and possibly converted to XML, before being returned.
UIXP:
The UIXPs return only json results.
The conversion into XML is done only if needed after the results are merged and sorted.
- UIXP id:
org.xwiki.platform.web.userOrGroupPickerSource
- Attributes:
- type = unique type
Parameters:
- exactMatch
- input
- wiki
Use
While the uorg
parameter is empty, groups
our users
, the use of the user picker stays the same.
When uorg
is *
or a specific set of types, the type of the returned value must be used to exploit the returned values in a relevant way.
New UIX
The results for the users and groups are currently defined inside uorgsuggest.vm
.
They should probably be moved to two dedicated UIX.
WDYT?