channel.rb 595 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. module ApplicationCable
  3. class Channel < ActionCable::Channel::Base
  4. protected
  5. def hydrate_status(encoded_message)
  6. message = ActiveSupport::JSON.decode(encoded_message)
  7. return [nil, message] if message['type'] == 'delete'
  8. status = Status.find_by(id: message['id'])
  9. message['message'] = FeedManager.instance.inline_render(current_user.account, status)
  10. [status, message]
  11. end
  12. def filter?(status)
  13. !status.nil? && FeedManager.instance.filter?(:public, status, current_user.account)
  14. end
  15. end
  16. end