perf(messages): caches unread messages count to reduce queries

Fixes #6942
Would it be better to do this in event hooks instead of hardcoded into actions?