linagora / james-project

Mirror of Apache James Project
Apache License 2.0
72 stars 62 forks source link

[MU] Ability to list inactive users #5298

Open chibenwa opened 2 weeks ago

chibenwa commented 2 weeks ago

Why ?

As an administrator I wish to list inactive users of my email service.

We can distinguish two kind of inactive users:

We can easily add filters in the /users webadmin endpoint to support this.

curl -XGET /users?hasNoMailboxes
curl -XGET /users?hasNotAllSystemMailboxes

Ideally it could be great to allow easily add further users filters by defining a little extension for it:

(for one I can see more crazier ideas of filters potentially on extensions... for 2 I do not like a hard dependencies onto mailbox component from the users route. all this call for additional indirection.)

// foreach user indicate if if shall be included in the respose
interface UserFilter extends Function<Username, Publisher<Boolean>>  
class HasNoMailboxesUserFilter implements UserFilter { ... } 
class HasNotAllSystemMailboxesUserFilter implements UserFilter { ... }

And inject a map into usersroutes.

FinallyMailboxesRoutesModule can declare the injections for those (mailbox related) filters:

MapBinder<String, UserFilter> mapBinder = MapBinder.newMapBinder(binder(), String.class, UserFilter.class);
mapBinder.addBinding("hasNoMailboxes").to(HasNoMailboxesUserFilter.class);
mapBinder.addBinding("hasNotAllSystemMailboxes").to(HasNotAllSystemMailboxesUserFilter.class);

This extension would be available only for people using james as a toolkit (guice overides / combines). User defined userFilter loading is for now out of scope.

Definition of done

hungphan227 commented 2 days ago

pr https://github.com/apache/james-project/pull/2474