Merge upstream!! #64 <3 <3
This commit is contained in:
@@ -6,11 +6,16 @@ module Remotable
|
||||
|
||||
included do
|
||||
attachment_definitions.each_key do |attachment_name|
|
||||
attribute_name = "#{attachment_name}_remote_url".to_sym
|
||||
method_name = "#{attribute_name}=".to_sym
|
||||
attribute_name = "#{attachment_name}_remote_url".to_sym
|
||||
method_name = "#{attribute_name}=".to_sym
|
||||
alt_method_name = "reset_#{attachment_name}!".to_sym
|
||||
|
||||
define_method method_name do |url|
|
||||
parsed_url = Addressable::URI.parse(url).normalize
|
||||
begin
|
||||
parsed_url = Addressable::URI.parse(url).normalize
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
return
|
||||
end
|
||||
|
||||
return if !%w(http https).include?(parsed_url.scheme) || parsed_url.host.empty? || self[attribute_name] == url
|
||||
|
||||
@@ -26,10 +31,20 @@ module Remotable
|
||||
send("#{attachment_name}_file_name=", filename)
|
||||
|
||||
self[attribute_name] = url if has_attribute?(attribute_name)
|
||||
rescue HTTP::TimeoutError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError => e
|
||||
rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
|
||||
Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
define_method alt_method_name do
|
||||
url = self[attribute_name]
|
||||
|
||||
return if url.blank?
|
||||
|
||||
self[attribute_name] = ''
|
||||
send(method_name, url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
5
app/models/context.rb
Normal file
5
app/models/context.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Context < ActiveModelSerializers::Model
|
||||
attributes :ancestors, :descendants
|
||||
end
|
@@ -20,8 +20,7 @@ class Feed
|
||||
max_id = '+inf' if max_id.blank?
|
||||
since_id = '-inf' if since_id.blank?
|
||||
unhydrated = redis.zrevrangebyscore(key, "(#{max_id}", "(#{since_id}", limit: [0, limit], with_scores: true).map(&:last).map(&:to_i)
|
||||
status_map = Status.where(id: unhydrated).cache_ids.map { |s| [s.id, s] }.to_h
|
||||
unhydrated.map { |id| status_map[id] }.compact
|
||||
Status.where(id: unhydrated).cache_ids
|
||||
end
|
||||
|
||||
def from_database(limit, max_id, since_id)
|
||||
|
29
app/models/form/admin_settings.rb
Normal file
29
app/models/form/admin_settings.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Form::AdminSettings
|
||||
include ActiveModel::Model
|
||||
|
||||
delegate(
|
||||
:site_contact_username,
|
||||
:site_contact_username=,
|
||||
:site_contact_email,
|
||||
:site_contact_email=,
|
||||
:site_title,
|
||||
:site_title=,
|
||||
:site_description,
|
||||
:site_description=,
|
||||
:site_extended_description,
|
||||
:site_extended_description=,
|
||||
:site_terms,
|
||||
:site_terms=,
|
||||
:open_registrations,
|
||||
:open_registrations=,
|
||||
:closed_registrations_message,
|
||||
:closed_registrations_message=,
|
||||
:open_deletion,
|
||||
:open_deletion=,
|
||||
:timeline_preview,
|
||||
:timeline_preview=,
|
||||
to: Setting
|
||||
)
|
||||
end
|
@@ -18,6 +18,8 @@
|
||||
# file_meta :json
|
||||
#
|
||||
|
||||
require 'mime/types'
|
||||
|
||||
class MediaAttachment < ApplicationRecord
|
||||
self.inheritance_column = nil
|
||||
|
||||
|
5
app/models/search.rb
Normal file
5
app/models/search.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Search < ActiveModelSerializers::Model
|
||||
attributes :accounts, :statuses, :hashtags
|
||||
end
|
@@ -69,9 +69,7 @@ class SessionActivation < ApplicationRecord
|
||||
def assign_access_token
|
||||
superapp = Doorkeeper::Application.find_by(superapp: true)
|
||||
|
||||
return if superapp.nil?
|
||||
|
||||
self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp.id,
|
||||
self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id,
|
||||
resource_owner_id: user_id,
|
||||
scopes: 'read write follow',
|
||||
expires_in: Doorkeeper.configuration.access_token_expires_in,
|
||||
|
@@ -79,6 +79,10 @@ class User < ApplicationRecord
|
||||
settings.default_privacy || (account.locked? ? 'private' : 'public')
|
||||
end
|
||||
|
||||
def setting_default_sensitive
|
||||
settings.default_sensitive
|
||||
end
|
||||
|
||||
def setting_boost_modal
|
||||
settings.boost_modal
|
||||
end
|
||||
@@ -91,6 +95,10 @@ class User < ApplicationRecord
|
||||
settings.auto_play_gif
|
||||
end
|
||||
|
||||
def setting_system_font_ui
|
||||
settings.system_font_ui
|
||||
end
|
||||
|
||||
def activate_session(request)
|
||||
session_activations.activate(session_id: SecureRandom.hex,
|
||||
user_agent: request.user_agent,
|
||||
|
Reference in New Issue
Block a user