PERF: Update like count in visible posts without an extra GET per like (PR #14869)

Currently when a user is reading a topic and some post in it receive a like from another user, the Ember app will be notified via MessageBus and issue a GET to /posts/{id} to get the new like count. This worked fine for us until today, but it can easily create a self-inflicted DDoS when a topic with a large number of visitors gets a large number of likes, since we will issue visitors * likes GET requests requests.

This patch optimizes this flow, by sending the new like count down in the MessageBus notification, removing any need for the extra request.

It shouldn’t cause any drift on the count because we send down the full count instead of the difference too.

Possible follow-ups could include handling like removal.

GitHub

What is ID 2 here? Can we have this in a named const or something so it’s not a magic number?

Looks good, just a minor issue.

Fixed in 1d78b29

@xfalcox @martin-brennan Can we please add tests for the changes here? Sorry I’m late to the review.