Commit 7d2e6429 authored by Spencer Alves's avatar Spencer Alves
Browse files

Merge branch 'glitch' into thread-icon

parents f2ff167c e396fbfe
......@@ -11,6 +11,8 @@ aliases:
RAILS_ENV: test
PARALLEL_TEST_PROCESSORS: 4
ALLOW_NOPAM: true
CONTINUOUS_INTEGRATION: true
DISABLE_SIMPLECOV: true
working_directory: ~/projects/mastodon/
- &attach_workspace
......@@ -90,7 +92,7 @@ aliases:
command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
- run:
name: Run Tests
command: bundle exec parallel_test ./spec/ --group-by filesize --type rspec
command: ./bin/retry bundle exec parallel_test ./spec/ --group-by filesize --type rspec
jobs:
install:
......@@ -150,7 +152,7 @@ jobs:
- image: circleci/node:8.11.1-stretch
steps:
- *attach_workspace
- run: yarn test:jest
- run: ./bin/retry yarn test:jest
check-i18n:
<<: *defaults
......
......@@ -88,6 +88,10 @@ SMTP_FROM_ADDRESS=notifications@example.com
# CDN_HOST=https://assets.example.com
# S3 (optional)
# The attachment host must allow cross origin request from WEB_DOMAIN or
# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the
# following header field:
# Access-Control-Allow-Origin: https://192.168.1.123:9000/
# S3_ENABLED=true
# S3_BUCKET=
# AWS_ACCESS_KEY_ID=
......@@ -97,6 +101,8 @@ SMTP_FROM_ADDRESS=notifications@example.com
# S3_HOSTNAME=192.168.1.123:9000
# S3 (Minio Config (optional) Please check Minio instance for details)
# The attachment host must allow cross origin request - see the description
# above.
# S3_ENABLED=true
# S3_BUCKET=
# AWS_ACCESS_KEY_ID=
......@@ -108,11 +114,15 @@ SMTP_FROM_ADDRESS=notifications@example.com
# S3_SIGNATURE_VERSION=
# Swift (optional)
# The attachment host must allow cross origin request - see the description
# above.
# SWIFT_ENABLED=true
# SWIFT_USERNAME=
# For Keystone V3, the value for SWIFT_TENANT should be the project name
# SWIFT_TENANT=
# SWIFT_PASSWORD=
# Some OpenStack V3 providers require PROJECT_ID (optional)
# SWIFT_PROJECT_ID=
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
# issues with token rate-limiting during high load.
# SWIFT_AUTH_URL=
......
......@@ -7,6 +7,9 @@ env:
es6: true
jest: true
globals:
ATTACHMENT_HOST: false
parser: babel-eslint
plugins:
......
---
name: Bug Report
about: Create a report to help us improve
---
[Issue text goes here].
* * * *
......
---
name: Feature Request
about: Suggest an idea for this project
---
[Issue text goes here].
* * * *
- [ ] I searched or browsed the repo’s other issues to ensure this is not a duplicate.
......@@ -37,7 +37,7 @@ addons:
rvm:
- 2.4.3
- 2.5.0
- 2.5.1
services:
- redis-server
......@@ -47,6 +47,10 @@ install:
- bundle install --path=vendor/bundle --with pam_authentication --without development production --retry=3 --jobs=16
- yarn install
# https://github.com/travis-ci/travis-ci/issues/9333
before_install:
- gem install bundler
before_script:
- travis_wait ./bin/rails parallel:create parallel:load_schema parallel:prepare assets:precompile
......
......@@ -19,7 +19,6 @@ gem 'fog-local', '~> 0.5', require: false
gem 'fog-openstack', '~> 0.1', require: false
gem 'paperclip', '~> 6.0'
gem 'paperclip-av-transcoder', '~> 0.6'
gem 'posix-spawn', '~> 0.3'
gem 'streamio-ffmpeg', '~> 3.0'
gem 'active_model_serializers', '~> 0.10'
......@@ -42,7 +41,7 @@ gem 'omniauth-cas', '~> 1.1'
gem 'omniauth-saml', '~> 1.10'
gem 'omniauth', '~> 1.2'
gem 'doorkeeper', '~> 4.3'
gem 'doorkeeper', '~> 4.2', '< 4.3'
gem 'fast_blank', '~> 1.0'
gem 'fastimage'
gem 'goldfinger', '~> 2.1'
......@@ -52,6 +51,7 @@ gem 'html2text'
gem 'htmlentities', '~> 4.3'
gem 'http', '~> 3.2'
gem 'http_accept_language', '~> 2.1'
gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2'
gem 'httplog', '~> 1.0'
gem 'idn-ruby', require: 'idn'
gem 'kaminari', '~> 1.1'
......@@ -62,6 +62,7 @@ gem 'nsa', '~> 0.2'
gem 'oj', '~> 3.5'
gem 'ostatus2', '~> 2.0'
gem 'ox', '~> 2.9'
gem 'posix-spawn', git: 'https://github.com/rtomayko/posix-spawn', ref: '58465d2e213991f8afb13b984854a49fcdcc980c'
gem 'pundit', '~> 1.1'
gem 'premailer-rails'
gem 'rack-attack', '~> 5.2'
......@@ -113,7 +114,6 @@ group :test do
gem 'microformats', '~> 4.0'
gem 'rails-controller-testing', '~> 1.0'
gem 'rspec-sidekiq', '~> 3.0'
gem 'rspec-retry', '~> 0.5', require: false
gem 'simplecov', '~> 0.16', require: false
gem 'webmock', '~> 3.3'
gem 'parallel_tests', '~> 2.21'
......
GIT
remote: https://github.com/rtomayko/posix-spawn
revision: 58465d2e213991f8afb13b984854a49fcdcc980c
ref: 58465d2e213991f8afb13b984854a49fcdcc980c
specs:
posix-spawn (0.3.13)
GIT
remote: https://github.com/tmm1/http_parser.rb
revision: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
ref: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
specs:
http_parser.rb (0.6.1)
GEM
remote: https://rubygems.org/
specs:
......@@ -167,7 +181,7 @@ GEM
docile (1.3.0)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
doorkeeper (4.3.2)
doorkeeper (4.2.6)
railties (>= 4.2)
dotenv (2.2.2)
dotenv-rails (2.2.2)
......@@ -254,7 +268,6 @@ GEM
domain_name (~> 0.5)
http-form_data (2.1.0)
http_accept_language (2.1.1)
http_parser.rb (0.6.0)
httplog (1.0.2)
colorize (~> 0.8)
rack (>= 1.0)
......@@ -383,7 +396,6 @@ GEM
pghero (2.1.0)
activerecord
pkg-config (1.3.0)
posix-spawn (0.3.13)
powerpack (0.1.1)
premailer (1.11.1)
addressable
......@@ -503,8 +515,6 @@ GEM
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-retry (0.5.7)
rspec-core (> 3.3)
rspec-sidekiq (3.0.3)
rspec-core (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0)
......@@ -663,7 +673,7 @@ DEPENDENCIES
devise (~> 4.4)
devise-two-factor (~> 3.0)
devise_pam_authenticatable2 (~> 9.1)
doorkeeper (~> 4.3)
doorkeeper (~> 4.2, < 4.3)
dotenv-rails (~> 2.2, < 2.3)
fabrication (~> 2.20)
faker (~> 1.8)
......@@ -680,6 +690,7 @@ DEPENDENCIES
htmlentities (~> 4.3)
http (~> 3.2)
http_accept_language (~> 2.1)
http_parser.rb (~> 0.6)!
httplog (~> 1.0)
i18n-tasks (~> 0.9)
idn-ruby
......@@ -709,7 +720,7 @@ DEPENDENCIES
pg (~> 1.0)
pghero (~> 2.1)
pkg-config (~> 1.3)
posix-spawn (~> 0.3)
posix-spawn!
premailer-rails
private_address_check (~> 0.4.1)
pry-byebug (~> 3.6)
......@@ -729,7 +740,6 @@ DEPENDENCIES
redis-rails (~> 5.0)
rqrcode (~> 0.10)
rspec-rails (~> 3.7)
rspec-retry (~> 0.5)
rspec-sidekiq (~> 3.0)
rubocop (~> 0.55)
ruby-progressbar (~> 1.4)
......
......@@ -3,6 +3,7 @@
module Admin
class ConfirmationsController < BaseController
before_action :set_user
before_action :check_confirmation, only: [:resend]
def create
authorize @user, :confirm?
......@@ -11,10 +12,28 @@ module Admin
redirect_to admin_accounts_path
end
def resend
authorize @user, :confirm?
@user.resend_confirmation_instructions
log_action :confirm, @user
flash[:notice] = I18n.t('admin.accounts.resend_confirmation.success')
redirect_to admin_accounts_path
end
private
def set_user
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
end
def check_confirmation
if @user.confirmed?
flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed')
redirect_to admin_accounts_path
end
end
end
end
......@@ -3,7 +3,6 @@
module Admin
class ReportedStatusesController < BaseController
before_action :set_report
before_action :set_status, only: [:update, :destroy]
def create
authorize :status, :update?
......@@ -14,20 +13,6 @@ module Admin
redirect_to admin_report_path(@report)
end
def update
authorize @status, :update?
@status.update!(status_params)
log_action :update, @status
redirect_to admin_report_path(@report)
end
def destroy
authorize @status, :destroy?
RemovalWorker.perform_async(@status.id)
log_action :destroy, @status
render json: @status
end
private
def status_params
......@@ -51,9 +36,5 @@ module Admin
def set_report
@report = Report.find(params[:report_id])
end
def set_status
@status = @report.statuses.find(params[:id])
end
end
end
......@@ -5,7 +5,6 @@ module Admin
helper_method :current_params
before_action :set_account
before_action :set_status, only: [:update, :destroy]
PER_PAGE = 20
......@@ -26,40 +25,18 @@ module Admin
def create
authorize :status, :update?
@form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account))
@form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button))
flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
redirect_to admin_account_statuses_path(@account.id, current_params)
end
def update
authorize @status, :update?
@status.update!(status_params)
log_action :update, @status
redirect_to admin_account_statuses_path(@account.id, current_params)
end
def destroy
authorize @status, :destroy?
RemovalWorker.perform_async(@status.id)
log_action :destroy, @status
render json: @status
end
private
def status_params
params.require(:status).permit(:sensitive)
end
def form_status_batch_params
params.require(:form_status_batch).permit(:action, status_ids: [])
end
def set_status
@status = @account.statuses.find(params[:id])
end
def set_account
@account = Account.find(params[:account_id])
end
......@@ -72,5 +49,15 @@ module Admin
page: page > 1 && page,
}.select { |_, value| value.present? }
end
def action_from_button
if params[:nsfw_on]
'nsfw_on'
elsif params[:nsfw_off]
'nsfw_off'
elsif params[:delete]
'delete'
end
end
end
end
......@@ -21,7 +21,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
private
def account_params
params.permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value])
params.permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value])
end
def user_settings_params
......
......@@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
end
def load_accounts
return [] if @account.user_hides_network? && current_account.id != @account.id
default_accounts.merge(paginated_follows).to_a
end
......
......@@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
end
def load_accounts
return [] if @account.user_hides_network? && current_account.id != @account.id
default_accounts.merge(paginated_follows).to_a
end
......
......@@ -27,19 +27,17 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
end
def account_statuses
default_statuses.tap do |statuses|
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
statuses.merge!(pinned_scope) if truthy_param?(:pinned)
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
end
end
def default_statuses
permitted_account_statuses.paginate_by_max_id(
statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses
statuses = statuses.paginate_by_max_id(
limit_param(DEFAULT_STATUSES_LIMIT),
params[:max_id],
params[:since_id]
)
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
statuses
end
def permitted_account_statuses
......
# frozen_string_literal: true
class Api::V1::Push::SubscriptionsController < Api::BaseController
before_action -> { doorkeeper_authorize! :push }
before_action :require_user!
before_action :set_web_push_subscription
def create
@web_subscription&.destroy!
@web_subscription = ::Web::PushSubscription.create!(
endpoint: subscription_params[:endpoint],
key_p256dh: subscription_params[:keys][:p256dh],
key_auth: subscription_params[:keys][:auth],
data: data_params,
user_id: current_user.id,
access_token_id: doorkeeper_token.id
)
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
end
def show
raise ActiveRecord::RecordNotFound if @web_subscription.nil?
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
end
def update
raise ActiveRecord::RecordNotFound if @web_subscription.nil?
@web_subscription.update!(data: data_params)
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
end
def destroy
@web_subscription&.destroy!
render_empty
end
private
def set_web_push_subscription
@web_subscription = ::Web::PushSubscription.find_by(access_token_id: doorkeeper_token.id)
end
def subscription_params
params.require(:subscription).permit(:endpoint, keys: [:auth, :p256dh])
end
def data_params
return {} if params[:data].blank?
params.require(:data).permit(alerts: [:follow, :favourite, :reblog, :mention])
end
end
......@@ -39,7 +39,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController
adapter: ActivityPub::Adapter
).as_json
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account)
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
end
def distribute_remove_activity!
......@@ -49,6 +49,6 @@ class Api::V1::Statuses::PinsController < Api::BaseController
adapter: ActivityPub::Adapter
).as_json
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account)
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
end
end
......@@ -10,6 +10,12 @@ class Api::V1::StatusesController < Api::BaseController
respond_to :json
# This API was originally unlimited, pagination cannot be introduced without
# breaking backwards-compatibility. Arbitrarily high number to cover most
# conversations as quasi-unlimited, it would be too much work to render more
# than this anyway
CONTEXT_LIMIT = 4_096
def show
cached = Rails.cache.read(@status.cache_key)
@status = cached unless cached.nil?
......@@ -17,8 +23,8 @@ class Api::V1::StatusesController < Api::BaseController
end
def context
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(DEFAULT_STATUSES_LIMIT, current_account)
descendants_results = @status.descendants(DEFAULT_STATUSES_LIMIT, current_account)
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(CONTEXT_LIMIT, current_account)
descendants_results = @status.descendants(CONTEXT_LIMIT, current_account)
loaded_ancestors = cache_collection(ancestors_results, Status)
loaded_descendants = cache_collection(descendants_results, Status)
......
......@@ -23,15 +23,18 @@ class Api::V1::Timelines::DirectController < Api::BaseController
end
def direct_statuses
direct_timeline_statuses.paginate_by_max_id(
limit_param(DEFAULT_STATUSES_LIMIT),
params[:max_id],
params[:since_id]
)
direct_timeline_statuses
end
def direct_timeline_statuses
Status.as_direct_timeline(current_account)
# this query requires built in pagination.
Status.as_direct_timeline(
current_account,
limit_param(DEFAULT_STATUSES_LIMIT),
params[:max_id],
params[:since_id],
true # returns array of cache_ids object
)
end
def insert_pagination_headers
......
# frozen_string_literal: true
class Api::V1::TrendsController < Api::BaseController
before_action :set_tags
respond_to :json
def index
render json: @tags, each_serializer: REST::TagSerializer
end
private
def set_tags
@tags = TrendingTags.get(limit_param(10))
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment