Inviting a group generates a notification for each member. If this happens synchronously it may take a while, leading to a poor user experience.
if post is nil this will blow up
I like to exit early like this
return unless user = User.find_by(id: args[:user_id]) return unless group = Group.find_by(id: args[:group_id]) return unless post = Post.find_by(id: args[:post_id]) return unless topic = post.topic
Do you need to create a new
PostAlerter instance for every group member?
This bit could also be generated once outside the loop.
Yay Async + moar perf