forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change interaction modal in web UI (mastodon#26075)
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
- Loading branch information
1 parent
1e4ccc6
commit b4e739f
Showing
111 changed files
with
679 additions
and
1,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class InstancesIndex < Chewy::Index | ||
settings index: { refresh_interval: '30s' } | ||
|
||
index_scope ::Instance.searchable | ||
|
||
root date_detection: false do | ||
field :domain, type: 'text', index_prefixes: { min_chars: 1 } | ||
field :accounts_count, type: 'long' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::Peers::SearchController < Api::BaseController | ||
before_action :require_enabled_api! | ||
before_action :set_domains | ||
|
||
skip_before_action :require_authenticated_user!, unless: :whitelist_mode? | ||
skip_around_action :set_locale | ||
|
||
vary_by '' | ||
|
||
def index | ||
cache_even_if_authenticated! | ||
render json: @domains | ||
end | ||
|
||
private | ||
|
||
def require_enabled_api! | ||
head 404 unless Setting.peers_api_enabled && !whitelist_mode? | ||
end | ||
|
||
def set_domains | ||
return if params[:q].blank? | ||
|
||
if Chewy.enabled? | ||
@domains = InstancesIndex.query(function_score: { | ||
query: { | ||
prefix: { | ||
domain: params[:q], | ||
}, | ||
}, | ||
|
||
field_value_factor: { | ||
field: 'accounts_count', | ||
modifier: 'log2p', | ||
}, | ||
}).limit(10).pluck(:domain) | ||
else | ||
domain = params[:q].strip | ||
domain = TagManager.instance.normalize_domain(domain) | ||
@domains = Instance.searchable.where(Instance.arel_table[:domain].matches("#{Instance.sanitize_sql_like(domain)}%", false, true)).limit(10).pluck(:domain) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoteInteractionHelperController < ApplicationController | ||
vary_by '' | ||
|
||
skip_before_action :require_functional! | ||
skip_around_action :set_locale | ||
skip_before_action :update_user_sign_in | ||
|
||
content_security_policy do |p| | ||
# We inherit the normal `script-src` | ||
|
||
# Set every directive that does not have a fallback | ||
p.default_src :none | ||
p.form_action :none | ||
p.base_uri :none | ||
|
||
# Disable every directive with a fallback to cut on response size | ||
p.base_uri false | ||
p.font_src false | ||
p.img_src false | ||
p.style_src false | ||
p.media_src false | ||
p.frame_src false | ||
p.manifest_src false | ||
p.connect_src false | ||
p.child_src false | ||
p.worker_src false | ||
|
||
# Widen the directives that we do need | ||
p.frame_ancestors :self | ||
p.connect_src :https | ||
end | ||
|
||
def index | ||
expires_in(5.minutes, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) | ||
|
||
response.headers['X-Frame-Options'] = 'SAMEORIGIN' | ||
response.headers['Referrer-Policy'] = 'no-referrer' | ||
|
||
render layout: 'helper_frame' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.