Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.github/workflows/build-image.yml`: Fix erroneous deletion in a previous merge. - `Gemfile`: Conflict caused by glitch-soc-only hCaptcha dependency - `app/controllers/auth/sessions_controller.rb`: Minor conflict due to glitch-soc's theming system. - `app/controllers/filters_controller.rb`: Minor conflict due to glitch-soc's theming system. - `app/serializers/rest/status_serializer.rb`: Minor conflict due to glitch-soc having an extra `local_only` property
This commit is contained in:
9
app/serializers/rest/admin/domain_allow_serializer.rb
Normal file
9
app/serializers/rest/admin/domain_allow_serializer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::Admin::DomainAllowSerializer < ActiveModel::Serializer
|
||||
attributes :id, :domain, :created_at
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
@@ -2,7 +2,7 @@
|
||||
|
||||
class REST::Admin::ReportSerializer < ActiveModel::Serializer
|
||||
attributes :id, :action_taken, :action_taken_at, :category, :comment,
|
||||
:created_at, :updated_at
|
||||
:forwarded, :created_at, :updated_at
|
||||
|
||||
has_one :account, serializer: REST::Admin::AccountSerializer
|
||||
has_one :target_account, serializer: REST::Admin::AccountSerializer
|
||||
|
9
app/serializers/rest/filter_keyword_serializer.rb
Normal file
9
app/serializers/rest/filter_keyword_serializer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::FilterKeywordSerializer < ActiveModel::Serializer
|
||||
attributes :id, :keyword, :whole_word
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
6
app/serializers/rest/filter_result_serializer.rb
Normal file
6
app/serializers/rest/filter_result_serializer.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::FilterResultSerializer < ActiveModel::Serializer
|
||||
belongs_to :filter, serializer: REST::FilterSerializer
|
||||
has_many :keyword_matches
|
||||
end
|
@@ -1,10 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::FilterSerializer < ActiveModel::Serializer
|
||||
attributes :id, :phrase, :context, :whole_word, :expires_at,
|
||||
:irreversible
|
||||
attributes :id, :title, :context, :expires_at, :filter_action
|
||||
has_many :keywords, serializer: REST::FilterKeywordSerializer, if: :rules_requested?
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def rules_requested?
|
||||
instance_options[:rules_requested]
|
||||
end
|
||||
end
|
||||
|
@@ -5,6 +5,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
||||
|
||||
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
||||
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
||||
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
@@ -13,4 +14,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
||||
def status_type?
|
||||
[:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type)
|
||||
end
|
||||
|
||||
def report_type?
|
||||
object.type == :'admin.report'
|
||||
end
|
||||
end
|
||||
|
@@ -1,7 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ReportSerializer < ActiveModel::Serializer
|
||||
attributes :id, :action_taken
|
||||
attributes :id, :action_taken, :action_taken_at, :category, :comment,
|
||||
:forwarded, :created_at, :status_ids, :rule_ids
|
||||
|
||||
has_one :target_account, serializer: REST::AccountSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
@@ -14,6 +14,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attribute :bookmarked, if: :current_user?
|
||||
attribute :pinned, if: :pinnable?
|
||||
attribute :local_only if :local?
|
||||
has_many :filtered, serializer: REST::FilterResultSerializer, if: :current_user?
|
||||
|
||||
attribute :content, unless: :source_requested?
|
||||
attribute :text, if: :source_requested?
|
||||
@@ -122,6 +123,14 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
end
|
||||
|
||||
def filtered
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].filters_map[object.id] || []
|
||||
else
|
||||
current_user.account.status_matches_filters(object)
|
||||
end
|
||||
end
|
||||
|
||||
def pinnable?
|
||||
current_user? &&
|
||||
current_user.account_id == object.account_id &&
|
||||
|
26
app/serializers/rest/v1/filter_serializer.rb
Normal file
26
app/serializers/rest/v1/filter_serializer.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::V1::FilterSerializer < ActiveModel::Serializer
|
||||
attributes :id, :phrase, :context, :whole_word, :expires_at,
|
||||
:irreversible
|
||||
|
||||
delegate :context, :expires_at, to: :custom_filter
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def phrase
|
||||
object.keyword
|
||||
end
|
||||
|
||||
def irreversible
|
||||
custom_filter.irreversible?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def custom_filter
|
||||
object.custom_filter
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user