If a moderator manually grants (or revokes) an ability, we add an entry to the admin audit log. For consistency, and to be able to help monitor the earning of abilities, let's also add an entry for automatic grants.
The log entry for manual grants is in UsersController.mod_privilege_action. That method calls CommunityUser.grant_privilege!. My first thought was to move the logging to grant_privilege!, but that might make mod_privilege_action harder to read (other things are logged there). It would also mean passing the performing user in; on the one hand that's starting to clutter the model with side effects, but on the other hand, we're already performing the notification there. Automatic grants call grant_privilege! from CommunityUser.recalc_privilege!, so maybe log there and leave the grant and its notification alone?
The entry in the audit log should be attributed to System.
If a moderator manually grants (or revokes) an ability, we add an entry to the admin audit log. For consistency, and to be able to help monitor the earning of abilities, let's also add an entry for automatic grants.
The log entry for manual grants is in
UsersController.mod_privilege_action. That method callsCommunityUser.grant_privilege!. My first thought was to move the logging togrant_privilege!, but that might makemod_privilege_actionharder to read (other things are logged there). It would also mean passing the performing user in; on the one hand that's starting to clutter the model with side effects, but on the other hand, we're already performing the notification there. Automatic grants callgrant_privilege!fromCommunityUser.recalc_privilege!, so maybe log there and leave the grant and its notification alone?The entry in the audit log should be attributed to System.