Compare commits
1 Commits
cybrespace
...
setting-sh
Author | SHA1 | Date |
---|---|---|
khr | fe6a7dfb2c |
|
@ -1,3 +1,4 @@
|
||||||
https://github.com/heroku/heroku-buildpack-apt
|
https://github.com/heroku/heroku-buildpack-apt
|
||||||
https://github.com/Scalingo/ffmpeg-buildpack
|
https://github.com/Scalingo/ffmpeg-buildpack
|
||||||
|
https://github.com/Scalingo/nodejs-buildpack
|
||||||
https://github.com/Scalingo/ruby-buildpack
|
https://github.com/Scalingo/ruby-buildpack
|
||||||
|
|
|
@ -3,15 +3,13 @@ version: 2
|
||||||
aliases:
|
aliases:
|
||||||
- &defaults
|
- &defaults
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/ruby:2.7-buster-node
|
- image: circleci/ruby:2.6.0-stretch-node
|
||||||
environment: &ruby_environment
|
environment: &ruby_environment
|
||||||
BUNDLE_JOBS: 3
|
|
||||||
BUNDLE_RETRY: 3
|
|
||||||
BUNDLE_APP_CONFIG: ./.bundle/
|
BUNDLE_APP_CONFIG: ./.bundle/
|
||||||
BUNDLE_PATH: ./vendor/bundle/
|
|
||||||
DB_HOST: localhost
|
DB_HOST: localhost
|
||||||
DB_USER: root
|
DB_USER: root
|
||||||
RAILS_ENV: test
|
RAILS_ENV: test
|
||||||
|
PARALLEL_TEST_PROCESSORS: 4
|
||||||
ALLOW_NOPAM: true
|
ALLOW_NOPAM: true
|
||||||
CONTINUOUS_INTEGRATION: true
|
CONTINUOUS_INTEGRATION: true
|
||||||
DISABLE_SIMPLECOV: true
|
DISABLE_SIMPLECOV: true
|
||||||
|
@ -33,25 +31,25 @@ aliases:
|
||||||
- &restore_ruby_dependencies
|
- &restore_ruby_dependencies
|
||||||
restore_cache:
|
restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
|
- v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
|
||||||
- v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
|
- v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
|
||||||
- v3-ruby-dependencies-
|
- v2-ruby-dependencies-
|
||||||
|
|
||||||
- &install_steps
|
- &install_steps
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- v2-node-dependencies-{{ checksum "yarn.lock" }}
|
- v1-node-dependencies-{{ checksum "yarn.lock" }}
|
||||||
- v2-node-dependencies-
|
- v1-node-dependencies-
|
||||||
- run:
|
- run: yarn install --frozen-lockfile
|
||||||
name: Install yarn dependencies
|
|
||||||
command: yarn install --frozen-lockfile
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: v2-node-dependencies-{{ checksum "yarn.lock" }}
|
key: v1-node-dependencies-{{ checksum "yarn.lock" }}
|
||||||
paths:
|
paths:
|
||||||
- ./node_modules/
|
- ./node_modules/
|
||||||
|
|
||||||
- *persist_to_workspace
|
- *persist_to_workspace
|
||||||
|
|
||||||
- &install_system_dependencies
|
- &install_system_dependencies
|
||||||
|
@ -64,25 +62,14 @@ aliases:
|
||||||
- &install_ruby_dependencies
|
- &install_ruby_dependencies
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
|
|
||||||
- *install_system_dependencies
|
- *install_system_dependencies
|
||||||
- run:
|
|
||||||
name: Set Ruby version
|
- run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
|
||||||
command: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
|
|
||||||
- *restore_ruby_dependencies
|
- *restore_ruby_dependencies
|
||||||
- run:
|
- run: bundle install --clean --jobs 16 --path ./vendor/bundle/ --retry 3 --with pam_authentication --without development production && bundle clean
|
||||||
name: Set bundler settings
|
|
||||||
command: |
|
|
||||||
bundle config --local clean 'true'
|
|
||||||
bundle config --local deployment 'true'
|
|
||||||
bundle config --local with 'pam_authentication'
|
|
||||||
bundle config --local without 'development production'
|
|
||||||
bundle config --local frozen 'true'
|
|
||||||
bundle config --local path $BUNDLE_PATH
|
|
||||||
- run:
|
|
||||||
name: Install bundler dependencies
|
|
||||||
command: bundle check || (bundle install && bundle clean)
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: v3-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
|
key: v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
|
||||||
paths:
|
paths:
|
||||||
- ./.bundle/
|
- ./.bundle/
|
||||||
- ./vendor/bundle/
|
- ./vendor/bundle/
|
||||||
|
@ -93,39 +80,39 @@ aliases:
|
||||||
- ./mastodon/vendor/bundle/
|
- ./mastodon/vendor/bundle/
|
||||||
|
|
||||||
- &test_steps
|
- &test_steps
|
||||||
parallelism: 4
|
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
|
|
||||||
- *install_system_dependencies
|
- *install_system_dependencies
|
||||||
|
- run: sudo apt-get install -y ffmpeg
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Install FFMPEG
|
name: Prepare Tests
|
||||||
command: sudo apt-get install -y ffmpeg
|
command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
|
||||||
- run:
|
- run:
|
||||||
name: Load database schema
|
name: Run Tests
|
||||||
command: ./bin/rails db:create db:schema:load db:seed
|
command: ./bin/retry bundle exec parallel_test ./spec/ --group-by filesize --type rspec
|
||||||
- run:
|
|
||||||
name: Run rspec in parallel
|
|
||||||
command: |
|
|
||||||
bundle exec rspec --profile 10 \
|
|
||||||
--format RspecJunitFormatter \
|
|
||||||
--out test_results/rspec.xml \
|
|
||||||
--format progress \
|
|
||||||
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
||||||
- store_test_results:
|
|
||||||
path: test_results
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
install:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
<<: *install_steps
|
<<: *install_steps
|
||||||
|
|
||||||
install-ruby2.7:
|
install-ruby2.6:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
<<: *install_ruby_dependencies
|
<<: *install_ruby_dependencies
|
||||||
|
|
||||||
install-ruby2.6:
|
install-ruby2.5:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/ruby:2.6-buster-node
|
- image: circleci/ruby:2.5.3-stretch-node
|
||||||
|
environment: *ruby_environment
|
||||||
|
<<: *install_ruby_dependencies
|
||||||
|
|
||||||
|
install-ruby2.4:
|
||||||
|
<<: *defaults
|
||||||
|
docker:
|
||||||
|
- image: circleci/ruby:2.4.5-stretch-node
|
||||||
environment: *ruby_environment
|
environment: *ruby_environment
|
||||||
<<: *install_ruby_dependencies
|
<<: *install_ruby_dependencies
|
||||||
|
|
||||||
|
@ -134,116 +121,97 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
- *install_system_dependencies
|
- *install_system_dependencies
|
||||||
- run:
|
- run: ./bin/rails assets:precompile
|
||||||
name: Precompile assets
|
|
||||||
command: ./bin/rails assets:precompile
|
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: ~/projects/
|
root: ~/projects/
|
||||||
paths:
|
paths:
|
||||||
- ./mastodon/public/assets
|
- ./mastodon/public/assets
|
||||||
- ./mastodon/public/packs-test/
|
- ./mastodon/public/packs-test/
|
||||||
|
|
||||||
test-migrations:
|
|
||||||
<<: *defaults
|
|
||||||
docker:
|
|
||||||
- image: circleci/ruby:2.7-buster-node
|
|
||||||
environment: *ruby_environment
|
|
||||||
- image: circleci/postgres:12.2
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: root
|
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
|
||||||
- image: circleci/redis:5-alpine
|
|
||||||
steps:
|
|
||||||
- *attach_workspace
|
|
||||||
- *install_system_dependencies
|
|
||||||
- run:
|
|
||||||
name: Create database
|
|
||||||
command: ./bin/rails db:create
|
|
||||||
- run:
|
|
||||||
name: Run migrations
|
|
||||||
command: ./bin/rails db:migrate
|
|
||||||
|
|
||||||
test-ruby2.7:
|
|
||||||
<<: *defaults
|
|
||||||
docker:
|
|
||||||
- image: circleci/ruby:2.7-buster-node
|
|
||||||
environment: *ruby_environment
|
|
||||||
- image: circleci/postgres:12.2
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: root
|
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
|
||||||
- image: circleci/redis:5-alpine
|
|
||||||
<<: *test_steps
|
|
||||||
|
|
||||||
test-ruby2.6:
|
test-ruby2.6:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/ruby:2.6-buster-node
|
- image: circleci/ruby:2.6.0-stretch-node
|
||||||
environment: *ruby_environment
|
environment: *ruby_environment
|
||||||
- image: circleci/postgres:12.2
|
- image: circleci/postgres:10.6-alpine
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: root
|
POSTGRES_USER: root
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
- image: circleci/redis:5.0.3-alpine3.8
|
||||||
- image: circleci/redis:5-alpine
|
<<: *test_steps
|
||||||
|
|
||||||
|
test-ruby2.5:
|
||||||
|
<<: *defaults
|
||||||
|
docker:
|
||||||
|
- image: circleci/ruby:2.5.3-stretch-node
|
||||||
|
environment: *ruby_environment
|
||||||
|
- image: circleci/postgres:10.6-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: root
|
||||||
|
- image: circleci/redis:4.0.12-alpine
|
||||||
|
<<: *test_steps
|
||||||
|
|
||||||
|
test-ruby2.4:
|
||||||
|
<<: *defaults
|
||||||
|
docker:
|
||||||
|
- image: circleci/ruby:2.4.5-stretch-node
|
||||||
|
environment: *ruby_environment
|
||||||
|
- image: circleci/postgres:10.6-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: root
|
||||||
|
- image: circleci/redis:4.0.12-alpine
|
||||||
<<: *test_steps
|
<<: *test_steps
|
||||||
|
|
||||||
test-webui:
|
test-webui:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:12-buster
|
- image: circleci/node:8.15.0-stretch
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
- run:
|
- run: ./bin/retry yarn test:jest
|
||||||
name: Run jest
|
|
||||||
command: yarn test:jest
|
|
||||||
|
|
||||||
check-i18n:
|
check-i18n:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
- *install_system_dependencies
|
- run: bundle exec i18n-tasks check-normalized
|
||||||
- run:
|
- run: bundle exec i18n-tasks unused
|
||||||
name: Check locale file normalization
|
- run: bundle exec i18n-tasks missing -t plural
|
||||||
command: bundle exec i18n-tasks check-normalized
|
- run: bundle exec i18n-tasks check-consistent-interpolations
|
||||||
- run:
|
|
||||||
name: Check for unused strings
|
|
||||||
command: bundle exec i18n-tasks unused -l en
|
|
||||||
- run:
|
|
||||||
name: Check for wrong string interpolations
|
|
||||||
command: bundle exec i18n-tasks check-consistent-interpolations
|
|
||||||
- run:
|
|
||||||
name: Check that all required locale files exist
|
|
||||||
command: bundle exec rake repo:check_locales_files
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
build-and-test:
|
build-and-test:
|
||||||
jobs:
|
jobs:
|
||||||
- install
|
- install
|
||||||
- install-ruby2.7:
|
|
||||||
requires:
|
|
||||||
- install
|
|
||||||
- install-ruby2.6:
|
- install-ruby2.6:
|
||||||
requires:
|
requires:
|
||||||
- install
|
- install
|
||||||
- install-ruby2.7
|
- install-ruby2.5:
|
||||||
|
requires:
|
||||||
|
- install
|
||||||
|
- install-ruby2.6
|
||||||
|
- install-ruby2.4:
|
||||||
|
requires:
|
||||||
|
- install
|
||||||
|
- install-ruby2.6
|
||||||
- build:
|
- build:
|
||||||
requires:
|
requires:
|
||||||
- install-ruby2.7
|
- install-ruby2.6
|
||||||
- test-migrations:
|
|
||||||
requires:
|
|
||||||
- install-ruby2.7
|
|
||||||
- test-ruby2.7:
|
|
||||||
requires:
|
|
||||||
- install-ruby2.7
|
|
||||||
- build
|
|
||||||
- test-ruby2.6:
|
- test-ruby2.6:
|
||||||
requires:
|
requires:
|
||||||
- install-ruby2.6
|
- install-ruby2.6
|
||||||
- build
|
- build
|
||||||
|
- test-ruby2.5:
|
||||||
|
requires:
|
||||||
|
- install-ruby2.5
|
||||||
|
- build
|
||||||
|
- test-ruby2.4:
|
||||||
|
requires:
|
||||||
|
- install-ruby2.4
|
||||||
|
- build
|
||||||
- test-webui:
|
- test-webui:
|
||||||
requires:
|
requires:
|
||||||
- install
|
- install
|
||||||
- check-i18n:
|
- check-i18n:
|
||||||
requires:
|
requires:
|
||||||
- install-ruby2.7
|
- install-ruby2.6
|
||||||
|
|
|
@ -27,11 +27,11 @@ plugins:
|
||||||
enabled: true
|
enabled: true
|
||||||
eslint:
|
eslint:
|
||||||
enabled: true
|
enabled: true
|
||||||
channel: eslint-7
|
channel: eslint-5
|
||||||
rubocop:
|
rubocop:
|
||||||
enabled: true
|
enabled: true
|
||||||
channel: rubocop-0-92
|
channel: rubocop-0-54
|
||||||
sass-lint:
|
scss-lint:
|
||||||
enabled: true
|
enabled: true
|
||||||
exclude_patterns:
|
exclude_patterns:
|
||||||
- spec/
|
- spec/
|
||||||
|
|
65
.env.nanobox
65
.env.nanobox
|
@ -11,14 +11,24 @@ DB_NAME=gonano
|
||||||
DB_PASS=$DATA_DB_PASS
|
DB_PASS=$DATA_DB_PASS
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
|
||||||
# DATABASE_URL=postgresql://$DATA_DB_USER:$DATA_DB_PASS@$DATA_DB_HOST/gonano
|
DATABASE_URL=postgresql://$DATA_DB_USER:$DATA_DB_PASS@$DATA_DB_HOST/gonano
|
||||||
|
|
||||||
# Optional ElasticSearch configuration
|
# Optional ElasticSearch configuration
|
||||||
ES_ENABLED=true
|
ES_ENABLED=true
|
||||||
ES_HOST=$DATA_ELASTIC_HOST
|
ES_HOST=$DATA_ELASTIC_HOST
|
||||||
ES_PORT=9200
|
ES_PORT=9200
|
||||||
|
|
||||||
BIND=0.0.0.0
|
# Optimizations
|
||||||
|
LD_PRELOAD=/data/lib/libjemalloc.so
|
||||||
|
|
||||||
|
# ImageMagick optimizations
|
||||||
|
MAGICK_TEMPORARY_PATH=/app/tmp
|
||||||
|
MAGICK_MEMORY_LIMIT=128MiB
|
||||||
|
MAGICK_MAP_LIMIT=64MiB
|
||||||
|
MAGICK_TIME_LIMIT=15
|
||||||
|
MAGICK_AREA_LIMIT=16MP
|
||||||
|
MAGICK_WIDTH_LIMIT=8KP
|
||||||
|
MAGICK_HEIGHT_LIMIT=8KP
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation.
|
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation.
|
||||||
|
@ -74,7 +84,6 @@ SMTP_PORT=587
|
||||||
SMTP_LOGIN=$SMTP_LOGIN
|
SMTP_LOGIN=$SMTP_LOGIN
|
||||||
SMTP_PASSWORD=$SMTP_PASSWORD
|
SMTP_PASSWORD=$SMTP_PASSWORD
|
||||||
SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
#SMTP_REPLY_TO=
|
|
||||||
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
||||||
#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail
|
#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail
|
||||||
#SMTP_AUTH_METHOD=plain
|
#SMTP_AUTH_METHOD=plain
|
||||||
|
@ -88,17 +97,9 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# PAPERCLIP_ROOT_URL=/system
|
# PAPERCLIP_ROOT_URL=/system
|
||||||
|
|
||||||
# Optional asset host for multi-server setups
|
# Optional asset host for multi-server setups
|
||||||
# The asset 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://example.com/
|
|
||||||
# CDN_HOST=https://assets.example.com
|
# CDN_HOST=https://assets.example.com
|
||||||
|
|
||||||
# S3 (optional)
|
# 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_ENABLED=true
|
||||||
# S3_BUCKET=
|
# S3_BUCKET=
|
||||||
# AWS_ACCESS_KEY_ID=
|
# AWS_ACCESS_KEY_ID=
|
||||||
|
@ -108,8 +109,6 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# S3_HOSTNAME=192.168.1.123:9000
|
# S3_HOSTNAME=192.168.1.123:9000
|
||||||
|
|
||||||
# S3 (Minio Config (optional) Please check Minio instance for details)
|
# 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_ENABLED=true
|
||||||
# S3_BUCKET=
|
# S3_BUCKET=
|
||||||
# AWS_ACCESS_KEY_ID=
|
# AWS_ACCESS_KEY_ID=
|
||||||
|
@ -120,30 +119,12 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# S3_ENDPOINT=
|
# S3_ENDPOINT=
|
||||||
# S3_SIGNATURE_VERSION=
|
# S3_SIGNATURE_VERSION=
|
||||||
|
|
||||||
# Google Cloud Storage (optional)
|
|
||||||
# Use S3 compatible API. Since GCS does not support Multipart Upload,
|
|
||||||
# increase the value of S3_MULTIPART_THRESHOLD to disable Multipart Upload.
|
|
||||||
# The attachment host must allow cross origin request - see the description
|
|
||||||
# above.
|
|
||||||
# S3_ENABLED=true
|
|
||||||
# AWS_ACCESS_KEY_ID=
|
|
||||||
# AWS_SECRET_ACCESS_KEY=
|
|
||||||
# S3_REGION=
|
|
||||||
# S3_PROTOCOL=https
|
|
||||||
# S3_HOSTNAME=storage.googleapis.com
|
|
||||||
# S3_ENDPOINT=https://storage.googleapis.com
|
|
||||||
# S3_MULTIPART_THRESHOLD=52428801 # 50.megabytes
|
|
||||||
|
|
||||||
# Swift (optional)
|
# Swift (optional)
|
||||||
# The attachment host must allow cross origin request - see the description
|
|
||||||
# above.
|
|
||||||
# SWIFT_ENABLED=true
|
# SWIFT_ENABLED=true
|
||||||
# SWIFT_USERNAME=
|
# SWIFT_USERNAME=
|
||||||
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
||||||
# SWIFT_TENANT=
|
# SWIFT_TENANT=
|
||||||
# SWIFT_PASSWORD=
|
# 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
|
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
|
||||||
# issues with token rate-limiting during high load.
|
# issues with token rate-limiting during high load.
|
||||||
# SWIFT_AUTH_URL=
|
# SWIFT_AUTH_URL=
|
||||||
|
@ -183,11 +164,6 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# LDAP_BIND_DN=
|
# LDAP_BIND_DN=
|
||||||
# LDAP_PASSWORD=
|
# LDAP_PASSWORD=
|
||||||
# LDAP_UID=cn
|
# LDAP_UID=cn
|
||||||
# LDAP_MAIL=mail
|
|
||||||
# LDAP_SEARCH_FILTER=(|(%{uid}=%{email})(%{mail}=%{email}))
|
|
||||||
# LDAP_UID_CONVERSION_ENABLED=true
|
|
||||||
# LDAP_UID_CONVERSION_SEARCH=., -
|
|
||||||
# LDAP_UID_CONVERSION_REPLACE=_
|
|
||||||
|
|
||||||
# PAM authentication (optional)
|
# PAM authentication (optional)
|
||||||
# PAM authentication uses for the email generation the "email" pam variable
|
# PAM authentication uses for the email generation the "email" pam variable
|
||||||
|
@ -195,8 +171,8 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# The pam environment variable "email" is provided by:
|
# The pam environment variable "email" is provided by:
|
||||||
# https://github.com/devkral/pam_email_extractor
|
# https://github.com/devkral/pam_email_extractor
|
||||||
# PAM_ENABLED=true
|
# PAM_ENABLED=true
|
||||||
# Fallback email domain for email address generation (LOCAL_DOMAIN by default)
|
# Fallback Suffix for email address generation (nil by default)
|
||||||
# PAM_EMAIL_DOMAIN=example.com
|
# PAM_DEFAULT_SUFFIX=pam
|
||||||
# Name of the pam service (pam "auth" section is evaluated)
|
# Name of the pam service (pam "auth" section is evaluated)
|
||||||
# PAM_DEFAULT_SERVICE=rpam
|
# PAM_DEFAULT_SERVICE=rpam
|
||||||
# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default)
|
# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default)
|
||||||
|
@ -231,8 +207,8 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
|
|
||||||
# Optional SAML authentication (cf. omniauth-saml)
|
# Optional SAML authentication (cf. omniauth-saml)
|
||||||
# SAML_ENABLED=true
|
# SAML_ENABLED=true
|
||||||
# SAML_ACS_URL=http://localhost:3000/auth/auth/saml/callback
|
# SAML_ACS_URL=
|
||||||
# SAML_ISSUER=https://example.com
|
# SAML_ISSUER=http://localhost:3000/auth/auth/saml/callback
|
||||||
# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO
|
# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO
|
||||||
# SAML_IDP_CERT=
|
# SAML_IDP_CERT=
|
||||||
# SAML_IDP_CERT_FINGERPRINT=
|
# SAML_IDP_CERT_FINGERPRINT=
|
||||||
|
@ -244,14 +220,7 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
||||||
# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
|
# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1"
|
# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1"
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
|
# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241"
|
# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.5.4.42"
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42"
|
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4"
|
|
||||||
# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
|
# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
|
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
|
||||||
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
|
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
|
||||||
|
|
||||||
# Use HTTP proxy for outgoing request (optional)
|
|
||||||
# http_proxy=http://gateway.local:8118
|
|
||||||
# Access control for hidden service.
|
|
||||||
# ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
|
|
||||||
|
|
|
@ -1,60 +1,232 @@
|
||||||
# This is a sample configuration file. You can generate your configuration
|
# Service dependencies
|
||||||
# with the `rake mastodon:setup` interactive setup wizard, but to customize
|
# You may set REDIS_URL instead for more advanced options
|
||||||
# your setup even further, you'll need to edit it manually. This sample does
|
# You may also set REDIS_NAMESPACE to share Redis between multiple Mastodon servers
|
||||||
# not demonstrate all available configuration options. Please look at
|
REDIS_HOST=redis
|
||||||
# https://docs.joinmastodon.org/admin/config/ for the full documentation.
|
|
||||||
|
|
||||||
# Federation
|
|
||||||
# ----------
|
|
||||||
# This identifies your server and cannot be changed safely later
|
|
||||||
# ----------
|
|
||||||
LOCAL_DOMAIN=example.com
|
|
||||||
|
|
||||||
# Redis
|
|
||||||
# -----
|
|
||||||
REDIS_HOST=localhost
|
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
# You may set DATABASE_URL instead for more advanced options
|
||||||
# PostgreSQL
|
DB_HOST=db
|
||||||
# ----------
|
DB_USER=postgres
|
||||||
DB_HOST=/var/run/postgresql
|
DB_NAME=postgres
|
||||||
DB_USER=mastodon
|
|
||||||
DB_NAME=mastodon_production
|
|
||||||
DB_PASS=
|
DB_PASS=
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
# Optional ElasticSearch configuration
|
||||||
|
# ES_ENABLED=true
|
||||||
|
# ES_HOST=es
|
||||||
|
# ES_PORT=9200
|
||||||
|
|
||||||
# ElasticSearch (optional)
|
# Federation
|
||||||
# ------------------------
|
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation.
|
||||||
ES_ENABLED=true
|
# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com.
|
||||||
ES_HOST=localhost
|
LOCAL_DOMAIN=example.com
|
||||||
ES_PORT=9200
|
|
||||||
|
|
||||||
# Secrets
|
# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links)
|
||||||
# -------
|
|
||||||
# Make sure to use `rake secret` to generate secrets
|
# Use this only if you need to run mastodon on a different domain than the one used for federation.
|
||||||
# -------
|
# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md
|
||||||
|
# DO *NOT* USE THIS UNLESS YOU KNOW *EXACTLY* WHAT YOU ARE DOING.
|
||||||
|
# WEB_DOMAIN=mastodon.example.com
|
||||||
|
|
||||||
|
# Use this if you want to have several aliases handler@example1.com
|
||||||
|
# handler@example2.com etc. for the same user. LOCAL_DOMAIN should not
|
||||||
|
# be added. Comma separated values
|
||||||
|
# ALTERNATE_DOMAINS=example1.com,example2.com
|
||||||
|
|
||||||
|
# Application secrets
|
||||||
|
# Generate each with the `RAILS_ENV=production bundle exec rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
|
||||||
SECRET_KEY_BASE=
|
SECRET_KEY_BASE=
|
||||||
OTP_SECRET=
|
OTP_SECRET=
|
||||||
|
|
||||||
# Web Push
|
# VAPID keys (used for push notifications
|
||||||
# --------
|
# You can generate the keys using the following command (first is the private key, second is the public one)
|
||||||
# Generate with `rake mastodon:webpush:generate_vapid_key`
|
# You should only generate this once per instance. If you later decide to change it, all push subscription will
|
||||||
# --------
|
# be invalidated, requiring the users to access the website again to resubscribe.
|
||||||
|
#
|
||||||
|
# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
|
||||||
|
#
|
||||||
|
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
|
||||||
VAPID_PRIVATE_KEY=
|
VAPID_PRIVATE_KEY=
|
||||||
VAPID_PUBLIC_KEY=
|
VAPID_PUBLIC_KEY=
|
||||||
|
|
||||||
# Sending mail
|
# Registrations
|
||||||
# ------------
|
# Single user mode will disable registrations and redirect frontpage to the first profile
|
||||||
|
# SINGLE_USER_MODE=true
|
||||||
|
# Prevent registrations with following e-mail domains
|
||||||
|
# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc
|
||||||
|
# Only allow registrations with the following e-mail domains
|
||||||
|
# EMAIL_DOMAIN_WHITELIST=example1.com|example2.de|etc
|
||||||
|
|
||||||
|
# Optionally change default language
|
||||||
|
# DEFAULT_LOCALE=de
|
||||||
|
|
||||||
|
# E-mail configuration
|
||||||
|
# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers
|
||||||
|
# If you want to use an SMTP server without authentication (e.g local Postfix relay)
|
||||||
|
# then set SMTP_AUTH_METHOD and SMTP_OPENSSL_VERIFY_MODE to 'none' and
|
||||||
|
# *comment* SMTP_LOGIN and SMTP_PASSWORD (leaving them blank is not enough).
|
||||||
SMTP_SERVER=smtp.mailgun.org
|
SMTP_SERVER=smtp.mailgun.org
|
||||||
SMTP_PORT=587
|
SMTP_PORT=587
|
||||||
SMTP_LOGIN=
|
SMTP_LOGIN=
|
||||||
SMTP_PASSWORD=
|
SMTP_PASSWORD=
|
||||||
SMTP_FROM_ADDRESS=notificatons@example.com
|
SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
|
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
||||||
|
#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail
|
||||||
|
#SMTP_AUTH_METHOD=plain
|
||||||
|
#SMTP_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||||
|
#SMTP_OPENSSL_VERIFY_MODE=peer
|
||||||
|
#SMTP_ENABLE_STARTTLS_AUTO=true
|
||||||
|
#SMTP_TLS=true
|
||||||
|
|
||||||
# File storage (optional)
|
# Optional user upload path and URL (images, avatars). Default is :rails_root/public/system. If you set this variable, you are responsible for making your HTTP server (eg. nginx) serve these files.
|
||||||
# -----------------------
|
# PAPERCLIP_ROOT_PATH=/var/lib/mastodon/public-system
|
||||||
S3_ENABLED=true
|
# PAPERCLIP_ROOT_URL=/system
|
||||||
S3_BUCKET=files.example.com
|
|
||||||
AWS_ACCESS_KEY_ID=
|
# Optional asset host for multi-server setups
|
||||||
AWS_SECRET_ACCESS_KEY=
|
# The asset host must allow cross origin request from WEB_DOMAIN or LOCAL_DOMAIN
|
||||||
S3_ALIAS_HOST=files.example.com
|
# if WEB_DOMAIN is not set. For example, the server may have the
|
||||||
|
# following header field:
|
||||||
|
# Access-Control-Allow-Origin: https://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=
|
||||||
|
# AWS_SECRET_ACCESS_KEY=
|
||||||
|
# S3_REGION=
|
||||||
|
# S3_PROTOCOL=http
|
||||||
|
# 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=
|
||||||
|
# AWS_SECRET_ACCESS_KEY=
|
||||||
|
# S3_REGION=
|
||||||
|
# S3_PROTOCOL=https
|
||||||
|
# S3_HOSTNAME=
|
||||||
|
# S3_ENDPOINT=
|
||||||
|
# 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=
|
||||||
|
# SWIFT_CONTAINER=
|
||||||
|
# SWIFT_OBJECT_URL=
|
||||||
|
# SWIFT_REGION=
|
||||||
|
# Defaults to 'default'
|
||||||
|
# SWIFT_DOMAIN_NAME=
|
||||||
|
# Defaults to 60 seconds. Set to 0 to disable
|
||||||
|
# SWIFT_CACHE_TTL=
|
||||||
|
|
||||||
|
# Optional alias for S3 (e.g. to serve files on a custom domain, possibly using Cloudfront or Cloudflare)
|
||||||
|
# S3_ALIAS_HOST=
|
||||||
|
|
||||||
|
# Streaming API integration
|
||||||
|
# STREAMING_API_BASE_URL=
|
||||||
|
|
||||||
|
# Advanced settings
|
||||||
|
# If you need to use pgBouncer, you need to disable prepared statements:
|
||||||
|
# PREPARED_STATEMENTS=false
|
||||||
|
|
||||||
|
# Cluster number setting for streaming API server.
|
||||||
|
# If you comment out following line, cluster number will be `numOfCpuCores - 1`.
|
||||||
|
STREAMING_CLUSTER_NUM=1
|
||||||
|
|
||||||
|
# Docker mastodon user
|
||||||
|
# If you use Docker, you may want to assign UID/GID manually.
|
||||||
|
# UID=1000
|
||||||
|
# GID=1000
|
||||||
|
|
||||||
|
# LDAP authentication (optional)
|
||||||
|
# LDAP_ENABLED=true
|
||||||
|
# LDAP_HOST=localhost
|
||||||
|
# LDAP_PORT=389
|
||||||
|
# LDAP_METHOD=simple_tls
|
||||||
|
# LDAP_BASE=
|
||||||
|
# LDAP_BIND_DN=
|
||||||
|
# LDAP_PASSWORD=
|
||||||
|
# LDAP_UID=cn
|
||||||
|
# LDAP_SEARCH_FILTER="%{uid}=%{email}"
|
||||||
|
|
||||||
|
# PAM authentication (optional)
|
||||||
|
# PAM authentication uses for the email generation the "email" pam variable
|
||||||
|
# and optional as fallback PAM_DEFAULT_SUFFIX
|
||||||
|
# The pam environment variable "email" is provided by:
|
||||||
|
# https://github.com/devkral/pam_email_extractor
|
||||||
|
# PAM_ENABLED=true
|
||||||
|
# Fallback email domain for email address generation (LOCAL_DOMAIN by default)
|
||||||
|
# PAM_EMAIL_DOMAIN=example.com
|
||||||
|
# Name of the pam service (pam "auth" section is evaluated)
|
||||||
|
# PAM_DEFAULT_SERVICE=rpam
|
||||||
|
# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default)
|
||||||
|
# PAM_CONTROLLED_SERVICE=rpam
|
||||||
|
|
||||||
|
# Global OAuth settings (optional) :
|
||||||
|
# If you have only one strategy, you may want to enable this
|
||||||
|
# OAUTH_REDIRECT_AT_SIGN_IN=true
|
||||||
|
|
||||||
|
# Optional CAS authentication (cf. omniauth-cas) :
|
||||||
|
# CAS_ENABLED=true
|
||||||
|
# CAS_URL=https://sso.myserver.com/
|
||||||
|
# CAS_HOST=sso.myserver.com/
|
||||||
|
# CAS_PORT=443
|
||||||
|
# CAS_SSL=true
|
||||||
|
# CAS_VALIDATE_URL=
|
||||||
|
# CAS_CALLBACK_URL=
|
||||||
|
# CAS_LOGOUT_URL=
|
||||||
|
# CAS_LOGIN_URL=
|
||||||
|
# CAS_UID_FIELD='user'
|
||||||
|
# CAS_CA_PATH=
|
||||||
|
# CAS_DISABLE_SSL_VERIFICATION=false
|
||||||
|
# CAS_UID_KEY='user'
|
||||||
|
# CAS_NAME_KEY='name'
|
||||||
|
# CAS_EMAIL_KEY='email'
|
||||||
|
# CAS_NICKNAME_KEY='nickname'
|
||||||
|
# CAS_FIRST_NAME_KEY='firstname'
|
||||||
|
# CAS_LAST_NAME_KEY='lastname'
|
||||||
|
# CAS_LOCATION_KEY='location'
|
||||||
|
# CAS_IMAGE_KEY='image'
|
||||||
|
# CAS_PHONE_KEY='phone'
|
||||||
|
|
||||||
|
# Optional SAML authentication (cf. omniauth-saml)
|
||||||
|
# SAML_ENABLED=true
|
||||||
|
# SAML_ACS_URL=
|
||||||
|
# SAML_ISSUER=http://localhost:3000/auth/auth/saml/callback
|
||||||
|
# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO
|
||||||
|
# SAML_IDP_CERT=
|
||||||
|
# SAML_IDP_CERT_FINGERPRINT=
|
||||||
|
# SAML_NAME_IDENTIFIER_FORMAT=
|
||||||
|
# SAML_CERT=
|
||||||
|
# SAML_PRIVATE_KEY=
|
||||||
|
# SAML_SECURITY_WANT_ASSERTION_SIGNED=true
|
||||||
|
# SAML_SECURITY_WANT_ASSERTION_ENCRYPTED=true
|
||||||
|
# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1"
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6"
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241"
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42"
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4"
|
||||||
|
# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1"
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED=
|
||||||
|
# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL=
|
||||||
|
|
||||||
|
# Use HTTP proxy for outgoing request (optional)
|
||||||
|
# http_proxy=http://gateway.local:8118
|
||||||
|
# Access control for hidden service.
|
||||||
|
# ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Node.js
|
# Node.js
|
||||||
NODE_ENV=tests
|
NODE_ENV=test
|
||||||
# Federation
|
# Federation
|
||||||
LOCAL_DOMAIN=cb6e6126.ngrok.io
|
LOCAL_DOMAIN=cb6e6126.ngrok.io
|
||||||
LOCAL_HTTPS=true
|
LOCAL_HTTPS=true
|
||||||
|
|
|
@ -1,4 +1,2 @@
|
||||||
VAGRANT=true
|
VAGRANT=true
|
||||||
LOCAL_DOMAIN=mastodon.local
|
LOCAL_DOMAIN=mastodon.local
|
||||||
BIND=0.0.0.0
|
|
||||||
DB_HOST=/var/run/postgresql/
|
|
||||||
|
|
12
.eslintrc.js
12
.eslintrc.js
|
@ -41,11 +41,6 @@ module.exports = {
|
||||||
'node_modules',
|
'node_modules',
|
||||||
'\\.(css|scss|json)$',
|
'\\.(css|scss|json)$',
|
||||||
],
|
],
|
||||||
'import/resolver': {
|
|
||||||
node: {
|
|
||||||
paths: ['app/javascript'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
@ -199,11 +194,6 @@ module.exports = {
|
||||||
'import/no-unresolved': 'error',
|
'import/no-unresolved': 'error',
|
||||||
'import/no-webpack-loader-syntax': 'error',
|
'import/no-webpack-loader-syntax': 'error',
|
||||||
|
|
||||||
'promise/catch-or-return': [
|
'promise/catch-or-return': 'error',
|
||||||
'error',
|
|
||||||
{
|
|
||||||
allowFinally: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
patreon: mastodon
|
|
||||||
open_collective: mastodon
|
|
||||||
github: [Gargron]
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
name: Bug Report
|
name: Bug Report
|
||||||
about: If something isn't working as expected
|
about: If something isn't working as expected
|
||||||
labels: bug
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Make sure that you are submitting a new bug that was not previously reported or already fixed -->
|
<!-- Make sure that you are submitting a new bug that was not previously reported or already fixed -->
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Mastodon Meta Discussion Board
|
|
||||||
url: https://discourse.joinmastodon.org/
|
|
||||||
about: Please ask and answer questions here.
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
name: Feature Request
|
name: Feature Request
|
||||||
about: I have a suggestion
|
about: I have a suggestion
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Please use a concise and distinct title for the issue -->
|
<!-- Please use a concise and distinct title for the issue -->
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
open-pull-requests-limit: 99
|
|
||||||
allow:
|
|
||||||
- dependency-type: direct
|
|
||||||
|
|
||||||
- package-ecosystem: bundler
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
open-pull-requests-limit: 99
|
|
||||||
allow:
|
|
||||||
- dependency-type: direct
|
|
|
@ -1,10 +0,0 @@
|
||||||
daysUntilStale: 120
|
|
||||||
daysUntilClose: 7
|
|
||||||
exemptLabels:
|
|
||||||
- security
|
|
||||||
staleLabel: wontfix
|
|
||||||
markComment: >
|
|
||||||
This issue has been automatically marked as stale because it has not had
|
|
||||||
recent activity. It will be closed if no further activity occurs. Thank you
|
|
||||||
for your contributions.
|
|
||||||
only: pulls
|
|
|
@ -13,40 +13,33 @@
|
||||||
/db/*.sqlite3-journal
|
/db/*.sqlite3-journal
|
||||||
|
|
||||||
# Ignore all logfiles and tempfiles.
|
# Ignore all logfiles and tempfiles.
|
||||||
.eslintcache
|
|
||||||
/log/*
|
/log/*
|
||||||
!/log/.keep
|
!/log/.keep
|
||||||
/tmp
|
/tmp
|
||||||
/coverage
|
coverage
|
||||||
/public/system
|
public/system
|
||||||
/public/assets
|
public/assets
|
||||||
/public/packs
|
public/packs
|
||||||
/public/packs-test
|
public/packs-test
|
||||||
.env
|
.env
|
||||||
.env.production
|
.env.production
|
||||||
.env.development
|
node_modules/
|
||||||
/node_modules/
|
build/
|
||||||
/build/
|
|
||||||
|
|
||||||
# Ignore Vagrant files
|
# Ignore Vagrant files
|
||||||
.vagrant/
|
.vagrant/
|
||||||
|
|
||||||
# Ignore Capistrano customizations
|
# Ignore Capistrano customizations
|
||||||
/config/deploy/*
|
config/deploy/*
|
||||||
|
|
||||||
# Ignore IDE files
|
# Ignore IDE files
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# Ignore postgres + redis + elasticsearch volume optionally created by docker-compose
|
# Ignore postgres + redis + elasticsearch volume optionally created by docker-compose
|
||||||
/postgres
|
postgres
|
||||||
/redis
|
redis
|
||||||
/elasticsearch
|
elasticsearch
|
||||||
|
|
||||||
# ignore Helm lockfile, dependency charts, and local values file
|
|
||||||
/chart/Chart.lock
|
|
||||||
/chart/charts/*.tgz
|
|
||||||
/chart/values.yaml
|
|
||||||
|
|
||||||
# Ignore Apple files
|
# Ignore Apple files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
@ -62,8 +55,6 @@ npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
yarn-debug.log
|
yarn-debug.log
|
||||||
|
|
||||||
# Ignore vagrant log files
|
|
||||||
*-cloudimg-console.log
|
|
||||||
|
|
||||||
# Ignore Docker option files
|
# Ignore Docker option files
|
||||||
docker-compose.override.yml
|
docker-compose.override.yml
|
||||||
|
|
||||||
|
|
197
.rubocop.yml
197
.rubocop.yml
|
@ -1,8 +1,5 @@
|
||||||
require:
|
|
||||||
- rubocop-rails
|
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.4
|
TargetRubyVersion: 2.3
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/**/*'
|
- 'spec/**/*'
|
||||||
- 'db/**/*'
|
- 'db/**/*'
|
||||||
|
@ -25,78 +22,34 @@ Layout/AccessModifierIndentation:
|
||||||
Layout/EmptyLineAfterMagicComment:
|
Layout/EmptyLineAfterMagicComment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Layout/EmptyLineAfterGuardClause:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Layout/EmptyLinesAroundAttributeAccessor:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Layout/HashAlignment:
|
|
||||||
Enabled: false
|
|
||||||
# EnforcedHashRocketStyle: table
|
|
||||||
# EnforcedColonStyle: table
|
|
||||||
|
|
||||||
Layout/SpaceAroundMethodCallOperator:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Layout/SpaceInsideHashLiteralBraces:
|
Layout/SpaceInsideHashLiteralBraces:
|
||||||
EnforcedStyle: space
|
EnforcedStyle: space
|
||||||
|
|
||||||
Lint/DeprecatedOpenSSLConstant:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Lint/DuplicateElsifCondition:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Lint/MixedRegexpCaptureTypes:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Lint/RaiseException:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Lint/StructNewOverride:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Lint/UselessAccessModifier:
|
|
||||||
ContextCreatingMethods:
|
|
||||||
- class_methods
|
|
||||||
|
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 100
|
Max: 100
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Max: 55
|
Max: 35
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/tasks/**/*'
|
- 'lib/tasks/**/*'
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Max: 3
|
Max: 3
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
CountComments: false
|
CountComments: false
|
||||||
Max: 400
|
Max: 300
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 25
|
Max: 25
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Layout/LineLength:
|
Metrics/LineLength:
|
||||||
AllowURI: true
|
AllowURI: true
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
CountComments: false
|
CountComments: false
|
||||||
Max: 65
|
Max: 55
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*_cli.rb'
|
|
||||||
|
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
CountComments: false
|
CountComments: false
|
||||||
|
@ -107,89 +60,27 @@ Metrics/ParameterLists:
|
||||||
CountKeywordArgs: true
|
CountKeywordArgs: true
|
||||||
|
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 25
|
Max: 20
|
||||||
|
|
||||||
Naming/MemoizedInstanceVariableName:
|
Naming/MemoizedInstanceVariableName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Naming/MethodParameterName:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Rails:
|
Rails:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Rails/ApplicationController:
|
|
||||||
Enabled: false
|
|
||||||
Exclude:
|
|
||||||
- 'app/controllers/well_known/**/*.rb'
|
|
||||||
|
|
||||||
Rails/BelongsTo:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/ContentTag:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/EnumHash:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/Exit:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/*'
|
|
||||||
- 'lib/cli.rb'
|
|
||||||
|
|
||||||
Rails/FilePath:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/HasAndBelongsToMany:
|
Rails/HasAndBelongsToMany:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Rails/HasManyOrHasOneDependent:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/HelperInstanceVariable:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/HttpStatus:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/IndexBy:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/InverseOf:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/LexicallyScopedActionFilter:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/OutputSafety:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Rails/RakeEnvironment:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/RedundantForeignKey:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Rails/SkipsModelValidations:
|
Rails/SkipsModelValidations:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Rails/UniqueValidationWithoutIndex:
|
Rails/HttpStatus:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/AccessorGrouping:
|
Rails/Exit:
|
||||||
Enabled: true
|
Exclude:
|
||||||
|
- 'lib/mastodon/*'
|
||||||
Style/AccessModifierDeclarations:
|
- 'lib/cli'
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/ArrayCoercion:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/BisectedAttrAccessor:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/CaseLikeIf:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/ClassAndModuleChildren:
|
Style/ClassAndModuleChildren:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -205,51 +96,15 @@ Style/Documentation:
|
||||||
Style/DoubleNegation:
|
Style/DoubleNegation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Style/ExpandPathArguments:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/ExponentialNotation:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/FormatString:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/FormatStringToken:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/HashAsLastArrayItem:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/HashEachMethods:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/HashLikeCase:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/HashTransformKeys:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/HashTransformValues:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/IfUnlessModifier:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/InverseMethods:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/Lambda:
|
Style/Lambda:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/MutableConstant:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/PercentLiteralDelimiters:
|
Style/PercentLiteralDelimiters:
|
||||||
PreferredDelimiters:
|
PreferredDelimiters:
|
||||||
'%i': '()'
|
'%i': '()'
|
||||||
|
@ -258,36 +113,9 @@ Style/PercentLiteralDelimiters:
|
||||||
Style/PerlBackrefs:
|
Style/PerlBackrefs:
|
||||||
AutoCorrect: false
|
AutoCorrect: false
|
||||||
|
|
||||||
Style/RedundantAssignment:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantFetchBlock:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/RedundantFileExtensionInRequire:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/RedundantRegexpCharacterClass:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantRegexpEscape:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantReturn:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/RescueStandardError:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/SignalException:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/SlicingWithRange:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/SymbolArray:
|
Style/SymbolArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -296,6 +124,3 @@ Style/TrailingCommaInArrayLiteral:
|
||||||
|
|
||||||
Style/TrailingCommaInHashLiteral:
|
Style/TrailingCommaInHashLiteral:
|
||||||
EnforcedStyleForMultiline: 'comma'
|
EnforcedStyleForMultiline: 'comma'
|
||||||
|
|
||||||
Style/UnpackFirst:
|
|
||||||
Enabled: false
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
2.7.2
|
2.6.0
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
# Linter Documentation:
|
|
||||||
# https://github.com/sasstools/sass-lint/tree/v1.13.1/docs/options
|
|
||||||
|
|
||||||
files:
|
|
||||||
include: app/javascript/styles/**/*.scss
|
|
||||||
ignore:
|
|
||||||
- app/javascript/styles/mastodon/reset.scss
|
|
||||||
|
|
||||||
rules:
|
|
||||||
# Disallows
|
|
||||||
no-color-literals: 0
|
|
||||||
no-css-comments: 0
|
|
||||||
no-duplicate-properties: 0
|
|
||||||
no-ids: 0
|
|
||||||
no-important: 0
|
|
||||||
no-mergeable-selectors: 0
|
|
||||||
no-misspelled-properties: 0
|
|
||||||
no-qualifying-elements: 0
|
|
||||||
no-transition-all: 0
|
|
||||||
no-vendor-prefixes: 0
|
|
||||||
|
|
||||||
# Nesting
|
|
||||||
force-element-nesting: 0
|
|
||||||
force-attribute-nesting: 0
|
|
||||||
force-pseudo-nesting: 0
|
|
||||||
|
|
||||||
# Name Formats
|
|
||||||
class-name-format: 0
|
|
||||||
leading-zero: 0
|
|
||||||
|
|
||||||
# Style Guide
|
|
||||||
attribute-quotes: 0
|
|
||||||
hex-length: 0
|
|
||||||
indentation: 0
|
|
||||||
nesting-depth: 0
|
|
||||||
property-sort-order: 0
|
|
||||||
quotes: 0
|
|
|
@ -0,0 +1,264 @@
|
||||||
|
# Linter Documentation:
|
||||||
|
# https://github.com/brigade/scss-lint/blob/v0.42.2/lib/scss_lint/linter/README.md
|
||||||
|
|
||||||
|
scss_files: 'app/javascript/styles/**/*.scss'
|
||||||
|
|
||||||
|
exclude:
|
||||||
|
- app/javascript/styles/reset.scss
|
||||||
|
|
||||||
|
linters:
|
||||||
|
# Reports when you use improper spacing around ! (the "bang") in !default,
|
||||||
|
# !global, !important, and !optional flags.
|
||||||
|
BangFormat:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Whether or not to prefer `border: 0` over `border: none`.
|
||||||
|
BorderZero:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Reports when you define a rule set using a selector with chained classes
|
||||||
|
# (a.k.a. adjoining classes).
|
||||||
|
ChainedClasses:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Prefer hexadecimal color codes over color keywords.
|
||||||
|
# (e.g. `color: green` is a color keyword)
|
||||||
|
ColorKeyword:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Prefer color literals (keywords or hexadecimal codes) to be used only in
|
||||||
|
# variable declarations. They should be referred to via variables everywhere
|
||||||
|
# else.
|
||||||
|
ColorVariable:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Which form of comments to prefer in CSS.
|
||||||
|
Comment:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Reports @debug statements (which you probably left behind accidentally).
|
||||||
|
DebugStatement:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Rule sets should be ordered as follows:
|
||||||
|
# - @extend declarations
|
||||||
|
# - @include declarations without inner @content
|
||||||
|
# - properties, @include declarations with inner @content
|
||||||
|
# - nested rule sets.
|
||||||
|
DeclarationOrder:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# `scss-lint:disable` control comments should be preceded by a comment
|
||||||
|
# explaining why these linters are being disabled for this file.
|
||||||
|
# See https://github.com/brigade/scss-lint#disabling-linters-via-source for
|
||||||
|
# more information.
|
||||||
|
DisableLinterReason:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Reports when you define the same property twice in a single rule set.
|
||||||
|
DuplicateProperty:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Separate rule, function, and mixin declarations with empty lines.
|
||||||
|
EmptyLineBetweenBlocks:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Reports when you have an empty rule set.
|
||||||
|
EmptyRule:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Reports when you have an @extend directive.
|
||||||
|
ExtendDirective:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Files should always have a final newline. This results in better diffs
|
||||||
|
# when adding lines to the file, since SCM systems such as git won't
|
||||||
|
# think that you touched the last line.
|
||||||
|
FinalNewline:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# HEX colors should use three-character values where possible.
|
||||||
|
HexLength:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# HEX color values should use lower-case colors to differentiate between
|
||||||
|
# letters and numbers, e.g. `#E3E3E3` vs. `#e3e3e3`.
|
||||||
|
HexNotation:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Avoid using ID selectors.
|
||||||
|
IdSelector:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# The basenames of @imported SCSS partials should not begin with an
|
||||||
|
# underscore and should not include the filename extension.
|
||||||
|
ImportPath:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Avoid using !important in properties. It is usually indicative of a
|
||||||
|
# misunderstanding of CSS specificity and can lead to brittle code.
|
||||||
|
ImportantRule:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Indentation should always be done in increments of 2 spaces.
|
||||||
|
Indentation:
|
||||||
|
enabled: true
|
||||||
|
width: 2
|
||||||
|
|
||||||
|
# Don't write leading zeros for numeric values with a decimal point.
|
||||||
|
LeadingZero:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Reports when you define the same selector twice in a single sheet.
|
||||||
|
MergeableSelector:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Functions, mixins, variables, and placeholders should be declared
|
||||||
|
# with all lowercase letters and hyphens instead of underscores.
|
||||||
|
NameFormat:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Avoid nesting selectors too deeply.
|
||||||
|
NestingDepth:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Always use placeholder selectors in @extend.
|
||||||
|
PlaceholderInExtend:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Sort properties in a strict order.
|
||||||
|
PropertySortOrder:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Reports when you use an unknown or disabled CSS property
|
||||||
|
# (ignoring vendor-prefixed properties).
|
||||||
|
PropertySpelling:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Configure which units are allowed for property values.
|
||||||
|
PropertyUnits:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Pseudo-elements, like ::before, and ::first-letter, should be declared
|
||||||
|
# with two colons. Pseudo-classes, like :hover and :first-child, should
|
||||||
|
# be declared with one colon.
|
||||||
|
PseudoElement:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Avoid qualifying elements in selectors (also known as "tag-qualifying").
|
||||||
|
QualifyingElement:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Don't write selectors with a depth of applicability greater than 3.
|
||||||
|
SelectorDepth:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Selectors should always use hyphenated-lowercase, rather than camelCase or
|
||||||
|
# snake_case.
|
||||||
|
SelectorFormat:
|
||||||
|
enabled: false
|
||||||
|
convention: hyphenated_lowercase
|
||||||
|
|
||||||
|
# Prefer the shortest shorthand form possible for properties that support it.
|
||||||
|
Shorthand:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Each property should have its own line, except in the special case of
|
||||||
|
# single line rulesets.
|
||||||
|
SingleLinePerProperty:
|
||||||
|
enabled: true
|
||||||
|
allow_single_line_rule_sets: true
|
||||||
|
|
||||||
|
# Split selectors onto separate lines after each comma, and have each
|
||||||
|
# individual selector occupy a single line.
|
||||||
|
SingleLinePerSelector:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Commas in lists should be followed by a space.
|
||||||
|
SpaceAfterComma:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Properties should be formatted with a single space separating the colon
|
||||||
|
# from the property's value.
|
||||||
|
SpaceAfterPropertyColon:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Properties should be formatted with no space between the name and the
|
||||||
|
# colon.
|
||||||
|
SpaceAfterPropertyName:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Variables should be formatted with a single space separating the colon
|
||||||
|
# from the variable's value.
|
||||||
|
SpaceAfterVariableColon:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Variables should be formatted with no space between the name and the
|
||||||
|
# colon.
|
||||||
|
SpaceAfterVariableName:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Operators should be formatted with a single space on both sides of an
|
||||||
|
# infix operator.
|
||||||
|
SpaceAroundOperator:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Opening braces should be preceded by a single space.
|
||||||
|
SpaceBeforeBrace:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Parentheses should not be padded with spaces.
|
||||||
|
SpaceBetweenParens:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Enforces that string literals should be written with a consistent form
|
||||||
|
# of quotes (single or double).
|
||||||
|
StringQuotes:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Property values, @extend, @include, and @import directives, and variable
|
||||||
|
# declarations should always end with a semicolon.
|
||||||
|
TrailingSemicolon:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Reports lines containing trailing whitespace.
|
||||||
|
TrailingWhitespace:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Don't write trailing zeros for numeric values with a decimal point.
|
||||||
|
TrailingZero:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Don't use the `all` keyword to specify transition properties.
|
||||||
|
TransitionAll:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Numeric values should not contain unnecessary fractional portions.
|
||||||
|
UnnecessaryMantissa:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Do not use parent selector references (&) when they would otherwise
|
||||||
|
# be unnecessary.
|
||||||
|
UnnecessaryParentReference:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# URLs should be valid and not contain protocols or domain names.
|
||||||
|
UrlFormat:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# URLs should always be enclosed within quotes.
|
||||||
|
UrlQuotes:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Properties, like color and font, are easier to read and maintain
|
||||||
|
# when defined using variables rather than literals.
|
||||||
|
VariableForProperty:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Avoid vendor prefixes. Or rather: don't write them yourself.
|
||||||
|
VendorPrefix:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Omit length units on zero values, e.g. `0px` vs. `0`.
|
||||||
|
ZeroUnit:
|
||||||
|
enabled: true
|
|
@ -43,4 +43,4 @@ Gruntfile.js
|
||||||
|
|
||||||
# for specific ignore
|
# for specific ignore
|
||||||
!.svgo.yml
|
!.svgo.yml
|
||||||
!sass-lint/**/*.yml
|
|
||||||
|
|
1093
AUTHORS.md
1093
AUTHORS.md
File diff suppressed because it is too large
Load Diff
1
Aptfile
1
Aptfile
|
@ -5,6 +5,7 @@ libidn11
|
||||||
libidn11-dev
|
libidn11-dev
|
||||||
libpq-dev
|
libpq-dev
|
||||||
libprotobuf-dev
|
libprotobuf-dev
|
||||||
|
libssl-dev
|
||||||
libxdamage1
|
libxdamage1
|
||||||
libxfixes3
|
libxfixes3
|
||||||
protobuf-compiler
|
protobuf-compiler
|
||||||
|
|
1360
CHANGELOG.md
1360
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
|
@ -10,17 +10,15 @@ You can contribute in the following ways:
|
||||||
- Contributing code to Mastodon by fixing bugs or implementing features
|
- Contributing code to Mastodon by fixing bugs or implementing features
|
||||||
- Improving the documentation
|
- Improving the documentation
|
||||||
|
|
||||||
If your contributions are accepted into Mastodon, you can request to be paid through [our OpenCollective](https://opencollective.com/mastodon).
|
|
||||||
|
|
||||||
## Bug reports
|
## Bug reports
|
||||||
|
|
||||||
Bug reports and feature suggestions must use descriptive and concise titles and be submitted to [GitHub Issues](https://github.com/tootsuite/mastodon/issues). Please use the search function to make sure that you are not submitting duplicates, and that a similar report or request has not already been resolved or rejected.
|
Bug reports and feature suggestions can be submitted to [GitHub Issues](https://github.com/tootsuite/mastodon/issues). Please make sure that you are not submitting duplicates, and that a similar report or request has not already been resolved or rejected in the past using the search function. Please also use descriptive, concise titles.
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
|
||||||
You can submit translations via [Crowdin](https://crowdin.com/project/mastodon). They are periodically merged into the codebase.
|
You can submit translations via [Weblate](https://weblate.joinmastodon.org/). They are periodically merged into the codebase.
|
||||||
|
|
||||||
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/mastodon/localized.svg)](https://crowdin.com/project/mastodon)
|
[![Mastodon translation statistics by language](https://weblate.joinmastodon.org/widgets/mastodon/-/multi-auto.svg)](https://weblate.joinmastodon.org/)
|
||||||
|
|
||||||
## Pull requests
|
## Pull requests
|
||||||
|
|
||||||
|
|
208
Dockerfile
208
Dockerfile
|
@ -1,144 +1,90 @@
|
||||||
FROM ubuntu:20.04 as build-dep
|
FROM node:8.15-alpine as node
|
||||||
|
FROM ruby:2.6-alpine3.8
|
||||||
|
|
||||||
# Use bash for the shell
|
LABEL maintainer="https://github.com/tootsuite/mastodon" \
|
||||||
SHELL ["bash", "-c"]
|
description="Your self-hosted, globally interconnected microblogging community"
|
||||||
|
|
||||||
# Install Node v12 (LTS)
|
|
||||||
ENV NODE_VER="12.20.0"
|
|
||||||
RUN ARCH= && \
|
|
||||||
dpkgArch="$(dpkg --print-architecture)" && \
|
|
||||||
case "${dpkgArch##*-}" in \
|
|
||||||
amd64) ARCH='x64';; \
|
|
||||||
ppc64el) ARCH='ppc64le';; \
|
|
||||||
s390x) ARCH='s390x';; \
|
|
||||||
arm64) ARCH='arm64';; \
|
|
||||||
armhf) ARCH='armv7l';; \
|
|
||||||
i386) ARCH='x86';; \
|
|
||||||
*) echo "unsupported architecture"; exit 1 ;; \
|
|
||||||
esac && \
|
|
||||||
echo "Etc/UTC" > /etc/localtime && \
|
|
||||||
apt update && \
|
|
||||||
apt -y install wget python && \
|
|
||||||
cd ~ && \
|
|
||||||
wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER-linux-$ARCH.tar.gz && \
|
|
||||||
tar xf node-v$NODE_VER-linux-$ARCH.tar.gz && \
|
|
||||||
rm node-v$NODE_VER-linux-$ARCH.tar.gz && \
|
|
||||||
mv node-v$NODE_VER-linux-$ARCH /opt/node
|
|
||||||
|
|
||||||
# Install jemalloc
|
|
||||||
ENV JE_VER="5.2.1"
|
|
||||||
RUN apt update && \
|
|
||||||
apt -y install make autoconf gcc g++ && \
|
|
||||||
cd ~ && \
|
|
||||||
wget https://github.com/jemalloc/jemalloc/archive/$JE_VER.tar.gz && \
|
|
||||||
tar xf $JE_VER.tar.gz && \
|
|
||||||
cd jemalloc-$JE_VER && \
|
|
||||||
./autogen.sh && \
|
|
||||||
./configure --prefix=/opt/jemalloc && \
|
|
||||||
make -j$(nproc) > /dev/null && \
|
|
||||||
make install_bin install_include install_lib && \
|
|
||||||
cd .. && rm -rf jemalloc-$JE_VER $JE_VER.tar.gz
|
|
||||||
|
|
||||||
# Install Ruby
|
|
||||||
ENV RUBY_VER="2.7.2"
|
|
||||||
ENV CPPFLAGS="-I/opt/jemalloc/include"
|
|
||||||
ENV LDFLAGS="-L/opt/jemalloc/lib/"
|
|
||||||
RUN apt update && \
|
|
||||||
apt -y install build-essential \
|
|
||||||
bison libyaml-dev libgdbm-dev libreadline-dev \
|
|
||||||
libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \
|
|
||||||
cd ~ && \
|
|
||||||
wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VER%.*}/ruby-$RUBY_VER.tar.gz && \
|
|
||||||
tar xf ruby-$RUBY_VER.tar.gz && \
|
|
||||||
cd ruby-$RUBY_VER && \
|
|
||||||
./configure --prefix=/opt/ruby \
|
|
||||||
--with-jemalloc \
|
|
||||||
--with-shared \
|
|
||||||
--disable-install-doc && \
|
|
||||||
ln -s /opt/jemalloc/lib/* /usr/lib/ && \
|
|
||||||
make -j$(nproc) > /dev/null && \
|
|
||||||
make install && \
|
|
||||||
cd .. && rm -rf ruby-$RUBY_VER.tar.gz ruby-$RUBY_VER
|
|
||||||
|
|
||||||
ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin"
|
|
||||||
|
|
||||||
RUN npm install -g yarn && \
|
|
||||||
gem install bundler && \
|
|
||||||
apt update && \
|
|
||||||
apt -y install git libicu-dev libidn11-dev \
|
|
||||||
libpq-dev libprotobuf-dev protobuf-compiler
|
|
||||||
|
|
||||||
COPY Gemfile* package.json yarn.lock /opt/mastodon/
|
|
||||||
|
|
||||||
RUN cd /opt/mastodon && \
|
|
||||||
bundle config set deployment 'true' && \
|
|
||||||
bundle config set without 'development test' && \
|
|
||||||
bundle install -j$(nproc) && \
|
|
||||||
yarn install --pure-lockfile
|
|
||||||
|
|
||||||
FROM ubuntu:20.04
|
|
||||||
|
|
||||||
# Copy over all the langs needed for runtime
|
|
||||||
COPY --from=build-dep /opt/node /opt/node
|
|
||||||
COPY --from=build-dep /opt/ruby /opt/ruby
|
|
||||||
COPY --from=build-dep /opt/jemalloc /opt/jemalloc
|
|
||||||
|
|
||||||
# Add more PATHs to the PATH
|
|
||||||
ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin"
|
|
||||||
|
|
||||||
# Create the mastodon user
|
|
||||||
ARG UID=991
|
ARG UID=991
|
||||||
ARG GID=991
|
ARG GID=991
|
||||||
RUN apt update && \
|
|
||||||
echo "Etc/UTC" > /etc/localtime && \
|
|
||||||
ln -s /opt/jemalloc/lib/* /usr/lib/ && \
|
|
||||||
apt install -y whois wget && \
|
|
||||||
addgroup --gid $GID mastodon && \
|
|
||||||
useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
|
|
||||||
echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd
|
|
||||||
|
|
||||||
# Install mastodon runtime deps
|
ENV PATH=/mastodon/bin:$PATH \
|
||||||
RUN apt -y --no-install-recommends install \
|
RAILS_SERVE_STATIC_FILES=true \
|
||||||
libssl1.1 libpq5 imagemagick ffmpeg \
|
RAILS_ENV=production \
|
||||||
libicu66 libprotobuf17 libidn11 libyaml-0-2 \
|
NODE_ENV=production
|
||||||
file ca-certificates tzdata libreadline8 && \
|
|
||||||
apt -y install gcc && \
|
|
||||||
ln -s /opt/mastodon /mastodon && \
|
|
||||||
gem install bundler && \
|
|
||||||
rm -rf /var/cache && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Add tini
|
ARG LIBICONV_VERSION=1.15
|
||||||
ENV TINI_VERSION="0.19.0"
|
ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
|
||||||
RUN dpkgArch="$(dpkg --print-architecture)" && \
|
|
||||||
ARCH=$dpkgArch && \
|
|
||||||
wget https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$ARCH \
|
|
||||||
https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$ARCH.sha256sum && \
|
|
||||||
cat tini-$ARCH.sha256sum | sha256sum -c - && \
|
|
||||||
mv tini-$ARCH /tini && rm tini-$ARCH.sha256sum && \
|
|
||||||
chmod +x /tini
|
|
||||||
|
|
||||||
# Copy over mastodon source, and dependencies from building, and set permissions
|
EXPOSE 3000 4000
|
||||||
COPY --chown=mastodon:mastodon . /opt/mastodon
|
|
||||||
COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
|
|
||||||
|
|
||||||
# Run mastodon services in prod mode
|
WORKDIR /mastodon
|
||||||
ENV RAILS_ENV="production"
|
|
||||||
ENV NODE_ENV="production"
|
|
||||||
|
|
||||||
# Tell rails to serve static files
|
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
||||||
ENV RAILS_SERVE_STATIC_FILES="true"
|
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
|
||||||
ENV BIND="0.0.0.0"
|
COPY --from=node /usr/local/bin/npm /usr/local/bin/npm
|
||||||
|
COPY --from=node /opt/yarn-* /opt/yarn
|
||||||
|
|
||||||
|
RUN apk -U upgrade \
|
||||||
|
&& apk add -t build-dependencies \
|
||||||
|
build-base \
|
||||||
|
icu-dev \
|
||||||
|
libidn-dev \
|
||||||
|
libressl \
|
||||||
|
libtool \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt-dev \
|
||||||
|
postgresql-dev \
|
||||||
|
protobuf-dev \
|
||||||
|
python \
|
||||||
|
&& apk add \
|
||||||
|
ca-certificates \
|
||||||
|
ffmpeg \
|
||||||
|
file \
|
||||||
|
git \
|
||||||
|
icu-libs \
|
||||||
|
imagemagick \
|
||||||
|
libidn \
|
||||||
|
libpq \
|
||||||
|
libxml2 \
|
||||||
|
libxslt \
|
||||||
|
protobuf \
|
||||||
|
tini \
|
||||||
|
tzdata \
|
||||||
|
&& update-ca-certificates \
|
||||||
|
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
|
||||||
|
&& ln -s /opt/yarn/bin/yarnpkg /usr/local/bin/yarnpkg \
|
||||||
|
&& mkdir -p /tmp/src /opt \
|
||||||
|
&& wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
|
||||||
|
&& echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
|
||||||
|
&& tar -xzf libiconv.tar.gz -C /tmp/src \
|
||||||
|
&& rm libiconv.tar.gz \
|
||||||
|
&& cd /tmp/src/libiconv-$LIBICONV_VERSION \
|
||||||
|
&& ./configure --prefix=/usr/local \
|
||||||
|
&& make -j$(getconf _NPROCESSORS_ONLN)\
|
||||||
|
&& make install \
|
||||||
|
&& libtool --finish /usr/local/lib \
|
||||||
|
&& cd /mastodon \
|
||||||
|
&& rm -rf /tmp/* /var/cache/apk/*
|
||||||
|
|
||||||
|
COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
|
||||||
|
|
||||||
|
RUN bundle config build.nokogiri --use-system-libraries --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
|
||||||
|
&& bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
|
||||||
|
&& yarn install --pure-lockfile --ignore-engines \
|
||||||
|
&& yarn cache clean
|
||||||
|
|
||||||
|
RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
|
||||||
|
&& mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
|
||||||
|
&& chown -R mastodon:mastodon /mastodon/public
|
||||||
|
|
||||||
|
COPY . /mastodon
|
||||||
|
|
||||||
|
RUN chown -R mastodon:mastodon /mastodon
|
||||||
|
|
||||||
|
VOLUME /mastodon/public/system
|
||||||
|
|
||||||
# Set the run user
|
|
||||||
USER mastodon
|
USER mastodon
|
||||||
|
|
||||||
# Precompile assets
|
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
|
||||||
RUN cd ~ && \
|
|
||||||
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
|
|
||||||
yarn cache clean
|
|
||||||
|
|
||||||
# Set the work dir and the container entry point
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
WORKDIR /opt/mastodon
|
|
||||||
ENTRYPOINT ["/tini", "--"]
|
|
||||||
EXPOSE 3000 4000
|
|
||||||
|
|
160
Gemfile
160
Gemfile
|
@ -1,115 +1,105 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
ruby '>= 2.5.0', '< 3.0.0'
|
ruby '>= 2.4.0', '< 2.7.0'
|
||||||
|
|
||||||
gem 'pkg-config', '~> 1.4'
|
gem 'pkg-config', '~> 1.3'
|
||||||
|
|
||||||
gem 'puma', '~> 5.0'
|
gem 'puma', '~> 3.12'
|
||||||
gem 'rails', '~> 5.2.4.4'
|
gem 'rails', '~> 5.2.2'
|
||||||
gem 'sprockets', '~> 3.7.2'
|
gem 'thor', '~> 0.20'
|
||||||
gem 'thor', '~> 1.0'
|
|
||||||
gem 'rack', '~> 2.2.3'
|
|
||||||
|
|
||||||
gem 'hamlit-rails', '~> 0.2'
|
gem 'hamlit-rails', '~> 0.2'
|
||||||
gem 'pg', '~> 1.2'
|
gem 'pg', '~> 1.1'
|
||||||
gem 'makara', '~> 0.4'
|
gem 'makara', '~> 0.4'
|
||||||
gem 'pghero', '~> 2.7'
|
gem 'pghero', '~> 2.2'
|
||||||
gem 'dotenv-rails', '~> 2.7'
|
gem 'dotenv-rails', '~> 2.6'
|
||||||
|
|
||||||
gem 'aws-sdk-s3', '~> 1.85', require: false
|
gem 'aws-sdk-s3', '~> 1.30', require: false
|
||||||
gem 'fog-core', '<= 2.1.0'
|
gem 'fog-core', '<= 2.1.0'
|
||||||
gem 'fog-openstack', '~> 0.3', require: false
|
gem 'fog-openstack', '~> 0.3', require: false
|
||||||
gem 'paperclip', '~> 6.0'
|
gem 'paperclip', '~> 6.0'
|
||||||
gem 'paperclip-av-transcoder', '~> 0.6'
|
gem 'paperclip-av-transcoder', '~> 0.6'
|
||||||
gem 'streamio-ffmpeg', '~> 3.0'
|
gem 'streamio-ffmpeg', '~> 3.0'
|
||||||
gem 'blurhash', '~> 0.1'
|
|
||||||
|
|
||||||
gem 'active_model_serializers', '~> 0.10'
|
gem 'active_model_serializers', '~> 0.10'
|
||||||
gem 'addressable', '~> 2.7'
|
gem 'addressable', '~> 2.6'
|
||||||
gem 'bootsnap', '~> 1.5', require: false
|
gem 'bootsnap', '~> 1.3', require: false
|
||||||
gem 'browser'
|
gem 'browser'
|
||||||
gem 'charlock_holmes', '~> 0.7.7'
|
gem 'charlock_holmes', '~> 0.7.6'
|
||||||
gem 'iso-639'
|
gem 'iso-639'
|
||||||
gem 'chewy', '~> 5.1'
|
gem 'chewy', '~> 5.0'
|
||||||
gem 'cld3', '~> 3.3.0'
|
gem 'cld3', '~> 3.2.3'
|
||||||
gem 'devise', '~> 4.7'
|
gem 'devise', '~> 4.5'
|
||||||
gem 'devise-two-factor', '~> 3.1'
|
gem 'devise-two-factor', '~> 3.0'
|
||||||
|
|
||||||
group :pam_authentication, optional: true do
|
group :pam_authentication, optional: true do
|
||||||
gem 'devise_pam_authenticatable2', '~> 9.2'
|
gem 'devise_pam_authenticatable2', '~> 9.2'
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'net-ldap', '~> 0.16'
|
gem 'net-ldap', '~> 0.10'
|
||||||
gem 'omniauth-cas', '~> 2.0'
|
gem 'omniauth-cas', '~> 1.1'
|
||||||
gem 'omniauth-saml', '~> 1.10'
|
gem 'omniauth-saml', '~> 1.10'
|
||||||
gem 'omniauth', '~> 1.9'
|
gem 'omniauth', '~> 1.9'
|
||||||
gem 'omniauth-rails_csrf_protection', '~> 0.1'
|
|
||||||
|
|
||||||
gem 'color_diff', '~> 0.1'
|
gem 'doorkeeper', '~> 5.0'
|
||||||
gem 'discard', '~> 1.2'
|
|
||||||
gem 'doorkeeper', '~> 5.4'
|
|
||||||
gem 'ed25519', '~> 1.2'
|
|
||||||
gem 'fast_blank', '~> 1.0'
|
gem 'fast_blank', '~> 1.0'
|
||||||
gem 'fastimage'
|
gem 'fastimage'
|
||||||
|
gem 'goldfinger', '~> 2.1'
|
||||||
gem 'hiredis', '~> 0.6'
|
gem 'hiredis', '~> 0.6'
|
||||||
gem 'redis-namespace', '~> 1.8'
|
gem 'redis-namespace', '~> 1.5'
|
||||||
gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b799ead604f900ed50685e9b2d469cd2befba5b'
|
|
||||||
gem 'htmlentities', '~> 4.3'
|
gem 'htmlentities', '~> 4.3'
|
||||||
gem 'http', '~> 4.4'
|
gem 'http', '~> 3.3'
|
||||||
gem 'http_accept_language', '~> 2.1'
|
gem 'http_accept_language', '~> 2.1'
|
||||||
gem 'httplog', '~> 1.4.3'
|
gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2'
|
||||||
|
gem 'httplog', '~> 1.2'
|
||||||
gem 'idn-ruby', require: 'idn'
|
gem 'idn-ruby', require: 'idn'
|
||||||
gem 'kaminari', '~> 1.2'
|
gem 'kaminari', '~> 1.1'
|
||||||
gem 'link_header', '~> 0.0'
|
gem 'link_header', '~> 0.0'
|
||||||
gem 'mime-types', '~> 3.3.1', require: 'mime/types/columnar'
|
gem 'mime-types', '~> 3.2', require: 'mime/types/columnar'
|
||||||
gem 'nilsimsa', git: 'https://github.com/witgo/nilsimsa', ref: 'fd184883048b922b176939f851338d0a4971a532'
|
|
||||||
gem 'nokogiri', '~> 1.10'
|
gem 'nokogiri', '~> 1.10'
|
||||||
gem 'nsa', '~> 0.2'
|
gem 'nsa', '~> 0.2'
|
||||||
gem 'oj', '~> 3.10'
|
gem 'oj', '~> 3.7'
|
||||||
gem 'ox', '~> 2.13'
|
gem 'ostatus2', '~> 2.0'
|
||||||
gem 'parslet'
|
gem 'ox', '~> 2.10'
|
||||||
gem 'parallel', '~> 1.20'
|
gem 'posix-spawn', git: 'https://github.com/rtomayko/posix-spawn', ref: '58465d2e213991f8afb13b984854a49fcdcc980c'
|
||||||
gem 'posix-spawn'
|
gem 'pundit', '~> 2.0'
|
||||||
gem 'pundit', '~> 2.1'
|
|
||||||
gem 'premailer-rails'
|
gem 'premailer-rails'
|
||||||
gem 'rack-attack', '~> 6.3'
|
gem 'rack-attack', '~> 5.4'
|
||||||
gem 'rack-cors', '~> 1.1', require: 'rack/cors'
|
gem 'rack-cors', '~> 1.0', require: 'rack/cors'
|
||||||
gem 'rails-i18n', '~> 5.1'
|
gem 'rails-i18n', '~> 5.1'
|
||||||
gem 'rails-settings-cached', '~> 0.6'
|
gem 'rails-settings-cached', '~> 0.6'
|
||||||
gem 'redis', '~> 4.2', require: ['redis', 'redis/connection/hiredis']
|
gem 'redis', '~> 4.1', require: ['redis', 'redis/connection/hiredis']
|
||||||
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
||||||
gem 'rqrcode', '~> 1.1'
|
gem 'rqrcode', '~> 0.10'
|
||||||
gem 'ruby-progressbar', '~> 1.10'
|
gem 'sanitize', '~> 5.0'
|
||||||
gem 'sanitize', '~> 5.2'
|
gem 'sidekiq', '~> 5.2'
|
||||||
gem 'scenic', '~> 1.5'
|
|
||||||
gem 'sidekiq', '~> 6.1'
|
|
||||||
gem 'sidekiq-scheduler', '~> 3.0'
|
gem 'sidekiq-scheduler', '~> 3.0'
|
||||||
gem 'sidekiq-unique-jobs', '~> 6.0'
|
gem 'sidekiq-unique-jobs', '~> 6.0'
|
||||||
gem 'sidekiq-bulk', '~>0.2.0'
|
gem 'sidekiq-bulk', '~>0.2.0'
|
||||||
gem 'simple-navigation', '~> 4.1'
|
gem 'simple-navigation', '~> 4.0'
|
||||||
gem 'simple_form', '~> 5.0'
|
gem 'simple_form', '~> 4.1'
|
||||||
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
||||||
gem 'stoplight', '~> 2.2.1'
|
gem 'stoplight', '~> 2.1.3'
|
||||||
gem 'strong_migrations', '~> 0.7'
|
gem 'strong_migrations', '~> 0.3'
|
||||||
gem 'tty-prompt', '~> 0.22', require: false
|
gem 'tty-command', '~> 0.8', require: false
|
||||||
|
gem 'tty-prompt', '~> 0.18', require: false
|
||||||
gem 'twitter-text', '~> 1.14'
|
gem 'twitter-text', '~> 1.14'
|
||||||
gem 'tzinfo-data', '~> 1.2020'
|
gem 'tzinfo-data', '~> 1.2018'
|
||||||
gem 'webpacker', '~> 5.2'
|
gem 'webpacker', '~> 3.5'
|
||||||
gem 'webpush'
|
gem 'webpush'
|
||||||
gem 'webauthn', '~> 3.0.0.alpha1'
|
|
||||||
|
|
||||||
gem 'json-ld'
|
gem 'json-ld', '~> 3.0'
|
||||||
gem 'json-ld-preloaded', '~> 3.1'
|
gem 'json-ld-preloaded', '~> 3.0'
|
||||||
gem 'rdf-normalize', '~> 0.4'
|
gem 'rdf-normalize', '~> 0.3'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'fabrication', '~> 2.21'
|
gem 'fabrication', '~> 2.20'
|
||||||
gem 'fuubar', '~> 2.5'
|
gem 'fuubar', '~> 2.3'
|
||||||
gem 'i18n-tasks', '~> 0.9', require: false
|
gem 'i18n-tasks', '~> 0.9', require: false
|
||||||
gem 'pry-byebug', '~> 3.9'
|
gem 'pry-byebug', '~> 3.6'
|
||||||
gem 'pry-rails', '~> 0.3'
|
gem 'pry-rails', '~> 0.3'
|
||||||
gem 'rspec-rails', '~> 4.0'
|
gem 'rspec-rails', '~> 3.8'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production, :test do
|
group :production, :test do
|
||||||
|
@ -117,47 +107,43 @@ group :production, :test do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara', '~> 3.33'
|
gem 'capybara', '~> 3.12'
|
||||||
gem 'climate_control', '~> 0.2'
|
gem 'climate_control', '~> 0.2'
|
||||||
gem 'faker', '~> 2.14'
|
gem 'faker', '~> 1.9'
|
||||||
gem 'microformats', '~> 4.2'
|
gem 'microformats', '~> 4.0'
|
||||||
gem 'rails-controller-testing', '~> 1.0'
|
gem 'rails-controller-testing', '~> 1.0'
|
||||||
gem 'rspec-sidekiq', '~> 3.1'
|
gem 'rspec-sidekiq', '~> 3.0'
|
||||||
gem 'simplecov', '~> 0.19', require: false
|
gem 'simplecov', '~> 0.16', require: false
|
||||||
gem 'webmock', '~> 3.10'
|
gem 'webmock', '~> 3.5'
|
||||||
gem 'parallel_tests', '~> 3.4'
|
gem 'parallel_tests', '~> 2.27'
|
||||||
gem 'rspec_junit_formatter', '~> 0.4'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'active_record_query_trace', '~> 1.8'
|
gem 'active_record_query_trace', '~> 1.5'
|
||||||
gem 'annotate', '~> 3.1'
|
gem 'annotate', '~> 2.7'
|
||||||
gem 'better_errors', '~> 2.9'
|
gem 'better_errors', '~> 2.5'
|
||||||
gem 'binding_of_caller', '~> 0.7'
|
gem 'binding_of_caller', '~> 0.7'
|
||||||
gem 'bullet', '~> 6.1'
|
gem 'bullet', '~> 5.9'
|
||||||
gem 'letter_opener', '~> 1.7'
|
gem 'letter_opener', '~> 1.7'
|
||||||
gem 'letter_opener_web', '~> 1.4'
|
gem 'letter_opener_web', '~> 1.3'
|
||||||
gem 'memory_profiler'
|
gem 'memory_profiler'
|
||||||
gem 'rubocop', '~> 1.3', require: false
|
gem 'rubocop', '~> 0.63', require: false
|
||||||
gem 'rubocop-rails', '~> 2.8', require: false
|
gem 'brakeman', '~> 4.4', require: false
|
||||||
gem 'brakeman', '~> 4.10', require: false
|
gem 'bundler-audit', '~> 0.6', require: false
|
||||||
gem 'bundler-audit', '~> 0.7', require: false
|
gem 'scss_lint', '~> 0.57', require: false
|
||||||
|
|
||||||
gem 'capistrano', '~> 3.14'
|
gem 'capistrano', '~> 3.11'
|
||||||
gem 'capistrano-rails', '~> 1.6'
|
gem 'capistrano-rails', '~> 1.4'
|
||||||
gem 'capistrano-rbenv', '~> 2.2'
|
gem 'capistrano-rbenv', '~> 2.1'
|
||||||
gem 'capistrano-yarn', '~> 2.0'
|
gem 'capistrano-yarn', '~> 2.0'
|
||||||
|
|
||||||
|
gem 'derailed_benchmarks'
|
||||||
gem 'stackprof'
|
gem 'stackprof'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
gem 'lograge', '~> 0.11'
|
gem 'lograge', '~> 0.10'
|
||||||
gem 'redis-rails', '~> 5.0'
|
gem 'redis-rails', '~> 5.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'concurrent-ruby', require: false
|
gem 'concurrent-ruby', require: false
|
||||||
gem 'connection_pool', require: false
|
|
||||||
|
|
||||||
gem 'xorcist', '~> 1.1'
|
|
||||||
gem 'pluck_each', '~> 0.1.3'
|
|
||||||
|
|
943
Gemfile.lock
943
Gemfile.lock
File diff suppressed because it is too large
Load Diff
14
Procfile
14
Procfile
|
@ -1,14 +1,2 @@
|
||||||
web: bin/heroku-web
|
web: bundle exec puma -C config/puma.rb
|
||||||
worker: bundle exec sidekiq
|
worker: bundle exec sidekiq
|
||||||
|
|
||||||
# For the streaming API, you need a separate app that shares Postgres and Redis:
|
|
||||||
#
|
|
||||||
# heroku create
|
|
||||||
# heroku buildpacks:add heroku/nodejs
|
|
||||||
# heroku config:set RUN_STREAMING=true
|
|
||||||
# heroku addons:attach <main-app>::DATABASE
|
|
||||||
# heroku addons:attach <main-app>::REDIS
|
|
||||||
#
|
|
||||||
# and let the main app use the separate app:
|
|
||||||
#
|
|
||||||
# heroku config:set STREAMING_API_BASE_URL=wss://<streaming-app>.herokuapp.com -a <main-app>
|
|
||||||
|
|
22
README.md
22
README.md
|
@ -4,16 +4,16 @@
|
||||||
[![GitHub release](https://img.shields.io/github/release/tootsuite/mastodon.svg)][releases]
|
[![GitHub release](https://img.shields.io/github/release/tootsuite/mastodon.svg)][releases]
|
||||||
[![Build Status](https://img.shields.io/circleci/project/github/tootsuite/mastodon.svg)][circleci]
|
[![Build Status](https://img.shields.io/circleci/project/github/tootsuite/mastodon.svg)][circleci]
|
||||||
[![Code Climate](https://img.shields.io/codeclimate/maintainability/tootsuite/mastodon.svg)][code_climate]
|
[![Code Climate](https://img.shields.io/codeclimate/maintainability/tootsuite/mastodon.svg)][code_climate]
|
||||||
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/mastodon/localized.svg)][crowdin]
|
[![Translation status](https://weblate.joinmastodon.org/widgets/mastodon/-/svg-badge.svg)][weblate]
|
||||||
[![Docker Pulls](https://img.shields.io/docker/pulls/tootsuite/mastodon.svg)][docker]
|
[![Docker Pulls](https://img.shields.io/docker/pulls/tootsuite/mastodon.svg)][docker]
|
||||||
|
|
||||||
[releases]: https://github.com/tootsuite/mastodon/releases
|
[releases]: https://github.com/tootsuite/mastodon/releases
|
||||||
[circleci]: https://circleci.com/gh/tootsuite/mastodon
|
[circleci]: https://circleci.com/gh/tootsuite/mastodon
|
||||||
[code_climate]: https://codeclimate.com/github/tootsuite/mastodon
|
[code_climate]: https://codeclimate.com/github/tootsuite/mastodon
|
||||||
[crowdin]: https://crowdin.com/project/mastodon
|
[weblate]: https://weblate.joinmastodon.org/engage/mastodon/
|
||||||
[docker]: https://hub.docker.com/r/tootsuite/mastodon/
|
[docker]: https://hub.docker.com/r/tootsuite/mastodon/
|
||||||
|
|
||||||
Mastodon is a **free, open-source social network server** based on ActivityPub where users can follow friends and discover new ones. On Mastodon, users can publish anything they want: links, pictures, text, video. All Mastodon servers are interoperable as a federated network (users on one server can seamlessly communicate with users from another one, including non-Mastodon software that implements ActivityPub)!
|
Mastodon is a **free, open-source social network server** based on ActivityPub. Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. All servers of Mastodon are interoperable as a federated network, i.e. users on one server can seamlessly communicate with users from another one. This includes non-Mastodon software that also implements ActivityPub!
|
||||||
|
|
||||||
Click below to **learn more** in a video:
|
Click below to **learn more** in a video:
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ Private posts, locked accounts, phrase filtering, muting, blocking and all sorts
|
||||||
|
|
||||||
**OAuth2 and a straightforward REST API**
|
**OAuth2 and a straightforward REST API**
|
||||||
|
|
||||||
Mastodon acts as an OAuth2 provider so 3rd party apps can use the REST and Streaming APIs, resulting in a rich app ecosystem with a lot of choices!
|
Mastodon acts as an OAuth2 provider so 3rd party apps can use the REST and Streaming APIs, resulting in a rich app ecosystem with a lot of choice!
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
|
@ -68,25 +68,25 @@ Mastodon acts as an OAuth2 provider so 3rd party apps can use the REST and Strea
|
||||||
**Requirements:**
|
**Requirements:**
|
||||||
|
|
||||||
- **PostgreSQL** 9.5+
|
- **PostgreSQL** 9.5+
|
||||||
- **Redis** 4+
|
- **Redis**
|
||||||
- **Ruby** 2.5+
|
- **Ruby** 2.4+
|
||||||
- **Node.js** 10.13+
|
- **Node.js** 8+
|
||||||
|
|
||||||
The repository includes deployment configurations for **Docker and docker-compose**, but also a few specific platforms like **Heroku**, **Scalingo**, and **Nanobox**. The [**stand-alone** installation guide](https://docs.joinmastodon.org/admin/install/) is available in the documentation.
|
The repository includes deployment configurations for **Docker and docker-compose**, but also a few specific platforms like **Heroku**, **Scalingo**, and **Nanobox**. The [**stand-alone** installation guide](https://docs.joinmastodon.org/administration/installation/) is available in the documentation.
|
||||||
|
|
||||||
A **Vagrant** configuration is included for development purposes.
|
A **Vagrant** configuration is included for development purposes.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Mastodon is **free, open-source software** licensed under **AGPLv3**.
|
Mastodon is **free, open source software** licensed under **AGPLv3**.
|
||||||
|
|
||||||
You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository, or submit translations using Crowdin. To get started, take a look at [CONTRIBUTING.md](CONTRIBUTING.md). If your contributions are accepted into Mastodon, you can request to be paid through [our OpenCollective](https://opencollective.com/mastodon).
|
You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository, or submit translations using Weblate. To get started, take a look at [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||||
|
|
||||||
**IRC channel**: #mastodon on irc.freenode.net
|
**IRC channel**: #mastodon on irc.freenode.net
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (C) 2016-2020 Eugen Rochko & other Mastodon contributors (see [AUTHORS.md](AUTHORS.md))
|
Copyright (C) 2016-2018 Eugen Rochko & other Mastodon contributors (see [AUTHORS.md](AUTHORS.md))
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
|
12
SECURITY.md
12
SECURITY.md
|
@ -1,12 +0,0 @@
|
||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 3.1.x | :white_check_mark: |
|
|
||||||
| < 3.1 | :x: |
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
hello@joinmastodon.org
|
|
|
@ -12,7 +12,7 @@ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||||
sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main'
|
sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main'
|
||||||
|
|
||||||
# Add repo for NodeJS
|
# Add repo for NodeJS
|
||||||
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
|
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
|
||||||
|
|
||||||
# Add firewall rule to redirect 80 to PORT and save
|
# Add firewall rule to redirect 80 to PORT and save
|
||||||
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]}
|
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]}
|
||||||
|
@ -44,18 +44,7 @@ sudo apt-get install \
|
||||||
|
|
||||||
# Install rvm
|
# Install rvm
|
||||||
read RUBY_VERSION < .ruby-version
|
read RUBY_VERSION < .ruby-version
|
||||||
|
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
||||||
gpg_command="gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB"
|
|
||||||
$($gpg_command)
|
|
||||||
if [ $? -ne 0 ];then
|
|
||||||
echo "GPG command failed, This prevented RVM from installing."
|
|
||||||
echo "Retrying once..." && $($gpg_command)
|
|
||||||
if [ $? -ne 0 ];then
|
|
||||||
echo "GPG failed for the second time, please ensure network connectivity."
|
|
||||||
echo "Exiting..." && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer | bash -s stable --ruby=$RUBY_VERSION
|
curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer | bash -s stable --ruby=$RUBY_VERSION
|
||||||
source /home/vagrant/.rvm/scripts/rvm
|
source /home/vagrant/.rvm/scripts/rvm
|
||||||
|
|
||||||
|
@ -91,7 +80,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||||
|
|
||||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
|
|
||||||
config.vm.box = "ubuntu/bionic64"
|
config.vm.box = "ubuntu/xenial64"
|
||||||
|
|
||||||
config.vm.provider :virtualbox do |vb|
|
config.vm.provider :virtualbox do |vb|
|
||||||
vb.name = "mastodon"
|
vb.name = "mastodon"
|
||||||
|
|
12
app.json
12
app.json
|
@ -13,6 +13,15 @@
|
||||||
"description": "The domain that your Mastodon instance will run on (this can be appname.herokuapp.com or a custom domain)",
|
"description": "The domain that your Mastodon instance will run on (this can be appname.herokuapp.com or a custom domain)",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
"LOCAL_HTTPS": {
|
||||||
|
"description": "Will your domain support HTTPS? (Automatic for herokuapp, requires manual configuration for custom domains)",
|
||||||
|
"value": "false",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"PAPERCLIP_SECRET": {
|
||||||
|
"description": "The secret key for storing media files",
|
||||||
|
"generator": "secret"
|
||||||
|
},
|
||||||
"SECRET_KEY_BASE": {
|
"SECRET_KEY_BASE": {
|
||||||
"description": "The secret key base",
|
"description": "The secret key base",
|
||||||
"generator": "secret"
|
"generator": "secret"
|
||||||
|
@ -88,6 +97,9 @@
|
||||||
{
|
{
|
||||||
"url": "https://github.com/heroku/heroku-buildpack-apt"
|
"url": "https://github.com/heroku/heroku-buildpack-apt"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"url": "heroku/nodejs"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url": "heroku/ruby"
|
"url": "heroku/ruby"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AccountsIndex < Chewy::Index
|
|
||||||
settings index: { refresh_interval: '5m' }, analysis: {
|
|
||||||
analyzer: {
|
|
||||||
content: {
|
|
||||||
tokenizer: 'whitespace',
|
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
|
||||||
},
|
|
||||||
|
|
||||||
edge_ngram: {
|
|
||||||
tokenizer: 'edge_ngram',
|
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
tokenizer: {
|
|
||||||
edge_ngram: {
|
|
||||||
type: 'edge_ngram',
|
|
||||||
min_gram: 1,
|
|
||||||
max_gram: 15,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
define_type ::Account.searchable.includes(:account_stat), delete_if: ->(account) { account.destroyed? || !account.searchable? } do
|
|
||||||
root date_detection: false do
|
|
||||||
field :id, type: 'long'
|
|
||||||
|
|
||||||
field :display_name, type: 'text', analyzer: 'content' do
|
|
||||||
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content'
|
|
||||||
end
|
|
||||||
|
|
||||||
field :acct, type: 'text', analyzer: 'content', value: ->(account) { [account.username, account.domain].compact.join('@') } do
|
|
||||||
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content'
|
|
||||||
end
|
|
||||||
|
|
||||||
field :following_count, type: 'long', value: ->(account) { account.following.local.count }
|
|
||||||
field :followers_count, type: 'long', value: ->(account) { account.followers.local.count }
|
|
||||||
field :last_status_at, type: 'date', value: ->(account) { account.last_status_at || account.created_at }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -31,36 +31,31 @@ class StatusesIndex < Chewy::Index
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
define_type ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :preloadable_poll) do
|
define_type ::Status.unscoped.without_reblogs do
|
||||||
crutch :mentions do |collection|
|
crutch :mentions do |collection|
|
||||||
data = ::Mention.where(status_id: collection.map(&:id)).where(account: Account.local, silent: false).pluck(:status_id, :account_id)
|
data = ::Mention.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
|
||||||
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
crutch :favourites do |collection|
|
crutch :favourites do |collection|
|
||||||
data = ::Favourite.where(status_id: collection.map(&:id)).where(account: Account.local).pluck(:status_id, :account_id)
|
data = ::Favourite.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
|
||||||
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
crutch :reblogs do |collection|
|
crutch :reblogs do |collection|
|
||||||
data = ::Status.where(reblog_of_id: collection.map(&:id)).where(account: Account.local).pluck(:reblog_of_id, :account_id)
|
data = ::Status.where(reblog_of_id: collection.map(&:id)).pluck(:reblog_of_id, :account_id)
|
||||||
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
|
||||||
end
|
|
||||||
|
|
||||||
crutch :bookmarks do |collection|
|
|
||||||
data = ::Bookmark.where(status_id: collection.map(&:id)).where(account: Account.local).pluck(:status_id, :account_id)
|
|
||||||
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
root date_detection: false do
|
root date_detection: false do
|
||||||
field :id, type: 'long'
|
|
||||||
field :account_id, type: 'long'
|
field :account_id, type: 'long'
|
||||||
|
|
||||||
field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).concat(status.preloadable_poll ? status.preloadable_poll.options : []).join("\n\n") } do
|
field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].join("\n\n") } do
|
||||||
field :stemmed, type: 'text', analyzer: 'content'
|
field :stemmed, type: 'text', analyzer: 'content'
|
||||||
end
|
end
|
||||||
|
|
||||||
field :searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) }
|
field :searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) }
|
||||||
|
field :created_at, type: 'date'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class TagsIndex < Chewy::Index
|
|
||||||
settings index: { refresh_interval: '15m' }, analysis: {
|
|
||||||
analyzer: {
|
|
||||||
content: {
|
|
||||||
tokenizer: 'keyword',
|
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
|
||||||
},
|
|
||||||
|
|
||||||
edge_ngram: {
|
|
||||||
tokenizer: 'edge_ngram',
|
|
||||||
filter: %w(lowercase asciifolding cjk_width),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
tokenizer: {
|
|
||||||
edge_ngram: {
|
|
||||||
type: 'edge_ngram',
|
|
||||||
min_gram: 2,
|
|
||||||
max_gram: 15,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
define_type ::Tag.listable, delete_if: ->(tag) { tag.destroyed? || !tag.listable? } do
|
|
||||||
root date_detection: false do
|
|
||||||
field :name, type: 'text', analyzer: 'content' do
|
|
||||||
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content'
|
|
||||||
end
|
|
||||||
|
|
||||||
field :reviewed, type: 'boolean', value: ->(tag) { tag.reviewed? }
|
|
||||||
field :usage, type: 'long', value: ->(tag) { tag.history.reduce(0) { |total, day| total + day[:accounts].to_i } }
|
|
||||||
field :last_status_at, type: 'date', value: ->(tag) { tag.last_status_at || tag.created_at }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,67 +1,42 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AboutController < ApplicationController
|
class AboutController < ApplicationController
|
||||||
include RegistrationSpamConcern
|
before_action :set_body_classes
|
||||||
|
before_action :set_instance_presenter, only: [:show, :more, :terms]
|
||||||
|
|
||||||
layout 'public'
|
def show
|
||||||
|
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
|
||||||
before_action :require_open_federation!, only: [:show, :more]
|
@initial_state_json = serializable_resource.to_json
|
||||||
before_action :set_body_classes, only: :show
|
|
||||||
before_action :set_instance_presenter
|
|
||||||
before_action :set_expires_in, only: [:more, :terms]
|
|
||||||
before_action :set_registration_form_time, only: :show
|
|
||||||
|
|
||||||
skip_before_action :require_functional!, only: [:more, :terms]
|
|
||||||
|
|
||||||
def show; end
|
|
||||||
|
|
||||||
def more
|
|
||||||
flash.now[:notice] = I18n.t('about.instance_actor_flash') if params[:instance_actor]
|
|
||||||
|
|
||||||
toc_generator = TOCGenerator.new(@instance_presenter.site_extended_description)
|
|
||||||
|
|
||||||
@contents = toc_generator.html
|
|
||||||
@table_of_contents = toc_generator.toc
|
|
||||||
@blocks = DomainBlock.with_user_facing_limitations.by_severity if display_blocks?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def terms; end
|
def more
|
||||||
|
render layout: 'public'
|
||||||
|
end
|
||||||
|
|
||||||
helper_method :display_blocks?
|
def terms
|
||||||
helper_method :display_blocks_rationale?
|
render layout: 'public'
|
||||||
helper_method :public_fetch_mode?
|
end
|
||||||
helper_method :new_user
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def require_open_federation!
|
|
||||||
not_found if whitelist_mode?
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_blocks?
|
|
||||||
Setting.show_domain_blocks == 'all' || (Setting.show_domain_blocks == 'users' && user_signed_in?)
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_blocks_rationale?
|
|
||||||
Setting.show_domain_blocks_rationale == 'all' || (Setting.show_domain_blocks_rationale == 'users' && user_signed_in?)
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_user
|
def new_user
|
||||||
User.new.tap do |user|
|
User.new.tap(&:build_account)
|
||||||
user.build_account
|
|
||||||
user.build_invite_request
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
helper_method :new_user
|
||||||
|
|
||||||
def set_instance_presenter
|
def set_instance_presenter
|
||||||
@instance_presenter = InstancePresenter.new
|
@instance_presenter = InstancePresenter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_body_classes
|
def set_body_classes
|
||||||
@hide_navbar = true
|
@body_classes = 'with-modals'
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_expires_in
|
def initial_state_params
|
||||||
expires_in 0, public: true
|
{
|
||||||
|
settings: { known_fediverse: Setting.show_known_fediverse_at_about_page },
|
||||||
|
token: current_session&.token,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class AccountFollowController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def create
|
def create
|
||||||
FollowService.new.call(current_user.account, @account, with_rate_limit: true)
|
FollowService.new.call(current_user.account, @account.acct)
|
||||||
redirect_to account_path(@account)
|
redirect_to account_path(@account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,27 +1,18 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AccountsController < ApplicationController
|
class AccountsController < ApplicationController
|
||||||
PAGE_SIZE = 20
|
PAGE_SIZE = 20
|
||||||
PAGE_SIZE_MAX = 200
|
|
||||||
|
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
include SignatureAuthentication
|
|
||||||
|
|
||||||
before_action :require_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
|
|
||||||
before_action :set_cache_headers
|
before_action :set_cache_headers
|
||||||
before_action :set_body_classes
|
|
||||||
|
|
||||||
skip_around_action :set_locale, if: -> { [:json, :rss].include?(request.format&.to_sym) }
|
|
||||||
skip_before_action :require_functional!, unless: :whitelist_mode?
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
expires_in 0, public: true unless user_signed_in?
|
@body_classes = 'with-modals'
|
||||||
|
|
||||||
@pinned_statuses = []
|
@pinned_statuses = []
|
||||||
@endorsed_accounts = @account.endorsed_accounts.to_a.sample(4)
|
@endorsed_accounts = @account.endorsed_accounts.to_a.sample(4)
|
||||||
@featured_hashtags = @account.featured_tags.order(statuses_count: :desc)
|
|
||||||
|
|
||||||
if current_account && @account.blocking?(current_account)
|
if current_account && @account.blocking?(current_account)
|
||||||
@statuses = []
|
@statuses = []
|
||||||
|
@ -29,8 +20,8 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@pinned_statuses = cache_collection(@account.pinned_statuses, Status) if show_pinned_statuses?
|
@pinned_statuses = cache_collection(@account.pinned_statuses, Status) if show_pinned_statuses?
|
||||||
@statuses = cached_filtered_status_page
|
@statuses = filtered_status_page(params)
|
||||||
@rss_url = rss_url
|
@statuses = cache_collection(@statuses, Status)
|
||||||
|
|
||||||
unless @statuses.empty?
|
unless @statuses.empty?
|
||||||
@older_url = older_url if @statuses.last.id > filtered_statuses.last.id
|
@older_url = older_url if @statuses.last.id > filtered_statuses.last.id
|
||||||
|
@ -38,35 +29,34 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
format.rss do
|
format.atom do
|
||||||
expires_in 1.minute, public: true
|
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(PAGE_SIZE, params[:max_id], params[:since_id])
|
||||||
|
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.reject { |entry| entry.status.nil? }))
|
||||||
|
end
|
||||||
|
|
||||||
limit = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
|
format.rss do
|
||||||
@statuses = filtered_statuses.without_reblogs.limit(limit)
|
@statuses = cache_collection(default_statuses.without_reblogs.without_replies.limit(PAGE_SIZE), Status)
|
||||||
@statuses = cache_collection(@statuses, Status)
|
render xml: RSS::AccountSerializer.render(@account, @statuses)
|
||||||
render xml: RSS::AccountSerializer.render(@account, @statuses, params[:tag])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
expires_in 3.minutes, public: !(authorized_fetch_mode? && signed_request_account.present?)
|
skip_session!
|
||||||
render_with_cache json: @account, content_type: 'application/activity+json', serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter
|
|
||||||
|
render_cached_json(['activitypub', 'actor', @account], content_type: 'application/activity+json') do
|
||||||
|
ActiveModelSerializers::SerializableResource.new(@account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_body_classes
|
|
||||||
@body_classes = 'with-modals'
|
|
||||||
end
|
|
||||||
|
|
||||||
def show_pinned_statuses?
|
def show_pinned_statuses?
|
||||||
[replies_requested?, media_requested?, tag_requested?, params[:max_id].present?, params[:min_id].present?].none?
|
[replies_requested?, media_requested?, params[:max_id].present?, params[:min_id].present?].none?
|
||||||
end
|
end
|
||||||
|
|
||||||
def filtered_statuses
|
def filtered_statuses
|
||||||
default_statuses.tap do |statuses|
|
default_statuses.tap do |statuses|
|
||||||
statuses.merge!(hashtag_scope) if tag_requested?
|
|
||||||
statuses.merge!(only_media_scope) if media_requested?
|
statuses.merge!(only_media_scope) if media_requested?
|
||||||
statuses.merge!(no_replies_scope) unless replies_requested?
|
statuses.merge!(no_replies_scope) unless replies_requested?
|
||||||
end
|
end
|
||||||
|
@ -81,40 +71,19 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_media_status_ids
|
def account_media_status_ids
|
||||||
@account.media_attachments.attached.reorder(nil).select(:status_id).group(:status_id)
|
@account.media_attachments.attached.reorder(nil).select(:status_id).distinct
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_replies_scope
|
def no_replies_scope
|
||||||
Status.without_replies
|
Status.without_replies
|
||||||
end
|
end
|
||||||
|
|
||||||
def hashtag_scope
|
def set_account
|
||||||
tag = Tag.find_normalized(params[:tag])
|
@account = Account.find_local!(params[:username])
|
||||||
|
|
||||||
if tag
|
|
||||||
Status.tagged_with(tag.id)
|
|
||||||
else
|
|
||||||
Status.none
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def username_param
|
|
||||||
params[:username]
|
|
||||||
end
|
|
||||||
|
|
||||||
def skip_temporary_suspension_response?
|
|
||||||
request.format == :json
|
|
||||||
end
|
|
||||||
|
|
||||||
def rss_url
|
|
||||||
if tag_requested?
|
|
||||||
short_account_tag_url(@account, params[:tag], format: 'rss')
|
|
||||||
else
|
|
||||||
short_account_url(@account, format: 'rss')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def older_url
|
def older_url
|
||||||
|
::Rails.logger.info("older: max_id #{@statuses.last.id}, url #{pagination_url(max_id: @statuses.last.id)}")
|
||||||
pagination_url(max_id: @statuses.last.id)
|
pagination_url(max_id: @statuses.last.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,9 +92,7 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_url(max_id: nil, min_id: nil)
|
def pagination_url(max_id: nil, min_id: nil)
|
||||||
if tag_requested?
|
if media_requested?
|
||||||
short_account_tag_url(@account, params[:tag], max_id: max_id, min_id: min_id)
|
|
||||||
elsif media_requested?
|
|
||||||
short_account_media_url(@account, max_id: max_id, min_id: min_id)
|
short_account_media_url(@account, max_id: max_id, min_id: min_id)
|
||||||
elsif replies_requested?
|
elsif replies_requested?
|
||||||
short_account_with_replies_url(@account, max_id: max_id, min_id: min_id)
|
short_account_with_replies_url(@account, max_id: max_id, min_id: min_id)
|
||||||
|
@ -135,27 +102,18 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def media_requested?
|
def media_requested?
|
||||||
request.path.split('.').first.ends_with?('/media') && !tag_requested?
|
request.path.ends_with?('/media')
|
||||||
end
|
end
|
||||||
|
|
||||||
def replies_requested?
|
def replies_requested?
|
||||||
request.path.split('.').first.ends_with?('/with_replies') && !tag_requested?
|
request.path.ends_with?('/with_replies')
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_requested?
|
def filtered_status_page(params)
|
||||||
request.path.split('.').first.ends_with?(Addressable::URI.parse("/tagged/#{params[:tag]}").normalize)
|
if params[:min_id].present?
|
||||||
end
|
filtered_statuses.paginate_by_min_id(PAGE_SIZE, params[:min_id]).reverse
|
||||||
|
else
|
||||||
def cached_filtered_status_page
|
filtered_statuses.paginate_by_max_id(PAGE_SIZE, params[:max_id], params[:since_id]).to_a
|
||||||
cache_collection_paginated_by_id(
|
end
|
||||||
filtered_statuses,
|
|
||||||
Status,
|
|
||||||
PAGE_SIZE,
|
|
||||||
params_slice(:max_id, :min_id, :since_id)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def params_slice(*keys)
|
|
||||||
params.slice(*keys).permit(*keys)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class ActivityPub::BaseController < Api::BaseController
|
|
||||||
skip_before_action :require_authenticated_user!
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_cache_headers
|
|
||||||
response.headers['Vary'] = 'Signature' if authorized_fetch_mode?
|
|
||||||
end
|
|
||||||
|
|
||||||
def skip_temporary_suspension_response?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,21 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class ActivityPub::ClaimsController < ActivityPub::BaseController
|
|
||||||
include SignatureVerification
|
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
skip_before_action :authenticate_user!
|
|
||||||
|
|
||||||
before_action :require_signature!
|
|
||||||
before_action :set_claim_result
|
|
||||||
|
|
||||||
def create
|
|
||||||
render json: @claim_result, serializer: ActivityPub::OneTimeKeySerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_claim_result
|
|
||||||
@claim_result = ::Keys::ClaimService.new.call(@account.id, params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,73 +1,57 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::CollectionsController < ActivityPub::BaseController
|
class ActivityPub::CollectionsController < Api::BaseController
|
||||||
include SignatureVerification
|
include SignatureVerification
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
before_action :require_signature!, if: :authorized_fetch_mode?
|
before_action :set_account
|
||||||
before_action :set_items
|
|
||||||
before_action :set_size
|
before_action :set_size
|
||||||
before_action :set_type
|
before_action :set_statuses
|
||||||
before_action :set_cache_headers
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
expires_in 3.minutes, public: public_fetch_mode?
|
render json: collection_presenter,
|
||||||
render_with_cache json: collection_presenter, content_type: 'application/activity+json', serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
|
serializer: ActivityPub::CollectionSerializer,
|
||||||
|
adapter: ActivityPub::Adapter,
|
||||||
|
content_type: 'application/activity+json',
|
||||||
|
skip_activities: true
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_items
|
def set_account
|
||||||
case params[:id]
|
@account = Account.find_local!(params[:account_username])
|
||||||
when 'featured'
|
end
|
||||||
@items = for_signed_account { cache_collection(@account.pinned_statuses, Status) }
|
|
||||||
when 'tags'
|
def set_statuses
|
||||||
@items = for_signed_account { @account.featured_tags }
|
@statuses = scope_for_collection
|
||||||
when 'devices'
|
@statuses = cache_collection(@statuses, Status)
|
||||||
@items = @account.devices
|
|
||||||
else
|
|
||||||
not_found
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_size
|
def set_size
|
||||||
case params[:id]
|
case params[:id]
|
||||||
when 'featured', 'devices', 'tags'
|
when 'featured'
|
||||||
@size = @items.size
|
@account.pinned_statuses.count
|
||||||
else
|
else
|
||||||
not_found
|
raise ActiveRecord::RecordNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_type
|
def scope_for_collection
|
||||||
case params[:id]
|
case params[:id]
|
||||||
when 'featured'
|
when 'featured'
|
||||||
@type = :ordered
|
@account.statuses.permitted_for(@account, signed_request_account).tap do |scope|
|
||||||
when 'devices', 'tags'
|
scope.merge!(@account.pinned_statuses)
|
||||||
@type = :unordered
|
end
|
||||||
else
|
else
|
||||||
not_found
|
raise ActiveRecord::RecordNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_collection_url(@account, params[:id]),
|
id: account_collection_url(@account, params[:id]),
|
||||||
type: @type,
|
type: :ordered,
|
||||||
size: @size,
|
size: @size,
|
||||||
items: @items
|
items: @statuses
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_signed_account
|
|
||||||
# Because in public fetch mode we cache the response, there would be no
|
|
||||||
# benefit from performing the check below, since a blocked account or domain
|
|
||||||
# would likely be served the cache from the reverse proxy anyway
|
|
||||||
|
|
||||||
if authorized_fetch_mode? && !signed_request_account.nil? && (@account.blocking?(signed_request_account) || (!signed_request_account.domain.nil? && @account.domain_blocking?(signed_request_account.domain)))
|
|
||||||
[]
|
|
||||||
else
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class ActivityPub::FollowersSynchronizationsController < ActivityPub::BaseController
|
|
||||||
include SignatureVerification
|
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
before_action :require_signature!
|
|
||||||
before_action :set_items
|
|
||||||
before_action :set_cache_headers
|
|
||||||
|
|
||||||
def show
|
|
||||||
expires_in 0, public: false
|
|
||||||
render json: collection_presenter,
|
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def uri_prefix
|
|
||||||
signed_request_account.uri[/http(s?):\/\/[^\/]+\//]
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_items
|
|
||||||
@items = @account.followers.where(Account.arel_table[:uri].matches(uri_prefix + '%', false, true)).pluck(:uri)
|
|
||||||
end
|
|
||||||
|
|
||||||
def collection_presenter
|
|
||||||
ActivityPub::CollectionPresenter.new(
|
|
||||||
id: account_followers_synchronization_url(@account),
|
|
||||||
type: :ordered,
|
|
||||||
items: @items
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,51 +1,28 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::InboxesController < ActivityPub::BaseController
|
class ActivityPub::InboxesController < Api::BaseController
|
||||||
include SignatureVerification
|
include SignatureVerification
|
||||||
include JsonLdHelper
|
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
before_action :skip_unknown_actor_delete
|
before_action :set_account
|
||||||
before_action :require_signature!
|
|
||||||
skip_before_action :authenticate_user!
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
upgrade_account
|
if signed_request_account
|
||||||
process_collection_synchronization
|
upgrade_account
|
||||||
process_payload
|
process_payload
|
||||||
head 202
|
head 202
|
||||||
|
else
|
||||||
|
render plain: signature_verification_failure_reason, status: 401
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def skip_unknown_actor_delete
|
def set_account
|
||||||
head 202 if unknown_deleted_account?
|
@account = Account.find_local!(params[:account_username]) if params[:account_username]
|
||||||
end
|
|
||||||
|
|
||||||
def unknown_deleted_account?
|
|
||||||
json = Oj.load(body, mode: :strict)
|
|
||||||
json.is_a?(Hash) && json['type'] == 'Delete' && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.where(uri: json['actor']).exists?
|
|
||||||
rescue Oj::ParseError
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def account_required?
|
|
||||||
params[:account_username].present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def skip_temporary_suspension_response?
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def body
|
||||||
return @body if defined?(@body)
|
@body ||= request.body.read
|
||||||
|
|
||||||
@body = request.body.read
|
|
||||||
@body.force_encoding('UTF-8') if @body.present?
|
|
||||||
|
|
||||||
request.body.rewind if request.body.respond_to?(:rewind)
|
|
||||||
|
|
||||||
@body
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_account
|
def upgrade_account
|
||||||
|
@ -54,23 +31,11 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
||||||
ResolveAccountWorker.perform_async(signed_request_account.acct)
|
ResolveAccountWorker.perform_async(signed_request_account.acct)
|
||||||
end
|
end
|
||||||
|
|
||||||
DeliveryFailureTracker.reset!(signed_request_account.inbox_url)
|
Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed?
|
||||||
end
|
DeliveryFailureTracker.track_inverse_success!(signed_request_account)
|
||||||
|
|
||||||
def process_collection_synchronization
|
|
||||||
raw_params = request.headers['Collection-Synchronization']
|
|
||||||
return if raw_params.blank? || ENV['DISABLE_FOLLOWERS_SYNCHRONIZATION'] == 'true'
|
|
||||||
|
|
||||||
# Re-using the syntax for signature parameters
|
|
||||||
tree = SignatureParamsParser.new.parse(raw_params)
|
|
||||||
params = SignatureParamsTransformer.new.apply(tree)
|
|
||||||
|
|
||||||
ActivityPub::PrepareFollowersSynchronizationService.new.call(signed_request_account, params)
|
|
||||||
rescue Parslet::ParseFailed
|
|
||||||
Rails.logger.warn 'Error parsing Collection-Synchronization header'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_payload
|
def process_payload
|
||||||
ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body, @account&.id)
|
ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body.force_encoding('UTF-8'), @account&.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,28 +1,29 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::OutboxesController < ActivityPub::BaseController
|
class ActivityPub::OutboxesController < Api::BaseController
|
||||||
LIMIT = 20
|
LIMIT = 20
|
||||||
|
|
||||||
include SignatureVerification
|
include SignatureVerification
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
before_action :require_signature!, if: :authorized_fetch_mode?
|
before_action :set_account
|
||||||
before_action :set_statuses
|
before_action :set_statuses
|
||||||
before_action :set_cache_headers
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
expires_in(page_requested? ? 0 : 3.minutes, public: public_fetch_mode? && !(signed_request_account.present? && page_requested?))
|
|
||||||
render json: outbox_presenter, serializer: ActivityPub::OutboxSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
render json: outbox_presenter, serializer: ActivityPub::OutboxSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find_local!(params[:account_username])
|
||||||
|
end
|
||||||
|
|
||||||
def outbox_presenter
|
def outbox_presenter
|
||||||
if page_requested?
|
if page_requested?
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: outbox_url(page_params),
|
id: account_outbox_url(@account, page_params),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
part_of: outbox_url,
|
part_of: account_outbox_url(@account),
|
||||||
prev: prev_page,
|
prev: prev_page,
|
||||||
next: next_page,
|
next: next_page,
|
||||||
items: @statuses
|
items: @statuses
|
||||||
|
@ -32,20 +33,12 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
id: account_outbox_url(@account),
|
id: account_outbox_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.statuses_count,
|
size: @account.statuses_count,
|
||||||
first: outbox_url(page: true),
|
first: account_outbox_url(@account, page: true),
|
||||||
last: outbox_url(page: true, min_id: 0)
|
last: account_outbox_url(@account, page: true, min_id: 0)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def outbox_url(**kwargs)
|
|
||||||
if params[:account_username].present?
|
|
||||||
account_outbox_url(@account, **kwargs)
|
|
||||||
else
|
|
||||||
instance_actor_outbox_url(**kwargs)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_page
|
def next_page
|
||||||
account_outbox_url(@account, page: true, max_id: @statuses.last.id) if @statuses.size == LIMIT
|
account_outbox_url(@account, page: true, max_id: @statuses.last.id) if @statuses.size == LIMIT
|
||||||
end
|
end
|
||||||
|
@ -57,23 +50,16 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
def set_statuses
|
def set_statuses
|
||||||
return unless page_requested?
|
return unless page_requested?
|
||||||
|
|
||||||
@statuses = cache_collection_paginated_by_id(
|
@statuses = @account.statuses.permitted_for(@account, signed_request_account)
|
||||||
@account.statuses.permitted_for(@account, signed_request_account),
|
@statuses = params[:min_id].present? ? @statuses.paginate_by_min_id(LIMIT, params[:min_id]).reverse : @statuses.paginate_by_max_id(LIMIT, params[:max_id])
|
||||||
Status,
|
@statuses = cache_collection(@statuses, Status)
|
||||||
LIMIT,
|
|
||||||
params_slice(:max_id, :min_id, :since_id)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_requested?
|
def page_requested?
|
||||||
truthy_param?(:page)
|
params[:page] == 'true'
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_params
|
def page_params
|
||||||
{ page: true, max_id: params[:max_id], min_id: params[:min_id] }.compact
|
{ page: true, max_id: params[:max_id], min_id: params[:min_id] }.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = params[:account_username].present? ? Account.find_local!(username_param) : Account.representative
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class ActivityPub::RepliesController < ActivityPub::BaseController
|
|
||||||
include SignatureVerification
|
|
||||||
include Authorization
|
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
DESCENDANTS_LIMIT = 60
|
|
||||||
|
|
||||||
before_action :require_signature!, if: :authorized_fetch_mode?
|
|
||||||
before_action :set_status
|
|
||||||
before_action :set_cache_headers
|
|
||||||
before_action :set_replies
|
|
||||||
|
|
||||||
def index
|
|
||||||
expires_in 0, public: public_fetch_mode?
|
|
||||||
render json: replies_collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json', skip_activities: true
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def pundit_user
|
|
||||||
signed_request_account
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = @account.statuses.find(params[:status_id])
|
|
||||||
authorize @status, :show?
|
|
||||||
rescue Mastodon::NotPermittedError
|
|
||||||
not_found
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_replies
|
|
||||||
@replies = only_other_accounts? ? Status.where.not(account_id: @account.id).joins(:account).merge(Account.without_suspended) : @account.statuses
|
|
||||||
@replies = @replies.where(in_reply_to_id: @status.id, visibility: [:public, :unlisted])
|
|
||||||
@replies = @replies.paginate_by_min_id(DESCENDANTS_LIMIT, params[:min_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def replies_collection_presenter
|
|
||||||
page = ActivityPub::CollectionPresenter.new(
|
|
||||||
id: account_status_replies_url(@account, @status, page_params),
|
|
||||||
type: :unordered,
|
|
||||||
part_of: account_status_replies_url(@account, @status),
|
|
||||||
next: next_page,
|
|
||||||
items: @replies.map { |status| status.local? ? status : status.uri }
|
|
||||||
)
|
|
||||||
|
|
||||||
return page if page_requested?
|
|
||||||
|
|
||||||
ActivityPub::CollectionPresenter.new(
|
|
||||||
id: account_status_replies_url(@account, @status),
|
|
||||||
type: :unordered,
|
|
||||||
first: page
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def page_requested?
|
|
||||||
truthy_param?(:page)
|
|
||||||
end
|
|
||||||
|
|
||||||
def only_other_accounts?
|
|
||||||
truthy_param?(:only_other_accounts)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_page
|
|
||||||
only_other_accounts = !(@replies&.last&.account_id == @account.id && @replies.size == DESCENDANTS_LIMIT)
|
|
||||||
|
|
||||||
account_status_replies_url(
|
|
||||||
@account,
|
|
||||||
@status,
|
|
||||||
page: true,
|
|
||||||
min_id: only_other_accounts && !only_other_accounts? ? nil : @replies&.last&.id,
|
|
||||||
only_other_accounts: only_other_accounts
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def page_params
|
|
||||||
params_slice(:only_other_accounts, :min_id).merge(page: true)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -5,7 +5,7 @@ module Admin
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true, include_statuses: true)
|
@account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true)
|
||||||
@warning_presets = AccountWarningPreset.all
|
@warning_presets = AccountWarningPreset.all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:admin_account_action).permit(:type, :report_id, :warning_preset_id, :text, :send_email_notification, :include_statuses)
|
params.require(:admin_account_action).permit(:type, :report_id, :warning_preset_id, :text, :send_email_notification)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class AccountsController < BaseController
|
class AccountsController < BaseController
|
||||||
before_action :set_account, except: [:index]
|
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize]
|
||||||
before_action :require_remote_account!, only: [:redownload]
|
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
|
||||||
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
|
before_action :require_local_account!, only: [:enable, :memorialize]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :account, :index?
|
authorize :account, :index?
|
||||||
|
@ -14,49 +14,34 @@ module Admin
|
||||||
def show
|
def show
|
||||||
authorize @account, :show?
|
authorize @account, :show?
|
||||||
|
|
||||||
@deletion_request = @account.deletion_request
|
|
||||||
@account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
|
@account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
|
||||||
@moderation_notes = @account.targeted_moderation_notes.latest
|
@moderation_notes = @account.targeted_moderation_notes.latest
|
||||||
@warnings = @account.targeted_account_warnings.latest.custom
|
@warnings = @account.targeted_account_warnings.latest.custom
|
||||||
@domain_block = DomainBlock.rule_for(@account.domain)
|
end
|
||||||
|
|
||||||
|
def subscribe
|
||||||
|
authorize @account, :subscribe?
|
||||||
|
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
||||||
|
redirect_to admin_account_path(@account.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribe
|
||||||
|
authorize @account, :unsubscribe?
|
||||||
|
Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
|
||||||
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def memorialize
|
def memorialize
|
||||||
authorize @account, :memorialize?
|
authorize @account, :memorialize?
|
||||||
@account.memorialize!
|
@account.memorialize!
|
||||||
log_action :memorialize, @account
|
log_action :memorialize, @account
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.memorialized_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable
|
def enable
|
||||||
authorize @account.user, :enable?
|
authorize @account.user, :enable?
|
||||||
@account.user.enable!
|
@account.user.enable!
|
||||||
log_action :enable, @account.user
|
log_action :enable, @account.user
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.enabled_msg', username: @account.acct)
|
|
||||||
end
|
|
||||||
|
|
||||||
def approve
|
|
||||||
authorize @account.user, :approve?
|
|
||||||
@account.user.approve!
|
|
||||||
redirect_to admin_pending_accounts_path, notice: I18n.t('admin.accounts.approved_msg', username: @account.acct)
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject
|
|
||||||
authorize @account.user, :reject?
|
|
||||||
DeleteAccountService.new.call(@account, reserve_email: false, reserve_username: false)
|
|
||||||
redirect_to admin_pending_accounts_path, notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct)
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize @account, :destroy?
|
|
||||||
Admin::AccountDeletionWorker.perform_async(@account.id)
|
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.destroyed_msg', username: @account.acct)
|
|
||||||
end
|
|
||||||
|
|
||||||
def unsensitive
|
|
||||||
authorize @account, :unsensitive?
|
|
||||||
@account.unsensitize!
|
|
||||||
log_action :unsensitive, @account
|
|
||||||
redirect_to admin_account_path(@account.id)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,15 +49,14 @@ module Admin
|
||||||
authorize @account, :unsilence?
|
authorize @account, :unsilence?
|
||||||
@account.unsilence!
|
@account.unsilence!
|
||||||
log_action :unsilence, @account
|
log_action :unsilence, @account
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unsilenced_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unsuspend
|
def unsuspend
|
||||||
authorize @account, :unsuspend?
|
authorize @account, :unsuspend?
|
||||||
@account.unsuspend!
|
@account.unsuspend!
|
||||||
Admin::UnsuspensionWorker.perform_async(@account.id)
|
|
||||||
log_action :unsuspend, @account
|
log_action :unsuspend, @account
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unsuspended_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def redownload
|
def redownload
|
||||||
|
@ -81,7 +65,7 @@ module Admin
|
||||||
@account.update!(last_webfingered_at: nil)
|
@account.update!(last_webfingered_at: nil)
|
||||||
ResolveAccountService.new.call(@account)
|
ResolveAccountService.new.call(@account)
|
||||||
|
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.redownloaded_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_avatar
|
def remove_avatar
|
||||||
|
@ -92,7 +76,7 @@ module Admin
|
||||||
|
|
||||||
log_action :remove_avatar, @account.user
|
log_action :remove_avatar, @account.user
|
||||||
|
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_avatar_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_header
|
def remove_header
|
||||||
|
@ -103,7 +87,7 @@ module Admin
|
||||||
|
|
||||||
log_action :remove_header, @account.user
|
log_action :remove_header, @account.user
|
||||||
|
|
||||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_header_msg', username: @account.acct)
|
redirect_to admin_account_path(@account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -125,7 +109,19 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(*AccountFilter::KEYS).permit(*AccountFilter::KEYS)
|
params.permit(
|
||||||
|
:local,
|
||||||
|
:remote,
|
||||||
|
:by_domain,
|
||||||
|
:active,
|
||||||
|
:silenced,
|
||||||
|
:suspended,
|
||||||
|
:username,
|
||||||
|
:display_name,
|
||||||
|
:email,
|
||||||
|
:ip,
|
||||||
|
:staff
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,18 +2,8 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class ActionLogsController < BaseController
|
class ActionLogsController < BaseController
|
||||||
before_action :set_action_logs
|
def index
|
||||||
|
@action_logs = Admin::ActionLog.page(params[:page])
|
||||||
def index; end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_action_logs
|
|
||||||
@action_logs = Admin::ActionLogFilter.new(filter_params).results.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.slice(:page, *Admin::ActionLogFilter::KEYS).permit(:page, *Admin::ActionLogFilter::KEYS)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Admin::AnnouncementsController < Admin::BaseController
|
|
||||||
before_action :set_announcements, only: :index
|
|
||||||
before_action :set_announcement, except: [:index, :new, :create]
|
|
||||||
|
|
||||||
def index
|
|
||||||
authorize :announcement, :index?
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
authorize :announcement, :create?
|
|
||||||
|
|
||||||
@announcement = Announcement.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
authorize :announcement, :create?
|
|
||||||
|
|
||||||
@announcement = Announcement.new(resource_params)
|
|
||||||
|
|
||||||
if @announcement.save
|
|
||||||
PublishScheduledAnnouncementWorker.perform_async(@announcement.id) if @announcement.published?
|
|
||||||
log_action :create, @announcement
|
|
||||||
redirect_to admin_announcements_path, notice: @announcement.published? ? I18n.t('admin.announcements.published_msg') : I18n.t('admin.announcements.scheduled_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
authorize :announcement, :update?
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
authorize :announcement, :update?
|
|
||||||
|
|
||||||
if @announcement.update(resource_params)
|
|
||||||
PublishScheduledAnnouncementWorker.perform_async(@announcement.id) if @announcement.published?
|
|
||||||
log_action :update, @announcement
|
|
||||||
redirect_to admin_announcements_path, notice: I18n.t('admin.announcements.updated_msg')
|
|
||||||
else
|
|
||||||
render :edit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def publish
|
|
||||||
authorize :announcement, :update?
|
|
||||||
@announcement.publish!
|
|
||||||
PublishScheduledAnnouncementWorker.perform_async(@announcement.id)
|
|
||||||
log_action :update, @announcement
|
|
||||||
redirect_to admin_announcements_path, notice: I18n.t('admin.announcements.published_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
def unpublish
|
|
||||||
authorize :announcement, :update?
|
|
||||||
@announcement.unpublish!
|
|
||||||
UnpublishAnnouncementWorker.perform_async(@announcement.id)
|
|
||||||
log_action :update, @announcement
|
|
||||||
redirect_to admin_announcements_path, notice: I18n.t('admin.announcements.unpublished_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize :announcement, :destroy?
|
|
||||||
@announcement.destroy!
|
|
||||||
UnpublishAnnouncementWorker.perform_async(@announcement.id) if @announcement.published?
|
|
||||||
log_action :destroy, @announcement
|
|
||||||
redirect_to admin_announcements_path, notice: I18n.t('admin.announcements.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_announcements
|
|
||||||
@announcements = AnnouncementFilter.new(filter_params).results.reverse_chronological.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_announcement
|
|
||||||
@announcement = Announcement.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.slice(*AnnouncementFilter::KEYS).permit(*AnnouncementFilter::KEYS)
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:announcement).permit(:text, :scheduled_at, :starts_at, :ends_at, :all_day)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class CustomEmojisController < BaseController
|
class CustomEmojisController < BaseController
|
||||||
|
before_action :set_custom_emoji, except: [:index, :new, :create]
|
||||||
|
before_action :set_filter_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :custom_emoji, :index?
|
authorize :custom_emoji, :index?
|
||||||
|
|
||||||
@custom_emojis = filtered_custom_emojis.eager_load(:local_counterpart).page(params[:page])
|
@custom_emojis = filtered_custom_emojis.eager_load(:local_counterpart).page(params[:page])
|
||||||
@form = Form::CustomEmojiBatch.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
authorize :custom_emoji, :create?
|
authorize :custom_emoji, :create?
|
||||||
|
|
||||||
@custom_emoji = CustomEmoji.new
|
@custom_emoji = CustomEmoji.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,19 +28,69 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def batch
|
def update
|
||||||
@form = Form::CustomEmojiBatch.new(form_custom_emoji_batch_params.merge(current_account: current_account, action: action_from_button))
|
authorize @custom_emoji, :update?
|
||||||
@form.save
|
|
||||||
rescue ActionController::ParameterMissing
|
if @custom_emoji.update(resource_params)
|
||||||
flash[:alert] = I18n.t('admin.accounts.no_account_selected')
|
log_action :update, @custom_emoji
|
||||||
rescue Mastodon::NotPermittedError
|
flash[:notice] = I18n.t('admin.custom_emojis.updated_msg')
|
||||||
flash[:alert] = I18n.t('admin.custom_emojis.not_permitted')
|
else
|
||||||
ensure
|
flash[:alert] = I18n.t('admin.custom_emojis.update_failed_msg')
|
||||||
redirect_to admin_custom_emojis_path(filter_params)
|
end
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
authorize @custom_emoji, :destroy?
|
||||||
|
@custom_emoji.destroy!
|
||||||
|
log_action :destroy, @custom_emoji
|
||||||
|
flash[:notice] = I18n.t('admin.custom_emojis.destroyed_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def copy
|
||||||
|
authorize @custom_emoji, :copy?
|
||||||
|
|
||||||
|
emoji = CustomEmoji.find_or_initialize_by(domain: nil,
|
||||||
|
shortcode: @custom_emoji.shortcode)
|
||||||
|
emoji.image = @custom_emoji.image
|
||||||
|
|
||||||
|
if emoji.save
|
||||||
|
log_action :create, emoji
|
||||||
|
flash[:notice] = I18n.t('admin.custom_emojis.copied_msg')
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('admin.custom_emojis.copy_failed_msg')
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def enable
|
||||||
|
authorize @custom_emoji, :enable?
|
||||||
|
@custom_emoji.update!(disabled: false)
|
||||||
|
log_action :enable, @custom_emoji
|
||||||
|
flash[:notice] = I18n.t('admin.custom_emojis.enabled_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def disable
|
||||||
|
authorize @custom_emoji, :disable?
|
||||||
|
@custom_emoji.update!(disabled: true)
|
||||||
|
log_action :disable, @custom_emoji
|
||||||
|
flash[:notice] = I18n.t('admin.custom_emojis.disabled_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_custom_emoji
|
||||||
|
@custom_emoji = CustomEmoji.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_filter_params
|
||||||
|
@filter_params = filter_params.to_hash.symbolize_keys
|
||||||
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
|
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
|
||||||
end
|
end
|
||||||
|
@ -50,29 +100,12 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(:page, *CustomEmojiFilter::KEYS).permit(:page, *CustomEmojiFilter::KEYS)
|
params.permit(
|
||||||
end
|
:local,
|
||||||
|
:remote,
|
||||||
def action_from_button
|
:by_domain,
|
||||||
if params[:update]
|
:shortcode
|
||||||
'update'
|
)
|
||||||
elsif params[:list]
|
|
||||||
'list'
|
|
||||||
elsif params[:unlist]
|
|
||||||
'unlist'
|
|
||||||
elsif params[:enable]
|
|
||||||
'enable'
|
|
||||||
elsif params[:disable]
|
|
||||||
'disable'
|
|
||||||
elsif params[:copy]
|
|
||||||
'copy'
|
|
||||||
elsif params[:delete]
|
|
||||||
'delete'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def form_custom_emoji_batch_params
|
|
||||||
params.require(:form_custom_emoji_batch).permit(:action, :category_id, :category_name, custom_emoji_ids: [])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,13 +5,12 @@ module Admin
|
||||||
class DashboardController < BaseController
|
class DashboardController < BaseController
|
||||||
def index
|
def index
|
||||||
@users_count = User.count
|
@users_count = User.count
|
||||||
@pending_users_count = User.pending.count
|
|
||||||
@registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
|
@registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
|
||||||
@logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
|
@logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
|
||||||
@interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
|
@interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
|
||||||
@relay_enabled = Relay.enabled.exists?
|
@relay_enabled = Relay.enabled.exists?
|
||||||
@single_user_mode = Rails.configuration.x.single_user_mode
|
@single_user_mode = Rails.configuration.x.single_user_mode
|
||||||
@registrations_enabled = Setting.registrations_mode != 'none'
|
@registrations_enabled = Setting.open_registrations
|
||||||
@deletions_enabled = Setting.open_deletion
|
@deletions_enabled = Setting.open_deletion
|
||||||
@invites_enabled = Setting.min_invite_role == 'user'
|
@invites_enabled = Setting.min_invite_role == 'user'
|
||||||
@search_enabled = Chewy.enabled?
|
@search_enabled = Chewy.enabled?
|
||||||
|
@ -20,7 +19,7 @@ module Admin
|
||||||
@redis_version = redis_info['redis_version']
|
@redis_version = redis_info['redis_version']
|
||||||
@reports_count = Report.unresolved.count
|
@reports_count = Report.unresolved.count
|
||||||
@queue_backlog = Sidekiq::Stats.new.enqueued
|
@queue_backlog = Sidekiq::Stats.new.enqueued
|
||||||
@recent_users = User.confirmed.recent.includes(:account).limit(8)
|
@recent_users = User.confirmed.recent.includes(:account).limit(4)
|
||||||
@database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size']
|
@database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size']
|
||||||
@redis_size = redis_info['used_memory']
|
@redis_size = redis_info['used_memory']
|
||||||
@ldap_enabled = ENV['LDAP_ENABLED'] == 'true'
|
@ldap_enabled = ENV['LDAP_ENABLED'] == 'true'
|
||||||
|
@ -28,14 +27,8 @@ module Admin
|
||||||
@saml_enabled = ENV['SAML_ENABLED'] == 'true'
|
@saml_enabled = ENV['SAML_ENABLED'] == 'true'
|
||||||
@pam_enabled = ENV['PAM_ENABLED'] == 'true'
|
@pam_enabled = ENV['PAM_ENABLED'] == 'true'
|
||||||
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
|
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
|
||||||
@trending_hashtags = TrendingTags.get(10, filtered: false)
|
@trending_hashtags = TrendingTags.get(7)
|
||||||
@pending_tags_count = Tag.pending_review.count
|
|
||||||
@authorized_fetch = authorized_fetch_mode?
|
|
||||||
@whitelist_enabled = whitelist_mode?
|
|
||||||
@profile_directory = Setting.profile_directory
|
@profile_directory = Setting.profile_directory
|
||||||
@timeline_preview = Setting.timeline_preview
|
|
||||||
@spam_check_enabled = Setting.spam_check_enabled
|
|
||||||
@trends_enabled = Setting.trends
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -45,13 +38,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def redis_info
|
def redis_info
|
||||||
@redis_info ||= begin
|
@redis_info ||= Redis.current.info
|
||||||
if Redis.current.is_a?(Redis::Namespace)
|
|
||||||
Redis.current.redis.info
|
|
||||||
else
|
|
||||||
Redis.current.info
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Admin::DomainAllowsController < Admin::BaseController
|
|
||||||
before_action :set_domain_allow, only: [:destroy]
|
|
||||||
|
|
||||||
def new
|
|
||||||
authorize :domain_allow, :create?
|
|
||||||
|
|
||||||
@domain_allow = DomainAllow.new(domain: params[:_domain])
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
authorize :domain_allow, :create?
|
|
||||||
|
|
||||||
@domain_allow = DomainAllow.new(resource_params)
|
|
||||||
|
|
||||||
if @domain_allow.save
|
|
||||||
log_action :create, @domain_allow
|
|
||||||
redirect_to admin_instances_path, notice: I18n.t('admin.domain_allows.created_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize @domain_allow, :destroy?
|
|
||||||
UnallowDomainService.new.call(@domain_allow)
|
|
||||||
redirect_to admin_instances_path, notice: I18n.t('admin.domain_allows.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_domain_allow
|
|
||||||
@domain_allow = DomainAllow.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:domain_allow).permit(:domain)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -2,57 +2,24 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class DomainBlocksController < BaseController
|
class DomainBlocksController < BaseController
|
||||||
before_action :set_domain_block, only: [:show, :destroy, :edit, :update]
|
before_action :set_domain_block, only: [:show, :destroy]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
authorize :domain_block, :create?
|
authorize :domain_block, :create?
|
||||||
@domain_block = DomainBlock.new(domain: params[:_domain])
|
@domain_block = DomainBlock.new(domain: params[:_domain])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
|
||||||
authorize :domain_block, :create?
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize :domain_block, :create?
|
authorize :domain_block, :create?
|
||||||
|
|
||||||
@domain_block = DomainBlock.new(resource_params)
|
@domain_block = DomainBlock.new(resource_params)
|
||||||
existing_domain_block = resource_params[:domain].present? ? DomainBlock.rule_for(resource_params[:domain]) : nil
|
|
||||||
|
|
||||||
if existing_domain_block.present? && !@domain_block.stricter_than?(existing_domain_block)
|
|
||||||
@domain_block.save
|
|
||||||
flash.now[:alert] = I18n.t('admin.domain_blocks.existing_domain_block_html', name: existing_domain_block.domain, unblock_url: admin_domain_block_path(existing_domain_block)).html_safe # rubocop:disable Rails/OutputSafety
|
|
||||||
@domain_block.errors[:domain].clear
|
|
||||||
render :new
|
|
||||||
else
|
|
||||||
if existing_domain_block.present?
|
|
||||||
@domain_block = existing_domain_block
|
|
||||||
@domain_block.update(resource_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
if @domain_block.save
|
|
||||||
DomainBlockWorker.perform_async(@domain_block.id)
|
|
||||||
log_action :create, @domain_block
|
|
||||||
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.created_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
authorize :domain_block, :update?
|
|
||||||
|
|
||||||
@domain_block.update(update_params)
|
|
||||||
|
|
||||||
severity_changed = @domain_block.severity_changed?
|
|
||||||
|
|
||||||
if @domain_block.save
|
if @domain_block.save
|
||||||
DomainBlockWorker.perform_async(@domain_block.id, severity_changed)
|
DomainBlockWorker.perform_async(@domain_block.id)
|
||||||
log_action :update, @domain_block
|
log_action :create, @domain_block
|
||||||
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.created_msg')
|
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.created_msg')
|
||||||
else
|
else
|
||||||
render :edit
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +29,7 @@ module Admin
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
authorize @domain_block, :destroy?
|
authorize @domain_block, :destroy?
|
||||||
UnblockDomainService.new.call(@domain_block)
|
UnblockDomainService.new.call(@domain_block, retroactive_unblock?)
|
||||||
log_action :destroy, @domain_block
|
log_action :destroy, @domain_block
|
||||||
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.destroyed_msg')
|
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.destroyed_msg')
|
||||||
end
|
end
|
||||||
|
@ -73,12 +40,12 @@ module Admin
|
||||||
@domain_block = DomainBlock.find(params[:id])
|
@domain_block = DomainBlock.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_params
|
def resource_params
|
||||||
params.require(:domain_block).permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_reports, :retroactive)
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def retroactive_unblock?
|
||||||
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
ActiveRecord::Type.lookup(:boolean).cast(resource_params[:retroactive])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,12 +6,12 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :email_domain_block, :index?
|
authorize :email_domain_block, :index?
|
||||||
@email_domain_blocks = EmailDomainBlock.where(parent_id: nil).includes(:children).order(id: :desc).page(params[:page])
|
@email_domain_blocks = EmailDomainBlock.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
authorize :email_domain_block, :create?
|
authorize :email_domain_block, :create?
|
||||||
@email_domain_block = EmailDomainBlock.new(domain: params[:_domain])
|
@email_domain_block = EmailDomainBlock.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -21,28 +21,6 @@ module Admin
|
||||||
|
|
||||||
if @email_domain_block.save
|
if @email_domain_block.save
|
||||||
log_action :create, @email_domain_block
|
log_action :create, @email_domain_block
|
||||||
|
|
||||||
if @email_domain_block.with_dns_records?
|
|
||||||
hostnames = []
|
|
||||||
ips = []
|
|
||||||
|
|
||||||
Resolv::DNS.open do |dns|
|
|
||||||
dns.timeouts = 5
|
|
||||||
|
|
||||||
hostnames = dns.getresources(@email_domain_block.domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }
|
|
||||||
|
|
||||||
([@email_domain_block.domain] + hostnames).uniq.each do |hostname|
|
|
||||||
ips.concat(dns.getresources(hostname, Resolv::DNS::Resource::IN::A).to_a.map { |e| e.address.to_s })
|
|
||||||
ips.concat(dns.getresources(hostname, Resolv::DNS::Resource::IN::AAAA).to_a.map { |e| e.address.to_s })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
(hostnames + ips).each do |hostname|
|
|
||||||
another_email_domain_block = EmailDomainBlock.new(domain: hostname, parent: @email_domain_block)
|
|
||||||
log_action :create, another_email_domain_block if another_email_domain_block.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.created_msg')
|
redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.created_msg')
|
||||||
else
|
else
|
||||||
render :new
|
render :new
|
||||||
|
@ -63,7 +41,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:email_domain_block).permit(:domain, :with_dns_records)
|
params.require(:email_domain_block).permit(:domain)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Admin
|
||||||
|
class FollowersController < BaseController
|
||||||
|
before_action :set_account
|
||||||
|
|
||||||
|
PER_PAGE = 40
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize :account, :index?
|
||||||
|
@followers = @account.followers.local.recent.page(params[:page]).per(PER_PAGE)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:account_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,33 +2,43 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class InstancesController < BaseController
|
class InstancesController < BaseController
|
||||||
before_action :set_instances, only: :index
|
|
||||||
before_action :set_instance, only: :show
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :instance, :index?
|
authorize :instance, :index?
|
||||||
|
|
||||||
|
@instances = ordered_instances
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
authorize :instance, :show?
|
authorize :instance, :show?
|
||||||
|
|
||||||
|
@instance = Instance.new(Account.by_domain_accounts.find_by(domain: params[:id]) || DomainBlock.find_by!(domain: params[:id]))
|
||||||
|
@following_count = Follow.where(account: Account.where(domain: params[:id])).count
|
||||||
|
@followers_count = Follow.where(target_account: Account.where(domain: params[:id])).count
|
||||||
|
@reports_count = Report.where(target_account: Account.where(domain: params[:id])).count
|
||||||
|
@blocks_count = Block.where(target_account: Account.where(domain: params[:id])).count
|
||||||
|
@available = DeliveryFailureTracker.available?(Account.select(:shared_inbox_url).where(domain: params[:id]).first&.shared_inbox_url)
|
||||||
|
@media_storage = MediaAttachment.where(account: Account.where(domain: params[:id])).sum(:file_file_size)
|
||||||
|
@domain_block = DomainBlock.find_by(domain: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_instance
|
|
||||||
@instance = Instance.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_instances
|
|
||||||
@instances = filtered_instances.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_instances
|
def filtered_instances
|
||||||
InstanceFilter.new(whitelist_mode? ? { allowed: true } : filter_params).results
|
InstanceFilter.new(filter_params).results
|
||||||
|
end
|
||||||
|
|
||||||
|
def paginated_instances
|
||||||
|
filtered_instances.page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
helper_method :paginated_instances
|
||||||
|
|
||||||
|
def ordered_instances
|
||||||
|
paginated_instances.map { |resource| Instance.new(resource) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(*InstanceFilter::KEYS).permit(*InstanceFilter::KEYS)
|
params.permit(:limited)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(*InviteFilter::KEYS).permit(*InviteFilter::KEYS)
|
params.permit(:available, :expired)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class IpBlocksController < BaseController
|
|
||||||
def index
|
|
||||||
authorize :ip_block, :index?
|
|
||||||
|
|
||||||
@ip_blocks = IpBlock.page(params[:page])
|
|
||||||
@form = Form::IpBlockBatch.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
authorize :ip_block, :create?
|
|
||||||
|
|
||||||
@ip_block = IpBlock.new(ip: '', severity: :no_access, expires_in: 1.year)
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
authorize :ip_block, :create?
|
|
||||||
|
|
||||||
@ip_block = IpBlock.new(resource_params)
|
|
||||||
|
|
||||||
if @ip_block.save
|
|
||||||
log_action :create, @ip_block
|
|
||||||
redirect_to admin_ip_blocks_path, notice: I18n.t('admin.ip_blocks.created_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def batch
|
|
||||||
@form = Form::IpBlockBatch.new(form_ip_block_batch_params.merge(current_account: current_account, action: action_from_button))
|
|
||||||
@form.save
|
|
||||||
rescue ActionController::ParameterMissing
|
|
||||||
flash[:alert] = I18n.t('admin.ip_blocks.no_ip_block_selected')
|
|
||||||
rescue Mastodon::NotPermittedError
|
|
||||||
flash[:alert] = I18n.t('admin.custom_emojis.not_permitted')
|
|
||||||
ensure
|
|
||||||
redirect_to admin_ip_blocks_path
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:ip_block).permit(:ip, :severity, :comment, :expires_in)
|
|
||||||
end
|
|
||||||
|
|
||||||
def action_from_button
|
|
||||||
'delete' if params[:delete]
|
|
||||||
end
|
|
||||||
|
|
||||||
def form_ip_block_batch_params
|
|
||||||
params.require(:form_ip_block_batch).permit(ip_block_ids: [])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,52 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class PendingAccountsController < BaseController
|
|
||||||
before_action :set_accounts, only: :index
|
|
||||||
|
|
||||||
def index
|
|
||||||
@form = Form::AccountBatch.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def batch
|
|
||||||
@form = Form::AccountBatch.new(form_account_batch_params.merge(current_account: current_account, action: action_from_button))
|
|
||||||
@form.save
|
|
||||||
rescue ActionController::ParameterMissing
|
|
||||||
flash[:alert] = I18n.t('admin.accounts.no_account_selected')
|
|
||||||
ensure
|
|
||||||
redirect_to admin_pending_accounts_path(current_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def approve_all
|
|
||||||
Form::AccountBatch.new(current_account: current_account, account_ids: User.pending.pluck(:account_id), action: 'approve').save
|
|
||||||
redirect_to admin_pending_accounts_path(current_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject_all
|
|
||||||
Form::AccountBatch.new(current_account: current_account, account_ids: User.pending.pluck(:account_id), action: 'reject').save
|
|
||||||
redirect_to admin_pending_accounts_path(current_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_accounts
|
|
||||||
@accounts = Account.joins(:user).merge(User.pending.recent).includes(user: :invite_request).page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def form_account_batch_params
|
|
||||||
params.require(:form_account_batch).permit(:action, account_ids: [])
|
|
||||||
end
|
|
||||||
|
|
||||||
def action_from_button
|
|
||||||
if params[:approve]
|
|
||||||
'approve'
|
|
||||||
elsif params[:reject]
|
|
||||||
'reject'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_params
|
|
||||||
params.slice(:page).permit(:page)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class RelationshipsController < BaseController
|
|
||||||
before_action :set_account
|
|
||||||
|
|
||||||
PER_PAGE = 40
|
|
||||||
|
|
||||||
def index
|
|
||||||
authorize :account, :index?
|
|
||||||
|
|
||||||
@accounts = RelationshipFilter.new(@account, filter_params).results.page(params[:page]).per(PER_PAGE)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:account_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.slice(*RelationshipFilter::KEYS).permit(*RelationshipFilter::KEYS)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -3,7 +3,6 @@
|
||||||
module Admin
|
module Admin
|
||||||
class RelaysController < BaseController
|
class RelaysController < BaseController
|
||||||
before_action :set_relay, except: [:index, :new, :create]
|
before_action :set_relay, except: [:index, :new, :create]
|
||||||
before_action :require_signatures_enabled!, only: [:new, :create, :enable]
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :relay, :update?
|
authorize :relay, :update?
|
||||||
|
@ -12,7 +11,7 @@ module Admin
|
||||||
|
|
||||||
def new
|
def new
|
||||||
authorize :relay, :update?
|
authorize :relay, :update?
|
||||||
@relay = Relay.new
|
@relay = Relay.new(inbox_url: Relay::PRESET_RELAY)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -55,9 +54,5 @@ module Admin
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:relay).permit(:inbox_url)
|
params.require(:relay).permit(:inbox_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_signatures_enabled!
|
|
||||||
redirect_to admin_relays_path, alert: I18n.t('admin.relays.signatures_not_enabled') if authorized_fetch_mode?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,10 @@ module Admin
|
||||||
before_action :set_report_note, only: [:destroy]
|
before_action :set_report_note, only: [:destroy]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize :report_note, :create?
|
authorize ReportNote, :create?
|
||||||
|
|
||||||
@report_note = current_account.report_notes.new(resource_params)
|
@report_note = current_account.report_notes.new(resource_params)
|
||||||
@report = @report_note.report
|
@report = @report_note.report
|
||||||
|
|
||||||
if @report_note.save
|
if @report_note.save
|
||||||
if params[:create_and_resolve]
|
if params[:create_and_resolve]
|
||||||
|
@ -26,8 +26,9 @@ module Admin
|
||||||
|
|
||||||
redirect_to admin_report_path(@report), notice: I18n.t('admin.report_notes.created_msg')
|
redirect_to admin_report_path(@report), notice: I18n.t('admin.report_notes.created_msg')
|
||||||
else
|
else
|
||||||
@report_notes = (@report.notes.latest + @report.history + @report.target_account.targeted_account_warnings.latest.custom).sort_by(&:created_at)
|
@report_notes = @report.notes.latest
|
||||||
@form = Form::StatusBatch.new
|
@report_history = @report.history
|
||||||
|
@form = Form::StatusBatch.new
|
||||||
|
|
||||||
render template: 'admin/reports/show'
|
render template: 'admin/reports/show'
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,10 +10,6 @@ module Admin
|
||||||
@form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button))
|
@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
|
flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
|
||||||
|
|
||||||
redirect_to admin_report_path(@report)
|
|
||||||
rescue ActionController::ParameterMissing
|
|
||||||
flash[:alert] = I18n.t('admin.statuses.no_status_selected')
|
|
||||||
|
|
||||||
redirect_to admin_report_path(@report)
|
redirect_to admin_report_path(@report)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,11 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(*ReportFilter::KEYS).permit(*ReportFilter::KEYS)
|
params.permit(
|
||||||
|
:account_id,
|
||||||
|
:resolved,
|
||||||
|
:target_account_id
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_report
|
def set_report
|
||||||
|
|
|
@ -2,29 +2,85 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class SettingsController < BaseController
|
class SettingsController < BaseController
|
||||||
|
ADMIN_SETTINGS = %w(
|
||||||
|
site_contact_username
|
||||||
|
site_contact_email
|
||||||
|
site_title
|
||||||
|
site_short_description
|
||||||
|
site_description
|
||||||
|
site_extended_description
|
||||||
|
site_terms
|
||||||
|
open_registrations
|
||||||
|
closed_registrations_message
|
||||||
|
open_deletion
|
||||||
|
timeline_preview
|
||||||
|
show_staff_badge
|
||||||
|
bootstrap_timeline_accounts
|
||||||
|
theme
|
||||||
|
thumbnail
|
||||||
|
hero
|
||||||
|
mascot
|
||||||
|
min_invite_role
|
||||||
|
activity_api_enabled
|
||||||
|
peers_api_enabled
|
||||||
|
show_known_fediverse_at_about_page
|
||||||
|
preview_sensitive_media
|
||||||
|
custom_css
|
||||||
|
profile_directory
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
BOOLEAN_SETTINGS = %w(
|
||||||
|
open_registrations
|
||||||
|
open_deletion
|
||||||
|
timeline_preview
|
||||||
|
show_staff_badge
|
||||||
|
activity_api_enabled
|
||||||
|
peers_api_enabled
|
||||||
|
show_known_fediverse_at_about_page
|
||||||
|
preview_sensitive_media
|
||||||
|
profile_directory
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
UPLOAD_SETTINGS = %w(
|
||||||
|
thumbnail
|
||||||
|
hero
|
||||||
|
mascot
|
||||||
|
).freeze
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
authorize :settings, :show?
|
authorize :settings, :show?
|
||||||
|
|
||||||
@admin_settings = Form::AdminSettings.new
|
@admin_settings = Form::AdminSettings.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
authorize :settings, :update?
|
authorize :settings, :update?
|
||||||
|
|
||||||
@admin_settings = Form::AdminSettings.new(settings_params)
|
settings_params.each do |key, value|
|
||||||
|
if UPLOAD_SETTINGS.include?(key)
|
||||||
if @admin_settings.save
|
upload = SiteUpload.where(var: key).first_or_initialize(var: key)
|
||||||
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
upload.update(file: value)
|
||||||
redirect_to edit_admin_settings_path
|
else
|
||||||
else
|
setting = Setting.where(var: key).first_or_initialize(var: key)
|
||||||
render :edit
|
setting.update(value: value_for_update(key, value))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
||||||
|
redirect_to edit_admin_settings_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def settings_params
|
def settings_params
|
||||||
params.require(:form_admin_settings).permit(*Form::AdminSettings::KEYS)
|
params.require(:form_admin_settings).permit(ADMIN_SETTINGS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def value_for_update(key, value)
|
||||||
|
if BOOLEAN_SETTINGS.include?(key)
|
||||||
|
value == '1'
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class SiteUploadsController < BaseController
|
|
||||||
before_action :set_site_upload
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize :settings, :destroy?
|
|
||||||
|
|
||||||
@site_upload.destroy!
|
|
||||||
|
|
||||||
redirect_to edit_admin_settings_path, notice: I18n.t('admin.site_uploads.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_site_upload
|
|
||||||
@site_upload = SiteUpload.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -14,7 +14,7 @@ module Admin
|
||||||
@statuses = @account.statuses.where(visibility: [:public, :unlisted])
|
@statuses = @account.statuses.where(visibility: [:public, :unlisted])
|
||||||
|
|
||||||
if params[:media]
|
if params[:media]
|
||||||
account_media_status_ids = @account.media_attachments.attached.reorder(nil).select(:status_id).group(:status_id)
|
account_media_status_ids = @account.media_attachments.attached.reorder(nil).select(:status_id).distinct
|
||||||
@statuses.merge!(Status.where(id: account_media_status_ids))
|
@statuses.merge!(Status.where(id: account_media_status_ids))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,102 +2,43 @@
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class TagsController < BaseController
|
class TagsController < BaseController
|
||||||
before_action :set_tag, except: [:index, :batch, :approve_all, :reject_all]
|
before_action :set_tags, only: :index
|
||||||
before_action :set_usage_by_domain, except: [:index, :batch, :approve_all, :reject_all]
|
before_action :set_tag, except: :index
|
||||||
before_action :set_counters, except: [:index, :batch, :approve_all, :reject_all]
|
before_action :set_filter_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :tag, :index?
|
authorize :tag, :index?
|
||||||
|
|
||||||
@tags = filtered_tags.page(params[:page])
|
|
||||||
@form = Form::TagBatch.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def batch
|
def hide
|
||||||
@form = Form::TagBatch.new(form_tag_batch_params.merge(current_account: current_account, action: action_from_button))
|
authorize @tag, :hide?
|
||||||
@form.save
|
@tag.account_tag_stat.update!(hidden: true)
|
||||||
rescue ActionController::ParameterMissing
|
redirect_to admin_tags_path(@filter_params)
|
||||||
flash[:alert] = I18n.t('admin.accounts.no_account_selected')
|
|
||||||
ensure
|
|
||||||
redirect_to admin_tags_path(filter_params)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def approve_all
|
def unhide
|
||||||
Form::TagBatch.new(current_account: current_account, tag_ids: Tag.pending_review.pluck(:id), action: 'approve').save
|
authorize @tag, :unhide?
|
||||||
redirect_to admin_tags_path(filter_params)
|
@tag.account_tag_stat.update!(hidden: false)
|
||||||
end
|
redirect_to admin_tags_path(@filter_params)
|
||||||
|
|
||||||
def reject_all
|
|
||||||
Form::TagBatch.new(current_account: current_account, tag_ids: Tag.pending_review.pluck(:id), action: 'reject').save
|
|
||||||
redirect_to admin_tags_path(filter_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
authorize @tag, :show?
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
authorize @tag, :update?
|
|
||||||
|
|
||||||
if @tag.update(tag_params.merge(reviewed_at: Time.now.utc))
|
|
||||||
redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg')
|
|
||||||
else
|
|
||||||
render :show
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_tags
|
||||||
|
@tags = Tag.discoverable
|
||||||
|
@tags.merge!(Tag.hidden) if filter_params[:hidden]
|
||||||
|
end
|
||||||
|
|
||||||
def set_tag
|
def set_tag
|
||||||
@tag = Tag.find(params[:id])
|
@tag = Tag.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_usage_by_domain
|
def set_filter_params
|
||||||
@usage_by_domain = @tag.statuses
|
@filter_params = filter_params.to_hash.symbolize_keys
|
||||||
.with_public_visibility
|
|
||||||
.excluding_silenced_accounts
|
|
||||||
.where(Status.arel_table[:id].gteq(Mastodon::Snowflake.id_at(Time.now.utc.beginning_of_day)))
|
|
||||||
.joins(:account)
|
|
||||||
.group('accounts.domain')
|
|
||||||
.reorder('statuses_count desc')
|
|
||||||
.pluck('accounts.domain, count(*) AS statuses_count')
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_counters
|
|
||||||
@accounts_today = @tag.history.first[:accounts]
|
|
||||||
@accounts_week = Redis.current.pfcount(*current_week_days.map { |day| "activity:tags:#{@tag.id}:#{day}:accounts" })
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_tags
|
|
||||||
TagFilter.new(filter_params).results
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(:page, *TagFilter::KEYS).permit(:page, *TagFilter::KEYS)
|
params.permit(:hidden)
|
||||||
end
|
|
||||||
|
|
||||||
def tag_params
|
|
||||||
params.require(:tag).permit(:name, :trendable, :usable, :listable)
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_week_days
|
|
||||||
now = Time.now.utc.beginning_of_day.to_date
|
|
||||||
|
|
||||||
(Date.commercial(now.cwyear, now.cweek)..now).map do |date|
|
|
||||||
date.to_time(:utc).beginning_of_day.to_i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def form_tag_batch_params
|
|
||||||
params.require(:form_tag_batch).permit(:action, tag_ids: [])
|
|
||||||
end
|
|
||||||
|
|
||||||
def action_from_button
|
|
||||||
if params[:approve]
|
|
||||||
'approve'
|
|
||||||
elsif params[:reject]
|
|
||||||
'reject'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,6 @@ module Admin
|
||||||
authorize @user, :disable_2fa?
|
authorize @user, :disable_2fa?
|
||||||
@user.disable_two_factor!
|
@user.disable_two_factor!
|
||||||
log_action :disable_2fa, @user
|
log_action :disable_2fa, @user
|
||||||
UserMailer.two_factor_disabled(@user).deliver_later!
|
|
||||||
redirect_to admin_accounts_path
|
redirect_to admin_accounts_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Admin
|
||||||
def index
|
def index
|
||||||
authorize :account_warning_preset, :index?
|
authorize :account_warning_preset, :index?
|
||||||
|
|
||||||
@warning_presets = AccountWarningPreset.alphabetic
|
@warning_presets = AccountWarningPreset.all
|
||||||
@warning_preset = AccountWarningPreset.new
|
@warning_preset = AccountWarningPreset.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ module Admin
|
||||||
if @warning_preset.save
|
if @warning_preset.save
|
||||||
redirect_to admin_warning_presets_path
|
redirect_to admin_warning_presets_path
|
||||||
else
|
else
|
||||||
@warning_presets = AccountWarningPreset.alphabetic
|
@warning_presets = AccountWarningPreset.all
|
||||||
render :index
|
render :index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def warning_preset_params
|
def warning_preset_params
|
||||||
params.require(:account_warning_preset).permit(:title, :text)
|
params.require(:account_warning_preset).permit(:text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,23 +7,14 @@ class Api::BaseController < ApplicationController
|
||||||
include RateLimitHeaders
|
include RateLimitHeaders
|
||||||
|
|
||||||
skip_before_action :store_current_location
|
skip_before_action :store_current_location
|
||||||
skip_before_action :require_functional!, unless: :whitelist_mode?
|
skip_before_action :check_user_permissions
|
||||||
|
|
||||||
before_action :require_authenticated_user!, if: :disallow_unauthenticated_api_access?
|
|
||||||
before_action :set_cache_headers
|
|
||||||
|
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
|
|
||||||
skip_around_action :set_locale
|
|
||||||
|
|
||||||
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
|
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
|
||||||
render json: { error: e.to_s }, status: 422
|
render json: { error: e.to_s }, status: 422
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from ActiveRecord::RecordNotUnique do
|
|
||||||
render json: { error: 'Duplicate record' }, status: 422
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue_from ActiveRecord::RecordNotFound do
|
rescue_from ActiveRecord::RecordNotFound do
|
||||||
render json: { error: 'Record not found' }, status: 404
|
render json: { error: 'Record not found' }, status: 404
|
||||||
end
|
end
|
||||||
|
@ -40,18 +31,6 @@ class Api::BaseController < ApplicationController
|
||||||
render json: { error: 'This action is not allowed' }, status: 403
|
render json: { error: 'This action is not allowed' }, status: 403
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from Mastodon::RaceConditionError, Seahorse::Client::NetworkingError, Stoplight::Error::RedLight do
|
|
||||||
render json: { error: 'There was a temporary problem serving your request, please try again' }, status: 503
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue_from Mastodon::RateLimitExceededError do
|
|
||||||
render json: { error: I18n.t('errors.429') }, status: 429
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue_from ActionController::ParameterMissing do |e|
|
|
||||||
render json: { error: e.to_s }, status: 400
|
|
||||||
end
|
|
||||||
|
|
||||||
def doorkeeper_unauthorized_render_options(error: nil)
|
def doorkeeper_unauthorized_render_options(error: nil)
|
||||||
{ json: { error: (error.try(:description) || 'Not authorized') } }
|
{ json: { error: (error.try(:description) || 'Not authorized') } }
|
||||||
end
|
end
|
||||||
|
@ -71,7 +50,6 @@ class Api::BaseController < ApplicationController
|
||||||
|
|
||||||
def limit_param(default_limit)
|
def limit_param(default_limit)
|
||||||
return default_limit unless params[:limit]
|
return default_limit unless params[:limit]
|
||||||
|
|
||||||
[params[:limit].to_i.abs, default_limit * 2].min
|
[params[:limit].to_i.abs, default_limit * 2].min
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -89,21 +67,15 @@ class Api::BaseController < ApplicationController
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_authenticated_user!
|
|
||||||
render json: { error: 'This method requires an authenticated user' }, status: 401 unless current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
def require_user!
|
def require_user!
|
||||||
if !current_user
|
if !current_user
|
||||||
render json: { error: 'This method requires an authenticated user' }, status: 422
|
render json: { error: 'This method requires an authenticated user' }, status: 422
|
||||||
elsif !current_user.confirmed?
|
elsif current_user.disabled?
|
||||||
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
|
|
||||||
elsif !current_user.functional?
|
|
||||||
render json: { error: 'Your login is currently disabled' }, status: 403
|
render json: { error: 'Your login is currently disabled' }, status: 403
|
||||||
|
elsif !current_user.confirmed?
|
||||||
|
render json: { error: 'Email confirmation is not completed' }, status: 403
|
||||||
else
|
else
|
||||||
update_user_sign_in
|
set_user_activity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,12 +86,4 @@ class Api::BaseController < ApplicationController
|
||||||
def authorize_if_got_token!(*scopes)
|
def authorize_if_got_token!(*scopes)
|
||||||
doorkeeper_authorize!(*scopes) if doorkeeper_token
|
doorkeeper_authorize!(*scopes) if doorkeeper_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_cache_headers
|
|
||||||
response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
|
|
||||||
end
|
|
||||||
|
|
||||||
def disallow_unauthenticated_api_access?
|
|
||||||
authorized_fetch_mode?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,25 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::OEmbedController < Api::BaseController
|
class Api::OEmbedController < Api::BaseController
|
||||||
skip_before_action :require_authenticated_user!
|
respond_to :json
|
||||||
|
|
||||||
before_action :set_status
|
|
||||||
before_action :require_public_status!
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@status = status_finder.status
|
||||||
render json: @status, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default
|
render json: @status, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = status_finder.status
|
|
||||||
end
|
|
||||||
|
|
||||||
def require_public_status!
|
|
||||||
not_found if @status.hidden?
|
|
||||||
end
|
|
||||||
|
|
||||||
def status_finder
|
def status_finder
|
||||||
StatusFinder.new(params[:url])
|
StatusFinder.new(params[:url])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::ProofsController < Api::BaseController
|
|
||||||
include AccountOwnedConcern
|
|
||||||
|
|
||||||
skip_before_action :require_authenticated_user!
|
|
||||||
|
|
||||||
before_action :set_provider
|
|
||||||
|
|
||||||
def index
|
|
||||||
render json: @account, serializer: @provider.serializer_class
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_provider
|
|
||||||
@provider = ProofProvider.find(params[:provider]) || raise(ActiveRecord::RecordNotFound)
|
|
||||||
end
|
|
||||||
|
|
||||||
def username_param
|
|
||||||
params[:username]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::PushController < Api::BaseController
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
|
def update
|
||||||
|
response, status = process_push_request
|
||||||
|
render plain: response, status: status
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_push_request
|
||||||
|
case hub_mode
|
||||||
|
when 'subscribe'
|
||||||
|
Pubsubhubbub::SubscribeService.new.call(account_from_topic, hub_callback, hub_secret, hub_lease_seconds, verified_domain)
|
||||||
|
when 'unsubscribe'
|
||||||
|
Pubsubhubbub::UnsubscribeService.new.call(account_from_topic, hub_callback)
|
||||||
|
else
|
||||||
|
["Unknown mode: #{hub_mode}", 422]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_mode
|
||||||
|
params['hub.mode']
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_topic
|
||||||
|
params['hub.topic']
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_callback
|
||||||
|
params['hub.callback']
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_lease_seconds
|
||||||
|
params['hub.lease_seconds']
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_secret
|
||||||
|
params['hub.secret']
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_from_topic
|
||||||
|
if hub_topic.present? && local_domain? && account_feed_path?
|
||||||
|
Account.find_local(hub_topic_params[:username])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_topic_params
|
||||||
|
@_hub_topic_params ||= Rails.application.routes.recognize_path(hub_topic_uri.path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_topic_uri
|
||||||
|
@_hub_topic_uri ||= Addressable::URI.parse(hub_topic).normalize
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_domain?
|
||||||
|
TagManager.instance.web_domain?(hub_topic_domain)
|
||||||
|
end
|
||||||
|
|
||||||
|
def verified_domain
|
||||||
|
return signed_request_account.domain if signed_request_account
|
||||||
|
end
|
||||||
|
|
||||||
|
def hub_topic_domain
|
||||||
|
hub_topic_uri.host + (hub_topic_uri.port ? ":#{hub_topic_uri.port}" : '')
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_feed_path?
|
||||||
|
hub_topic_params[:controller] == 'accounts' && hub_topic_params[:action] == 'show' && hub_topic_params[:format] == 'atom'
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,37 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::SalmonController < Api::BaseController
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
|
before_action :set_account
|
||||||
|
respond_to :txt
|
||||||
|
|
||||||
|
def update
|
||||||
|
if verify_payload?
|
||||||
|
process_salmon
|
||||||
|
head 202
|
||||||
|
elsif payload.present?
|
||||||
|
render plain: signature_verification_failure_reason, status: 401
|
||||||
|
else
|
||||||
|
head 400
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def payload
|
||||||
|
@_payload ||= request.body.read
|
||||||
|
end
|
||||||
|
|
||||||
|
def verify_payload?
|
||||||
|
payload.present? && VerifySalmonService.new.call(payload)
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_salmon
|
||||||
|
SalmonWorker.perform_async(@account.id, payload.force_encoding('UTF-8'))
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,51 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::SubscriptionsController < Api::BaseController
|
||||||
|
before_action :set_account
|
||||||
|
respond_to :txt
|
||||||
|
|
||||||
|
def show
|
||||||
|
if subscription.valid?(params['hub.topic'])
|
||||||
|
@account.update(subscription_expires_at: future_expires)
|
||||||
|
render plain: encoded_challenge, status: 200
|
||||||
|
else
|
||||||
|
head 404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if subscription.verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
|
||||||
|
ProcessingWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
|
||||||
|
end
|
||||||
|
|
||||||
|
head 200
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def subscription
|
||||||
|
@_subscription ||= @account.subscription(
|
||||||
|
api_subscription_url(@account.id)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def body
|
||||||
|
@_body ||= request.body.read
|
||||||
|
end
|
||||||
|
|
||||||
|
def encoded_challenge
|
||||||
|
HTMLEntities.new.encode(params['hub.challenge'])
|
||||||
|
end
|
||||||
|
|
||||||
|
def future_expires
|
||||||
|
Time.now.utc + lease_seconds_or_default
|
||||||
|
end
|
||||||
|
|
||||||
|
def lease_seconds_or_default
|
||||||
|
(params['hub.lease_seconds'] || 1.day).to_i.seconds
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
|
@ -25,7 +25,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_settings_params
|
def user_settings_params
|
||||||
return nil if params[:source].blank?
|
return nil unless params.key?(:source)
|
||||||
|
|
||||||
source_params = params.require(:source)
|
source_params = params.require(:source)
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Accounts::FeaturedTagsController < Api::BaseController
|
|
||||||
before_action :set_account
|
|
||||||
before_action :set_featured_tags
|
|
||||||
|
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
def index
|
|
||||||
render json: @featured_tags, each_serializer: REST::FeaturedTagSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:account_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_featured_tags
|
|
||||||
@featured_tags = @account.suspended? ? [] : @account.featured_tags
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -5,6 +5,8 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
after_action :insert_pagination_headers
|
after_action :insert_pagination_headers
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
|
@ -17,15 +19,9 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
return [] if hide_results?
|
return [] if @account.user_hides_network? && current_account.id != @account.id
|
||||||
|
|
||||||
scope = default_accounts
|
default_accounts.merge(paginated_follows).to_a
|
||||||
scope = scope.where.not(id: current_account.excluded_from_timeline_account_ids) unless current_account.nil? || current_account.id == @account.id
|
|
||||||
scope.merge(paginated_follows).to_a
|
|
||||||
end
|
|
||||||
|
|
||||||
def hide_results?
|
|
||||||
@account.suspended? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
|
|
|
@ -5,6 +5,8 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
after_action :insert_pagination_headers
|
after_action :insert_pagination_headers
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
|
@ -17,15 +19,9 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
return [] if hide_results?
|
return [] if @account.user_hides_network? && current_account.id != @account.id
|
||||||
|
|
||||||
scope = default_accounts
|
default_accounts.merge(paginated_follows).to_a
|
||||||
scope = scope.where.not(id: current_account.excluded_from_timeline_account_ids) unless current_account.nil? || current_account.id == @account.id
|
|
||||||
scope.merge(paginated_follows).to_a
|
|
||||||
end
|
|
||||||
|
|
||||||
def hide_results?
|
|
||||||
@account.suspended? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Accounts::IdentityProofsController < Api::BaseController
|
|
||||||
before_action :require_user!
|
|
||||||
before_action :set_account
|
|
||||||
|
|
||||||
def index
|
|
||||||
@proofs = @account.suspended? ? [] : @account.identity_proofs.active
|
|
||||||
render json: @proofs, each_serializer: REST::IdentityProofSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:account_id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -5,8 +5,10 @@ class Api::V1::Accounts::ListsController < Api::BaseController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@lists = @account.suspended? ? [] : @account.lists.where(account: current_account)
|
@lists = @account.lists.where(account: current_account)
|
||||||
render json: @lists, each_serializer: REST::ListSerializer
|
render json: @lists, each_serializer: REST::ListSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Accounts::NotesController < Api::BaseController
|
|
||||||
include Authorization
|
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }
|
|
||||||
before_action :require_user!
|
|
||||||
before_action :set_account
|
|
||||||
|
|
||||||
def create
|
|
||||||
if params[:comment].blank?
|
|
||||||
AccountNote.find_by(account: current_account, target_account: @account)&.destroy
|
|
||||||
else
|
|
||||||
@note = AccountNote.find_or_initialize_by(account: current_account, target_account: @account)
|
|
||||||
@note.comment = params[:comment]
|
|
||||||
@note.save! if @note.changed?
|
|
||||||
end
|
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:account_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def relationships_presenter
|
|
||||||
AccountRelationshipsPresenter.new([@account.id], current_user.account_id)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -7,6 +7,8 @@ class Api::V1::Accounts::PinsController < Api::BaseController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
AccountPin.create!(account: current_account, target_account: @account)
|
AccountPin.create!(account: current_account, target_account: @account)
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter
|
||||||
|
|
|
@ -4,8 +4,10 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:follows' }
|
before_action -> { doorkeeper_authorize! :read, :'read:follows' }
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
accounts = Account.without_suspended.where(id: account_ids).select('id')
|
accounts = Account.where(id: account_ids).select('id')
|
||||||
# .where doesn't guarantee that our results are in the same order
|
# .where doesn't guarantee that our results are in the same order
|
||||||
# we requested them, so return the "right" order to the requestor.
|
# we requested them, so return the "right" order to the requestor.
|
||||||
@accounts = accounts.index_by(&:id).values_at(*account_ids).compact
|
@accounts = accounts.index_by(&:id).values_at(*account_ids).compact
|
||||||
|
|
|
@ -4,6 +4,8 @@ class Api::V1::Accounts::SearchController < Api::BaseController
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }
|
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@accounts = account_search
|
@accounts = account_search
|
||||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
|
@ -14,11 +16,10 @@ class Api::V1::Accounts::SearchController < Api::BaseController
|
||||||
def account_search
|
def account_search
|
||||||
AccountSearchService.new.call(
|
AccountSearchService.new.call(
|
||||||
params[:q],
|
params[:q],
|
||||||
|
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||||
current_account,
|
current_account,
|
||||||
limit: limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
|
||||||
resolve: truthy_param?(:resolve),
|
resolve: truthy_param?(:resolve),
|
||||||
following: truthy_param?(:following),
|
following: truthy_param?(:following)
|
||||||
offset: params[:offset]
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
class Api::V1::Accounts::StatusesController < Api::BaseController
|
class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
|
after_action :insert_pagination_headers
|
||||||
|
|
||||||
after_action :insert_pagination_headers, unless: -> { truthy_param?(:pinned) }
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
|
@ -18,23 +19,22 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
@account.suspended? ? [] : cached_account_statuses
|
cached_account_statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_account_statuses
|
def cached_account_statuses
|
||||||
|
cache_collection account_statuses, Status
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_statuses
|
||||||
statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses
|
statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses
|
||||||
|
statuses = statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
|
|
||||||
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
||||||
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
||||||
statuses.merge!(no_reblogs_scope) if truthy_param?(:exclude_reblogs)
|
statuses.merge!(no_reblogs_scope) if truthy_param?(:exclude_reblogs)
|
||||||
statuses.merge!(hashtag_scope) if params[:tagged].present?
|
|
||||||
|
|
||||||
cache_collection_paginated_by_id(
|
statuses
|
||||||
statuses,
|
|
||||||
Status,
|
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def permitted_account_statuses
|
def permitted_account_statuses
|
||||||
|
@ -42,12 +42,20 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def only_media_scope
|
def only_media_scope
|
||||||
Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id)
|
Status.where(id: account_media_status_ids)
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_media_status_ids
|
||||||
|
# `SELECT DISTINCT id, updated_at` is too slow, so pluck ids at first, and then select id, updated_at with ids.
|
||||||
|
# Also, Avoid getting slow by not narrowing down by `statuses.account_id`.
|
||||||
|
# When narrowing down by `statuses.account_id`, `index_statuses_20180106` will be used
|
||||||
|
# and the table will be joined by `Merge Semi Join`, so the query will be slow.
|
||||||
|
Status.joins(:media_attachments).merge(@account.media_attachments).permitted_for(@account, current_account)
|
||||||
|
.paginate_by_max_id(limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id])
|
||||||
|
.reorder(id: :desc).distinct(:id).pluck(:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pinned_scope
|
def pinned_scope
|
||||||
return Status.none if @account.blocking?(current_account)
|
|
||||||
|
|
||||||
@account.pinned_statuses
|
@account.pinned_statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,16 +67,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
Status.without_reblogs
|
Status.without_reblogs
|
||||||
end
|
end
|
||||||
|
|
||||||
def hashtag_scope
|
|
||||||
tag = Tag.find_normalized(params[:tagged])
|
|
||||||
|
|
||||||
if tag
|
|
||||||
Status.tagged_with(tag.id)
|
|
||||||
else
|
|
||||||
Status.none
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
params.slice(:limit, :only_media, :exclude_replies).permit(:limit, :only_media, :exclude_replies).merge(core_params)
|
params.slice(:limit, :only_media, :exclude_replies).permit(:limit, :only_media, :exclude_replies).merge(core_params)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,18 +9,17 @@ class Api::V1::AccountsController < Api::BaseController
|
||||||
|
|
||||||
before_action :require_user!, except: [:show, :create]
|
before_action :require_user!, except: [:show, :create]
|
||||||
before_action :set_account, except: [:create]
|
before_action :set_account, except: [:create]
|
||||||
|
before_action :check_account_suspension, only: [:show]
|
||||||
before_action :check_enabled_registrations, only: [:create]
|
before_action :check_enabled_registrations, only: [:create]
|
||||||
|
|
||||||
skip_before_action :require_authenticated_user!, only: :create
|
respond_to :json
|
||||||
|
|
||||||
override_rate_limit_headers :follow, family: :follows
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: @account, serializer: REST::AccountSerializer
|
render json: @account, serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
token = AppSignUpService.new.call(doorkeeper_token.application, request.remote_ip, account_params)
|
token = AppSignUpService.new.call(doorkeeper_token.application, account_params)
|
||||||
response = Doorkeeper::OAuth::TokenResponse.new(token)
|
response = Doorkeeper::OAuth::TokenResponse.new(token)
|
||||||
|
|
||||||
headers.merge!(response.headers)
|
headers.merge!(response.headers)
|
||||||
|
@ -30,8 +29,9 @@ class Api::V1::AccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def follow
|
def follow
|
||||||
follow = FollowService.new.call(current_user.account, @account, reblogs: params.key?(:reblogs) ? truthy_param?(:reblogs) : nil, notify: params.key?(:notify) ? truthy_param?(:notify) : nil, with_rate_limit: true)
|
FollowService.new.call(current_user.account, @account, reblogs: truthy_param?(:reblogs))
|
||||||
options = @account.locked? || current_user.account.silenced? ? {} : { following_map: { @account.id => { reblogs: follow.show_reblogs?, notify: follow.notify? } }, requested_map: { @account.id => false } }
|
|
||||||
|
options = @account.locked? ? {} : { following_map: { @account.id => { reblogs: truthy_param?(:reblogs) } }, requested_map: { @account.id => false } }
|
||||||
|
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options)
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options)
|
||||||
end
|
end
|
||||||
|
@ -42,7 +42,7 @@ class Api::V1::AccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def mute
|
def mute
|
||||||
MuteService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications), duration: (params[:duration] || 0))
|
MuteService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications))
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,15 +71,15 @@ class Api::V1::AccountsController < Api::BaseController
|
||||||
AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
|
AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_account_suspension
|
||||||
|
gone if @account.suspended?
|
||||||
|
end
|
||||||
|
|
||||||
def account_params
|
def account_params
|
||||||
params.permit(:username, :email, :password, :agreement, :locale, :reason)
|
params.permit(:username, :email, :password, :agreement, :locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_enabled_registrations
|
def check_enabled_registrations
|
||||||
forbidden if single_user_mode? || !allowed_registrations?
|
forbidden if single_user_mode? || !Setting.open_registrations
|
||||||
end
|
|
||||||
|
|
||||||
def allowed_registrations?
|
|
||||||
Setting.registrations_mode != 'none'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Admin::AccountActionsController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :'admin:write', :'admin:write:accounts' }
|
|
||||||
before_action :require_staff!
|
|
||||||
before_action :set_account
|
|
||||||
|
|
||||||
def create
|
|
||||||
account_action = Admin::AccountAction.new(resource_params)
|
|
||||||
account_action.target_account = @account
|
|
||||||
account_action.current_account = current_account
|
|
||||||
account_action.save!
|
|
||||||
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:account_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.permit(
|
|
||||||
:type,
|
|
||||||
:report_id,
|
|
||||||
:warning_preset_id,
|
|
||||||
:text,
|
|
||||||
:send_email_notification
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,143 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Admin::AccountsController < Api::BaseController
|
|
||||||
include Authorization
|
|
||||||
include AccountableConcern
|
|
||||||
|
|
||||||
LIMIT = 100
|
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :'admin:read', :'admin:read:accounts' }, only: [:index, :show]
|
|
||||||
before_action -> { doorkeeper_authorize! :'admin:write', :'admin:write:accounts' }, except: [:index, :show]
|
|
||||||
before_action :require_staff!
|
|
||||||
before_action :set_accounts, only: :index
|
|
||||||
before_action :set_account, except: :index
|
|
||||||
before_action :require_local_account!, only: [:enable, :approve, :reject]
|
|
||||||
|
|
||||||
after_action :insert_pagination_headers, only: :index
|
|
||||||
|
|
||||||
FILTER_PARAMS = %i(
|
|
||||||
local
|
|
||||||
remote
|
|
||||||
by_domain
|
|
||||||
active
|
|
||||||
pending
|
|
||||||
disabled
|
|
||||||
sensitized
|
|
||||||
silenced
|
|
||||||
suspended
|
|
||||||
username
|
|
||||||
display_name
|
|
||||||
email
|
|
||||||
ip
|
|
||||||
staff
|
|
||||||
).freeze
|
|
||||||
|
|
||||||
PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze
|
|
||||||
|
|
||||||
def index
|
|
||||||
authorize :account, :index?
|
|
||||||
render json: @accounts, each_serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
authorize @account, :show?
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def enable
|
|
||||||
authorize @account.user, :enable?
|
|
||||||
@account.user.enable!
|
|
||||||
log_action :enable, @account.user
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def approve
|
|
||||||
authorize @account.user, :approve?
|
|
||||||
@account.user.approve!
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject
|
|
||||||
authorize @account.user, :reject?
|
|
||||||
DeleteAccountService.new.call(@account, reserve_email: false, reserve_username: false)
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize @account, :destroy?
|
|
||||||
Admin::AccountDeletionWorker.perform_async(@account.id)
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def unsensitive
|
|
||||||
authorize @account, :unsensitive?
|
|
||||||
@account.unsensitize!
|
|
||||||
log_action :unsensitive, @account
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def unsilence
|
|
||||||
authorize @account, :unsilence?
|
|
||||||
@account.unsilence!
|
|
||||||
log_action :unsilence, @account
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def unsuspend
|
|
||||||
authorize @account, :unsuspend?
|
|
||||||
@account.unsuspend!
|
|
||||||
Admin::UnsuspensionWorker.perform_async(@account.id)
|
|
||||||
log_action :unsuspend, @account
|
|
||||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_accounts
|
|
||||||
@accounts = filtered_accounts.order(id: :desc).includes(user: [:invite_request, :invite]).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_accounts
|
|
||||||
AccountFilter.new(filter_params).results
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.permit(*FILTER_PARAMS)
|
|
||||||
end
|
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
|
||||||
api_v1_admin_accounts_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
|
||||||
end
|
|
||||||
|
|
||||||
def prev_path
|
|
||||||
api_v1_admin_accounts_url(pagination_params(min_id: pagination_since_id)) unless @accounts.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_max_id
|
|
||||||
@accounts.last.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_since_id
|
|
||||||
@accounts.first.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def records_continue?
|
|
||||||
@accounts.size == limit_param(LIMIT)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
|
||||||
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def require_local_account!
|
|
||||||
forbidden unless @account.local? && @account.user.present?
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,108 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Admin::ReportsController < Api::BaseController
|
|
||||||
include Authorization
|
|
||||||
include AccountableConcern
|
|
||||||
|
|
||||||
LIMIT = 100
|
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :'admin:read', :'admin:read:reports' }, only: [:index, :show]
|
|
||||||
before_action -> { doorkeeper_authorize! :'admin:write', :'admin:write:reports' }, except: [:index, :show]
|
|
||||||
before_action :require_staff!
|
|
||||||
before_action :set_reports, only: :index
|
|
||||||
before_action :set_report, except: :index
|
|
||||||
|
|
||||||
after_action :insert_pagination_headers, only: :index
|
|
||||||
|
|
||||||
FILTER_PARAMS = %i(
|
|
||||||
resolved
|
|
||||||
account_id
|
|
||||||
target_account_id
|
|
||||||
).freeze
|
|
||||||
|
|
||||||
PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze
|
|
||||||
|
|
||||||
def index
|
|
||||||
authorize :report, :index?
|
|
||||||
render json: @reports, each_serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
authorize @report, :show?
|
|
||||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def assign_to_self
|
|
||||||
authorize @report, :update?
|
|
||||||
@report.update!(assigned_account_id: current_account.id)
|
|
||||||
log_action :assigned_to_self, @report
|
|
||||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def unassign
|
|
||||||
authorize @report, :update?
|
|
||||||
@report.update!(assigned_account_id: nil)
|
|
||||||
log_action :unassigned, @report
|
|
||||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def reopen
|
|
||||||
authorize @report, :update?
|
|
||||||
@report.unresolve!
|
|
||||||
log_action :reopen, @report
|
|
||||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def resolve
|
|
||||||
authorize @report, :update?
|
|
||||||
@report.resolve!(current_account)
|
|
||||||
log_action :resolve, @report
|
|
||||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_reports
|
|
||||||
@reports = filtered_reports.order(id: :desc).with_accounts.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_report
|
|
||||||
@report = Report.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_reports
|
|
||||||
ReportFilter.new(filter_params).results
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.permit(*FILTER_PARAMS)
|
|
||||||
end
|
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
|
||||||
api_v1_admin_reports_url(pagination_params(max_id: pagination_max_id)) if records_continue?
|
|
||||||
end
|
|
||||||
|
|
||||||
def prev_path
|
|
||||||
api_v1_admin_reports_url(pagination_params(min_id: pagination_since_id)) unless @reports.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_max_id
|
|
||||||
@reports.last.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_since_id
|
|
||||||
@reports.first.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def records_continue?
|
|
||||||
@reports.size == limit_param(LIMIT)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
|
||||||
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,29 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Announcements::ReactionsController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:favourites' }
|
|
||||||
before_action :require_user!
|
|
||||||
|
|
||||||
before_action :set_announcement
|
|
||||||
before_action :set_reaction, except: :update
|
|
||||||
|
|
||||||
def update
|
|
||||||
@announcement.announcement_reactions.create!(account: current_account, name: params[:id])
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@reaction.destroy!
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_reaction
|
|
||||||
@reaction = @announcement.announcement_reactions.where(account: current_account).find_by!(name: params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_announcement
|
|
||||||
@announcement = Announcement.published.find(params[:announcement_id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,29 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::AnnouncementsController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: :dismiss
|
|
||||||
before_action :require_user!
|
|
||||||
before_action :set_announcements, only: :index
|
|
||||||
before_action :set_announcement, except: :index
|
|
||||||
|
|
||||||
def index
|
|
||||||
render json: @announcements, each_serializer: REST::AnnouncementSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
def dismiss
|
|
||||||
AnnouncementMute.find_or_create_by!(account: current_account, announcement: @announcement)
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_announcements
|
|
||||||
@announcements = begin
|
|
||||||
Announcement.published.chronological
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_announcement
|
|
||||||
@announcement = Announcement.published.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -3,7 +3,9 @@
|
||||||
class Api::V1::Apps::CredentialsController < Api::BaseController
|
class Api::V1::Apps::CredentialsController < Api::BaseController
|
||||||
before_action -> { doorkeeper_authorize! :read }
|
before_action -> { doorkeeper_authorize! :read }
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def show
|
def show
|
||||||
render json: doorkeeper_token.application, serializer: REST::ApplicationSerializer, fields: %i(name website vapid_key)
|
render json: doorkeeper_token.application, serializer: REST::StatusSerializer::ApplicationSerializer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::AppsController < Api::BaseController
|
class Api::V1::AppsController < Api::BaseController
|
||||||
skip_before_action :require_authenticated_user!
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@app = Doorkeeper::Application.create!(application_options)
|
@app = Doorkeeper::Application.create!(application_options)
|
||||||
render json: @app, serializer: REST::ApplicationSerializer
|
render json: @app, serializer: REST::ApplicationSerializer
|
||||||
|
|
|
@ -5,6 +5,8 @@ class Api::V1::BlocksController < Api::BaseController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
after_action :insert_pagination_headers
|
after_action :insert_pagination_headers
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
|
@ -18,8 +20,6 @@ class Api::V1::BlocksController < Api::BaseController
|
||||||
|
|
||||||
def paginated_blocks
|
def paginated_blocks
|
||||||
@paginated_blocks ||= Block.eager_load(target_account: :account_stat)
|
@paginated_blocks ||= Block.eager_load(target_account: :account_stat)
|
||||||
.joins(:target_account)
|
|
||||||
.merge(Account.without_suspended)
|
|
||||||
.where(account: current_account)
|
.where(account: current_account)
|
||||||
.paginate_by_max_id(
|
.paginate_by_max_id(
|
||||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::BookmarksController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :read, :'read:bookmarks' }
|
|
||||||
before_action :require_user!
|
|
||||||
after_action :insert_pagination_headers
|
|
||||||
|
|
||||||
def index
|
|
||||||
@statuses = load_statuses
|
|
||||||
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def load_statuses
|
|
||||||
cached_bookmarks
|
|
||||||
end
|
|
||||||
|
|
||||||
def cached_bookmarks
|
|
||||||
cache_collection(results.map(&:status), Status)
|
|
||||||
end
|
|
||||||
|
|
||||||
def results
|
|
||||||
@_results ||= account_bookmarks.eager_load(:status).to_a_paginated_by_id(
|
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def account_bookmarks
|
|
||||||
current_account.bookmarks
|
|
||||||
end
|
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
|
||||||
api_v1_bookmarks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
|
||||||
end
|
|
||||||
|
|
||||||
def prev_path
|
|
||||||
api_v1_bookmarks_url pagination_params(min_id: pagination_since_id) unless results.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_max_id
|
|
||||||
results.last.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_since_id
|
|
||||||
results.first.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def records_continue?
|
|
||||||
results.size == limit_param(DEFAULT_STATUSES_LIMIT)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
|
||||||
params.slice(:limit).permit(:limit).merge(core_params)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -9,6 +9,8 @@ class Api::V1::ConversationsController < Api::BaseController
|
||||||
before_action :set_conversation, except: :index
|
before_action :set_conversation, except: :index
|
||||||
after_action :insert_pagination_headers, only: :index
|
after_action :insert_pagination_headers, only: :index
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@conversations = paginated_conversations
|
@conversations = paginated_conversations
|
||||||
render json: @conversations, each_serializer: REST::ConversationSerializer
|
render json: @conversations, each_serializer: REST::ConversationSerializer
|
||||||
|
@ -32,7 +34,7 @@ class Api::V1::ConversationsController < Api::BaseController
|
||||||
|
|
||||||
def paginated_conversations
|
def paginated_conversations
|
||||||
AccountConversation.where(account: current_account)
|
AccountConversation.where(account: current_account)
|
||||||
.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
.paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
def insert_pagination_headers
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Crypto::DeliveriesController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :crypto }
|
|
||||||
before_action :require_user!
|
|
||||||
before_action :set_current_device
|
|
||||||
|
|
||||||
def create
|
|
||||||
devices.each do |device_params|
|
|
||||||
DeliverToDeviceService.new.call(current_account, @current_device, device_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_current_device
|
|
||||||
@current_device = Device.find_by!(access_token: doorkeeper_token)
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:device)
|
|
||||||
params.permit(device: [:account_id, :device_id, :type, :body, :hmac])
|
|
||||||
end
|
|
||||||
|
|
||||||
def devices
|
|
||||||
Array(resource_params[:device])
|
|
||||||
end
|
|
||||||
end
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue