Skip to content

Commit

Permalink
Bump version to 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 8, 2023
2 parents 1ac499a + 60f2e92 commit e9a18c7
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 55 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def context

ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(ancestors_limit, current_account)
descendants_results = @status.descendants(descendants_limit, current_account, descendants_depth_limit)
references_results = @status.references
references_results = @status.readable_references(current_account)
loaded_ancestors = cache_collection(ancestors_results, Status)
loaded_descendants = cache_collection(descendants_results, Status)
loaded_references = cache_collection(references_results, Status)
Expand Down
31 changes: 31 additions & 0 deletions app/helpers/kmyblue_capabilities_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module KmyblueCapabilitiesHelper
def fedibird_capabilities
capabilities = [
:enable_wide_emoji,
:kmyblue_searchability,
:searchability,
:kmyblue_markdown,
:kmyblue_reaction_deck,
:kmyblue_visibility_login,
:status_reference,
:visibility_mutual,
:visibility_limited,
:kmyblue_limited_scope,
:kmyblue_antenna,
:kmyblue_bookmark_category,
:kmyblue_quote,
:kmyblue_searchability_limited,
:kmyblue_visibility_public_unlisted,
]

capabilities << :profile_search unless Chewy.enabled?
if Setting.enable_emoji_reaction
capabilities << :emoji_reaction
capabilities << :enable_wide_emoji_reaction
end

capabilities
end
end
9 changes: 9 additions & 0 deletions app/models/concerns/status_threading_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ def descendants(limit, account = nil, depth = nil)
find_statuses_from_tree_path(descendant_ids(limit, depth), account, promote: true)
end

def readable_references(account = nil)
statuses = references.to_a
account_ids = statuses.map(&:account_id).uniq
domains = statuses.filter_map(&:account_domain).uniq
relations = account&.relations_map(account_ids, domains) || {}
statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? }
statuses
end

def self_replies(limit)
account.statuses.where(in_reply_to_id: id, visibility: [:public, :unlisted, :public_unlisted, :login]).reorder(id: :asc).limit(limit)
end
Expand Down
5 changes: 4 additions & 1 deletion app/serializers/nodeinfo/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class NodeInfo::Serializer < ActiveModel::Serializer
include RoutingHelper
include KmyblueCapabilitiesHelper

attributes :version, :software, :protocols, :services, :usage, :open_registrations, :metadata

Expand Down Expand Up @@ -38,7 +39,9 @@ def open_registrations
end

def metadata
{}
{
features: fedibird_capabilities,
}
end

private
Expand Down
26 changes: 1 addition & 25 deletions app/serializers/rest/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ContactSerializer < ActiveModel::Serializer
end

include RoutingHelper
include KmyblueCapabilitiesHelper

attributes :domain, :title, :version, :source_url, :description,
:usage, :thumbnail, :languages, :configuration,
Expand Down Expand Up @@ -105,31 +106,6 @@ def registrations
}
end

# for third party apps
def fedibird_capabilities
capabilities = [
:enable_wide_emoji,
:enable_wide_emoji_reaction,
:kmyblue_searchability,
:searchability,
:kmyblue_markdown,
:kmyblue_reaction_deck,
:kmyblue_visibility_login,
:status_reference,
:visibility_mutual,
:visibility_limited,
:kmyblue_limited_scope,
:kmyblue_antenna,
:kmyblue_bookmark_category,
]

capabilities << :profile_search unless Chewy.enabled?
capabilities << :emoji_reaction if Setting.enable_emoji_reaction
capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility

capabilities
end

private

def registrations_enabled?
Expand Down
26 changes: 1 addition & 25 deletions app/serializers/rest/v1/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class REST::V1::InstanceSerializer < ActiveModel::Serializer
include RoutingHelper
include KmyblueCapabilitiesHelper

attributes :uri, :title, :short_description, :description, :email,
:version, :urls, :stats, :thumbnail,
Expand Down Expand Up @@ -114,31 +115,6 @@ def invites_enabled
UserRole.everyone.can?(:invite_users)
end

# for third party apps
def fedibird_capabilities
capabilities = [
:enable_wide_emoji,
:enable_wide_emoji_reaction,
:kmyblue_searchability,
:searchability,
:kmyblue_markdown,
:kmyblue_reaction_deck,
:kmyblue_visibility_login,
:status_reference,
:visibility_mutual,
:visibility_limited,
:kmyblue_limited_scope,
:kmyblue_antenna,
:kmyblue_bookmark_category,
]

capabilities << :profile_search unless Chewy.enabled?
capabilities << :emoji_reaction if Setting.enable_emoji_reaction
capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility

capabilities
end

private

def instance_presenter
Expand Down
6 changes: 3 additions & 3 deletions lib/mastodon/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def kmyblue_major
end

def kmyblue_minor
0
1
end

def kmyblue_flag
Expand All @@ -25,11 +25,11 @@ def minor
end

def patch
1
0
end

def default_prerelease
'rc1'
''
end

def prerelease
Expand Down
32 changes: 32 additions & 0 deletions spec/serializers/nodeinfo/serializer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require 'rails_helper'

describe NodeInfo::Serializer do # rubocop:disable RSpec/FilePath
let(:serialization) do
JSON.parse(
ActiveModelSerializers::SerializableResource.new(
record, adapter: NodeInfo::Adapter, serializer: described_class, root: 'nodeinfo'
).to_json
)
end
let(:record) { {} }

describe 'nodeinfo version' do
it 'returns 2.0' do
expect(serialization['version']).to eq '2.0'
end
end

describe 'mastodon version' do
it 'contains kmyblue' do
expect(serialization['software']['version'].include?('kmyblue')).to be true
end
end

describe 'metadata' do
it 'returns features' do
expect(serialization['metadata']['features']).to include 'emoji_reaction'
end
end
end
6 changes: 6 additions & 0 deletions spec/serializers/rest/instance_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
end
end

describe 'fedibird_capabilities' do
it 'returns fedibird_capabilities' do
expect(serialization['fedibird_capabilities']).to include 'emoji_reaction'
end
end
end

0 comments on commit e9a18c7

Please sign in to comment.