forked from berserker/microblog
commit
9d07ca3615
1079 changed files with 27231 additions and 9928 deletions
@ -1,254 +0,0 @@ |
|||||||
# Service dependencies |
|
||||||
# You may set REDIS_URL instead for more advanced options |
|
||||||
REDIS_HOST=$DATA_REDIS_HOST |
|
||||||
REDIS_PORT=6379 |
|
||||||
# REDIS_DB=0 |
|
||||||
|
|
||||||
# You may set DATABASE_URL instead for more advanced options |
|
||||||
DB_HOST=$DATA_DB_HOST |
|
||||||
DB_USER=$DATA_DB_USER |
|
||||||
DB_NAME=gonano |
|
||||||
DB_PASS=$DATA_DB_PASS |
|
||||||
DB_PORT=5432 |
|
||||||
|
|
||||||
# DATABASE_URL=postgresql://$DATA_DB_USER:$DATA_DB_PASS@$DATA_DB_HOST/gonano |
|
||||||
|
|
||||||
# Optional Elasticsearch configuration |
|
||||||
ES_ENABLED=true |
|
||||||
ES_HOST=$DATA_ELASTIC_HOST |
|
||||||
ES_PORT=9200 |
|
||||||
|
|
||||||
BIND=0.0.0.0 |
|
||||||
|
|
||||||
# Federation |
|
||||||
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation. |
|
||||||
# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com. |
|
||||||
LOCAL_DOMAIN=${APP_NAME}.nanoapp.io |
|
||||||
|
|
||||||
# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links) |
|
||||||
|
|
||||||
# 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 `rake secret` task (`nanobox run bundle exec rake secret`) |
|
||||||
SECRET_KEY_BASE=$SECRET_KEY_BASE |
|
||||||
OTP_SECRET=$OTP_SECRET |
|
||||||
|
|
||||||
# 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) |
|
||||||
# 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 `rake mastodon:webpush:generate_vapid_key` task (`nanobox run bundle exec rake mastodon:webpush:generate_vapid_key`) |
|
||||||
# |
|
||||||
# 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 |
|
||||||
|
|
||||||
# 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_SERVER |
|
||||||
SMTP_PORT=587 |
|
||||||
SMTP_LOGIN=$SMTP_LOGIN |
|
||||||
SMTP_PASSWORD=$SMTP_PASSWORD |
|
||||||
SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io |
|
||||||
#SMTP_REPLY_TO= |
|
||||||
#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 |
|
||||||
|
|
||||||
# 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 |
|
||||||
# PAPERCLIP_ROOT_URL=/system |
|
||||||
|
|
||||||
# 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 |
|
||||||
|
|
||||||
# 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= |
|
||||||
|
|
||||||
# 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) |
|
||||||
# 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_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 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 |
|
||||||
|
|
||||||
# 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' |
|
||||||
# CAS_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true |
|
||||||
|
|
||||||
# Optional SAML authentication (cf. omniauth-saml) |
|
||||||
# SAML_ENABLED=true |
|
||||||
# SAML_ACS_URL=http://localhost:3000/auth/auth/saml/callback |
|
||||||
# SAML_ISSUER=https://example.com |
|
||||||
# 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 |
|
@ -0,0 +1 @@ |
|||||||
|
mastodon |
@ -1 +1 @@ |
|||||||
3.0.3 |
3.0.4 |
||||||
|
@ -1,20 +0,0 @@ |
|||||||
# frozen_string_literal: true |
|
||||||
|
|
||||||
module Admin |
|
||||||
class SubscriptionsController < BaseController |
|
||||||
def index |
|
||||||
authorize :subscription, :index? |
|
||||||
@subscriptions = ordered_subscriptions.page(requested_page) |
|
||||||
end |
|
||||||
|
|
||||||
private |
|
||||||
|
|
||||||
def ordered_subscriptions |
|
||||||
Subscription.order(id: :desc).includes(:account) |
|
||||||
end |
|
||||||
|
|
||||||
def requested_page |
|
||||||
params[:page].to_i |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -0,0 +1,34 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
module Admin |
||||||
|
class Users::RolesController < BaseController |
||||||
|
before_action :set_user |
||||||
|
|
||||||
|
def show |
||||||
|
authorize @user, :change_role? |
||||||
|
end |
||||||
|
|
||||||
|
def update |
||||||
|
authorize @user, :change_role? |
||||||
|
|
||||||
|
@user.current_account = current_account |
||||||
|
|
||||||
|
if @user.update(resource_params) |
||||||
|
log_action :change_role, @user |
||||||
|
redirect_to admin_account_path(@user.account_id), notice: I18n.t('admin.accounts.change_role.changed_msg') |
||||||
|
else |
||||||
|
render :show |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_user |
||||||
|
@user = User.find(params[:user_id]) |
||||||
|
end |
||||||
|
|
||||||
|
def resource_params |
||||||
|
params.require(:user).permit(:role_id) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,7 +1,7 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
module Admin |
module Admin |
||||||
class TwoFactorAuthenticationsController < BaseController |
class Users::TwoFactorAuthenticationsController < BaseController |
||||||
before_action :set_target_user |
before_action :set_target_user |
||||||
|
|
||||||
def destroy |
def destroy |
@ -0,0 +1,99 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::Admin::CanonicalEmailBlocksController < Api::BaseController |
||||||
|
include Authorization |
||||||
|
include AccountableConcern |
||||||
|
|
||||||
|
LIMIT = 100 |
||||||
|
|
||||||
|
before_action -> { authorize_if_got_token! :'admin:read', :'admin:read:canonical_email_blocks' }, only: [:index, :show, :test] |
||||||
|
before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:canonical_email_blocks' }, except: [:index, :show, :test] |
||||||
|
|
||||||
|
before_action :set_canonical_email_blocks, only: :index |
||||||
|
before_action :set_canonical_email_blocks_from_test, only: [:test] |
||||||
|
before_action :set_canonical_email_block, only: [:show, :destroy] |
||||||
|
|
||||||
|
after_action :verify_authorized |
||||||
|
after_action :insert_pagination_headers, only: :index |
||||||
|
|
||||||
|
PAGINATION_PARAMS = %i(limit).freeze |
||||||
|
|
||||||
|
def index |
||||||
|
authorize :canonical_email_block, :index? |
||||||
|
render json: @canonical_email_blocks, each_serializer: REST::Admin::CanonicalEmailBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def show |
||||||
|
authorize @canonical_email_block, :show? |
||||||
|
render json: @canonical_email_block, serializer: REST::Admin::CanonicalEmailBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def test |
||||||
|
authorize :canonical_email_block, :test? |
||||||
|
render json: @canonical_email_blocks, each_serializer: REST::Admin::CanonicalEmailBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def create |
||||||
|
authorize :canonical_email_block, :create? |
||||||
|
|
||||||
|
@canonical_email_block = CanonicalEmailBlock.create!(resource_params) |
||||||
|
log_action :create, @canonical_email_block |
||||||
|
|
||||||
|
render json: @canonical_email_block, serializer: REST::Admin::CanonicalEmailBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def destroy |
||||||
|
authorize @canonical_email_block, :destroy? |
||||||
|
|
||||||
|
@canonical_email_block.destroy! |
||||||
|
log_action :destroy, @canonical_email_block |
||||||
|
|
||||||
|
render json: @canonical_email_block, serializer: REST::Admin::CanonicalEmailBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def resource_params |
||||||
|
params.permit(:canonical_email_hash, :email) |
||||||
|
end |
||||||
|
|
||||||
|
def set_canonical_email_blocks |
||||||
|
@canonical_email_blocks = CanonicalEmailBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) |
||||||
|
end |
||||||
|
|
||||||
|
def set_canonical_email_blocks_from_test |
||||||
|
@canonical_email_blocks = CanonicalEmailBlock.matching_email(params[:email]) |
||||||
|
end |
||||||
|
|
||||||
|
def set_canonical_email_block |
||||||
|
@canonical_email_block = CanonicalEmailBlock.find(params[:id]) |
||||||
|
end |
||||||
|
|
||||||
|
def insert_pagination_headers |
||||||
|
set_pagination_headers(next_path, prev_path) |
||||||
|
end |
||||||
|
|
||||||
|
def next_path |
||||||
|
api_v1_admin_canonical_email_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue? |
||||||
|
end |
||||||
|
|
||||||
|
def prev_path |
||||||
|
api_v1_admin_canonical_email_blocks_url(pagination_params(min_id: pagination_since_id)) unless @canonical_email_blocks.empty? |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_max_id |
||||||
|
@canonical_email_blocks.last.id |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_since_id |
||||||
|
@canonical_email_blocks.first.id |
||||||
|
end |
||||||
|
|
||||||
|
def records_continue? |
||||||
|
@canonical_email_blocks.size == limit_param(LIMIT) |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_params(core_params) |
||||||
|
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,90 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::Admin::EmailDomainBlocksController < Api::BaseController |
||||||
|
include Authorization |
||||||
|
include AccountableConcern |
||||||
|
|
||||||
|
LIMIT = 100 |
||||||
|
|
||||||
|
before_action -> { authorize_if_got_token! :'admin:read', :'admin:read:email_domain_blocks' }, only: [:index, :show] |
||||||
|
before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:email_domain_blocks' }, except: [:index, :show] |
||||||
|
before_action :set_email_domain_blocks, only: :index |
||||||
|
before_action :set_email_domain_block, only: [:show, :destroy] |
||||||
|
|
||||||
|
after_action :verify_authorized |
||||||
|
after_action :insert_pagination_headers, only: :index |
||||||
|
|
||||||
|
PAGINATION_PARAMS = %i( |
||||||
|
limit |
||||||
|
).freeze |
||||||
|
|
||||||
|
def create |
||||||
|
authorize :email_domain_block, :create? |
||||||
|
|
||||||
|
@email_domain_block = EmailDomainBlock.create!(resource_params) |
||||||
|
log_action :create, @email_domain_block |
||||||
|
|
||||||
|
render json: @email_domain_block, serializer: REST::Admin::EmailDomainBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def index |
||||||
|
authorize :email_domain_block, :index? |
||||||
|
render json: @email_domain_blocks, each_serializer: REST::Admin::EmailDomainBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def show |
||||||
|
authorize @email_domain_block, :show? |
||||||
|
render json: @email_domain_block, serializer: REST::Admin::EmailDomainBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def destroy |
||||||
|
authorize @email_domain_block, :destroy? |
||||||
|
|
||||||
|
@email_domain_block.destroy! |
||||||
|
log_action :destroy, @email_domain_block |
||||||
|
|
||||||
|
render json: @email_domain_block, serializer: REST::Admin::EmailDomainBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_email_domain_blocks |
||||||
|
@email_domain_blocks = EmailDomainBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) |
||||||
|
end |
||||||
|
|
||||||
|
def set_email_domain_block |
||||||
|
@email_domain_block = EmailDomainBlock.find(params[:id]) |
||||||
|
end |
||||||
|
|
||||||
|
def resource_params |
||||||
|
params.permit(:domain) |
||||||
|
end |
||||||
|
|
||||||
|
def insert_pagination_headers |
||||||
|
set_pagination_headers(next_path, prev_path) |
||||||
|
end |
||||||
|
|
||||||
|
def next_path |
||||||
|
api_v1_admin_email_domain_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue? |
||||||
|
end |
||||||
|
|
||||||
|
def prev_path |
||||||
|
api_v1_admin_email_domain_blocks_url(pagination_params(min_id: pagination_since_id)) unless @email_domain_blocks.empty? |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_max_id |
||||||
|
@email_domain_blocks.last.id |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_since_id |
||||||
|
@email_domain_blocks.first.id |
||||||
|
end |
||||||
|
|
||||||
|
def records_continue? |
||||||
|
@email_domain_blocks.size == limit_param(LIMIT) |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_params(core_params) |
||||||
|
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,99 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::Admin::IpBlocksController < Api::BaseController |
||||||
|
include Authorization |
||||||
|
include AccountableConcern |
||||||
|
|
||||||
|
LIMIT = 100 |
||||||
|
|
||||||
|
before_action -> { authorize_if_got_token! :'admin:read', :'admin:read:ip_blocks' }, only: [:index, :show] |
||||||
|
before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:ip_blocks' }, except: [:index, :show] |
||||||
|
before_action :set_ip_blocks, only: :index |
||||||
|
before_action :set_ip_block, only: [:show, :update, :destroy] |
||||||
|
|
||||||
|
after_action :verify_authorized |
||||||
|
after_action :insert_pagination_headers, only: :index |
||||||
|
|
||||||
|
PAGINATION_PARAMS = %i( |
||||||
|
limit |
||||||
|
).freeze |
||||||
|
|
||||||
|
def create |
||||||
|
authorize :ip_block, :create? |
||||||
|
|
||||||
|
@ip_block = IpBlock.create!(resource_params) |
||||||
|
log_action :create, @ip_block |
||||||
|
|
||||||
|
render json: @ip_block, serializer: REST::Admin::IpBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def index |
||||||
|
authorize :ip_block, :index? |
||||||
|
render json: @ip_blocks, each_serializer: REST::Admin::IpBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def show |
||||||
|
authorize @ip_block, :show? |
||||||
|
render json: @ip_block, serializer: REST::Admin::IpBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def update |
||||||
|
authorize @ip_block, :update? |
||||||
|
|
||||||
|
@ip_block.update(resource_params) |
||||||
|
log_action :update, @ip_block |
||||||
|
|
||||||
|
render json: @ip_block, serializer: REST::Admin::IpBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def destroy |
||||||
|
authorize @ip_block, :destroy? |
||||||
|
|
||||||
|
@ip_block.destroy! |
||||||
|
log_action :destroy, @ip_block |
||||||
|
|
||||||
|
render json: @ip_block, serializer: REST::Admin::IpBlockSerializer |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_ip_blocks |
||||||
|
@ip_blocks = IpBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) |
||||||
|
end |
||||||
|
|
||||||
|
def set_ip_block |
||||||
|
@ip_block = IpBlock.find(params[:id]) |
||||||
|
end |
||||||
|
|
||||||
|
def resource_params |
||||||
|
params.permit(:ip, :severity, :comment, :expires_in) |
||||||
|
end |
||||||
|
|
||||||
|
def insert_pagination_headers |
||||||
|
set_pagination_headers(next_path, prev_path) |
||||||
|
end |
||||||
|
|
||||||
|
def next_path |
||||||
|
api_v1_admin_ip_blocks_url(pagination_params(max_id: pagination_max_id)) if records_continue? |
||||||
|
end |
||||||
|
|
||||||
|
def prev_path |
||||||
|
api_v1_admin_ip_blocks_url(pagination_params(min_id: pagination_since_id)) unless @ip_blocks.empty? |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_max_id |
||||||
|
@ip_blocks.last.id |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_since_id |
||||||
|
@ip_blocks.first.id |
||||||
|
end |
||||||
|
|
||||||
|
def records_continue? |
||||||
|
@ip_blocks.size == limit_param(LIMIT) |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_params(core_params) |
||||||
|
params.slice(*PAGINATION_PARAMS).permit(*PAGINATION_PARAMS).merge(core_params) |
||||||
|
end |
||||||
|
end |
@ -1,17 +1,19 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
class Api::V1::Admin::Trends::LinksController < Api::BaseController |
class Api::V1::Admin::Trends::LinksController < Api::V1::Trends::LinksController |
||||||
before_action -> { authorize_if_got_token! :'admin:read' } |
before_action -> { authorize_if_got_token! :'admin:read' } |
||||||
before_action :require_staff! |
|
||||||
before_action :set_links |
|
||||||
|
|
||||||
def index |
|
||||||
render json: @links, each_serializer: REST::Trends::LinkSerializer |
|
||||||
end |
|
||||||
|
|
||||||
private |
private |
||||||
|
|
||||||
def set_links |
def enabled? |
||||||
@links = Trends.links.query.limit(limit_param(10)) |
super || current_user&.can?(:manage_taxonomies) |
||||||
|
end |
||||||
|
|
||||||
|
def links_from_trends |
||||||
|
if current_user&.can?(:manage_taxonomies) |
||||||
|
Trends.links.query |
||||||
|
else |
||||||
|
super |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,17 +1,19 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
class Api::V1::Admin::Trends::StatusesController < Api::BaseController |
class Api::V1::Admin::Trends::StatusesController < Api::V1::Trends::StatusesController |
||||||
before_action -> { authorize_if_got_token! :'admin:read' } |
before_action -> { authorize_if_got_token! :'admin:read' } |
||||||
before_action :require_staff! |
|
||||||
before_action :set_statuses |
|
||||||
|
|
||||||
def index |
|
||||||
render json: @statuses, each_serializer: REST::StatusSerializer |
|
||||||
end |
|
||||||
|
|
||||||
private |
private |
||||||
|
|
||||||
def set_statuses |
def enabled? |
||||||
@statuses = cache_collection(Trends.statuses.query.limit(limit_param(DEFAULT_STATUSES_LIMIT)), Status) |
super || current_user&.can?(:manage_taxonomies) |
||||||
|
end |
||||||
|
|
||||||
|
def statuses_from_trends |
||||||
|
if current_user&.can?(:manage_taxonomies) |
||||||
|
Trends.statuses.query |
||||||
|
else |
||||||
|
super |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,17 +1,19 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
class Api::V1::Admin::Trends::TagsController < Api::BaseController |
class Api::V1::Admin::Trends::TagsController < Api::V1::Trends::TagsController |
||||||
before_action -> { authorize_if_got_token! :'admin:read' } |
before_action -> { authorize_if_got_token! :'admin:read' } |
||||||
before_action :require_staff! |
|
||||||
before_action :set_tags |
|
||||||
|
|
||||||
def index |
|
||||||
render json: @tags, each_serializer: REST::Admin::TagSerializer |
|
||||||
end |
|
||||||
|
|
||||||
private |
private |
||||||
|
|
||||||
def set_tags |
def enabled? |
||||||
@tags = Trends.tags.query.limit(limit_param(10)) |
super || current_user&.can?(:manage_taxonomies) |
||||||
|
end |
||||||
|
|
||||||
|
def tags_from_trends |
||||||
|
if current_user&.can?(:manage_taxonomies) |
||||||
|
Trends.tags.query |
||||||
|
else |
||||||
|
super |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,44 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::Filters::StatusesController < Api::BaseController |
||||||
|
before_action -> { doorkeeper_authorize! :read, :'read:filters' }, only: [:index, :show] |
||||||
|
before_action -> { doorkeeper_authorize! :write, :'write:filters' }, except: [:index, :show] |
||||||
|
before_action :require_user! |
||||||
|
|
||||||
|
before_action :set_status_filters, only: :index |
||||||
|
before_action :set_status_filter, only: [:show, :destroy] |
||||||
|
|
||||||
|
def index |
||||||
|
render json: @status_filters, each_serializer: REST::FilterStatusSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def create |
||||||
|
@status_filter = current_account.custom_filters.find(params[:filter_id]).statuses.create!(resource_params) |
||||||
|
|
||||||
|
render json: @status_filter, serializer: REST::FilterStatusSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def show |
||||||
|
render json: @status_filter, serializer: REST::FilterStatusSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def destroy |
||||||
|
@status_filter.destroy! |
||||||
|
render_empty |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_status_filters |
||||||
|
filter = current_account.custom_filters.includes(:statuses).find(params[:filter_id]) |
||||||
|
@status_filters = filter.statuses |
||||||
|
end |
||||||
|
|
||||||
|
def set_status_filter |
||||||
|
@status_filter = CustomFilterStatus.includes(:custom_filter).where(custom_filter: { account: current_account }).find(params[:id]) |
||||||
|
end |
||||||
|
|
||||||
|
def resource_params |
||||||
|
params.permit(:status_id) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,52 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::FollowedTagsController < Api::BaseController |
||||||
|
TAGS_LIMIT = 100 |
||||||
|
|
||||||
|
before_action -> { doorkeeper_authorize! :follow, :read, :'read:follows' }, except: :show |
||||||
|
before_action :require_user! |
||||||
|
before_action :set_results |
||||||
|
|
||||||
|
after_action :insert_pagination_headers, only: :show |
||||||
|
|
||||||
|
def index |
||||||
|
render json: @results.map(&:tag), each_serializer: REST::TagSerializer, relationships: TagRelationshipsPresenter.new(@results.map(&:tag), current_user&.account_id) |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_results |
||||||
|
@results = TagFollow.where(account: current_account).joins(:tag).eager_load(:tag).to_a_paginated_by_id( |
||||||
|
limit_param(TAGS_LIMIT), |
||||||
|
params_slice(:max_id, :since_id, :min_id) |
||||||
|
) |
||||||
|
end |
||||||
|
|
||||||
|
def insert_pagination_headers |
||||||
|
set_pagination_headers(next_path, prev_path) |
||||||
|
end |
||||||
|
|
||||||
|
def next_path |
||||||
|
api_v1_followed_tags_url pagination_params(max_id: pagination_max_id) if records_continue? |
||||||
|
end |
||||||
|
|
||||||
|
def prev_path |
||||||
|
api_v1_followed_tags_url pagination_params(since_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(TAG_LIMIT) |
||||||
|
end |
||||||
|
|
||||||
|
def pagination_params(core_params) |
||||||
|
params.slice(:limit).permit(:limit).merge(core_params) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,29 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::Statuses::TranslationsController < Api::BaseController |
||||||
|
include Authorization |
||||||
|
|
||||||
|
before_action -> { doorkeeper_authorize! :read, :'read:statuses' } |
||||||
|
before_action :set_status |
||||||
|
before_action :set_translation |
||||||
|
|
||||||
|
rescue_from TranslationService::NotConfiguredError, with: :not_found |
||||||
|
rescue_from TranslationService::UnexpectedResponseError, TranslationService::QuotaExceededError, TranslationService::TooManyRequestsError, with: :service_unavailable |
||||||
|
|
||||||
|
def create |
||||||
|
render json: @translation, serializer: REST::TranslationSerializer |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_status |
||||||
|
@status = Status.find(params[:status_id]) |
||||||
|
authorize @status, :show? |
||||||
|
rescue Mastodon::NotPermittedError |
||||||
|
not_found |
||||||
|
end |
||||||
|
|
||||||
|
def set_translation |
||||||
|
@translation = TranslateStatusService.new.call(@status, content_locale) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,30 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V1::TagsController < Api::BaseController |
||||||
|
before_action -> { doorkeeper_authorize! :follow, :write, :'write:follows' }, except: :show |
||||||
|
before_action :require_user!, except: :show |
||||||
|
before_action :set_or_create_tag |
||||||
|
|
||||||
|
override_rate_limit_headers :follow, family: :follows |
||||||
|
|
||||||
|
def show |
||||||
|
render json: @tag, serializer: REST::TagSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def follow |
||||||
|
TagFollow.create!(tag: @tag, account: current_account, rate_limit: true) |
||||||
|
render json: @tag, serializer: REST::TagSerializer |
||||||
|
end |
||||||
|
|
||||||
|
def unfollow |
||||||
|
TagFollow.find_by(account: current_account, tag: @tag)&.destroy! |
||||||
|
render json: @tag, serializer: REST::TagSerializer |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_or_create_tag |
||||||
|
return not_found unless /\A(#{Tag::HASHTAG_NAME_RE})\z/.match?(params[:id]) |
||||||
|
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id]) |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,8 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Api::V2::InstancesController < Api::V1::InstancesController |
||||||
|
def show |
||||||
|
expires_in 3.minutes, public: true |
||||||
|
render_with_cache json: InstancePresenter.new, serializer: REST::InstanceSerializer, root: 'instance' |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,54 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Filters::StatusesController < ApplicationController |
||||||
|
layout 'admin' |
||||||
|
|
||||||
|
before_action :authenticate_user! |
||||||
|
before_action :set_filter |
||||||
|
before_action :set_status_filters |
||||||
|
before_action :set_pack |
||||||
|
before_action :set_body_classes |
||||||
|
|
||||||
|
PER_PAGE = 20 |
||||||
|
|
||||||
|
def index |
||||||
|
@status_filter_batch_action = Form::StatusFilterBatchAction.new |
||||||
|
end |
||||||
|
|
||||||
|
def batch |
||||||
|
@status_filter_batch_action = Form::StatusFilterBatchAction.new(status_filter_batch_action_params.merge(current_account: current_account, filter_id: params[:filter_id], type: action_from_button)) |
||||||
|
@status_filter_batch_action.save! |
||||||
|
rescue ActionController::ParameterMissing |
||||||
|
flash[:alert] = I18n.t('admin.statuses.no_status_selected') |
||||||
|
ensure |
||||||
|
redirect_to edit_filter_path(@filter) |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_pack |
||||||
|
use_pack 'admin' |
||||||
|
end |
||||||
|
|
||||||
|
def set_filter |
||||||
|
@filter = current_account.custom_filters.find(params[:filter_id]) |
||||||
|
end |
||||||
|
|
||||||
|
def set_status_filters |
||||||
|
@status_filters = @filter.statuses.preload(:status).page(params[:page]).per(PER_PAGE) |
||||||
|
end |
||||||
|
|
||||||
|
def status_filter_batch_action_params |
||||||
|
params.require(:form_status_filter_batch_action).permit(status_filter_ids: []) |
||||||
|
end |
||||||
|
|
||||||
|
def action_from_button |
||||||
|
if params[:remove] |
||||||
|
'remove' |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def set_body_classes |
||||||
|
@body_classes = 'admin' |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,28 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class PrivacyController < ApplicationController |
||||||
|
layout 'public' |
||||||
|
|
||||||
|
before_action :set_pack |
||||||
|
|
||||||
|
before_action :set_instance_presenter |
||||||
|
before_action :set_expires_in |
||||||
|
|
||||||
|
skip_before_action :require_functional! |
||||||
|
|
||||||
|
def show; end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def set_pack |
||||||
|
use_pack 'public' |
||||||
|
end |
||||||
|
|
||||||
|
def set_instance_presenter |
||||||
|
@instance_presenter = InstancePresenter.new |
||||||
|
end |
||||||
|
|
||||||
|
def set_expires_in |
||||||
|
expires_in 0, public: true |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,6 @@ |
|||||||
|
export const APP_LAYOUT_CHANGE = 'APP_LAYOUT_CHANGE'; |
||||||
|
|
||||||
|
export const changeLayout = layout => ({ |
||||||
|
type: APP_LAYOUT_CHANGE, |
||||||
|
layout, |
||||||
|
}); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue