Fix public channel

master
Eugen Rochko 8 years ago
parent a9e40a3d80
commit abb8f5837e
  1. 4
      app/channels/public_channel.rb
  2. 6
      app/models/follow_suggestion.rb
  3. 4
      app/models/media_attachment.rb
  4. 2
      app/services/block_domain_service.rb
  5. 2
      app/services/fetch_remote_account_service.rb

@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading. # Be sure to restart your server when you modify this file. Action Cable runs in a loop that does not support auto reloading.
class PublicChannel < ApplicationCable::Channel class PublicChannel < ApplicationCable::Channel
def subscribed def subscribed
stream_from 'timeline:public', lambda do |encoded_message| stream_from 'timeline:public', lambda { |encoded_message|
message = ActiveSupport::JSON.decode(encoded_message) message = ActiveSupport::JSON.decode(encoded_message)
status = Status.find_by(id: message['id']) status = Status.find_by(id: message['id'])
@ -10,7 +10,7 @@ class PublicChannel < ApplicationCable::Channel
message['message'] = FeedManager.instance.inline_render(current_user.account, status) message['message'] = FeedManager.instance.inline_render(current_user.account, status)
transmit message transmit message
end }
end end
def unsubscribed def unsubscribed

@ -1,5 +1,6 @@
class FollowSuggestion class FollowSuggestion
def self.get(for_account_id, limit = 10) class << self
def get(for_account_id, limit = 10)
neo = Neography::Rest.new neo = Neography::Rest.new
query = <<END query = <<END
@ -32,7 +33,7 @@ END
private private
def self.fallback(for_account_id, limit) def fallback(for_account_id, limit)
neo = Neography::Rest.new neo = Neography::Rest.new
query = <<END query = <<END
@ -47,4 +48,5 @@ END
neo.execute_query(query, id: for_account_id, limit: limit) neo.execute_query(query, id: for_account_id, limit: limit)
end end
end
end end

@ -34,9 +34,10 @@ class MediaAttachment < ApplicationRecord
image? ? 'image' : 'video' image? ? 'image' : 'video'
end end
class << self
private private
def self.file_styles(f) def file_styles(f)
if f.instance.image? if f.instance.image?
{ {
original: '100%', original: '100%',
@ -56,4 +57,5 @@ class MediaAttachment < ApplicationRecord
} }
end end
end end
end
end end

@ -1,6 +1,6 @@
class BlockDomainService < BaseService class BlockDomainService < BaseService
def call(domain) def call(domain)
block = DomainBlock.find_or_create_by!(domain: domain) DomainBlock.find_or_create_by!(domain: domain)
Account.where(domain: domain).find_each do |account| Account.where(domain: domain).find_each do |account|
if account.subscribed? if account.subscribed?

@ -19,7 +19,7 @@ class FetchRemoteAccountService < BaseService
Rails.logger.debug "Going to webfinger #{username}@#{domain}" Rails.logger.debug "Going to webfinger #{username}@#{domain}"
return FollowRemoteAccountService.new.call("#{username}@#{domain}") return FollowRemoteAccountService.new.call("#{username}@#{domain}")
rescue TypeError => e rescue TypeError
Rails.logger.debug "Unparseable URL given: #{url}" Rails.logger.debug "Unparseable URL given: #{url}"
nil nil
rescue Nokogiri::XML::XPath::SyntaxError rescue Nokogiri::XML::XPath::SyntaxError

Loading…
Cancel
Save