闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
728 B

  1. # Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
  2. class PublicChannel < ApplicationCable::Channel
  3. def subscribed
  4. stream_from 'timeline:public', -> (encoded_message) do
  5. message = ActiveSupport::JSON.decode(encoded_message)
  6. status = Status.find_by(id: message['id'])
  7. next if status.nil? || current_user.account.blocking?(status.account) || (status.reblog? && current_user.account.blocking?(status.reblog.account))
  8. message['message'] = FeedManager.instance.inline_render(current_user.account, status)
  9. transmit message
  10. end
  11. end
  12. def unsubscribed
  13. # Any cleanup needed when channel is unsubscribed
  14. end
  15. end