Extract user notification type query generation into a new method

Fix #1705