Hi,
I implemented this feature in the following pull request. Feedback is appreciated.
https://github.com/discourse/discourse/pull/5065