Skip to content

Commit

Permalink
Merge pull request mastodon#960 from ThibG/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes
  • Loading branch information
ClearlyClaire committed Mar 14, 2019
2 parents fa75324 + 09ac5e7 commit c2fa0f7
Show file tree
Hide file tree
Showing 106 changed files with 536 additions and 433 deletions.
78 changes: 39 additions & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.2)
actionpack (= 5.2.2)
actioncable (5.2.2.1)
actionpack (= 5.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
actionmailer (5.2.2.1)
actionpack (= 5.2.2.1)
actionview (= 5.2.2.1)
activejob (= 5.2.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.2)
actionview (= 5.2.2)
activesupport (= 5.2.2)
actionpack (5.2.2.1)
actionview (= 5.2.2.1)
activesupport (= 5.2.2.1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.2)
activesupport (= 5.2.2)
actionview (5.2.2.1)
activesupport (= 5.2.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -44,20 +44,20 @@ GEM
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
active_record_query_trace (1.6.2)
activejob (5.2.2)
activesupport (= 5.2.2)
activejob (5.2.2.1)
activesupport (= 5.2.2.1)
globalid (>= 0.3.6)
activemodel (5.2.2)
activesupport (= 5.2.2)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
activemodel (5.2.2.1)
activesupport (= 5.2.2.1)
activerecord (5.2.2.1)
activemodel (= 5.2.2.1)
activesupport (= 5.2.2.1)
arel (>= 9.0)
activestorage (5.2.2)
actionpack (= 5.2.2)
activerecord (= 5.2.2)
activestorage (5.2.2.1)
actionpack (= 5.2.2.1)
activerecord (= 5.2.2.1)
marcel (~> 0.3.1)
activesupport (5.2.2)
activesupport (5.2.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -232,7 +232,7 @@ GEM
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
get_process_mem (0.2.3)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
goldfinger (2.1.0)
addressable (~> 2.5)
Expand Down Expand Up @@ -271,7 +271,7 @@ GEM
httplog (1.2.1)
rack (>= 1.0)
rainbow (>= 2.0.0)
i18n (1.5.3)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
i18n-tasks (0.9.28)
activesupport (>= 4.0.2)
Expand Down Expand Up @@ -343,7 +343,7 @@ GEM
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.2)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
Expand Down Expand Up @@ -436,18 +436,18 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.2)
actioncable (= 5.2.2)
actionmailer (= 5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
activemodel (= 5.2.2)
activerecord (= 5.2.2)
activestorage (= 5.2.2)
activesupport (= 5.2.2)
rails (5.2.2.1)
actioncable (= 5.2.2.1)
actionmailer (= 5.2.2.1)
actionpack (= 5.2.2.1)
actionview (= 5.2.2.1)
activejob (= 5.2.2.1)
activemodel (= 5.2.2.1)
activerecord (= 5.2.2.1)
activestorage (= 5.2.2.1)
activesupport (= 5.2.2.1)
bundler (>= 1.3.0)
railties (= 5.2.2)
railties (= 5.2.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
Expand All @@ -463,9 +463,9 @@ GEM
railties (>= 5.0, < 6)
rails-settings-cached (0.6.6)
rails (>= 4.2.0)
railties (5.2.2)
actionpack (= 5.2.2)
activesupport (= 5.2.2)
railties (5.2.2.1)
actionpack (= 5.2.2.1)
activesupport (= 5.2.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def hashtag_scope
end
end

def set_account
@account = Account.find_local!(params[:username])
def username_param
params[:username]
end

def older_url
Expand Down
17 changes: 15 additions & 2 deletions app/controllers/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Admin
class AccountsController < BaseController
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize]
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize, :approve, :reject]
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
before_action :require_local_account!, only: [:enable, :memorialize]
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]

def index
authorize :account, :index?
Expand Down Expand Up @@ -45,6 +45,18 @@ def enable
redirect_to admin_account_path(@account.id)
end

def approve
authorize @account.user, :approve?
@account.user.approve!
redirect_to admin_accounts_path(pending: '1')
end

def reject
authorize @account.user, :reject?
SuspendAccountService.new.call(@account, including_user: true, destroy: true)
redirect_to admin_accounts_path(pending: '1')
end

def unsilence
authorize @account, :unsilence?
@account.unsilence!
Expand Down Expand Up @@ -114,6 +126,7 @@ def filter_params
:remote,
:by_domain,
:active,
:pending,
:silenced,
:suspended,
:username,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
@interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
@relay_enabled = Relay.enabled.exists?
@single_user_mode = Rails.configuration.x.single_user_mode
@registrations_enabled = Setting.open_registrations
@registrations_enabled = Setting.registrations_mode != 'none'
@deletions_enabled = Setting.open_deletion
@invites_enabled = Setting.min_invite_role == 'user'
@search_enabled = Chewy.enabled?
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SettingsController < BaseController
site_description
site_extended_description
site_terms
open_registrations
registrations_mode
closed_registrations_message
open_deletion
timeline_preview
Expand All @@ -33,7 +33,6 @@ class SettingsController < BaseController
).freeze

