Fix #614 - extra reply-boolean on statuses to account for cases when replied-to
status is not in the system at time of distribution; fix #607 - reset privacy settings to defaults when cancelling repliesmaster
parent
c424df5192
commit
6331ed16e5
@ -1,22 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
module ApplicationCable |
||||
class Channel < ActionCable::Channel::Base |
||||
protected |
||||
|
||||
def hydrate_status(encoded_message) |
||||
message = Oj.load(encoded_message) |
||||
|
||||
return [nil, message] if message['event'] == 'delete' |
||||
|
||||
status_json = Oj.load(message['payload']) |
||||
status = Status.find(status_json['id']) |
||||
|
||||
[status, message] |
||||
end |
||||
|
||||
def filter?(status) |
||||
!status.nil? && FeedManager.instance.filter?(:public, status, current_user.account) |
||||
end |
||||
end |
||||
end |
@ -1,22 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
module ApplicationCable |
||||
class Connection < ActionCable::Connection::Base |
||||
identified_by :current_user |
||||
|
||||
def connect |
||||
self.current_user = find_verified_user |
||||
end |
||||
|
||||
protected |
||||
|
||||
def find_verified_user |
||||
catch :warden do |
||||
verified_user = env['warden'].user |
||||
return verified_user if verified_user |
||||
end |
||||
|
||||
reject_unauthorized_connection |
||||
end |
||||
end |
||||
end |
@ -1,13 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class HashtagChannel < ApplicationCable::Channel |
||||
def subscribed |
||||
tag = params[:tag].downcase |
||||
|
||||
stream_from "timeline:hashtag:#{tag}", lambda { |encoded_message| |
||||
status, message = hydrate_status(encoded_message) |
||||
next if filter?(status) |
||||
transmit message |
||||
} |
||||
end |
||||
end |
@ -1,11 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class PublicChannel < ApplicationCable::Channel |
||||
def subscribed |
||||
stream_from 'timeline:public', lambda { |encoded_message| |
||||
status, message = hydrate_status(encoded_message) |
||||
next if filter?(status) |
||||
transmit message |
||||
} |
||||
end |
||||
end |
@ -1,7 +0,0 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class TimelineChannel < ApplicationCable::Channel |
||||
def subscribed |
||||
stream_from "timeline:#{current_user.account_id}" |
||||
end |
||||
end |
@ -0,0 +1,10 @@ |
||||
class AddReplyToStatuses < ActiveRecord::Migration[5.0] |
||||
def up |
||||
add_column :statuses, :reply, :boolean, nil: false, default: false |
||||
Status.update_all('reply = (in_reply_to_id IS NOT NULL)') |
||||
end |
||||
|
||||
def down |
||||
remove_column :statuses, :reply |
||||
end |
||||
end |
Loading…
Reference in new issue