When a user has multiple notifications of the same type, the user may
not receive the notification depending on the order which the
notification was setup. To fix this the notification logic has changed
from looping over users to looping over notifications.
Fixes #4713.
(cherry picked from commit 01a895bbf7)