Part 1 done in:
https://github.com/discourse/discourse/commit/abcb6af8f953101a1f20b5e231f52cc81867bd38