BOOLEAN_SETTINGS = %w(
open_registrations
open_deletion
timeline_preview
show_staff_badge
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def require_user!
elsif current_user.disabled?
render json: { error: 'Your login is currently disabled' }, status: 403
elsif !current_user.confirmed?
render json: { error: 'Email confirmation is not completed' }, status: 403
render json: { error: 'Your login is missing a confirmed e-mail address' }, status: 403
elsif !current_user.approved?
render json: { error: 'Your login is currently pending approval' }, status: 403
else
set_user_activity
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def account_params
end

def check_enabled_registrations
forbidden if single_user_mode? || !Setting.open_registrations
forbidden if single_user_mode? || !allowed_registrations?
end

def allowed_registrations?
Setting.registrations_mode != 'none'
end
end
2 changes: 1 addition & 1 deletion app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def check_enabled_registrations
end

def allowed_registrations?
Setting.open_registrations || @invite&.valid_for_use?
Setting.registrations_mode != 'none' || @invite&.valid_for_use?
end

def invite_code
Expand Down
14 changes: 12 additions & 2 deletions app/controllers/concerns/account_controller_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ module AccountControllerConcern

included do
layout 'public'

before_action :set_account
before_action :check_account_approval
before_action :check_account_suspension
before_action :set_instance_presenter
before_action :set_link_headers
before_action :check_account_suspension
end

private

def set_account
@account = Account.find_local!(params[:account_username])
@account = Account.find_local!(username_param)
end

def set_instance_presenter
Expand All @@ -33,6 +35,10 @@ def set_link_headers
)
end

def username_param
params[:account_username]
end

def webfinger_account_link
[
webfinger_account_url,
Expand All @@ -58,6 +64,10 @@ def webfinger_account_url
webfinger_url(resource: @account.to_webfinger_s)
end

def check_account_approval
not_found if @account.user_pending?
end

def check_account_suspension
gone if @account.suspended?
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin/filter_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Admin::FilterHelper
ACCOUNT_FILTERS = %i(local remote by_domain active silenced suspended username display_name email ip staff).freeze
ACCOUNT_FILTERS = %i(local remote by_domain active pending silenced suspended username display_name email ip staff).freeze
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
INVITE_FILTER = %i(available expired).freeze
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
Expand Down
18 changes: 17 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ def show_landing_strip?
end

def open_registrations?
Setting.open_registrations
Setting.registrations_mode == 'open'
end

def approved_registrations?
Setting.registrations_mode == 'approved'
end

def closed_registrations?
Setting.registrations_mode == 'none'
end

def available_sign_up_path
if closed_registrations?
'https://joinmastodon.org/#getting-started'
else
new_user_registration_path
end
end

def open_deletion?
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ def optional_link_to(condition, path, options = {}, &block)
content_tag(:div, &block)
end
end

def sign_up_message
if closed_registrations?
t('auth.registration_closed', instance: site_hostname)
elsif open_registrations?
t('auth.register')
elsif approved_registrations?
t('auth.apply_for_account')
end
end
end
8 changes: 8 additions & 0 deletions app/javascript/flavours/glitch/styles/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,11 @@ a.name-tag,
overflow: hidden;
text-overflow: ellipsis;
}

.ellipsized-ip {
display: inline-block;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: middle;
}
4 changes: 4 additions & 0 deletions app/javascript/flavours/glitch/styles/tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
}
}
}

&--invites tbody td {
vertical-align: middle;
}
}

.table-wrapper {
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/styles/mastodon/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,11 @@ a.name-tag,
overflow: hidden;
text-overflow: ellipsis;
}

.ellipsized-ip {
display: inline-block;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: middle;
}
4 changes: 4 additions & 0 deletions app/javascript/styles/mastodon/tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
}
}
}

&--invites tbody td {
vertical-align: middle;
}
}

.table-wrapper {
Expand Down
10 changes: 10 additions & 0 deletions app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ def new_report(recipient, report)
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_report.subject', instance: @instance, id: @report.id)
end
end

def new_pending_account(recipient, user)
@account = user.account
@me = recipient
@instance = Rails.configuration.x.local_domain

locale_for_account(@me) do
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_pending_account.subject', instance: @instance, username: @account.username)
end
end
end
Loading

0 comments on commit c2fa0f7

Please sign in to comment.