Merge branch 'master' into master
This commit is contained in:
@ -9,7 +9,7 @@ const iconStyle = {
|
||||
};
|
||||
|
||||
const ClearColumnButton = ({ onClick }) => (
|
||||
<div className='column-icon' style={iconStyle} onClick={onClick}>
|
||||
<div className='column-icon' tabindex='0' style={iconStyle} onClick={onClick}>
|
||||
<i className='fa fa-trash' />
|
||||
</div>
|
||||
);
|
||||
|
@ -319,7 +319,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.simple_form {
|
||||
.simple_form, .closed-registrations-message {
|
||||
width: 300px;
|
||||
flex: 0 0 auto;
|
||||
background: rgba(darken($color1, 7%), 0.5);
|
||||
@ -340,3 +340,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.closed-registrations-message {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
text-shadow: 0 0 2px $color8;
|
||||
|
||||
small {
|
||||
display: block;
|
||||
@ -128,6 +129,7 @@
|
||||
text-transform: uppercase;
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
text-shadow: 0 0 2px $color8;
|
||||
}
|
||||
|
||||
.counter-number {
|
||||
@ -385,5 +387,6 @@
|
||||
.account__header__content {
|
||||
font-size: 14px;
|
||||
color: $color1;
|
||||
text-shadow: 0 0 2px $color8;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ class AboutController < ApplicationController
|
||||
before_action :set_body_classes
|
||||
|
||||
def index
|
||||
@description = Setting.site_description
|
||||
@description = Setting.site_description
|
||||
@open_registrations = Setting.open_registrations
|
||||
@closed_registrations_message = Setting.closed_registrations_message
|
||||
|
||||
@user = User.new
|
||||
@user.build_account
|
||||
|
@ -11,9 +11,13 @@ class Admin::SettingsController < ApplicationController
|
||||
|
||||
def update
|
||||
@setting = Setting.where(var: params[:id]).first_or_initialize(var: params[:id])
|
||||
value = settings_params[:value]
|
||||
|
||||
if @setting.value != params[:setting][:value]
|
||||
@setting.value = params[:setting][:value]
|
||||
# Special cases
|
||||
value = value == 'true' if @setting.var == 'open_registrations'
|
||||
|
||||
if @setting.value != value
|
||||
@setting.value = value
|
||||
@setting.save
|
||||
end
|
||||
|
||||
@ -22,4 +26,10 @@ class Admin::SettingsController < ApplicationController
|
||||
format.json { respond_with_bip(@setting) }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def settings_params
|
||||
params.require(:setting).permit(:value)
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
layout :determine_layout
|
||||
|
||||
before_action :check_single_user_mode
|
||||
before_action :check_enabled_registrations, only: [:new, :create]
|
||||
before_action :configure_sign_up_params, only: [:create]
|
||||
|
||||
protected
|
||||
@ -27,12 +27,12 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
new_user_session_path
|
||||
end
|
||||
|
||||
def check_single_user_mode
|
||||
redirect_to root_path if Rails.configuration.x.single_user_mode
|
||||
def check_enabled_registrations
|
||||
redirect_to root_path if Rails.configuration.x.single_user_mode || !Setting.open_registrations
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def determine_layout
|
||||
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
||||
end
|
||||
|
@ -8,6 +8,7 @@ class RemoteFollowController < ApplicationController
|
||||
|
||||
def new
|
||||
@remote_follow = RemoteFollow.new
|
||||
@remote_follow.acct = session[:remote_follow] if session.key?(:remote_follow)
|
||||
end
|
||||
|
||||
def create
|
||||
@ -22,6 +23,8 @@ class RemoteFollowController < ApplicationController
|
||||
render(:new) && return
|
||||
end
|
||||
|
||||
session[:remote_follow] = @remote_follow.acct
|
||||
|
||||
redirect_to Addressable::Template.new(redirect_url_link.template).expand(uri: "#{@account.username}@#{Rails.configuration.x.local_domain}").to_s
|
||||
else
|
||||
render :new
|
||||
|
@ -2,17 +2,30 @@
|
||||
|
||||
class EmailValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
return if Rails.configuration.x.email_domains_blacklist.empty?
|
||||
|
||||
record.errors.add(attribute, I18n.t('users.invalid_email')) if blocked_email?(value)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def blocked_email?(value)
|
||||
on_blacklist?(value) || not_on_whitelist?(value)
|
||||
end
|
||||
|
||||
def on_blacklist?(value)
|
||||
return false if Rails.configuration.x.email_domains_blacklist.blank?
|
||||
|
||||
domains = Rails.configuration.x.email_domains_blacklist.gsub('.', '\.')
|
||||
regexp = Regexp.new("@(.+\\.)?(#{domains})", true)
|
||||
|
||||
value =~ regexp
|
||||
end
|
||||
|
||||
def not_on_whitelist?(value)
|
||||
return false if Rails.configuration.x.email_domains_whitelist.blank?
|
||||
|
||||
domains = Rails.configuration.x.email_domains_whitelist.gsub('.', '\.')
|
||||
regexp = Regexp.new("@(.+\\.)?(#{domains})", true)
|
||||
|
||||
value !~ regexp
|
||||
end
|
||||
end
|
||||
|
@ -5,17 +5,17 @@ require 'singleton'
|
||||
class FeedManager
|
||||
include Singleton
|
||||
|
||||
MAX_ITEMS = 800
|
||||
MAX_ITEMS = 400
|
||||
|
||||
def key(type, id)
|
||||
"feed:#{type}:#{id}"
|
||||
end
|
||||
|
||||
def filter?(timeline_type, status, receiver)
|
||||
def filter?(timeline_type, status, receiver_id)
|
||||
if timeline_type == :home
|
||||
filter_from_home?(status, receiver)
|
||||
filter_from_home?(status, receiver_id)
|
||||
elsif timeline_type == :mentions
|
||||
filter_from_mentions?(status, receiver)
|
||||
filter_from_mentions?(status, receiver_id)
|
||||
else
|
||||
false
|
||||
end
|
||||
@ -50,10 +50,18 @@ class FeedManager
|
||||
|
||||
def merge_into_timeline(from_account, into_account)
|
||||
timeline_key = key(:home, into_account.id)
|
||||
query = from_account.statuses.limit(FeedManager::MAX_ITEMS / 4)
|
||||
|
||||
from_account.statuses.limit(MAX_ITEMS).each do |status|
|
||||
next if status.direct_visibility? || filter?(:home, status, into_account)
|
||||
redis.zadd(timeline_key, status.id, status.id)
|
||||
if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
|
||||
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true)&.first&.last&.to_i || 0
|
||||
query = query.where('id > ?', oldest_home_score)
|
||||
end
|
||||
|
||||
redis.pipelined do
|
||||
query.each do |status|
|
||||
next if status.direct_visibility? || filter?(:home, status, into_account)
|
||||
redis.zadd(timeline_key, status.id, status.id)
|
||||
end
|
||||
end
|
||||
|
||||
trim(:home, into_account.id)
|
||||
@ -61,31 +69,20 @@ class FeedManager
|
||||
|
||||
def unmerge_from_timeline(from_account, into_account)
|
||||
timeline_key = key(:home, into_account.id)
|
||||
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true)&.first&.last&.to_i || 0
|
||||
|
||||
from_account.statuses.select('id').find_each do |status|
|
||||
redis.zrem(timeline_key, status.id)
|
||||
redis.zremrangebyscore(timeline_key, status.id, status.id)
|
||||
from_account.statuses.select('id').where('id > ?', oldest_home_score).find_in_batches do |statuses|
|
||||
redis.pipelined do
|
||||
statuses.each do |status|
|
||||
redis.zrem(timeline_key, status.id)
|
||||
redis.zremrangebyscore(timeline_key, status.id, status.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def inline_render(target_account, template, object)
|
||||
rabl_scope = Class.new do
|
||||
include RoutingHelper
|
||||
|
||||
def initialize(account)
|
||||
@account = account
|
||||
end
|
||||
|
||||
def current_user
|
||||
@account.try(:user)
|
||||
end
|
||||
|
||||
def current_account
|
||||
@account
|
||||
end
|
||||
end
|
||||
|
||||
Rabl::Renderer.new(template, object, view_path: 'app/views', format: :json, scope: rabl_scope.new(target_account)).render
|
||||
Rabl::Renderer.new(template, object, view_path: 'app/views', format: :json, scope: InlineRablScope.new(target_account)).render
|
||||
end
|
||||
|
||||
private
|
||||
@ -94,37 +91,39 @@ class FeedManager
|
||||
Redis.current
|
||||
end
|
||||
|
||||
def filter_from_home?(status, receiver)
|
||||
return true if receiver.muting?(status.account)
|
||||
def filter_from_home?(status, receiver_id)
|
||||
return true if status.reply? && status.in_reply_to_id.nil?
|
||||
|
||||
should_filter = false
|
||||
check_for_mutes = [status.account_id]
|
||||
check_for_mutes.concat([status.reblog.account_id]) if status.reblog?
|
||||
|
||||
if status.reply? && status.in_reply_to_id.nil?
|
||||
should_filter = true
|
||||
elsif status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
||||
should_filter = !receiver.following?(status.in_reply_to_account) # and I'm not following the person it's a reply to
|
||||
should_filter &&= !(receiver.id == status.in_reply_to_account_id) # and it's not a reply to me
|
||||
should_filter &&= !(status.account_id == status.in_reply_to_account_id) # and it's not a self-reply
|
||||
elsif status.reblog? # Filter out a reblog
|
||||
should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person
|
||||
should_filter ||= receiver.muting?(status.reblog.account) # or muting that person
|
||||
should_filter ||= status.reblog.account.blocking?(receiver) # or if the author of the reblogged status is blocking me
|
||||
return true if Mute.where(account_id: receiver_id, target_account_id: check_for_mutes).any?
|
||||
|
||||
check_for_blocks = status.mentions.map(&:account_id)
|
||||
check_for_blocks.concat([status.reblog.account_id]) if status.reblog?
|
||||
|
||||
return true if Block.where(account_id: receiver_id, target_account_id: check_for_blocks).any?
|
||||
|
||||
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
||||
should_filter = !Follow.where(account_id: receiver_id, target_account_id: status.in_reply_to_account_id).exists? # and I'm not following the person it's a reply to
|
||||
should_filter &&= !(receiver_id == status.in_reply_to_account_id) # and it's not a reply to me
|
||||
should_filter &&= !(status.account_id == status.in_reply_to_account_id) # and it's not a self-reply
|
||||
return should_filter
|
||||
elsif status.reblog? # Filter out a reblog
|
||||
return Block.where(account_id: status.reblog.account_id, target_account_id: receiver_id).exists? # or if the author of the reblogged status is blocking me
|
||||
end
|
||||
|
||||
should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # or if it mentions someone I blocked
|
||||
|
||||
should_filter
|
||||
false
|
||||
end
|
||||
|
||||
def filter_from_mentions?(status, receiver)
|
||||
should_filter = receiver.id == status.account_id # Filter if I'm mentioning myself
|
||||
should_filter ||= receiver.blocking?(status.account) # or it's from someone I blocked
|
||||
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account)) # or if it mentions someone I blocked
|
||||
should_filter ||= (status.account.silenced? && !receiver.following?(status.account)) # of if the account is silenced and I'm not following them
|
||||
def filter_from_mentions?(status, receiver_id)
|
||||
check_for_blocks = [status.account_id]
|
||||
check_for_blocks.concat(status.mentions.pluck(:account_id))
|
||||
check_for_blocks.concat([status.in_reply_to_account]) if status.reply? && !status.in_reply_to_account_id.nil?
|
||||
|
||||
if status.reply? && !status.in_reply_to_account_id.nil? # or it's a reply
|
||||
should_filter ||= receiver.blocking?(status.in_reply_to_account) # to a user I blocked
|
||||
end
|
||||
should_filter = receiver_id == status.account_id # Filter if I'm mentioning myself
|
||||
should_filter ||= Block.where(account_id: receiver_id, target_account_id: check_for_blocks).any? # or it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked
|
||||
should_filter ||= (status.account.silenced? && !Follow.where(account_id: receiver_id, target_account_id: status.account_id).exists?) # of if the account is silenced and I'm not following them
|
||||
|
||||
should_filter
|
||||
end
|
||||
|
17
app/lib/inline_rabl_scope.rb
Normal file
17
app/lib/inline_rabl_scope.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class InlineRablScope
|
||||
include RoutingHelper
|
||||
|
||||
def initialize(account)
|
||||
@account = account
|
||||
end
|
||||
|
||||
def current_user
|
||||
@account.try(:user)
|
||||
end
|
||||
|
||||
def current_account
|
||||
@account
|
||||
end
|
||||
end
|
@ -3,9 +3,8 @@
|
||||
class Block < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :target_account, class_name: 'Account'
|
||||
belongs_to :account, required: true
|
||||
belongs_to :target_account, class_name: 'Account', required: true
|
||||
|
||||
validates :account, :target_account, presence: true
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
end
|
||||
|
@ -3,11 +3,14 @@
|
||||
class Follow < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
belongs_to :account, counter_cache: :following_count
|
||||
belongs_to :target_account, class_name: 'Account', counter_cache: :followers_count
|
||||
belongs_to :account, counter_cache: :following_count, required: true
|
||||
|
||||
belongs_to :target_account,
|
||||
class_name: 'Account',
|
||||
counter_cache: :followers_count,
|
||||
required: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account, :target_account, presence: true
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
end
|
||||
|
@ -3,12 +3,11 @@
|
||||
class FollowRequest < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :target_account, class_name: 'Account'
|
||||
belongs_to :account, required: true
|
||||
belongs_to :target_account, class_name: 'Account', required: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account, :target_account, presence: true
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
|
||||
def authorize!
|
||||
|
@ -1,11 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Mention < ApplicationRecord
|
||||
belongs_to :account, inverse_of: :mentions
|
||||
belongs_to :status
|
||||
belongs_to :account, inverse_of: :mentions, required: true
|
||||
belongs_to :status, required: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account, :status, presence: true
|
||||
validates :account, uniqueness: { scope: :status }
|
||||
end
|
||||
|
@ -33,9 +33,8 @@ class FanOutOnWriteService < BaseService
|
||||
def deliver_to_followers(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to followers"
|
||||
|
||||
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).find_each do |follower|
|
||||
next if FeedManager.instance.filter?(:home, status, follower)
|
||||
FeedManager.instance.push(:home, follower, status)
|
||||
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).find_each do |follower|
|
||||
FeedInsertWorker.perform_async(status.id, follower.id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -44,7 +43,7 @@ class FanOutOnWriteService < BaseService
|
||||
|
||||
status.mentions.includes(:account).each do |mention|
|
||||
mentioned_account = mention.account
|
||||
next if !mentioned_account.local? || !mentioned_account.following?(status.account) || FeedManager.instance.filter?(:home, status, mentioned_account)
|
||||
next if !mentioned_account.local? || !mentioned_account.following?(status.account) || FeedManager.instance.filter?(:home, status, mention.account_id)
|
||||
FeedManager.instance.push(:home, mentioned_account, status)
|
||||
end
|
||||
end
|
||||
@ -54,9 +53,9 @@ class FanOutOnWriteService < BaseService
|
||||
|
||||
payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
|
||||
|
||||
status.tags.find_each do |tag|
|
||||
FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: payload)
|
||||
FeedManager.instance.broadcast("hashtag:#{tag.name}:local", event: 'update', payload: payload) if status.account.local?
|
||||
status.tags.pluck(:name).each do |hashtag|
|
||||
FeedManager.instance.broadcast("hashtag:#{hashtag}", event: 'update', payload: payload)
|
||||
FeedManager.instance.broadcast("hashtag:#{hashtag}:local", event: 'update', payload: payload) if status.account.local?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,7 +17,7 @@ class NotifyService < BaseService
|
||||
private
|
||||
|
||||
def blocked_mention?
|
||||
FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient)
|
||||
FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient.id)
|
||||
end
|
||||
|
||||
def blocked_favourite?
|
||||
|
@ -5,9 +5,11 @@ class PrecomputeFeedService < BaseService
|
||||
# @param [Symbol] type :home or :mentions
|
||||
# @param [Account] account
|
||||
def call(_, account)
|
||||
Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS).each do |status|
|
||||
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account)
|
||||
redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
|
||||
redis.pipelined do
|
||||
Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS / 4).each do |status|
|
||||
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account.id)
|
||||
redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,21 +24,34 @@
|
||||
.screenshot-with-signup
|
||||
.mascot= image_tag 'fluffy-elephant-friend.png'
|
||||
|
||||
= simple_form_for(@user, url: user_registration_path) do |f|
|
||||
= f.simple_fields_for :account do |ff|
|
||||
= ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username') }
|
||||
- if @open_registrations
|
||||
= simple_form_for(@user, url: user_registration_path) do |f|
|
||||
= f.simple_fields_for :account do |ff|
|
||||
= ff.input :username, autofocus: true, placeholder: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username') }
|
||||
|
||||
= f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }
|
||||
= f.input :password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password') }
|
||||
= f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password') }
|
||||
= f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }
|
||||
= f.input :password, autocomplete: "off", placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password') }
|
||||
= f.input :password_confirmation, autocomplete: "off", placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password') }
|
||||
|
||||
.actions
|
||||
= f.button :button, t('about.get_started'), type: :submit
|
||||
.actions
|
||||
= f.button :button, t('about.get_started'), type: :submit
|
||||
|
||||
.info
|
||||
= link_to t('auth.login'), new_user_session_path, class: 'webapp-btn'
|
||||
·
|
||||
= link_to t('about.about_this'), about_more_path
|
||||
.info
|
||||
= link_to t('auth.login'), new_user_session_path, class: 'webapp-btn'
|
||||
·
|
||||
= link_to t('about.about_this'), about_more_path
|
||||
- else
|
||||
.closed-registrations-message
|
||||
- if @closed_registrations_message.blank?
|
||||
%p= t('about.closed_registrations')
|
||||
- else
|
||||
= @closed_registrations_message.html_safe
|
||||
.info
|
||||
= link_to t('auth.login'), new_user_session_path, class: 'webapp-btn'
|
||||
·
|
||||
= link_to t('about.other_instances'), 'https://github.com/tootsuite/mastodon/blob/master/docs/Using-Mastodon/List-of-Mastodon-instances.md'
|
||||
·
|
||||
= link_to t('about.about_this'), about_more_path
|
||||
|
||||
%h3= t('about.features_headline')
|
||||
|
||||
|
@ -38,3 +38,15 @@
|
||||
%br/
|
||||
You can use HTML tags
|
||||
%td= best_in_place @settings['site_extended_description'], :value, as: :textarea, url: admin_setting_path(@settings['site_extended_description'])
|
||||
%tr
|
||||
%td
|
||||
%strong Open registration
|
||||
%td= best_in_place @settings['open_registrations'], :value, as: :checkbox, collection: { false: 'Disabled', true: 'Enabled'}, url: admin_setting_path(@settings['open_registrations'])
|
||||
%tr
|
||||
%td
|
||||
%strong Closed registration message
|
||||
%br/
|
||||
Displayed on frontpage when registrations are closed
|
||||
%br/
|
||||
You can use HTML tags
|
||||
%td= best_in_place @settings['closed_registrations_message'], :value, as: :textarea, url: admin_setting_path(@settings['closed_registrations_message'])
|
||||
|
15
app/workers/feed_insert_worker.rb
Normal file
15
app/workers/feed_insert_worker.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FeedInsertWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(status_id, follower_id)
|
||||
status = Status.find(status_id)
|
||||
follower = Account.find(follower_id)
|
||||
|
||||
return if FeedManager.instance.filter?(:home, status, follower.id)
|
||||
FeedManager.instance.push(:home, follower, status)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
end
|
@ -3,7 +3,7 @@
|
||||
class ProcessingWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull', backtrace: true
|
||||
sidekiq_options backtrace: true
|
||||
|
||||
def perform(account_id, body)
|
||||
ProcessFeedService.new.call(body, Account.find(account_id))
|
||||
|
@ -22,6 +22,7 @@ class Pubsubhubbub::DeliveryWorker
|
||||
.headers(headers)
|
||||
.post(subscription.callback_url, body: payload)
|
||||
|
||||
return subscription.destroy! if response.code > 299 && response.code < 500 && response.code != 429 # HTTP 4xx means error is not temporary, except for 429 (throttling)
|
||||
raise "Delivery failed for #{subscription.callback_url}: HTTP #{response.code}" unless response.code > 199 && response.code < 300
|
||||
|
||||
subscription.touch(:last_successful_delivery_at)
|
||||
|
@ -3,7 +3,7 @@
|
||||
class RegenerationWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull', backtrace: true
|
||||
sidekiq_options queue: 'pull', backtrace: true, unique: :until_executed
|
||||
|
||||
def perform(account_id, _ = :home)
|
||||
PrecomputeFeedService.new.call(:home, Account.find(account_id))
|
||||
|
@ -3,7 +3,7 @@
|
||||
class SalmonWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull', backtrace: true
|
||||
sidekiq_options backtrace: true
|
||||
|
||||
def perform(account_id, body)
|
||||
ProcessInteractionService.new.call(body, Account.find(account_id))
|
||||
|
Reference in New Issue
Block a user