+ def handle_cast(%{action: :stream, topic: "user", item: item}, topics) do
+ Logger.debug("Trying to push to users")
+ recipient_topics = User.get_recipients_from_activity(item)
+ |> Enum.map(fn (%{id: id}) -> "user:#{id}" end)
+
+ Enum.each(recipient_topics, fn (topic) ->
+ push_to_socket(topics, topic, item)
+ end)
+ {:noreply, topics}
+ end
+
+ def handle_cast(%{action: :stream, topic: topic, item: item}, topics) do
+ Logger.debug("Trying to push to #{topic}")
+ Logger.debug("Pushing item to #{topic}")
+ push_to_socket(topics, topic, item)
+ {:noreply, topics}
+ end
+