Skip to content

Commit

Permalink
quotable concern stub, i think this is where you put this?
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Aug 19, 2024
1 parent bdf152d commit 7dd2591
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/javascript/flavours/glitch/api_types/statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ export interface ApiStatusJSON {
// glitch-soc additions
local_only?: boolean;
content_type?: string;
quotable?: boolean;
}
26 changes: 26 additions & 0 deletions app/models/concerns/status/quotable_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

# Determine whether a status can be quoted by a given account
module Status::QuotableConcern
extend ActiveSupport::Concern

included do
def quotable?
if current_user?
!noquote && !filtered && distributable?
else
false
end
end
end

def noquote
# whether the account has #NoQuote tag in bio
false
end

def filtered
# whether the account has filtered notifications from us
false
end
end
1 change: 1 addition & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Status < ApplicationRecord
include Discard::Model
include Paginable
include RateLimitable
include Status::QuotableConcern
include Status::SafeReblogInsert
include Status::SearchConcern
include Status::SnapshotConcern
Expand Down
2 changes: 2 additions & 0 deletions app/serializers/rest/status_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
attribute :pinned, if: :pinnable?
attribute :local_only, if: :local?
has_many :filtered, serializer: REST::FilterResultSerializer, if: :current_user?
attribute :quotable, if: :current_user?

attribute :content, unless: :source_requested?
attribute :text, if: :source_requested?
Expand All @@ -35,6 +36,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer

delegate :local?, to: :object
delegate :quotable?, to: :object

def id
object.id.to_s
Expand Down

0 comments on commit 7dd2591

Please sign in to comment.