Documentation for what values things like getFeature() can return

Hello!

Sorry if this is a novice question but when looking at the Nextcloud PHP API I often struggle finding out what values things can return. Lets take UserChangedEvent for example:

UserChangedEvent has a method getFeature() that the docs state returns a string, but what values can it get? I already suspected that there are some specific types of “changes” that it notifies about, but the only place I found was the tests written for the method in the nextcloud server git:
apps/admin_audit/tests/Listener/UserManagementEventListenerTest.php

from where it seems the only values $feature can get are “enabled” and “eMailAddress”.. (unless I’m misunderstanding)

Is there a better way to find out such things?


Or put in another way: where do I learn what more precisely triggers certain events? Like what is the difference between UserChangedEvent and UserUpdatedEvent? Both can be listened to for email adress changes..


Or put yet another way:
Lets say I’m looking to listen to when users email-addresses change, and do something then.
What procedure should I use to find the best event to listen to, and find out what data I get from it?

Hello!

Yes and no: the named test only mentiones these two values for feature, yeah, that is true. But this is just some arbitrary test (related to logging if I understand correclty). So, it is not necessarily the complete story.

I fear, this is not possible (as any app could trigger the events), but let’s look at this example: Your starting point is Code search results · GitHub. You could go even more specific.

You see the class OC\User\User triggers the event in the triggerChange method. Digging deeper into the code (and searching into the code), you find more options for the feature setting:

  • enabled
  • eMailAddress
  • quota
  • managers
  • displayName
  • avatar

Doing the same on the other event, you find that the UserChangedEvent is for changes to the user itself as configured. The OCP\Accounts\UserUpdatedEvent (also note the different namespace!) is about account data (like the data you set in the settings like mail addresses, alias, company, phone number, website etc). It is triggered once any of these change.

I fear there is only a single source of truth… the NC server code base. It is the ultimative source and you can find (almost) anything there. It would be nice if there was a documentation out there but unfortnately, I know of none (and thus search the source code if I need to get some infos).

Chris

1 Like