summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
committerrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
commit1172844ed18d94d84724dc6f11c6e9f72e0ba6ec (patch)
tree7d48a259e08856ab6db0eba255f20c0c19410463
parenta0f5e8b27edbe2224d9c2c3997ad5b8ea484244b (diff)
parentb4c6b262d6dc12362f0014a864e8aed6c727c39c (diff)
Merge branch 'release/2.2.0' into 'stable'v2.2.0
Release/2.2.0 See merge request pleroma/secteam/pleroma!19
-rw-r--r--.credo.exs6
-rw-r--r--.gitlab-ci.yml6
-rw-r--r--CC-BY-4.0395
-rw-r--r--CHANGELOG.md70
-rw-r--r--Dockerfile2
-rw-r--r--README.md7
-rw-r--r--SECURITY.md2
-rw-r--r--config/benchmark.exs2
-rw-r--r--config/config.exs72
-rw-r--r--config/description.exs148
-rw-r--r--config/test.exs11
-rw-r--r--coveralls.json3
-rw-r--r--docs/API/admin_api.md169
-rw-r--r--docs/API/pleroma_api.md153
-rw-r--r--docs/API/prometheus.md26
-rw-r--r--docs/administration/CLI_tasks/email.md16
-rw-r--r--docs/administration/CLI_tasks/instance.md3
-rw-r--r--docs/administration/CLI_tasks/user.md33
-rw-r--r--docs/administration/backup.md21
-rw-r--r--docs/administration/updating.md7
-rw-r--r--docs/clients.md2
-rw-r--r--docs/configuration/cheatsheet.md53
-rw-r--r--docs/dev.md4
-rw-r--r--docs/installation/alpine_linux_en.md14
-rw-r--r--docs/installation/arch_linux_en.md12
-rw-r--r--docs/installation/debian_based_en.md12
-rw-r--r--docs/installation/debian_based_jp.md13
-rw-r--r--docs/installation/freebsd_en.md6
-rw-r--r--docs/installation/gentoo_en.md12
-rw-r--r--docs/installation/netbsd_en.md6
-rw-r--r--docs/installation/openbsd_en.md18
-rw-r--r--docs/installation/openbsd_fi.md13
-rw-r--r--docs/installation/optional/media_graphics_packages.md32
-rw-r--r--docs/installation/otp_en.md26
-rw-r--r--installation/pleroma.nginx33
-rw-r--r--installation/pleroma.vcl6
-rw-r--r--lib/mix/pleroma.ex1
-rw-r--r--lib/mix/tasks/pleroma/benchmark.ex11
-rw-r--r--lib/mix/tasks/pleroma/config.ex10
-rw-r--r--lib/mix/tasks/pleroma/count_statuses.ex4
-rw-r--r--lib/mix/tasks/pleroma/database.ex21
-rw-r--r--lib/mix/tasks/pleroma/digest.ex4
-rw-r--r--lib/mix/tasks/pleroma/docs.ex4
-rw-r--r--lib/mix/tasks/pleroma/ecto.ex (renamed from lib/mix/tasks/pleroma/ecto/ecto.ex)0
-rw-r--r--lib/mix/tasks/pleroma/email.ex24
-rw-r--r--lib/mix/tasks/pleroma/emoji.ex12
-rw-r--r--lib/mix/tasks/pleroma/frontend.ex7
-rw-r--r--lib/mix/tasks/pleroma/instance.ex64
-rw-r--r--lib/mix/tasks/pleroma/notification_settings.ex4
-rw-r--r--lib/mix/tasks/pleroma/relay.ex13
-rw-r--r--lib/mix/tasks/pleroma/robots_txt.ex (renamed from lib/mix/tasks/pleroma/robotstxt.ex)0
-rw-r--r--lib/mix/tasks/pleroma/user.ex72
-rw-r--r--lib/phoenix/transports/web_socket/raw.ex94
-rw-r--r--lib/pleroma/activity.ex7
-rw-r--r--lib/pleroma/activity_expiration.ex74
-rw-r--r--lib/pleroma/application.ex71
-rw-r--r--lib/pleroma/application_requirements.ex72
-rw-r--r--lib/pleroma/bbs/authenticator.ex2
-rw-r--r--lib/pleroma/captcha.ex (renamed from lib/pleroma/captcha/captcha.ex)0
-rw-r--r--lib/pleroma/captcha/kocaptcha.ex2
-rw-r--r--lib/pleroma/captcha/service.ex (renamed from lib/pleroma/captcha/captcha_service.ex)0
-rw-r--r--lib/pleroma/chat.ex33
-rw-r--r--lib/pleroma/config/deprecation_warnings.ex138
-rw-r--r--lib/pleroma/config/oban.ex38
-rw-r--r--lib/pleroma/config_db.ex (renamed from lib/pleroma/config/config_db.ex)0
-rw-r--r--lib/pleroma/conversation/participation/recipient_ship.ex (renamed from lib/pleroma/conversation/participation_recipient_ship.ex)0
-rw-r--r--lib/pleroma/docs/generator.ex4
-rw-r--r--lib/pleroma/docs/json.ex4
-rw-r--r--lib/pleroma/docs/markdown.ex4
-rw-r--r--lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex34
-rw-r--r--lib/pleroma/emails/admin_email.ex2
-rw-r--r--lib/pleroma/emails/mailer.ex5
-rw-r--r--lib/pleroma/emoji.ex3
-rw-r--r--lib/pleroma/emoji/pack.ex144
-rw-r--r--lib/pleroma/gun.ex (renamed from lib/pleroma/gun/gun.ex)0
-rw-r--r--lib/pleroma/gun/conn.ex14
-rw-r--r--lib/pleroma/gun/connection_pool.ex4
-rw-r--r--lib/pleroma/gun/connection_pool/reclaimer.ex4
-rw-r--r--lib/pleroma/gun/connection_pool/worker.ex49
-rw-r--r--lib/pleroma/gun/connection_pool/worker_supervisor.ex4
-rw-r--r--lib/pleroma/helpers/inet_helper.ex19
-rw-r--r--lib/pleroma/helpers/media_helper.ex162
-rw-r--r--lib/pleroma/helpers/qt_fast_start.ex131
-rw-r--r--lib/pleroma/helpers/uri_helper.ex14
-rw-r--r--lib/pleroma/http.ex110
-rw-r--r--lib/pleroma/http/adapter_helper.ex6
-rw-r--r--lib/pleroma/http/adapter_helper/default.ex4
-rw-r--r--lib/pleroma/http/adapter_helper/gun.ex23
-rw-r--r--lib/pleroma/http/adapter_helper/hackney.ex19
-rw-r--r--lib/pleroma/http/ex_aws.ex2
-rw-r--r--lib/pleroma/http/http.ex117
-rw-r--r--lib/pleroma/http/tzdata.ex4
-rw-r--r--lib/pleroma/http/web_push.ex12
-rw-r--r--lib/pleroma/instances/instance.ex16
-rw-r--r--lib/pleroma/jwt.ex4
-rw-r--r--lib/pleroma/mfa/token.ex71
-rw-r--r--lib/pleroma/migration_helper/notification_backfill.ex15
-rw-r--r--lib/pleroma/mime.ex120
-rw-r--r--lib/pleroma/moderation_log.ex28
-rw-r--r--lib/pleroma/notification.ex12
-rw-r--r--lib/pleroma/object/containment.ex7
-rw-r--r--lib/pleroma/object/fetcher.ex83
-rw-r--r--lib/pleroma/plugs/admin_secret_authentication_plug.ex60
-rw-r--r--lib/pleroma/plugs/authentication_plug.ex80
-rw-r--r--lib/pleroma/plugs/basic_auth_decoder_plug.ex25
-rw-r--r--lib/pleroma/plugs/cache.ex136
-rw-r--r--lib/pleroma/plugs/ensure_authenticated_plug.ex41
-rw-r--r--lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex35
-rw-r--r--lib/pleroma/plugs/ensure_user_key_plug.ex18
-rw-r--r--lib/pleroma/plugs/expect_authenticated_check_plug.ex20
-rw-r--r--lib/pleroma/plugs/expect_public_or_authenticated_check_plug.ex21
-rw-r--r--lib/pleroma/plugs/federating_plug.ex32
-rw-r--r--lib/pleroma/plugs/frontend_static.ex55
-rw-r--r--lib/pleroma/plugs/http_security_plug.ex225
-rw-r--r--lib/pleroma/plugs/idempotency_plug.ex84
-rw-r--r--lib/pleroma/plugs/instance_static.ex53
-rw-r--r--lib/pleroma/plugs/legacy_authentication_plug.ex42
-rw-r--r--lib/pleroma/plugs/oauth_plug.ex120
-rw-r--r--lib/pleroma/plugs/oauth_scopes_plug.ex77
-rw-r--r--lib/pleroma/plugs/plug_helper.ex40
-rw-r--r--lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex50
-rw-r--r--lib/pleroma/plugs/rate_limiter/rate_limiter.ex267
-rw-r--r--lib/pleroma/plugs/rate_limiter/supervisor.ex16
-rw-r--r--lib/pleroma/plugs/remote_ip.ex54
-rw-r--r--lib/pleroma/plugs/session_authentication_plug.ex21
-rw-r--r--lib/pleroma/plugs/set_format_plug.ex24
-rw-r--r--lib/pleroma/plugs/set_locale_plug.ex63
-rw-r--r--lib/pleroma/plugs/set_user_session_id_plug.ex19
-rw-r--r--lib/pleroma/plugs/static_fe_plug.ex26
-rw-r--r--lib/pleroma/plugs/trailing_format_plug.ex42
-rw-r--r--lib/pleroma/plugs/uploaded_media.ex107
-rw-r--r--lib/pleroma/plugs/user_enabled_plug.ex23
-rw-r--r--lib/pleroma/plugs/user_fetcher_plug.ex21
-rw-r--r--lib/pleroma/plugs/user_is_admin_plug.ex24
-rw-r--r--lib/pleroma/repo.ex23
-rw-r--r--lib/pleroma/repo_streamer.ex34
-rw-r--r--lib/pleroma/reverse_proxy.ex432
-rw-r--r--lib/pleroma/reverse_proxy/client/tesla.ex2
-rw-r--r--lib/pleroma/reverse_proxy/reverse_proxy.ex427
-rw-r--r--lib/pleroma/signature.ex6
-rw-r--r--lib/pleroma/stats.ex77
-rw-r--r--lib/pleroma/telemetry/logger.ex22
-rw-r--r--lib/pleroma/tesla/middleware/connection_pool.ex50
-rw-r--r--lib/pleroma/tesla/middleware/follow_redirects.ex110
-rw-r--r--lib/pleroma/tests/auth_test_controller.ex4
-rw-r--r--lib/pleroma/upload.ex19
-rw-r--r--lib/pleroma/uploaders/uploader.ex2
-rw-r--r--lib/pleroma/user.ex122
-rw-r--r--lib/pleroma/user/import.ex85
-rw-r--r--lib/pleroma/user/query.ex27
-rw-r--r--lib/pleroma/user/search.ex73
-rw-r--r--lib/pleroma/utils.ex20
-rw-r--r--lib/pleroma/web.ex234
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex107
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex12
-rw-r--r--lib/pleroma/web/activity_pub/builder.ex4
-rw-r--r--lib/pleroma/web/activity_pub/mrf/activity_expiration_policy.ex4
-rw-r--r--lib/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy.ex56
-rw-r--r--lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex22
-rw-r--r--lib/pleroma/web/activity_pub/object_validator.ex31
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/article_note_validator.ex106
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex21
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/audio_validator.ex106
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex134
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex2
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/common_fixes.ex13
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/create_generic_validator.ex8
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/event_validator.ex5
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/note_validator.ex66
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/question_validator.ex9
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex24
-rw-r--r--lib/pleroma/web/activity_pub/publisher.ex38
-rw-r--r--lib/pleroma/web/activity_pub/relay.ex20
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex14
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex73
-rw-r--r--lib/pleroma/web/activity_pub/views/user_view.ex2
-rw-r--r--lib/pleroma/web/activity_pub/visibility.ex39
-rw-r--r--lib/pleroma/web/admin_api/controllers/admin_api_controller.ex24
-rw-r--r--lib/pleroma/web/admin_api/controllers/chat_controller.ex85
-rw-r--r--lib/pleroma/web/admin_api/controllers/config_controller.ex2
-rw-r--r--lib/pleroma/web/admin_api/controllers/instance_document_controller.ex41
-rw-r--r--lib/pleroma/web/admin_api/controllers/invite_controller.ex2
-rw-r--r--lib/pleroma/web/admin_api/controllers/media_proxy_cache_controller.ex2
-rw-r--r--lib/pleroma/web/admin_api/controllers/o_auth_app_controller.ex77
-rw-r--r--lib/pleroma/web/admin_api/controllers/oauth_app_controller.ex77
-rw-r--r--lib/pleroma/web/admin_api/controllers/relay_controller.ex18
-rw-r--r--lib/pleroma/web/admin_api/controllers/report_controller.ex2
-rw-r--r--lib/pleroma/web/admin_api/controllers/status_controller.ex2
-rw-r--r--lib/pleroma/web/admin_api/views/account_view.ex2
-rw-r--r--lib/pleroma/web/admin_api/views/chat_view.ex30
-rw-r--r--lib/pleroma/web/admin_api/views/report_view.ex2
-rw-r--r--lib/pleroma/web/admin_api/views/status_view.ex3
-rw-r--r--lib/pleroma/web/api_spec.ex13
-rw-r--r--lib/pleroma/web/api_spec/cast_and_validate.ex4
-rw-r--r--lib/pleroma/web/api_spec/helpers.ex6
-rw-r--r--lib/pleroma/web/api_spec/operations/account_operation.ex7
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/chat_operation.ex96
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/instance_document_operation.ex115
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/o_auth_app_operation.ex (renamed from lib/pleroma/web/api_spec/operations/admin/oauth_app_operation.ex)0
-rw-r--r--lib/pleroma/web/api_spec/operations/admin/relay_operation.ex12
-rw-r--r--lib/pleroma/web/api_spec/operations/chat_operation.ex3
-rw-r--r--lib/pleroma/web/api_spec/operations/custom_emoji_operation.ex2
-rw-r--r--lib/pleroma/web/api_spec/operations/emoji_reaction_operation.ex2
-rw-r--r--lib/pleroma/web/api_spec/operations/list_operation.ex21
-rw-r--r--lib/pleroma/web/api_spec/operations/pleroma_emoji_file_operation.ex139
-rw-r--r--lib/pleroma/web/api_spec/operations/pleroma_emoji_pack_operation.ex123
-rw-r--r--lib/pleroma/web/api_spec/operations/user_import_operation.ex80
-rw-r--r--lib/pleroma/web/api_spec/schemas/chat.ex2
-rw-r--r--lib/pleroma/web/api_spec/schemas/chat_message.ex3
-rw-r--r--lib/pleroma/web/api_spec/schemas/scheduled_status.ex4
-rw-r--r--lib/pleroma/web/api_spec/schemas/status.ex2
-rw-r--r--lib/pleroma/web/auth/pleroma_authenticator.ex4
-rw-r--r--lib/pleroma/web/auth/totp_authenticator.ex2
-rw-r--r--lib/pleroma/web/common_api.ex573
-rw-r--r--lib/pleroma/web/common_api/activity_draft.ex2
-rw-r--r--lib/pleroma/web/common_api/common_api.ex556
-rw-r--r--lib/pleroma/web/common_api/utils.ex13
-rw-r--r--lib/pleroma/web/controller_helper.ex20
-rw-r--r--lib/pleroma/web/endpoint.ex58
-rw-r--r--lib/pleroma/web/fallback/redirect_controller.ex108
-rw-r--r--lib/pleroma/web/fallback_redirect_controller.ex108
-rw-r--r--lib/pleroma/web/fed_sockets.ex185
-rw-r--r--lib/pleroma/web/fed_sockets/fed_registry.ex185
-rw-r--r--lib/pleroma/web/fed_sockets/fed_socket.ex137
-rw-r--r--lib/pleroma/web/fed_sockets/fetch_registry.ex151
-rw-r--r--lib/pleroma/web/fed_sockets/incoming_handler.ex88
-rw-r--r--lib/pleroma/web/fed_sockets/ingester_worker.ex33
-rw-r--r--lib/pleroma/web/fed_sockets/outgoing_handler.ex151
-rw-r--r--lib/pleroma/web/fed_sockets/socket_info.ex52
-rw-r--r--lib/pleroma/web/fed_sockets/supervisor.ex59
-rw-r--r--lib/pleroma/web/federator.ex111
-rw-r--r--lib/pleroma/web/federator/federator.ex105
-rw-r--r--lib/pleroma/web/feed/tag_controller.ex17
-rw-r--r--lib/pleroma/web/feed/user_controller.ex32
-rw-r--r--lib/pleroma/web/instance_document.ex62
-rw-r--r--lib/pleroma/web/mailer/subscription_controller.ex4
-rw-r--r--lib/pleroma/web/masto_fe_controller.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex8
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/app_controller.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/auth_controller.ex12
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/conversation_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/custom_emoji_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/filter_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/follow_request_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/instance_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/list_controller.ex8
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/marker_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/media_controller.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/notification_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/poll_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/report_controller.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/scheduled_activity_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/search_controller.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/status_controller.ex19
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/subscription_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex6
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex14
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex33
-rw-r--r--lib/pleroma/web/mastodon_api/websocket_handler.ex10
-rw-r--r--lib/pleroma/web/media_proxy.ex186
-rw-r--r--lib/pleroma/web/media_proxy/invalidation.ex4
-rw-r--r--lib/pleroma/web/media_proxy/invalidation/http.ex40
-rw-r--r--lib/pleroma/web/media_proxy/invalidation/script.ex (renamed from lib/pleroma/web/media_proxy/invalidations/script.ex)0
-rw-r--r--lib/pleroma/web/media_proxy/invalidations/http.ex40
-rw-r--r--lib/pleroma/web/media_proxy/media_proxy.ex127
-rw-r--r--lib/pleroma/web/media_proxy/media_proxy_controller.ex195
-rw-r--r--lib/pleroma/web/metadata/opengraph.ex119
-rw-r--r--lib/pleroma/web/metadata/providers/feed.ex (renamed from lib/pleroma/web/metadata/feed.ex)0
-rw-r--r--lib/pleroma/web/metadata/providers/open_graph.ex119
-rw-r--r--lib/pleroma/web/metadata/providers/provider.ex (renamed from lib/pleroma/web/metadata/provider.ex)0
-rw-r--r--lib/pleroma/web/metadata/providers/rel_me.ex (renamed from lib/pleroma/web/metadata/rel_me.ex)0
-rw-r--r--lib/pleroma/web/metadata/providers/restrict_indexing.ex24
-rw-r--r--lib/pleroma/web/metadata/providers/twitter_card.ex112
-rw-r--r--lib/pleroma/web/metadata/restrict_indexing.ex25
-rw-r--r--lib/pleroma/web/metadata/twitter_card.ex112
-rw-r--r--lib/pleroma/web/metadata/utils.ex2
-rw-r--r--lib/pleroma/web/mongoose_im/mongoose_im_controller.ex46
-rw-r--r--lib/pleroma/web/mongooseim/mongoose_im_controller.ex46
-rw-r--r--lib/pleroma/web/o_auth.ex (renamed from lib/pleroma/web/oauth.ex)0
-rw-r--r--lib/pleroma/web/o_auth/app.ex (renamed from lib/pleroma/web/oauth/app.ex)0
-rw-r--r--lib/pleroma/web/o_auth/authorization.ex (renamed from lib/pleroma/web/oauth/authorization.ex)0
-rw-r--r--lib/pleroma/web/o_auth/fallback_controller.ex (renamed from lib/pleroma/web/oauth/fallback_controller.ex)0
-rw-r--r--lib/pleroma/web/o_auth/mfa_controller.ex (renamed from lib/pleroma/web/oauth/mfa_controller.ex)0
-rw-r--r--lib/pleroma/web/o_auth/mfa_view.ex (renamed from lib/pleroma/web/oauth/mfa_view.ex)0
-rw-r--r--lib/pleroma/web/o_auth/o_auth_controller.ex613
-rw-r--r--lib/pleroma/web/o_auth/o_auth_view.ex (renamed from lib/pleroma/web/oauth/oauth_view.ex)0
-rw-r--r--lib/pleroma/web/o_auth/scopes.ex76
-rw-r--r--lib/pleroma/web/o_auth/token.ex135
-rw-r--r--lib/pleroma/web/o_auth/token/query.ex49
-rw-r--r--lib/pleroma/web/o_auth/token/strategy/refresh_token.ex58
-rw-r--r--lib/pleroma/web/o_auth/token/strategy/revoke.ex (renamed from lib/pleroma/web/oauth/token/strategy/revoke.ex)0
-rw-r--r--lib/pleroma/web/o_auth/token/utils.ex (renamed from lib/pleroma/web/oauth/token/utils.ex)0
-rw-r--r--lib/pleroma/web/o_status/o_status_controller.ex144
-rw-r--r--lib/pleroma/web/oauth/oauth_controller.ex610
-rw-r--r--lib/pleroma/web/oauth/scopes.ex76
-rw-r--r--lib/pleroma/web/oauth/token.ex126
-rw-r--r--lib/pleroma/web/oauth/token/clean_worker.ex38
-rw-r--r--lib/pleroma/web/oauth/token/query.ex55
-rw-r--r--lib/pleroma/web/oauth/token/strategy/refresh_token.ex58
-rw-r--r--lib/pleroma/web/ostatus/ostatus_controller.ex151
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/account_controller.ex11
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/chat_controller.ex73
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/conversation_controller.ex2
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/emoji_file_controller.ex137
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/emoji_pack_controller.ex125
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/emoji_reaction_controller.ex2
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex12
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/notification_controller.ex8
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/scrobble_controller.ex2
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller.ex2
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex61
-rw-r--r--lib/pleroma/web/pleroma_api/views/scrobble_view.ex4
-rw-r--r--lib/pleroma/web/plug.ex8
-rw-r--r--lib/pleroma/web/plugs/admin_secret_authentication_plug.ex60
-rw-r--r--lib/pleroma/web/plugs/authentication_plug.ex79
-rw-r--r--lib/pleroma/web/plugs/basic_auth_decoder_plug.ex25
-rw-r--r--lib/pleroma/web/plugs/cache.ex136
-rw-r--r--lib/pleroma/web/plugs/digest_plug.ex (renamed from lib/pleroma/plugs/digest.ex)0
-rw-r--r--lib/pleroma/web/plugs/ensure_authenticated_plug.ex41
-rw-r--r--lib/pleroma/web/plugs/ensure_public_or_authenticated_plug.ex35
-rw-r--r--lib/pleroma/web/plugs/ensure_user_key_plug.ex18
-rw-r--r--lib/pleroma/web/plugs/expect_authenticated_check_plug.ex20
-rw-r--r--lib/pleroma/web/plugs/expect_public_or_authenticated_check_plug.ex21
-rw-r--r--lib/pleroma/web/plugs/federating_plug.ex32
-rw-r--r--lib/pleroma/web/plugs/frontend_static.ex59
-rw-r--r--lib/pleroma/web/plugs/http_security_plug.ex225
-rw-r--r--lib/pleroma/web/plugs/http_signature_plug.ex (renamed from lib/pleroma/plugs/http_signature.ex)0
-rw-r--r--lib/pleroma/web/plugs/idempotency_plug.ex84
-rw-r--r--lib/pleroma/web/plugs/instance_static.ex53
-rw-r--r--lib/pleroma/web/plugs/legacy_authentication_plug.ex41
-rw-r--r--lib/pleroma/web/plugs/mapped_signature_to_identity_plug.ex (renamed from lib/pleroma/plugs/mapped_signature_to_identity_plug.ex)0
-rw-r--r--lib/pleroma/web/plugs/o_auth_plug.ex120
-rw-r--r--lib/pleroma/web/plugs/o_auth_scopes_plug.ex77
-rw-r--r--lib/pleroma/web/plugs/plug_helper.ex40
-rw-r--r--lib/pleroma/web/plugs/rate_limiter.ex267
-rw-r--r--lib/pleroma/web/plugs/rate_limiter/limiter_supervisor.ex54
-rw-r--r--lib/pleroma/web/plugs/rate_limiter/supervisor.ex20
-rw-r--r--lib/pleroma/web/plugs/remote_ip.ex48
-rw-r--r--lib/pleroma/web/plugs/session_authentication_plug.ex21
-rw-r--r--lib/pleroma/web/plugs/set_format_plug.ex24
-rw-r--r--lib/pleroma/web/plugs/set_locale_plug.ex63
-rw-r--r--lib/pleroma/web/plugs/set_user_session_id_plug.ex19
-rw-r--r--lib/pleroma/web/plugs/static_fe_plug.ex26
-rw-r--r--lib/pleroma/web/plugs/trailing_format_plug.ex42
-rw-r--r--lib/pleroma/web/plugs/uploaded_media.ex107
-rw-r--r--lib/pleroma/web/plugs/user_enabled_plug.ex23
-rw-r--r--lib/pleroma/web/plugs/user_fetcher_plug.ex21
-rw-r--r--lib/pleroma/web/plugs/user_is_admin_plug.ex24
-rw-r--r--lib/pleroma/web/preload/instance.ex50
-rw-r--r--lib/pleroma/web/preload/providers/instance.ex59
-rw-r--r--lib/pleroma/web/preload/providers/provider.ex (renamed from lib/pleroma/web/preload/provider.ex)0
-rw-r--r--lib/pleroma/web/preload/providers/timelines.ex (renamed from lib/pleroma/web/preload/timelines.ex)0
-rw-r--r--lib/pleroma/web/preload/providers/user.ex (renamed from lib/pleroma/web/preload/user.ex)0
-rw-r--r--lib/pleroma/web/push.ex (renamed from lib/pleroma/web/push/push.ex)0
-rw-r--r--lib/pleroma/web/push/impl.ex12
-rw-r--r--lib/pleroma/web/rel_me.ex15
-rw-r--r--lib/pleroma/web/rich_media/helpers.ex24
-rw-r--r--lib/pleroma/web/rich_media/parser.ex72
-rw-r--r--lib/pleroma/web/rich_media/parser/ttl.ex7
-rw-r--r--lib/pleroma/web/rich_media/parser/ttl/aws_signed_url.ex50
-rw-r--r--lib/pleroma/web/rich_media/parsers/o_embed.ex (renamed from lib/pleroma/web/rich_media/parsers/oembed_parser.ex)0
-rw-r--r--lib/pleroma/web/rich_media/parsers/ttl/aws_signed_url.ex46
-rw-r--r--lib/pleroma/web/rich_media/parsers/ttl/ttl.ex3
-rw-r--r--lib/pleroma/web/router.ex147
-rw-r--r--lib/pleroma/web/static_fe/static_fe_controller.ex177
-rw-r--r--lib/pleroma/web/streamer.ex331
-rw-r--r--lib/pleroma/web/streamer/streamer.ex295
-rw-r--r--lib/pleroma/web/templates/layout/app.html.eex2
-rw-r--r--lib/pleroma/web/templates/layout/email_styled.html.eex2
-rw-r--r--lib/pleroma/web/templates/layout/metadata_player.html.eex2
-rw-r--r--lib/pleroma/web/templates/layout/static_fe.html.eex2
-rw-r--r--lib/pleroma/web/twitter_api/controller.ex100
-rw-r--r--lib/pleroma/web/twitter_api/controllers/remote_follow_controller.ex7
-rw-r--r--lib/pleroma/web/twitter_api/controllers/util_controller.ex45
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api_controller.ex100
-rw-r--r--lib/pleroma/web/twitter_api/views/util_view.ex6
-rw-r--r--lib/pleroma/web/views/email_view.ex4
-rw-r--r--lib/pleroma/web/views/mailer/subscription_view.ex4
-rw-r--r--lib/pleroma/web/web.ex239
-rw-r--r--lib/pleroma/web/web_finger.ex (renamed from lib/pleroma/web/web_finger/web_finger.ex)0
-rw-r--r--lib/pleroma/web/web_finger/web_finger_controller.ex4
-rw-r--r--lib/pleroma/web/xml.ex (renamed from lib/pleroma/web/xml/xml.ex)0
-rw-r--r--lib/pleroma/workers/background_worker.ex24
-rw-r--r--lib/pleroma/workers/cron/clear_oauth_token_worker.ex23
-rw-r--r--lib/pleroma/workers/cron/purge_expired_activities_worker.ex48
-rw-r--r--lib/pleroma/workers/cron/stats_worker.ex17
-rw-r--r--lib/pleroma/workers/purge_expired_activity.ex72
-rw-r--r--lib/pleroma/workers/purge_expired_token.ex29
-rw-r--r--lib/pleroma/xml_builder.ex (renamed from lib/xml_builder.ex)0
-rw-r--r--lib/transports.ex89
-rw-r--r--mix.exs25
-rw-r--r--mix.lock41
-rw-r--r--priv/gettext/es/LC_MESSAGES/errors.po586
-rw-r--r--priv/gettext/zh_Hans/LC_MESSAGES/errors.po580
-rw-r--r--priv/repo/migrations/20200824115541_rename_activity_expiration_setting.exs13
-rw-r--r--priv/repo/migrations/20200825061316_move_activity_expirations_to_oban.exs28
-rw-r--r--priv/repo/migrations/20200825093037_drop_activity_expirations_table.exs7
-rw-r--r--priv/repo/migrations/20200831142509_chat_constraints.exs22
-rw-r--r--priv/repo/migrations/20200901061256_ensure_bio_is_string.exs7
-rw-r--r--priv/repo/migrations/20200901061637_bio_set_not_null.exs10
-rw-r--r--priv/repo/migrations/20200905082737_rename_await_up_timeout_in_connections_pool.exs13
-rw-r--r--priv/repo/migrations/20200905091427_rename_timeout_in_pools.exs19
-rw-r--r--priv/repo/migrations/20200906072147_remove_cron_stats_worker_from_oban_config.exs19
-rw-r--r--priv/repo/migrations/20200907084956_remove_cron_clear_oauth_token_worker_from_oban_config.exs19
-rw-r--r--priv/repo/migrations/20200907092050_move_tokens_expiration_into_oban.exs38
-rw-r--r--priv/repo/migrations/20200910113106_remove_managed_config_from_db.exs27
-rw-r--r--priv/repo/migrations/20200911055909_remove_cron_jobs.exs20
-rw-r--r--priv/repo/migrations/20200914105638_delete_notification_without_activity.exs30
-rw-r--r--priv/repo/migrations/20200914105800_add_notification_constraints.exs23
-rw-r--r--priv/repo/migrations/20200919182636_remoteip_plug_rename.exs19
-rw-r--r--priv/repo/migrations/20200925065249_make_user_ids_ci.exs9
-rw-r--r--priv/repo/migrations/20200928145912_revert_citext_change.exs11
-rw-r--r--priv/repo/migrations/20200930082320_user_ur_is_index_part_three.exs8
-rw-r--r--priv/repo/migrations/20201013141127_refactor_locked_user_field.exs15
-rw-r--r--priv/static/adminfe/app.07a1f8db.css1
-rw-r--r--priv/static/adminfe/app.6fb984d1.css1
-rw-r--r--priv/static/adminfe/chunk-0171.aa11eafe.css1
-rw-r--r--priv/static/adminfe/chunk-03c5.f59788cf.css1
-rw-r--r--priv/static/adminfe/chunk-0598.d8f2b478.css1
-rw-r--r--priv/static/adminfe/chunk-0f09.66ca2a61.css1
-rw-r--r--priv/static/adminfe/chunk-176e.a3c8376d.css (renamed from priv/static/adminfe/chunk-176e.b7aa5351.css)0
-rw-r--r--priv/static/adminfe/chunk-19e2.934ad654.css1
-rw-r--r--priv/static/adminfe/chunk-28f8.0aae6427.css1
-rw-r--r--priv/static/adminfe/chunk-2d97.82cbb623.css1
-rw-r--r--priv/static/adminfe/chunk-3221.0ef79c67.css1
-rw-r--r--priv/static/adminfe/chunk-3365.201aa8e6.css1
-rw-r--r--priv/static/adminfe/chunk-342d.e342722b.css1
-rw-r--r--priv/static/adminfe/chunk-39ad.ba67c97f.css1
-rw-r--r--priv/static/adminfe/chunk-3ba2.63b1228d.css1
-rw-r--r--priv/static/adminfe/chunk-40a4.665332db.css1
-rw-r--r--priv/static/adminfe/chunk-4eb4.b72d16c3.css1
-rw-r--r--priv/static/adminfe/chunk-521f.b745ee5d.css1
-rw-r--r--priv/static/adminfe/chunk-546f.692d1ab2.css1
-rw-r--r--priv/static/adminfe/chunk-565e.8c036a6e.css1
-rw-r--r--priv/static/adminfe/chunk-60a9.7b5b9559.css1
-rw-r--r--priv/static/adminfe/chunk-654d.94689c39.css (renamed from priv/static/adminfe/chunk-654e.b2e16b59.css)0
-rw-r--r--priv/static/adminfe/chunk-68ea.81e11186.css1
-rw-r--r--priv/static/adminfe/chunk-68ea9.dac85813.css (renamed from priv/static/adminfe/chunk-68ea.7633295f.css)0
-rw-r--r--priv/static/adminfe/chunk-6e81.1c0f2da2.css (renamed from priv/static/adminfe/chunk-6e81.0e9e6d27.css)0
-rw-r--r--priv/static/adminfe/chunk-6e81.7e5babfc.css1
-rw-r--r--priv/static/adminfe/chunk-6e8c.ef26acfd.css1
-rw-r--r--priv/static/adminfe/chunk-7503.cc089ee4.css1
-rw-r--r--priv/static/adminfe/chunk-7c6b.365cbeda.css (renamed from priv/static/adminfe/chunk-0778.29be65e2.css)0
-rw-r--r--priv/static/adminfe/chunk-7c6b.b529c720.css1
-rw-r--r--priv/static/adminfe/chunk-850d.cc4f0ac6.css1
-rw-r--r--priv/static/adminfe/chunk-9043.3f527a93.css1
-rw-r--r--priv/static/adminfe/chunk-97e2.9f9fab0f.css1
-rw-r--r--priv/static/adminfe/chunk-9a72.786caeb3.css1
-rw-r--r--priv/static/adminfe/chunk-9d55.e2cb1409.css1
-rw-r--r--priv/static/adminfe/chunk-commons.c0eb3eb7.css (renamed from priv/static/adminfe/chunk-commons.a343b725.css)0
-rw-r--r--priv/static/adminfe/chunk-d34d.b0dd6fb4.css (renamed from priv/static/adminfe/chunk-6198.3c37d6af.css)0
-rw-r--r--priv/static/adminfe/chunk-d892.56863b19.css1
-rw-r--r--priv/static/adminfe/chunk-elementUI.40545a1f.css1
-rw-r--r--priv/static/adminfe/chunk-elementUI.f77689d7.css1
-rw-r--r--priv/static/adminfe/chunk-f625.25a6a4ae.css1
-rw-r--r--priv/static/adminfe/chunk-libs.5cf7f50a.css (renamed from priv/static/adminfe/chunk-libs.0380664d.css)0
-rw-r--r--priv/static/adminfe/index.html2
-rw-r--r--priv/static/adminfe/static/js/app.1df22cde.js2
-rw-r--r--priv/static/adminfe/static/js/app.1df22cde.js.map1
-rw-r--r--priv/static/adminfe/static/js/app.69891fda.js2
-rw-r--r--priv/static/adminfe/static/js/app.69891fda.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-0171.9e927b8a.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-0171.9e927b8a.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-03c5.1c694c49.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-03c5.1c694c49.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-16d0.6ce78978.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-16d0.6ce78978.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-16d0.fef0ce65.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-16d0.fef0ce65.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-176e.5c19378d.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-176e.5c19378d.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-176e.be050aba.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-176e.be050aba.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-2d97.079e9e64.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-2d97.079e9e64.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-3365.b73c30a8.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-3365.b73c30a8.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-342d.479e01dd.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-342d.479e01dd.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-40a4.5dc0e299.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-40a4.5dc0e299.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-5118.7c48ad58.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-5118.7c48ad58.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-521f.748b331d.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-521f.748b331d.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-546f.81668ba7.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-546f.81668ba7.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-565e.e1555105.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-565e.e1555105.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-60a9.22fe45f3.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-60a9.22fe45f3.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-654d.653b067f.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-654d.653b067f.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-654e.38dd4b85.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-654e.38dd4b85.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea.0dae7e55.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea.0dae7e55.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea.6d56674a.js26
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea.6d56674a.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea9.9821cd6a.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-68ea9.9821cd6a.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-6e81.6043af74.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-6e81.6043af74.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-6e81.ebe9039f.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-6e81.ebe9039f.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-6e8c.2aa335e0.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-6e8c.2aa335e0.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-7503.278e0031.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-7503.278e0031.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-7c6b.1ebeb0e4.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-7c6b.1ebeb0e4.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-7c6b.56a14571.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-7c6b.56a14571.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-850d.3e6102c2.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-850d.3e6102c2.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-97e2.c51fe6b0.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-97e2.c51fe6b0.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-9a72.41e843cd.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-9a72.41e843cd.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-9d55.7af22f45.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-9d55.7af22f45.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-commons.51fe2926.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-commons.51fe2926.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-commons.a6002038.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-commons.a6002038.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-d34d.0f06fe76.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-d34d.0f06fe76.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-d55e.f9bab96d.js270
-rw-r--r--priv/static/adminfe/static/js/chunk-d55e.f9bab96d.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-df62.6c5105a6.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-df62.6c5105a6.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-elementUI.21957ec8.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-elementUI.21957ec8.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-elementUI.8e5c404c.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-elementUI.8e5c404c.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-f625.29237434.js2
-rw-r--r--priv/static/adminfe/static/js/chunk-f625.29237434.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-libs.32ea9181.js73
-rw-r--r--priv/static/adminfe/static/js/chunk-libs.32ea9181.js.map1
-rw-r--r--priv/static/adminfe/static/js/chunk-libs.f842b12e.js73
-rw-r--r--priv/static/adminfe/static/js/chunk-libs.f842b12e.js.map1
-rw-r--r--priv/static/adminfe/static/js/oAJy.2d5429b2.js2
-rw-r--r--priv/static/adminfe/static/js/oAJy.2d5429b2.js.map1
-rw-r--r--priv/static/adminfe/static/js/oAJy.840fb1c2.js2
-rw-r--r--priv/static/adminfe/static/js/oAJy.840fb1c2.js.map1
-rw-r--r--priv/static/adminfe/static/js/runtime.04c4fa2f.js2
-rw-r--r--priv/static/adminfe/static/js/runtime.04c4fa2f.js.map1
-rw-r--r--priv/static/adminfe/static/js/runtime.8f631d12.js2
-rw-r--r--priv/static/adminfe/static/js/runtime.8f631d12.js.map1
-rw-r--r--priv/static/index.html2
-rw-r--r--priv/static/static/config.json3
-rw-r--r--priv/static/static/css/app.77b1644622e3bae24b6b.css246
-rw-r--r--priv/static/static/css/app.77b1644622e3bae24b6b.css.map1
-rw-r--r--priv/static/static/css/app.9a4c5ede37b2f0230836.css246
-rw-r--r--priv/static/static/css/app.9a4c5ede37b2f0230836.css.map1
-rw-r--r--priv/static/static/font/fontello.1600365488745.eotbin24796 -> 0 bytes
-rw-r--r--priv/static/static/font/fontello.1600365488745.svg140
-rw-r--r--priv/static/static/font/fontello.1600365488745.ttfbin24628 -> 0 bytes
-rw-r--r--priv/static/static/font/fontello.1600365488745.woffbin15108 -> 0 bytes
-rw-r--r--priv/static/static/font/fontello.1600365488745.woff2bin12736 -> 0 bytes
-rw-r--r--priv/static/static/fontello.1600365488745.css160
-rw-r--r--priv/static/static/fontello.json416
-rw-r--r--priv/static/static/js/10.46f441b948010eda4403.js2
-rw-r--r--priv/static/static/js/10.46f441b948010eda4403.js.map1
-rw-r--r--priv/static/static/js/10.46fbbdfaf0d4800f349b.js2
-rw-r--r--priv/static/static/js/10.46fbbdfaf0d4800f349b.js.map1
-rw-r--r--priv/static/static/js/11.708cc2513c53879a92cc.js2
-rw-r--r--priv/static/static/js/11.708cc2513c53879a92cc.js.map1
-rw-r--r--priv/static/static/js/11.8ff1ed54814f2d34cb3e.js2
-rw-r--r--priv/static/static/js/11.8ff1ed54814f2d34cb3e.js.map1
-rw-r--r--priv/static/static/js/12.13204bdd0ad5703a3ea3.js2
-rw-r--r--priv/static/static/js/12.13204bdd0ad5703a3ea3.js.map1
-rw-r--r--priv/static/static/js/12.b3bf0bc313861d6ec36b.js2
-rw-r--r--priv/static/static/js/12.b3bf0bc313861d6ec36b.js.map1
-rw-r--r--priv/static/static/js/13.adb8a942514d735722c4.js2
-rw-r--r--priv/static/static/js/13.adb8a942514d735722c4.js.map1
-rw-r--r--priv/static/static/js/13.e27c3eeddcc4b11c1f54.js2
-rw-r--r--priv/static/static/js/13.e27c3eeddcc4b11c1f54.js.map1
-rw-r--r--priv/static/static/js/14.273855b3e4e27ce80219.js2
-rw-r--r--priv/static/static/js/14.273855b3e4e27ce80219.js.map1
-rw-r--r--priv/static/static/js/14.d015d9b2ea16407e389c.js2
-rw-r--r--priv/static/static/js/14.d015d9b2ea16407e389c.js.map1
-rw-r--r--priv/static/static/js/15.19866e6a366ccf982284.js2
-rw-r--r--priv/static/static/js/15.19866e6a366ccf982284.js.map1
-rw-r--r--priv/static/static/js/15.afbe29b6665fcd015b2d.js2
-rw-r--r--priv/static/static/js/15.afbe29b6665fcd015b2d.js.map1
-rw-r--r--priv/static/static/js/16.38a984effd54736f6a2c.js2
-rw-r--r--priv/static/static/js/16.38a984effd54736f6a2c.js.map1
-rw-r--r--priv/static/static/js/16.5e3f20da470591d0cabf.js2
-rw-r--r--priv/static/static/js/16.5e3f20da470591d0cabf.js.map1
-rw-r--r--priv/static/static/js/17.44e90ef82ee2ef12dc3f.js2
-rw-r--r--priv/static/static/js/17.44e90ef82ee2ef12dc3f.js.map1
-rw-r--r--priv/static/static/js/17.9c25507194320db2e85b.js2
-rw-r--r--priv/static/static/js/17.9c25507194320db2e85b.js.map1
-rw-r--r--priv/static/static/js/18.94946caca48930c224c7.js2
-rw-r--r--priv/static/static/js/18.94946caca48930c224c7.js.map1
-rw-r--r--priv/static/static/js/18.9a5b877f94b2b53065e1.js2
-rw-r--r--priv/static/static/js/18.9a5b877f94b2b53065e1.js.map1
-rw-r--r--priv/static/static/js/19.1fd4da643df0abf89122.js2
-rw-r--r--priv/static/static/js/19.1fd4da643df0abf89122.js.map1
-rw-r--r--priv/static/static/js/19.233c81ac2c28d55e9f13.js2
-rw-r--r--priv/static/static/js/19.233c81ac2c28d55e9f13.js.map1
-rw-r--r--priv/static/static/js/2.422e6c756ac673a6fd44.js2
-rw-r--r--priv/static/static/js/2.422e6c756ac673a6fd44.js.map1
-rw-r--r--priv/static/static/js/2.e852a6b4b3bba752b838.js2
-rw-r--r--priv/static/static/js/2.e852a6b4b3bba752b838.js.map1
-rw-r--r--priv/static/static/js/20.818c38d27369c3a4d677.js2
-rw-r--r--priv/static/static/js/20.818c38d27369c3a4d677.js.map1
-rw-r--r--priv/static/static/js/20.a64fd29da59076399a27.js2
-rw-r--r--priv/static/static/js/20.a64fd29da59076399a27.js.map1
-rw-r--r--priv/static/static/js/21.243d9e6ebf469a2dc740.js2
-rw-r--r--priv/static/static/js/21.243d9e6ebf469a2dc740.js.map1
-rw-r--r--priv/static/static/js/21.ce4cda179d888ca6bc2a.js2
-rw-r--r--priv/static/static/js/21.ce4cda179d888ca6bc2a.js.map1
-rw-r--r--priv/static/static/js/22.2ea93c6cc569ef0256ab.js2
-rw-r--r--priv/static/static/js/22.2ea93c6cc569ef0256ab.js.map1
-rw-r--r--priv/static/static/js/22.e20ef7e5fefc0964cdd1.js2
-rw-r--r--priv/static/static/js/22.e20ef7e5fefc0964cdd1.js.map1
-rw-r--r--priv/static/static/js/23.614a35f9ded445292f4a.js2
-rw-r--r--priv/static/static/js/23.614a35f9ded445292f4a.js.map1
-rw-r--r--priv/static/static/js/23.a57a7845cc20fafd06d1.js2
-rw-r--r--priv/static/static/js/23.a57a7845cc20fafd06d1.js.map1
-rw-r--r--priv/static/static/js/24.35eb55a657b5485f8491.js2
-rw-r--r--priv/static/static/js/24.35eb55a657b5485f8491.js.map1
-rw-r--r--priv/static/static/js/24.6ae9ca51e51e023afbe4.js2
-rw-r--r--priv/static/static/js/24.6ae9ca51e51e023afbe4.js.map1
-rw-r--r--priv/static/static/js/25.5a9efe20e3ae1352e6d2.js2
-rw-r--r--priv/static/static/js/25.5a9efe20e3ae1352e6d2.js.map1
-rw-r--r--priv/static/static/js/25.eadae0d48ee5be52a16c.js2
-rw-r--r--priv/static/static/js/25.eadae0d48ee5be52a16c.js.map1
-rw-r--r--priv/static/static/js/26.8fd0027b982c4bcdc88f.js2
-rw-r--r--priv/static/static/js/26.8fd0027b982c4bcdc88f.js.map1
-rw-r--r--priv/static/static/js/26.cf13231d524e5ca3b3e6.js2
-rw-r--r--priv/static/static/js/26.cf13231d524e5ca3b3e6.js.map1
-rw-r--r--priv/static/static/js/27.6d90a54efba08d261d69.js2
-rw-r--r--priv/static/static/js/27.6d90a54efba08d261d69.js.map1
-rw-r--r--priv/static/static/js/27.fca8d4f6e444bd14f376.js2
-rw-r--r--priv/static/static/js/27.fca8d4f6e444bd14f376.js.map1
-rw-r--r--priv/static/static/js/28.e0f9f164e0bfd890dc61.js2
-rw-r--r--priv/static/static/js/28.e0f9f164e0bfd890dc61.js.map1
-rw-r--r--priv/static/static/js/28.f1353aa382a104262d1a.js2
-rw-r--r--priv/static/static/js/28.f1353aa382a104262d1a.js.map1
-rw-r--r--priv/static/static/js/29.0b69359f0fe5c0785746.js2
-rw-r--r--priv/static/static/js/29.0b69359f0fe5c0785746.js.map1
-rw-r--r--priv/static/static/js/29.39c1e87a689c840395b2.js2
-rw-r--r--priv/static/static/js/29.39c1e87a689c840395b2.js.map1
-rw-r--r--priv/static/static/js/3.7d21accf4e5bd07e3ebf.js21
-rw-r--r--priv/static/static/js/3.7d21accf4e5bd07e3ebf.js.map1
-rw-r--r--priv/static/static/js/3.a0df8a5bcd120d1f8581.js21
-rw-r--r--priv/static/static/js/3.a0df8a5bcd120d1f8581.js.map1
-rw-r--r--priv/static/static/js/30.64736585965c63c2b5d4.js2
-rw-r--r--priv/static/static/js/30.64736585965c63c2b5d4.js.map1
-rw-r--r--priv/static/static/js/30.fce58be0b52ca3e32fa4.js2
-rw-r--r--priv/static/static/js/30.fce58be0b52ca3e32fa4.js.map1
-rw-r--r--priv/static/static/js/4.4cde7fdd1fe6bf2a9499.js2
-rw-r--r--priv/static/static/js/4.4cde7fdd1fe6bf2a9499.js.map1
-rw-r--r--priv/static/static/js/4.5719922a4e807145346d.js2
-rw-r--r--priv/static/static/js/4.5719922a4e807145346d.js.map1
-rw-r--r--priv/static/static/js/5.2e165bc072548e533dd4.js2
-rw-r--r--priv/static/static/js/5.2e165bc072548e533dd4.js.map1
-rw-r--r--priv/static/static/js/5.cf05c5ddbdbac890ae35.js2
-rw-r--r--priv/static/static/js/5.cf05c5ddbdbac890ae35.js.map1
-rw-r--r--priv/static/static/js/6.260ccd84f8cd2af27970.js2
-rw-r--r--priv/static/static/js/6.260ccd84f8cd2af27970.js.map1
-rw-r--r--priv/static/static/js/6.ecfd3302a692de148391.js2
-rw-r--r--priv/static/static/js/6.ecfd3302a692de148391.js.map1
-rw-r--r--priv/static/static/js/7.1c41eff6cfc75a00bde4.js2
-rw-r--r--priv/static/static/js/7.1c41eff6cfc75a00bde4.js.map1
-rw-r--r--priv/static/static/js/7.dd44c3d58fb9dced093d.js2
-rw-r--r--priv/static/static/js/7.dd44c3d58fb9dced093d.js.map1
-rw-r--r--priv/static/static/js/8.636322a87bb10a1754f8.js2
-rw-r--r--priv/static/static/js/8.636322a87bb10a1754f8.js.map1
-rw-r--r--priv/static/static/js/8.9b35c2fee24ab7481e00.js2
-rw-r--r--priv/static/static/js/8.9b35c2fee24ab7481e00.js.map1
-rw-r--r--priv/static/static/js/9.3a29094f1886648a0af3.js2
-rw-r--r--priv/static/static/js/9.3a29094f1886648a0af3.js.map1
-rw-r--r--priv/static/static/js/9.6010dbcce7b4d7c05a18.js2
-rw-r--r--priv/static/static/js/9.6010dbcce7b4d7c05a18.js.map1
-rw-r--r--priv/static/static/js/app.45547c05212c403dd77c.js2
-rw-r--r--priv/static/static/js/app.45547c05212c403dd77c.js.map1
-rw-r--r--priv/static/static/js/app.826c44232e0a76bbd9ba.js2
-rw-r--r--priv/static/static/js/app.826c44232e0a76bbd9ba.js.map1
-rw-r--r--priv/static/static/js/vendors~app.90c4af83c1ae68f4cd95.js49
-rw-r--r--priv/static/static/js/vendors~app.90c4af83c1ae68f4cd95.js.map1
-rw-r--r--priv/static/static/js/vendors~app.952124344a84613dbac0.js64
-rw-r--r--priv/static/static/js/vendors~app.952124344a84613dbac0.js.map1
-rw-r--r--priv/static/static/logo.pngbin1304 -> 0 bytes
-rw-r--r--priv/static/static/logo.svg71
-rw-r--r--priv/static/static/terms-of-service.html2
-rw-r--r--priv/static/sw-pleroma.js10
-rw-r--r--priv/static/sw-pleroma.js.map2
-rw-r--r--priv/templates/sample_config.eex4
-rw-r--r--test/activity/ir/topics_test.exs141
-rw-r--r--test/activity_expiration_test.exs55
-rw-r--r--test/activity_test.exs243
-rw-r--r--test/application_requirements_test.exs146
-rw-r--r--test/chat_test.exs61
-rw-r--r--test/config/deprecation_warnings_test.exs65
-rw-r--r--test/credo/check/consistency/file_location.ex166
-rw-r--r--test/docs/generator_test.exs222
-rw-r--r--test/emails/admin_email_test.exs69
-rw-r--r--test/emoji_test.exs43
-rw-r--r--test/fixtures/23211.atom508
-rw-r--r--test/fixtures/config/temp.secret.exs4
-rw-r--r--test/fixtures/custom_instance_panel.html1
-rw-r--r--test/fixtures/cw_retweet.xml68
-rw-r--r--test/fixtures/delete.xml39
-rw-r--r--test/fixtures/dm.xml27
-rw-r--r--test/fixtures/emojis.zipbin0 -> 1446 bytes
-rw-r--r--test/fixtures/empty.zipbin0 -> 22 bytes
-rw-r--r--test/fixtures/favorite.xml65
-rw-r--r--test/fixtures/favorite_with_local_note.xml64
-rw-r--r--test/fixtures/follow.xml68
-rwxr-xr-xtest/fixtures/image.gifbin0 -> 1001718 bytes
-rwxr-xr-xtest/fixtures/image.pngbin0 -> 104426 bytes
-rw-r--r--test/fixtures/incoming_note_activity.xml42
-rw-r--r--test/fixtures/incoming_note_activity_answer.xml42
-rw-r--r--test/fixtures/incoming_reply_mastodon.xml29
-rw-r--r--test/fixtures/incoming_websub_gnusocial_attachments.xml59
-rw-r--r--test/fixtures/lambadalambda.atom479
-rw-r--r--test/fixtures/mastodon-note-cw.xml39
-rw-r--r--test/fixtures/mastodon-note-unlisted.xml38
-rw-r--r--test/fixtures/mastodon-post-activity-nsfw.json68
-rw-r--r--test/fixtures/mastodon-problematic.xml72
-rw-r--r--test/fixtures/mastodon_conversation.xml30
-rw-r--r--test/fixtures/mewmew_no_name.json46
-rw-r--r--test/fixtures/modules/runtime_module.ex2
-rw-r--r--test/fixtures/nil_mention_entry.xml52
-rw-r--r--test/fixtures/ostatus_incoming_post.xml57
-rw-r--r--test/fixtures/ostatus_incoming_post_tag.xml59
-rw-r--r--test/fixtures/ostatus_incoming_reply.xml60
-rw-r--r--test/fixtures/share-gs-local.xml99
-rw-r--r--test/fixtures/share-gs.xml99
-rw-r--r--test/fixtures/share.xml54
-rw-r--r--test/fixtures/spoofed-object.json26
-rw-r--r--test/fixtures/tesla_mock/7369654.atom44
-rw-r--r--test/fixtures/tesla_mock/admin@mastdon.example.org.json44
-rw-r--r--test/fixtures/tesla_mock/atarifrosch_feed.xml473
-rw-r--r--test/fixtures/tesla_mock/emelie.atom306
-rw-r--r--test/fixtures/tesla_mock/framatube.org-video.json2
-rw-r--r--test/fixtures/tesla_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml460
-rw-r--r--test/fixtures/tesla_mock/https___mamot.fr_users_Skruyb.atom342
-rw-r--r--test/fixtures/tesla_mock/https___mastodon.social_users_lambadalambda.atom464
-rw-r--r--test/fixtures/tesla_mock/https___osada.macgirvin.com_channel_mike.json3
-rw-r--r--test/fixtures/tesla_mock/https___pawoo.net_users_pekorino.atom231
-rw-r--r--test/fixtures/tesla_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml1
-rw-r--r--test/fixtures/tesla_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml54
-rw-r--r--test/fixtures/tesla_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml454
-rw-r--r--test/fixtures/tesla_mock/https___shitposter.club_notice_2827873.json1
-rw-r--r--test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml591
-rw-r--r--test/fixtures/tesla_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml719
-rw-r--r--test/fixtures/tesla_mock/sakamoto.atom1
-rw-r--r--test/fixtures/tesla_mock/sakamoto_eal_feed.atom1
-rw-r--r--test/fixtures/tesla_mock/shp@pleroma.soykaf.com.feed1
-rw-r--r--test/fixtures/tesla_mock/spc_5381.atom438
-rw-r--r--test/fixtures/tesla_mock/wedistribute-create-article.json1
-rw-r--r--test/fixtures/unfollow.xml68
-rw-r--r--test/instance_static/emoji/blobs.gg/blank.pngbin0 -> 95 bytes
-rw-r--r--test/instance_static/emoji/blobs.gg/pack.json11
-rw-r--r--test/integration/mastodon_websocket_test.exs128
-rw-r--r--test/marker_test.exs78
-rw-r--r--test/mfa/backup_codes_test.exs11
-rw-r--r--test/mfa/totp_test.exs17
-rw-r--r--test/migrations/20200716195806_autolinker_to_linkify_test.exs68
-rw-r--r--test/migrations/20200722185515_fix_malformed_formatter_config_test.exs66
-rw-r--r--test/migrations/20200724133313_move_welcome_settings_test.exs140
-rw-r--r--test/migrations/20200802170532_fix_legacy_tags_test.exs24
-rw-r--r--test/mix/pleroma_test.exs (renamed from test/tasks/pleroma_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/app_test.exs (renamed from test/tasks/app_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/config_test.exs189
-rw-r--r--test/mix/tasks/pleroma/count_statuses_test.exs (renamed from test/tasks/count_statuses_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/database_test.exs175
-rw-r--r--test/mix/tasks/pleroma/digest_test.exs60
-rw-r--r--test/mix/tasks/pleroma/ecto/migrate_test.exs (renamed from test/tasks/ecto/migrate_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/ecto/rollback_test.exs (renamed from test/tasks/ecto/rollback_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/ecto_test.exs (renamed from test/tasks/ecto/ecto_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/email_test.exs127
-rw-r--r--test/mix/tasks/pleroma/emoji_test.exs243
-rw-r--r--test/mix/tasks/pleroma/frontend_test.exs85
-rw-r--r--test/mix/tasks/pleroma/instance_test.exs99
-rw-r--r--test/mix/tasks/pleroma/refresh_counter_cache_test.exs (renamed from test/tasks/refresh_counter_cache_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/relay_test.exs180
-rw-r--r--test/mix/tasks/pleroma/robots_txt_test.exs (renamed from test/tasks/robots_txt_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/uploads_test.exs (renamed from test/tasks/uploads_test.exs)0
-rw-r--r--test/mix/tasks/pleroma/user_test.exs619
-rw-r--r--test/notification_test.exs1142
-rw-r--r--test/object/fetcher_test.exs233
-rw-r--r--test/object_test.exs402
-rw-r--r--test/pleroma/activity/ir/topics_test.exs145
-rw-r--r--test/pleroma/activity_test.exs234
-rw-r--r--test/pleroma/application_requirements_test.exs149
-rw-r--r--test/pleroma/bbs/handler_test.exs (renamed from test/bbs/handler_test.exs)0
-rw-r--r--test/pleroma/bookmark_test.exs (renamed from test/bookmark_test.exs)0
-rw-r--r--test/pleroma/captcha_test.exs (renamed from test/captcha_test.exs)0
-rw-r--r--test/pleroma/chat/message_reference_test.exs (renamed from test/chat/message_reference_test.exs)0
-rw-r--r--test/pleroma/chat_test.exs83
-rw-r--r--test/pleroma/config/deprecation_warnings_test.exs140
-rw-r--r--test/pleroma/config/holder_test.exs (renamed from test/config/holder_test.exs)0
-rw-r--r--test/pleroma/config/loader_test.exs (renamed from test/config/loader_test.exs)0
-rw-r--r--test/pleroma/config/transfer_task_test.exs (renamed from test/config/transfer_task_test.exs)0
-rw-r--r--test/pleroma/config_db_test.exs (renamed from test/config/config_db_test.exs)0
-rw-r--r--test/pleroma/config_test.exs (renamed from test/config_test.exs)0
-rw-r--r--test/pleroma/conversation/participation_test.exs (renamed from test/conversation/participation_test.exs)0
-rw-r--r--test/pleroma/conversation_test.exs (renamed from test/conversation_test.exs)0
-rw-r--r--test/pleroma/docs/generator_test.exs226
-rw-r--r--test/pleroma/earmark_renderer_test.exs (renamed from test/earmark_renderer_test.exs)0
-rw-r--r--test/pleroma/ecto_type/activity_pub/object_validators/date_time_test.exs36
-rw-r--r--test/pleroma/ecto_type/activity_pub/object_validators/object_id_test.exs41
-rw-r--r--test/pleroma/ecto_type/activity_pub/object_validators/recipients_test.exs31
-rw-r--r--test/pleroma/ecto_type/activity_pub/object_validators/safe_text_test.exs30
-rw-r--r--test/pleroma/emails/admin_email_test.exs69
-rw-r--r--test/pleroma/emails/mailer_test.exs (renamed from test/emails/mailer_test.exs)0
-rw-r--r--test/pleroma/emails/user_email_test.exs (renamed from test/emails/user_email_test.exs)0
-rw-r--r--test/pleroma/emoji/formatter_test.exs (renamed from test/emoji/formatter_test.exs)0
-rw-r--r--test/pleroma/emoji/loader_test.exs (renamed from test/emoji/loader_test.exs)0
-rw-r--r--test/pleroma/emoji/pack_test.exs93
-rw-r--r--test/pleroma/emoji_test.exs43
-rw-r--r--test/pleroma/filter_test.exs (renamed from test/filter_test.exs)0
-rw-r--r--test/pleroma/following_relationship_test.exs (renamed from test/following_relationship_test.exs)0
-rw-r--r--test/pleroma/formatter_test.exs (renamed from test/formatter_test.exs)0
-rw-r--r--test/pleroma/gun/connection_pool_test.exs (renamed from test/gun/conneciton_pool_test.exs)0
-rw-r--r--test/pleroma/healthcheck_test.exs (renamed from test/healthcheck_test.exs)0
-rw-r--r--test/pleroma/html_test.exs (renamed from test/html_test.exs)0
-rw-r--r--test/pleroma/http/adapter_helper/gun_test.exs (renamed from test/http/adapter_helper/gun_test.exs)0
-rw-r--r--test/pleroma/http/adapter_helper/hackney_test.exs (renamed from test/http/adapter_helper/hackney_test.exs)0
-rw-r--r--test/pleroma/http/adapter_helper_test.exs (renamed from test/http/adapter_helper_test.exs)0
-rw-r--r--test/pleroma/http/ex_aws_test.exs (renamed from test/http/ex_aws_test.exs)0
-rw-r--r--test/pleroma/http/request_builder_test.exs (renamed from test/http/request_builder_test.exs)0
-rw-r--r--test/pleroma/http/tzdata_test.exs (renamed from test/http/tzdata_test.exs)0
-rw-r--r--test/pleroma/http_test.exs (renamed from test/http_test.exs)0
-rw-r--r--test/pleroma/instances/instance_test.exs152
-rw-r--r--test/pleroma/instances_test.exs (renamed from test/web/instances/instances_test.exs)0
-rw-r--r--test/pleroma/integration/federation_test.exs (renamed from test/federation/federation_test.exs)0
-rw-r--r--test/pleroma/integration/mastodon_websocket_test.exs128
-rw-r--r--test/pleroma/job_queue_monitor_test.exs (renamed from test/job_queue_monitor_test.exs)0
-rw-r--r--test/pleroma/keys_test.exs (renamed from test/keys_test.exs)0
-rw-r--r--test/pleroma/list_test.exs (renamed from test/list_test.exs)0
-rw-r--r--test/pleroma/marker_test.exs78
-rw-r--r--test/pleroma/mfa/backup_codes_test.exs15
-rw-r--r--test/pleroma/mfa/totp_test.exs21
-rw-r--r--test/pleroma/mfa_test.exs (renamed from test/mfa_test.exs)0
-rw-r--r--test/pleroma/migration_helper/notification_backfill_test.exs (renamed from test/migration_helper/notification_backfill_test.exs)0
-rw-r--r--test/pleroma/moderation_log_test.exs (renamed from test/moderation_log_test.exs)0
-rw-r--r--test/pleroma/notification_test.exs1144
-rw-r--r--test/pleroma/object/containment_test.exs (renamed from test/object/containment_test.exs)0
-rw-r--r--test/pleroma/object/fetcher_test.exs266
-rw-r--r--test/pleroma/object_test.exs409
-rw-r--r--test/pleroma/otp_version_test.exs (renamed from test/otp_version_test.exs)0
-rw-r--r--test/pleroma/pagination_test.exs (renamed from test/pagination_test.exs)0
-rw-r--r--test/pleroma/registration_test.exs (renamed from test/registration_test.exs)0
-rw-r--r--test/pleroma/repo/migrations/autolinker_to_linkify_test.exs72
-rw-r--r--test/pleroma/repo/migrations/fix_legacy_tags_test.exs28
-rw-r--r--test/pleroma/repo/migrations/fix_malformed_formatter_config_test.exs70
-rw-r--r--test/pleroma/repo/migrations/move_welcome_settings_test.exs144
-rw-r--r--test/pleroma/repo_test.exs80
-rw-r--r--test/pleroma/report_note_test.exs (renamed from test/report_note_test.exs)0
-rw-r--r--test/pleroma/reverse_proxy_test.exs (renamed from test/reverse_proxy/reverse_proxy_test.exs)0
-rw-r--r--test/pleroma/runtime_test.exs12
-rw-r--r--test/pleroma/safe_jsonb_set_test.exs16
-rw-r--r--test/pleroma/scheduled_activity_test.exs (renamed from test/scheduled_activity_test.exs)0
-rw-r--r--test/pleroma/signature_test.exs (renamed from test/signature_test.exs)0
-rw-r--r--test/pleroma/stats_test.exs122
-rw-r--r--test/pleroma/upload/filter/anonymize_filename_test.exs42
-rw-r--r--test/pleroma/upload/filter/dedupe_test.exs32
-rw-r--r--test/pleroma/upload/filter/exiftool_test.exs42
-rw-r--r--test/pleroma/upload/filter/mogrifun_test.exs44
-rw-r--r--test/pleroma/upload/filter/mogrify_test.exs41
-rw-r--r--test/pleroma/upload/filter_test.exs33
-rw-r--r--test/pleroma/upload_test.exs255
-rw-r--r--test/pleroma/uploaders/local_test.exs55
-rw-r--r--test/pleroma/uploaders/s3_test.exs88
-rw-r--r--test/pleroma/user/import_test.exs76
-rw-r--r--test/pleroma/user/notification_setting_test.exs (renamed from test/user/notification_setting_test.exs)0
-rw-r--r--test/pleroma/user/query_test.exs37
-rw-r--r--test/pleroma/user/welcome_chat_message_test.exs (renamed from test/user/welcome_chat_massage_test.exs)0
-rw-r--r--test/pleroma/user/welcome_email_test.exs (renamed from test/user/welcome_email_test.exs)0
-rw-r--r--test/pleroma/user/welcome_message_test.exs (renamed from test/user/welcome_message_test.exs)0
-rw-r--r--test/pleroma/user_invite_token_test.exs (renamed from test/user_invite_token_test.exs)0
-rw-r--r--test/pleroma/user_relationship_test.exs (renamed from test/user_relationship_test.exs)0
-rw-r--r--test/pleroma/user_search_test.exs362
-rw-r--r--test/pleroma/user_test.exs2124
-rw-r--r--test/pleroma/utils_test.exs15
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_controller_test.exs1503
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_test.exs2277
-rw-r--r--test/pleroma/web/activity_pub/mrf/activity_expiration_policy_test.exs84
-rw-r--r--test/pleroma/web/activity_pub/mrf/anti_followbot_policy_test.exs (renamed from test/web/activity_pub/mrf/anti_followbot_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/anti_link_spam_policy_test.exs (renamed from test/web/activity_pub/mrf/anti_link_spam_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs (renamed from test/web/activity_pub/mrf/ensure_re_prepended_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy_test.exs60
-rw-r--r--test/pleroma/web/activity_pub/mrf/hellthread_policy_test.exs (renamed from test/web/activity_pub/mrf/hellthread_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/keyword_policy_test.exs (renamed from test/web/activity_pub/mrf/keyword_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/media_proxy_warming_policy_test.exs53
-rw-r--r--test/pleroma/web/activity_pub/mrf/mention_policy_test.exs (renamed from test/web/activity_pub/mrf/mention_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/no_placeholder_text_policy_test.exs (renamed from test/web/activity_pub/mrf/no_placeholder_text_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/normalize_markup_test.exs (renamed from test/web/activity_pub/mrf/normalize_markup_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs (renamed from test/web/activity_pub/mrf/object_age_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/reject_non_public_test.exs100
-rw-r--r--test/pleroma/web/activity_pub/mrf/simple_policy_test.exs (renamed from test/web/activity_pub/mrf/simple_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs (renamed from test/web/activity_pub/mrf/steal_emoji_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/subchain_policy_test.exs (renamed from test/web/activity_pub/mrf/subchain_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/tag_policy_test.exs123
-rw-r--r--test/pleroma/web/activity_pub/mrf/user_allow_list_policy_test.exs (renamed from test/web/activity_pub/mrf/user_allowlist_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf/vocabulary_policy_test.exs (renamed from test/web/activity_pub/mrf/vocabulary_policy_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/mrf_test.exs90
-rw-r--r--test/pleroma/web/activity_pub/object_validators/accept_validation_test.exs (renamed from test/web/activity_pub/object_validators/accept_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/announce_validation_test.exs106
-rw-r--r--test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs35
-rw-r--r--test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs74
-rw-r--r--test/pleroma/web/activity_pub/object_validators/block_validation_test.exs (renamed from test/web/activity_pub/object_validators/block_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs212
-rw-r--r--test/pleroma/web/activity_pub/object_validators/delete_validation_test.exs (renamed from test/web/activity_pub/object_validators/delete_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/emoji_react_handling_test.exs (renamed from test/web/activity_pub/object_validators/emoji_react_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/follow_validation_test.exs (renamed from test/web/activity_pub/object_validators/follow_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/like_validation_test.exs (renamed from test/web/activity_pub/object_validators/like_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/reject_validation_test.exs (renamed from test/web/activity_pub/object_validators/reject_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/undo_handling_test.exs (renamed from test/web/activity_pub/object_validators/undo_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/object_validators/update_handling_test.exs (renamed from test/web/activity_pub/object_validators/update_validation_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/pipeline_test.exs (renamed from test/web/activity_pub/pipeline_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/publisher_test.exs (renamed from test/web/activity_pub/publisher_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/relay_test.exs168
-rw-r--r--test/pleroma/web/activity_pub/side_effects_test.exs (renamed from test/web/activity_pub/side_effects_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs91
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/announce_handling_test.exs176
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/answer_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/article_handling_test.exs82
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/audio_handling_test.exs84
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/block_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/block_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/chat_message_test.exs (renamed from test/web/activity_pub/transmogrifier/chat_message_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/delete_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/emoji_react_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/emoji_react_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/event_handling_test.exs42
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs208
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/like_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/like_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs176
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs67
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/undo_handling_test.exs (renamed from test/web/activity_pub/transmogrifier/undo_handling_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs159
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs93
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier_test.exs1230
-rw-r--r--test/pleroma/web/activity_pub/utils_test.exs548
-rw-r--r--test/pleroma/web/activity_pub/views/object_view_test.exs (renamed from test/web/activity_pub/views/object_view_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/views/user_view_test.exs (renamed from test/web/activity_pub/views/user_view_test.exs)0
-rw-r--r--test/pleroma/web/activity_pub/visibility_test.exs (renamed from test/web/activity_pub/visibilty_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs2034
-rw-r--r--test/pleroma/web/admin_api/controllers/chat_controller_test.exs219
-rw-r--r--test/pleroma/web/admin_api/controllers/config_controller_test.exs (renamed from test/web/admin_api/controllers/config_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/instance_document_controller_test.exs106
-rw-r--r--test/pleroma/web/admin_api/controllers/invite_controller_test.exs (renamed from test/web/admin_api/controllers/invite_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs (renamed from test/web/admin_api/controllers/media_proxy_cache_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/o_auth_app_controller_test.exs (renamed from test/web/admin_api/controllers/oauth_app_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/relay_controller_test.exs (renamed from test/web/admin_api/controllers/relay_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/report_controller_test.exs (renamed from test/web/admin_api/controllers/report_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/controllers/status_controller_test.exs (renamed from test/web/admin_api/controllers/status_controller_test.exs)0
-rw-r--r--test/pleroma/web/admin_api/search_test.exs190
-rw-r--r--test/pleroma/web/admin_api/views/report_view_test.exs (renamed from test/web/admin_api/views/report_view_test.exs)0
-rw-r--r--test/pleroma/web/api_spec/schema_examples_test.exs (renamed from test/web/api_spec/schema_examples_test.exs)0
-rw-r--r--test/pleroma/web/auth/auth_controller_test.exs242
-rw-r--r--test/pleroma/web/auth/authenticator_test.exs (renamed from test/web/auth/authenticator_test.exs)0
-rw-r--r--test/pleroma/web/auth/basic_auth_test.exs (renamed from test/web/auth/basic_auth_test.exs)0
-rw-r--r--test/pleroma/web/auth/pleroma_authenticator_test.exs (renamed from test/web/auth/pleroma_authenticator_test.exs)0
-rw-r--r--test/pleroma/web/auth/totp_authenticator_test.exs (renamed from test/web/auth/totp_authenticator_test.exs)0
-rw-r--r--test/pleroma/web/chat_channel_test.exs41
-rw-r--r--test/pleroma/web/common_api/utils_test.exs (renamed from test/web/common_api/common_api_utils_test.exs)0
-rw-r--r--test/pleroma/web/common_api_test.exs1258
-rw-r--r--test/pleroma/web/endpoint/metrics_exporter_test.exs68
-rw-r--r--test/pleroma/web/fallback_test.exs (renamed from test/web/fallback_test.exs)0
-rw-r--r--test/pleroma/web/fed_sockets/fed_registry_test.exs124
-rw-r--r--test/pleroma/web/fed_sockets/fetch_registry_test.exs67
-rw-r--r--test/pleroma/web/fed_sockets/socket_info_test.exs118
-rw-r--r--test/pleroma/web/federator_test.exs (renamed from test/web/federator_test.exs)0
-rw-r--r--test/pleroma/web/feed/tag_controller_test.exs196
-rw-r--r--test/pleroma/web/feed/user_controller_test.exs275
-rw-r--r--test/pleroma/web/mastodon_api/controllers/account_controller_test.exs1536
-rw-r--r--test/pleroma/web/mastodon_api/controllers/app_controller_test.exs (renamed from test/web/mastodon_api/controllers/app_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs159
-rw-r--r--test/pleroma/web/mastodon_api/controllers/conversation_controller_test.exs (renamed from test/web/mastodon_api/controllers/conversation_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/custom_emoji_controller_test.exs (renamed from test/web/mastodon_api/controllers/custom_emoji_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/domain_block_controller_test.exs (renamed from test/web/mastodon_api/controllers/domain_block_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/filter_controller_test.exs (renamed from test/web/mastodon_api/controllers/filter_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs74
-rw-r--r--test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs (renamed from test/web/mastodon_api/controllers/instance_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/list_controller_test.exs176
-rw-r--r--test/pleroma/web/mastodon_api/controllers/marker_controller_test.exs131
-rw-r--r--test/pleroma/web/mastodon_api/controllers/media_controller_test.exs146
-rw-r--r--test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs (renamed from test/web/mastodon_api/controllers/notification_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/poll_controller_test.exs (renamed from test/web/mastodon_api/controllers/poll_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/report_controller_test.exs (renamed from test/web/mastodon_api/controllers/report_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/scheduled_activity_controller_test.exs (renamed from test/web/mastodon_api/controllers/scheduled_activity_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/search_controller_test.exs413
-rw-r--r--test/pleroma/web/mastodon_api/controllers/status_controller_test.exs1743
-rw-r--r--test/pleroma/web/mastodon_api/controllers/subscription_controller_test.exs (renamed from test/web/mastodon_api/controllers/subscription_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/suggestion_controller_test.exs (renamed from test/web/mastodon_api/controllers/suggestion_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs560
-rw-r--r--test/pleroma/web/mastodon_api/masto_fe_controller_test.exs85
-rw-r--r--test/pleroma/web/mastodon_api/mastodon_api_controller_test.exs (renamed from test/web/mastodon_api/mastodon_api_controller_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/mastodon_api_test.exs (renamed from test/web/mastodon_api/mastodon_api_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/update_credentials_test.exs529
-rw-r--r--test/pleroma/web/mastodon_api/views/account_view_test.exs575
-rw-r--r--test/pleroma/web/mastodon_api/views/conversation_view_test.exs (renamed from test/web/mastodon_api/views/conversation_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/list_view_test.exs (renamed from test/web/mastodon_api/views/list_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/marker_view_test.exs (renamed from test/web/mastodon_api/views/marker_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/notification_view_test.exs (renamed from test/web/mastodon_api/views/notification_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/poll_view_test.exs (renamed from test/web/mastodon_api/views/poll_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs68
-rw-r--r--test/pleroma/web/mastodon_api/views/status_view_test.exs (renamed from test/web/mastodon_api/views/status_view_test.exs)0
-rw-r--r--test/pleroma/web/mastodon_api/views/subscription_view_test.exs (renamed from test/web/mastodon_api/views/subscription_view_test.exs)0
-rw-r--r--test/pleroma/web/media_proxy/invalidation/http_test.exs43
-rw-r--r--test/pleroma/web/media_proxy/invalidation/script_test.exs30
-rw-r--r--test/pleroma/web/media_proxy/invalidation_test.exs68
-rw-r--r--test/pleroma/web/media_proxy/media_proxy_controller_test.exs342
-rw-r--r--test/pleroma/web/media_proxy_test.exs234
-rw-r--r--test/pleroma/web/metadata/player_view_test.exs (renamed from test/web/metadata/player_view_test.exs)0
-rw-r--r--test/pleroma/web/metadata/providers/feed_test.exs (renamed from test/web/metadata/feed_test.exs)0
-rw-r--r--test/pleroma/web/metadata/providers/open_graph_test.exs (renamed from test/web/metadata/opengraph_test.exs)0
-rw-r--r--test/pleroma/web/metadata/providers/rel_me_test.exs (renamed from test/web/metadata/rel_me_test.exs)0
-rw-r--r--test/pleroma/web/metadata/providers/restrict_indexing_test.exs27
-rw-r--r--test/pleroma/web/metadata/providers/twitter_card_test.exs (renamed from test/web/metadata/twitter_card_test.exs)0
-rw-r--r--test/pleroma/web/metadata/utils_test.exs (renamed from test/web/metadata/utils_test.exs)0
-rw-r--r--test/pleroma/web/metadata_test.exs49
-rw-r--r--test/pleroma/web/mongoose_im_controller_test.exs81
-rw-r--r--test/pleroma/web/node_info_test.exs (renamed from test/web/node_info_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/app_test.exs (renamed from test/web/oauth/app_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/authorization_test.exs (renamed from test/web/oauth/authorization_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/ldap_authorization_test.exs (renamed from test/web/oauth/ldap_authorization_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/mfa_controller_test.exs (renamed from test/web/oauth/mfa_controller_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/o_auth_controller_test.exs1232
-rw-r--r--test/pleroma/web/o_auth/token/utils_test.exs (renamed from test/web/oauth/token/utils_test.exs)0
-rw-r--r--test/pleroma/web/o_auth/token_test.exs72
-rw-r--r--test/pleroma/web/o_status/o_status_controller_test.exs340
-rw-r--r--test/pleroma/web/pleroma_api/controllers/account_controller_test.exs (renamed from test/web/pleroma_api/controllers/account_controller_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs410
-rw-r--r--test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs (renamed from test/web/pleroma_api/controllers/conversation_controller_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/controllers/emoji_file_controller_test.exs357
-rw-r--r--test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs604
-rw-r--r--test/pleroma/web/pleroma_api/controllers/emoji_reaction_controller_test.exs (renamed from test/web/pleroma_api/controllers/emoji_reaction_controller_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs73
-rw-r--r--test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs (renamed from test/web/pleroma_api/controllers/notification_controller_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs (renamed from test/web/pleroma_api/controllers/scrobble_controller_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs264
-rw-r--r--test/pleroma/web/pleroma_api/controllers/user_import_controller_test.exs235
-rw-r--r--test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs72
-rw-r--r--test/pleroma/web/pleroma_api/views/chat_view_test.exs (renamed from test/web/pleroma_api/views/chat_view_test.exs)0
-rw-r--r--test/pleroma/web/pleroma_api/views/scrobble_view_test.exs20
-rw-r--r--test/pleroma/web/plugs/admin_secret_authentication_plug_test.exs75
-rw-r--r--test/pleroma/web/plugs/authentication_plug_test.exs125
-rw-r--r--test/pleroma/web/plugs/basic_auth_decoder_plug_test.exs35
-rw-r--r--test/pleroma/web/plugs/cache_control_test.exs20
-rw-r--r--test/pleroma/web/plugs/cache_test.exs186
-rw-r--r--test/pleroma/web/plugs/ensure_authenticated_plug_test.exs96
-rw-r--r--test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs48
-rw-r--r--test/pleroma/web/plugs/ensure_user_key_plug_test.exs29
-rw-r--r--test/pleroma/web/plugs/federating_plug_test.exs31
-rw-r--r--test/pleroma/web/plugs/frontend_static_plug_test.exs77
-rw-r--r--test/pleroma/web/plugs/http_security_plug_test.exs (renamed from test/plugs/http_security_plug_test.exs)0
-rw-r--r--test/pleroma/web/plugs/http_signature_plug_test.exs (renamed from test/plugs/http_signature_plug_test.exs)0
-rw-r--r--test/pleroma/web/plugs/idempotency_plug_test.exs110
-rw-r--r--test/pleroma/web/plugs/instance_static_test.exs65
-rw-r--r--test/pleroma/web/plugs/legacy_authentication_plug_test.exs82
-rw-r--r--test/pleroma/web/plugs/mapped_signature_to_identity_plug_test.exs (renamed from test/plugs/mapped_identity_to_signature_plug_test.exs)0
-rw-r--r--test/pleroma/web/plugs/o_auth_plug_test.exs80
-rw-r--r--test/pleroma/web/plugs/o_auth_scopes_plug_test.exs210
-rw-r--r--test/pleroma/web/plugs/plug_helper_test.exs91
-rw-r--r--test/pleroma/web/plugs/rate_limiter_test.exs263
-rw-r--r--test/pleroma/web/plugs/remote_ip_test.exs108
-rw-r--r--test/pleroma/web/plugs/session_authentication_plug_test.exs63
-rw-r--r--test/pleroma/web/plugs/set_format_plug_test.exs38
-rw-r--r--test/pleroma/web/plugs/set_locale_plug_test.exs46
-rw-r--r--test/pleroma/web/plugs/set_user_session_id_plug_test.exs45
-rw-r--r--test/pleroma/web/plugs/uploaded_media_plug_test.exs43
-rw-r--r--test/pleroma/web/plugs/user_enabled_plug_test.exs59
-rw-r--r--test/pleroma/web/plugs/user_fetcher_plug_test.exs41
-rw-r--r--test/pleroma/web/plugs/user_is_admin_plug_test.exs37
-rw-r--r--test/pleroma/web/preload/providers/instance_test.exs56
-rw-r--r--test/pleroma/web/preload/providers/timeline_test.exs (renamed from test/web/preload/timeline_test.exs)0
-rw-r--r--test/pleroma/web/preload/providers/user_test.exs (renamed from test/web/preload/user_test.exs)0
-rw-r--r--test/pleroma/web/push/impl_test.exs344
-rw-r--r--test/pleroma/web/rel_me_test.exs (renamed from test/web/rel_me_test.exs)0
-rw-r--r--test/pleroma/web/rich_media/helpers_test.exs85
-rw-r--r--test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs82
-rw-r--r--test/pleroma/web/rich_media/parser_test.exs176
-rw-r--r--test/pleroma/web/rich_media/parsers/twitter_card_test.exs (renamed from test/web/rich_media/parsers/twitter_card_test.exs)0
-rw-r--r--test/pleroma/web/static_fe/static_fe_controller_test.exs231
-rw-r--r--test/pleroma/web/streamer_test.exs767
-rw-r--r--test/pleroma/web/twitter_api/controller_test.exs (renamed from test/web/twitter_api/twitter_api_controller_test.exs)0
-rw-r--r--test/pleroma/web/twitter_api/password_controller_test.exs81
-rw-r--r--test/pleroma/web/twitter_api/remote_follow_controller_test.exs350
-rw-r--r--test/pleroma/web/twitter_api/twitter_api_test.exs (renamed from test/web/twitter_api/twitter_api_test.exs)0
-rw-r--r--test/pleroma/web/twitter_api/util_controller_test.exs437
-rw-r--r--test/pleroma/web/uploader_controller_test.exs (renamed from test/web/uploader_controller_test.exs)0
-rw-r--r--test/pleroma/web/views/error_view_test.exs (renamed from test/web/views/error_view_test.exs)0
-rw-r--r--test/pleroma/web/web_finger/web_finger_controller_test.exs (renamed from test/web/web_finger/web_finger_controller_test.exs)0
-rw-r--r--test/pleroma/web/web_finger_test.exs (renamed from test/web/web_finger/web_finger_test.exs)0
-rw-r--r--test/pleroma/workers/cron/digest_emails_worker_test.exs (renamed from test/workers/cron/digest_emails_worker_test.exs)0
-rw-r--r--test/pleroma/workers/cron/new_users_digest_worker_test.exs (renamed from test/workers/cron/new_users_digest_worker_test.exs)0
-rw-r--r--test/pleroma/workers/purge_expired_activity_test.exs59
-rw-r--r--test/pleroma/workers/purge_expired_token_test.exs51
-rw-r--r--test/pleroma/workers/scheduled_activity_worker_test.exs (renamed from test/workers/scheduled_activity_worker_test.exs)0
-rw-r--r--test/pleroma/xml_builder_test.exs (renamed from test/xml_builder_test.exs)0
-rw-r--r--test/plugs/admin_secret_authentication_plug_test.exs75
-rw-r--r--test/plugs/authentication_plug_test.exs125
-rw-r--r--test/plugs/basic_auth_decoder_plug_test.exs35
-rw-r--r--test/plugs/cache_control_test.exs20
-rw-r--r--test/plugs/cache_test.exs186
-rw-r--r--test/plugs/ensure_authenticated_plug_test.exs96
-rw-r--r--test/plugs/ensure_public_or_authenticated_plug_test.exs48
-rw-r--r--test/plugs/ensure_user_key_plug_test.exs29
-rw-r--r--test/plugs/frontend_static_test.exs57
-rw-r--r--test/plugs/idempotency_plug_test.exs110
-rw-r--r--test/plugs/instance_static_test.exs65
-rw-r--r--test/plugs/legacy_authentication_plug_test.exs82
-rw-r--r--test/plugs/oauth_plug_test.exs80
-rw-r--r--test/plugs/oauth_scopes_plug_test.exs210
-rw-r--r--test/plugs/rate_limiter_test.exs263
-rw-r--r--test/plugs/remote_ip_test.exs75
-rw-r--r--test/plugs/session_authentication_plug_test.exs63
-rw-r--r--test/plugs/set_format_plug_test.exs38
-rw-r--r--test/plugs/set_locale_plug_test.exs46
-rw-r--r--test/plugs/set_user_session_id_plug_test.exs45
-rw-r--r--test/plugs/uploaded_media_plug_test.exs43
-rw-r--r--test/plugs/user_enabled_plug_test.exs59
-rw-r--r--test/plugs/user_fetcher_plug_test.exs41
-rw-r--r--test/plugs/user_is_admin_plug_test.exs37
-rw-r--r--test/repo_test.exs50
-rw-r--r--test/runtime_test.exs11
-rw-r--r--test/safe_jsonb_set_test.exs12
-rw-r--r--test/stats_test.exs119
-rw-r--r--test/support/captcha/mock.ex (renamed from test/support/captcha_mock.ex)0
-rw-r--r--test/support/channel_case.ex2
-rw-r--r--test/support/conn_case.ex25
-rw-r--r--test/support/data_case.ex15
-rw-r--r--test/support/factory.ex20
-rw-r--r--test/support/http_request_mock.ex364
-rw-r--r--test/support/web_push_http_client_mock.ex23
-rw-r--r--test/tasks/config_test.exs176
-rw-r--r--test/tasks/database_test.exs169
-rw-r--r--test/tasks/digest_test.exs56
-rw-r--r--test/tasks/email_test.exs54
-rw-r--r--test/tasks/emoji_test.exs239
-rw-r--r--test/tasks/frontend_test.exs78
-rw-r--r--test/tasks/instance_test.exs92
-rw-r--r--test/tasks/relay_test.exs106
-rw-r--r--test/tasks/user_test.exs557
-rw-r--r--test/upload/filter/anonymize_filename_test.exs42
-rw-r--r--test/upload/filter/dedupe_test.exs32
-rw-r--r--test/upload/filter/exiftool_test.exs42
-rw-r--r--test/upload/filter/mogrifun_test.exs44
-rw-r--r--test/upload/filter/mogrify_test.exs41
-rw-r--r--test/upload/filter_test.exs33
-rw-r--r--test/upload_test.exs287
-rw-r--r--test/uploaders/local_test.exs55
-rw-r--r--test/uploaders/s3_test.exs88
-rw-r--r--test/user_search_test.exs314
-rw-r--r--test/user_test.exs2144
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs1550
-rw-r--r--test/web/activity_pub/activity_pub_test.exs2136
-rw-r--r--test/web/activity_pub/mrf/activity_expiration_policy_test.exs84
-rw-r--r--test/web/activity_pub/mrf/mediaproxy_warming_policy_test.exs51
-rw-r--r--test/web/activity_pub/mrf/mrf_test.exs84
-rw-r--r--test/web/activity_pub/mrf/reject_non_public_test.exs100
-rw-r--r--test/web/activity_pub/mrf/tag_policy_test.exs123
-rw-r--r--test/web/activity_pub/object_validators/announce_validation_test.exs106
-rw-r--r--test/web/activity_pub/object_validators/attachment_validator_test.exs74
-rw-r--r--test/web/activity_pub/object_validators/chat_validation_test.exs211
-rw-r--r--test/web/activity_pub/object_validators/note_validator_test.exs35
-rw-r--r--test/web/activity_pub/object_validators/types/date_time_test.exs32
-rw-r--r--test/web/activity_pub/object_validators/types/object_id_test.exs41
-rw-r--r--test/web/activity_pub/object_validators/types/recipients_test.exs27
-rw-r--r--test/web/activity_pub/object_validators/types/safe_text_test.exs30
-rw-r--r--test/web/activity_pub/relay_test.exs128
-rw-r--r--test/web/activity_pub/transmogrifier/accept_handling_test.exs91
-rw-r--r--test/web/activity_pub/transmogrifier/announce_handling_test.exs172
-rw-r--r--test/web/activity_pub/transmogrifier/audio_handling_test.exs83
-rw-r--r--test/web/activity_pub/transmogrifier/event_handling_test.exs40
-rw-r--r--test/web/activity_pub/transmogrifier/follow_handling_test.exs208
-rw-r--r--test/web/activity_pub/transmogrifier/question_handling_test.exs125
-rw-r--r--test/web/activity_pub/transmogrifier/reject_handling_test.exs67
-rw-r--r--test/web/activity_pub/transmogrifier/user_update_handling_test.exs159
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs1379
-rw-r--r--test/web/activity_pub/utils_test.exs548
-rw-r--r--test/web/admin_api/controllers/admin_api_controller_test.exs1979
-rw-r--r--test/web/admin_api/search_test.exs181
-rw-r--r--test/web/auth/auth_test_controller_test.exs242
-rw-r--r--test/web/chat_channel_test.exs37
-rw-r--r--test/web/common_api/common_api_test.exs1140
-rw-r--r--test/web/feed/tag_controller_test.exs197
-rw-r--r--test/web/feed/user_controller_test.exs265
-rw-r--r--test/web/instances/instance_test.exs135
-rw-r--r--test/web/masto_fe_controller_test.exs85
-rw-r--r--test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs529
-rw-r--r--test/web/mastodon_api/controllers/account_controller_test.exs1533
-rw-r--r--test/web/mastodon_api/controllers/auth_controller_test.exs162
-rw-r--r--test/web/mastodon_api/controllers/follow_request_controller_test.exs74
-rw-r--r--test/web/mastodon_api/controllers/list_controller_test.exs158
-rw-r--r--test/web/mastodon_api/controllers/marker_controller_test.exs131
-rw-r--r--test/web/mastodon_api/controllers/media_controller_test.exs146
-rw-r--r--test/web/mastodon_api/controllers/search_controller_test.exs413
-rw-r--r--test/web/mastodon_api/controllers/status_controller_test.exs1704
-rw-r--r--test/web/mastodon_api/controllers/timeline_controller_test.exs552
-rw-r--r--test/web/mastodon_api/views/account_view_test.exs572
-rw-r--r--test/web/mastodon_api/views/scheduled_activity_view_test.exs68
-rw-r--r--test/web/media_proxy/invalidation_test.exs64
-rw-r--r--test/web/media_proxy/invalidations/http_test.exs39
-rw-r--r--test/web/media_proxy/invalidations/script_test.exs26
-rw-r--r--test/web/media_proxy/media_proxy_controller_test.exs121
-rw-r--r--test/web/media_proxy/media_proxy_test.exs175
-rw-r--r--test/web/metadata/metadata_test.exs34
-rw-r--r--test/web/metadata/restrict_indexing_test.exs21
-rw-r--r--test/web/mongooseim/mongoose_im_controller_test.exs81
-rw-r--r--test/web/oauth/oauth_controller_test.exs1232
-rw-r--r--test/web/oauth/token_test.exs85
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs338
-rw-r--r--test/web/pleroma_api/controllers/chat_controller_test.exs390
-rw-r--r--test/web/pleroma_api/controllers/emoji_pack_controller_test.exs861
-rw-r--r--test/web/pleroma_api/controllers/mascot_controller_test.exs73
-rw-r--r--test/web/pleroma_api/controllers/two_factor_authentication_controller_test.exs260
-rw-r--r--test/web/pleroma_api/views/chat/message_reference_view_test.exs72
-rw-r--r--test/web/pleroma_api/views/scrobble_view_test.exs20
-rw-r--r--test/web/plugs/federating_plug_test.exs31
-rw-r--r--test/web/plugs/plug_test.exs91
-rw-r--r--test/web/preload/instance_test.exs48
-rw-r--r--test/web/push/impl_test.exs344
-rw-r--r--test/web/rich_media/aws_signed_url_test.exs82
-rw-r--r--test/web/rich_media/helpers_test.exs121
-rw-r--r--test/web/rich_media/parser_test.exs178
-rw-r--r--test/web/static_fe/static_fe_controller_test.exs192
-rw-r--r--test/web/streamer/streamer_test.exs671
-rw-r--r--test/web/twitter_api/password_controller_test.exs81
-rw-r--r--test/web/twitter_api/remote_follow_controller_test.exs350
-rw-r--r--test/web/twitter_api/util_controller_test.exs601
-rw-r--r--test/workers/cron/clear_oauth_token_worker_test.exs22
-rw-r--r--test/workers/cron/purge_expired_activities_worker_test.exs84
1234 files changed, 52480 insertions, 51217 deletions
diff --git a/.credo.exs b/.credo.exs
index 46d45d015..b85898af3 100644
--- a/.credo.exs
+++ b/.credo.exs
@@ -25,7 +25,7 @@
#
# If you create your own checks, you must specify the source files for
# them here, so they can be loaded by Credo before running the analysis.
- requires: [],
+ requires: ["./test/credo/check/consistency/file_location.ex"],
#
# Credo automatically checks for updates, like e.g. Hex does.
# You can disable this behaviour below:
@@ -71,7 +71,6 @@
# set this value to 0 (zero).
{Credo.Check.Design.TagTODO, exit_status: 0},
{Credo.Check.Design.TagFIXME, exit_status: 0},
-
{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100},
@@ -91,7 +90,6 @@
{Credo.Check.Readability.VariableNames},
{Credo.Check.Readability.Semicolons},
{Credo.Check.Readability.SpaceAfterCommas},
-
{Credo.Check.Refactor.DoubleBooleanNegation},
{Credo.Check.Refactor.CondStatements},
{Credo.Check.Refactor.CyclomaticComplexity},
@@ -102,7 +100,6 @@
{Credo.Check.Refactor.Nesting},
{Credo.Check.Refactor.PipeChainStart},
{Credo.Check.Refactor.UnlessWithElse},
-
{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
@@ -131,6 +128,7 @@
# Custom checks can be created using `mix credo.gen.check`.
#
+ {Credo.Check.Consistency.FileLocation}
]
}
]
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dc953a929..e65cae9d8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -25,6 +25,8 @@ before_script:
- apt-get update && apt-get install -y cmake
- mix local.hex --force
- mix local.rebar --force
+ - apt-get -qq update
+ - apt-get install -y libmagic-dev
build:
stage: build
@@ -59,7 +61,7 @@ unit-testing:
alias: postgres
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
script:
- - apt-get update && apt-get install -y libimage-exiftool-perl
+ - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
- mix deps.get
- mix ecto.create
- mix ecto.migrate
@@ -93,7 +95,7 @@ unit-testing-rum:
<<: *global_variables
RUM_ENABLED: "true"
script:
- - apt-get update && apt-get install -y libimage-exiftool-perl
+ - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
- mix deps.get
- mix ecto.create
- mix ecto.migrate
diff --git a/CC-BY-4.0 b/CC-BY-4.0
new file mode 100644
index 000000000..4ea99c213
--- /dev/null
+++ b/CC-BY-4.0
@@ -0,0 +1,395 @@
+Attribution 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+ Considerations for licensors: Our public licenses are
+ intended for use by those authorized to give the public
+ permission to use material in ways otherwise restricted by
+ copyright and certain other rights. Our licenses are
+ irrevocable. Licensors should read and understand the terms
+ and conditions of the license they choose before applying it.
+ Licensors should also secure all rights necessary before
+ applying our licenses so that the public can reuse the
+ material as expected. Licensors should clearly mark any
+ material not subject to the license. This includes other CC-
+ licensed material, or material used under an exception or
+ limitation to copyright. More considerations for licensors:
+ wiki.creativecommons.org/Considerations_for_licensors
+
+ Considerations for the public: By using one of our public
+ licenses, a licensor grants the public permission to use the
+ licensed material under specified terms and conditions. If
+ the licensor's permission is not necessary for any reason--for
+ example, because of any applicable exception or limitation to
+ copyright--then that use is not regulated by the license. Our
+ licenses grant only permissions under copyright and certain
+ other rights that a licensor has authority to grant. Use of
+ the licensed material may still be restricted for other
+ reasons, including because others have copyright or other
+ rights in the material. A licensor may make special requests,
+ such as asking that all changes be marked or described.
+ Although not required by our licenses, you are encouraged to
+ respect those requests where reasonable. More considerations
+ for the public:
+ wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution 4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution 4.0 International Public License ("Public License"). To the
+extent this Public License may be interpreted as a contract, You are
+granted the Licensed Rights in consideration of Your acceptance of
+these terms and conditions, and the Licensor grants You such rights in
+consideration of benefits the Licensor receives from making the
+Licensed Material available under these terms and conditions.
+
+
+Section 1 -- Definitions.
+
+ a. Adapted Material means material subject to Copyright and Similar
+ Rights that is derived from or based upon the Licensed Material
+ and in which the Licensed Material is translated, altered,
+ arranged, transformed, or otherwise modified in a manner requiring
+ permission under the Copyright and Similar Rights held by the
+ Licensor. For purposes of this Public License, where the Licensed
+ Material is a musical work, performance, or sound recording,
+ Adapted Material is always produced where the Licensed Material is
+ synched in timed relation with a moving image.
+
+ b. Adapter's License means the license You apply to Your Copyright
+ and Similar Rights in Your contributions to Adapted Material in
+ accordance with the terms and conditions of this Public License.
+
+ c. Copyright and Similar Rights means copyright and/or similar rights
+ closely related to copyright including, without limitation,
+ performance, broadcast, sound recording, and Sui Generis Database
+ Rights, without regard to how the rights are labeled or
+ categorized. For purposes of this Public License, the rights
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
+ Rights.
+
+ d. Effective Technological Measures means those measures that, in the
+ absence of proper authority, may not be circumvented under laws
+ fulfilling obligations under Article 11 of the WIPO Copyright
+ Treaty adopted on December 20, 1996, and/or similar international
+ agreements.
+
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
+ any other exception or limitation to Copyright and Similar Rights
+ that applies to Your use of the Licensed Material.
+
+ f. Licensed Material means the artistic or literary work, database,
+ or other material to which the Licensor applied this Public
+ License.
+
+ g. Licensed Rights means the rights granted to You subject to the
+ terms and conditions of this Public License, which are limited to
+ all Copyright and Similar Rights that apply to Your use of the
+ Licensed Material and that the Licensor has authority to license.
+
+ h. Licensor means the individual(s) or entity(ies) granting rights
+ under this Public License.
+
+ i. Share means to provide material to the public by any means or
+ process that requires permission under the Licensed Rights, such
+ as reproduction, public display, public performance, distribution,
+ dissemination, communication, or importation, and to make material
+ available to the public including in ways that members of the
+ public may access the material from a place and at a time
+ individually chosen by them.
+
+ j. Sui Generis Database Rights means rights other than copyright
+ resulting from Directive 96/9/EC of the European Parliament and of
+ the Council of 11 March 1996 on the legal protection of databases,
+ as amended and/or succeeded, as well as other essentially
+ equivalent rights anywhere in the world.
+
+ k. You means the individual or entity exercising the Licensed Rights
+ under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+ a. License grant.
+
+ 1. Subject to the terms and conditions of this Public License,
+ the Licensor hereby grants You a worldwide, royalty-free,
+ non-sublicensable, non-exclusive, irrevocable license to
+ exercise the Licensed Rights in the Licensed Material to:
+
+ a. reproduce and Share the Licensed Material, in whole or
+ in part; and
+
+ b. produce, reproduce, and Share Adapted Material.
+
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
+ Exceptions and Limitations apply to Your use, this Public
+ License does not apply, and You do not need to comply with
+ its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section
+ 6(a).
+
+ 4. Media and formats; technical modifications allowed. The
+ Licensor authorizes You to exercise the Licensed Rights in
+ all media and formats whether now known or hereafter created,
+ and to make technical modifications necessary to do so. The
+ Licensor waives and/or agrees not to assert any right or
+ authority to forbid You from making technical modifications
+ necessary to exercise the Licensed Rights, including
+ technical modifications necessary to circumvent Effective
+ Technological Measures. For purposes of this Public License,
+ simply making modifications authorized by this Section 2(a)
+ (4) never produces Adapted Material.
+
+ 5. Downstream recipients.
+
+ a. Offer from the Licensor -- Licensed Material. Every
+ recipient of the Licensed Material automatically
+ receives an offer from the Licensor to exercise the
+ Licensed Rights under the terms and conditions of this
+ Public License.
+
+ b. No downstream restrictions. You may not offer or impose
+ any additional or different terms or conditions on, or
+ apply any Effective Technological Measures to, the
+ Licensed Material if doing so restricts exercise of the
+ Licensed Rights by any recipient of the Licensed
+ Material.
+
+ 6. No endorsement. Nothing in this Public License constitutes or
+ may be construed as permission to assert or imply that You
+ are, or that Your use of the Licensed Material is, connected
+ with, or sponsored, endorsed, or granted official status by,
+ the Licensor or others designated to receive attribution as
+ provided in Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+ 1. Moral rights, such as the right of integrity, are not
+ licensed under this Public License, nor are publicity,
+ privacy, and/or other similar personality rights; however, to
+ the extent possible, the Licensor waives and/or agrees not to
+ assert any such rights held by the Licensor to the limited
+ extent necessary to allow You to exercise the Licensed
+ Rights, but not otherwise.
+
+ 2. Patent and trademark rights are not licensed under this
+ Public License.
+
+ 3. To the extent possible, the Licensor waives any right to
+ collect royalties from You for the exercise of the Licensed
+ Rights, whether directly or through a collecting society
+ under any voluntary or waivable statutory or compulsory
+ licensing scheme. In all other cases the Licensor expressly
+ reserves any right to collect such royalties.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+ a. Attribution.
+
+ 1. If You Share the Licensed Material (including in modified
+ form), You must:
+
+ a. retain the following if it is supplied by the Licensor
+ with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed
+ Material and any others designated to receive
+ attribution, in any reasonable manner requested by
+ the Licensor (including by pseudonym if
+ designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of
+ warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the
+ extent reasonably practicable;
+
+ b. indicate if You modified the Licensed Material and
+ retain an indication of any previous modifications; and
+
+ c. indicate the Licensed Material is licensed under this
+ Public License, and include the text of, or the URI or
+ hyperlink to, this Public License.
+
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
+ reasonable manner based on the medium, means, and context in
+ which You Share the Licensed Material. For example, it may be
+ reasonable to satisfy the conditions by providing a URI or
+ hyperlink to a resource that includes the required
+ information.
+
+ 3. If requested by the Licensor, You must remove any of the
+ information required by Section 3(a)(1)(A) to the extent
+ reasonably practicable.
+
+ 4. If You Share Adapted Material You produce, the Adapter's
+ License You apply must not prevent recipients of the Adapted
+ Material from complying with this Public License.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+ to extract, reuse, reproduce, and Share all or a substantial
+ portion of the contents of the database;
+
+ b. if You include all or a substantial portion of the database
+ contents in a database in which You have Sui Generis Database
+ Rights, then the database in which You have Sui Generis Database
+ Rights (but not its individual contents) is Adapted Material; and
+
+ c. You must comply with the conditions in Section 3(a) if You Share
+ all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+ c. The disclaimer of warranties and limitation of liability provided
+ above shall be interpreted in a manner that, to the extent
+ possible, most closely approximates an absolute disclaimer and
+ waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+ a. This Public License applies for the term of the Copyright and
+ Similar Rights licensed here. However, if You fail to comply with
+ this Public License, then Your rights under this Public License
+ terminate automatically.
+
+ b. Where Your right to use the Licensed Material has terminated under
+ Section 6(a), it reinstates:
+
+ 1. automatically as of the date the violation is cured, provided
+ it is cured within 30 days of Your discovery of the
+ violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+ For the avoidance of doubt, this Section 6(b) does not affect any
+ right the Licensor may have to seek remedies for Your violations
+ of this Public License.
+
+ c. For the avoidance of doubt, the Licensor may also offer the
+ Licensed Material under separate terms or conditions or stop
+ distributing the Licensed Material at any time; however, doing so
+ will not terminate this Public License.
+
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+ License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+ a. The Licensor shall not be bound by any additional or different
+ terms or conditions communicated by You unless expressly agreed.
+
+ b. Any arrangements, understandings, or agreements regarding the
+ Licensed Material not stated herein are separate from and
+ independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+ a. For the avoidance of doubt, this Public License does not, and
+ shall not be interpreted to, reduce, limit, restrict, or impose
+ conditions on any use of the Licensed Material that could lawfully
+ be made without permission under this Public License.
+
+ b. To the extent possible, if any provision of this Public License is
+ deemed unenforceable, it shall be automatically reformed to the
+ minimum extent necessary to make it enforceable. If the provision
+ cannot be reformed, it shall be severed from this Public License
+ without affecting the enforceability of the remaining terms and
+ conditions.
+
+ c. No term or condition of this Public License will be waived and no
+ failure to comply consented to unless expressly agreed to by the
+ Licensor.
+
+ d. Nothing in this Public License constitutes or may be interpreted
+ as a limitation upon, or waiver of, any privileges and immunities
+ that apply to the Licensor or You, including from the legal
+ processes of any jurisdiction or authority.
+
+
+=======================================================================
+
+Creative Commons is not a party to its public
+licenses. Notwithstanding, Creative Commons may elect to apply one of
+its public licenses to material it publishes and in those instances
+will be considered the “Licensor.” The text of the Creative Commons
+public licenses is dedicated to the public domain under the CC0 Public
+Domain Dedication. Except for the limited purpose of indicating that
+material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the
+public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f85cc302..051050a94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,70 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
+## [2.2.0] - 2020-11-12
+
+### Security
+- Fixed the possibility of using file uploads to spoof posts.
+
+### Changed
+
+- **Breaking** Requires `libmagic` (or `file`) to guess file types.
+- **Breaking:** App metrics endpoint (`/api/pleroma/app_metrics`) is disabled by default, check `docs/API/prometheus.md` on enabling and configuring.
+- **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
+- **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
+- Search: Users are now findable by their urls.
+- Renamed `:await_up_timeout` in `:connections_pool` namespace to `:connect_timeout`, old name is deprecated.
+- Renamed `:timeout` in `pools` namespace to `:recv_timeout`, old name is deprecated.
+- The `discoverable` field in the `User` struct will now add a NOINDEX metatag to profile pages when false.
+- Users with the `discoverable` field set to false will not show up in searches.
+- Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
+- Introduced optional dependencies on `ffmpeg`, `ImageMagick`, `exiftool` software packages. Please refer to `docs/installation/optional/media_graphics_packages.md`.
+- <details>
+ <summary>API Changes</summary>
+- API: Empty parameter values for integer parameters are now ignored in non-strict validaton mode.
+</details>
+
+### Removed
+
+- **Breaking:** `Pleroma.Workers.Cron.StatsWorker` setting from Oban `:crontab` (moved to a simpler implementation).
+- **Breaking:** `Pleroma.Workers.Cron.ClearOauthTokenWorker` setting from Oban `:crontab` (moved to scheduled jobs).
+- **Breaking:** `Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker` setting from Oban `:crontab` (moved to scheduled jobs).
+- Removed `:managed_config` option. In practice, it was accidentally removed with 2.0.0 release when frontends were
+switched to a new configuration mechanism, however it was not officially removed until now.
+
+### Added
+- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
+- Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`)
+- Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`)
+- Mix task option for force-unfollowing relays
+- App metrics: ability to restrict access to specified IP whitelist.
+- <details>
+ <summary>API Changes</summary>
+
+- Admin API: Importing emoji from a zip file
+- Pleroma API: Importing the mutes users from CSV files.
+- Pleroma API: Pagination for remote/local packs and emoji.
+
+</details>
+
+
+### Fixed
+
+- Add documented-but-missing chat pagination.
+- Allow sending out emails again.
+- Allow sending chat messages to yourself
+- OStatus / static FE endpoints: fixed inaccessibility for anonymous users on non-federating instances, switched to handling per `:restrict_unauthenticated` setting.
+- Fix remote users with a whitespace name.
+
+### Upgrade notes
+
+1. Install libmagic and development headers (`libmagic-dev` on Ubuntu/Debian, `file-dev` on Alpine Linux)
+2. Run database migrations (inside Pleroma directory):
+ - OTP: `./bin/pleroma_ctl migrate`
+ - From Source: `mix ecto.migrate`
+3. Restart Pleroma
+
+
## [2.1.2] - 2020-09-17
### Security
@@ -40,6 +104,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Rich media failure tracking (along with `:failure_backoff` option).
+<details>
+ <summary>Admin API Changes</summary>
+
+- Add `PATCH /api/pleroma/admin/instance_document/:document_name` to modify the Terms of Service and Instance Panel HTML pages via Admin API
+</details>
+
### Fixed
- Default HTTP adapter not respecting pool setting, leading to possible OOM.
- Fixed uploading webp images when the Exiftool Upload Filter is enabled by skipping them
diff --git a/Dockerfile b/Dockerfile
index aa50e27ec..c210cf79c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -31,7 +31,7 @@ LABEL maintainer="ops@pleroma.social" \
ARG HOME=/opt/pleroma
ARG DATA=/var/lib/pleroma
-RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories &&\
+RUN echo "https://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories &&\
apk update &&\
apk add exiftool imagemagick ncurses postgresql-client &&\
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
diff --git a/README.md b/README.md
index 6ca3118fb..7a05b9e48 100644
--- a/README.md
+++ b/README.md
@@ -18,15 +18,16 @@ If you are running Linux (glibc or musl) on x86/arm, the recommended way to inst
### From Source
If your platform is not supported, or you just want to be able to edit the source code easily, you may install Pleroma from source.
-- [Debian-based](https://docs-develop.pleroma.social/backend/installation/debian_based_en/)
-- [Debian-based (jp)](https://docs-develop.pleroma.social/backend/installation/debian_based_jp/)
- [Alpine Linux](https://docs-develop.pleroma.social/backend/installation/alpine_linux_en/)
- [Arch Linux](https://docs-develop.pleroma.social/backend/installation/arch_linux_en/)
+- [CentOS 7](https://docs-develop.pleroma.social/backend/installation/centos7_en/)
+- [Debian-based](https://docs-develop.pleroma.social/backend/installation/debian_based_en/)
+- [Debian-based (jp)](https://docs-develop.pleroma.social/backend/installation/debian_based_jp/)
+- [FreeBSD](https://docs-develop.pleroma.social/backend/installation/freebsd_en/)
- [Gentoo Linux](https://docs-develop.pleroma.social/backend/installation/gentoo_en/)
- [NetBSD](https://docs-develop.pleroma.social/backend/installation/netbsd_en/)
- [OpenBSD](https://docs-develop.pleroma.social/backend/installation/openbsd_en/)
- [OpenBSD (fi)](https://docs-develop.pleroma.social/backend/installation/openbsd_fi/)
-- [CentOS 7](https://docs-develop.pleroma.social/backend/installation/centos7_en/)
### OS/Distro packages
Currently Pleroma is not packaged by any OS/Distros, but if you want to package it for one, we can guide you through the process on our [community channels](#community-channels). If you want to change default options in your Pleroma package, please **discuss it with us first**.
diff --git a/SECURITY.md b/SECURITY.md
index c212a2505..c009d21d9 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -6,7 +6,7 @@ Currently, Pleroma offers bugfixes and security patches only for the latest mino
| Version | Support
|---------| --------
-| 2.0 | Bugfixes and security patches
+| 2.2 | Bugfixes and security patches
## Reporting a vulnerability
diff --git a/config/benchmark.exs b/config/benchmark.exs
index e867253eb..5567ff26e 100644
--- a/config/benchmark.exs
+++ b/config/benchmark.exs
@@ -59,8 +59,6 @@ config :web_push_encryption, :vapid_details,
"BLH1qVhJItRGCfxgTtONfsOKDc9VRAraXw-3NsmjMngWSh7NxOizN6bkuRA7iLTMPS82PjwJAr3UoK9EC1IFrz4",
private_key: "_-XZ0iebPrRfZ_o0-IatTdszYa8VCH1yLN-JauK7HHA"
-config :web_push_encryption, :http_client, Pleroma.Web.WebPushHttpClientMock
-
config :pleroma, Pleroma.ScheduledActivity,
daily_user_limit: 2,
total_user_limit: 3,
diff --git a/config/config.exs b/config/config.exs
index 88f6125e5..99c33010f 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -123,13 +123,15 @@ websocket_config = [
# Configures the endpoint
config :pleroma, Pleroma.Web.Endpoint,
- instrumenters: [Pleroma.Web.Endpoint.Instrumenter],
url: [host: "localhost"],
http: [
ip: {127, 0, 0, 1},
dispatch: [
{:_,
[
+ # FedSockets are commented out of the dispatch table on stable because they can't even
+ # fail properly when they are disabled. They will hang the connection instead of returning a 404.
+ # {"/api/fedsocket/v1", Pleroma.Web.FedSockets.IncomingHandler, []},
{"/api/v1/streaming", Pleroma.Web.MastodonAPI.WebsocketHandler, []},
{"/websocket", Phoenix.Endpoint.CowboyWebSocket,
{Phoenix.Transports.WebSocket,
@@ -142,12 +144,22 @@ config :pleroma, Pleroma.Web.Endpoint,
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
signing_salt: "CqaoopA2",
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
- pubsub: [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2],
+ pubsub_server: Pleroma.PubSub,
secure_cookie_flag: true,
extra_cookie_attrs: [
"SameSite=Lax"
]
+config :pleroma, :fed_sockets,
+ enabled: false,
+ connection_duration: :timer.hours(8),
+ rejection_duration: :timer.minutes(15),
+ fed_socket_fetches: [
+ default: 12_000,
+ interval: 3_000,
+ lazy: false
+ ]
+
# Configures Elixir's Logger
config :logger, :console,
level: :debug,
@@ -216,7 +228,6 @@ config :pleroma, :instance,
allow_relay: true,
public: true,
quarantined_instances: [],
- managed_config: true,
static_dir: "instance/static/",
allowed_post_formats: [
"text/plain",
@@ -424,6 +435,8 @@ config :pleroma, :media_proxy,
proxy_opts: [
redirect_on_failure: false,
max_body_length: 25 * 1_048_576,
+ # Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1
+ max_read_duration: 30_000,
http: [
follow_redirect: true,
pool: :media
@@ -438,6 +451,14 @@ config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Http,
config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Script, script_path: nil
+# Note: media preview proxy depends on media proxy to be enabled
+config :pleroma, :media_preview_proxy,
+ enabled: false,
+ thumbnail_max_width: 600,
+ thumbnail_max_height: 600,
+ image_quality: 85,
+ min_content_length: 100 * 1024
+
config :pleroma, :chat, enabled: true
config :phoenix, :format_encoders, json: Jason
@@ -530,8 +551,10 @@ config :pleroma, Oban,
log: false,
queues: [
activity_expiration: 10,
+ token_expiration: 5,
federator_incoming: 50,
federator_outgoing: 50,
+ ingestion_queue: 50,
web_push: 50,
mailer: 10,
transmogrifier: 20,
@@ -543,9 +566,6 @@ config :pleroma, Oban,
],
plugins: [Oban.Plugins.Pruner],
crontab: [
- {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
- {"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
- {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
]
@@ -617,7 +637,12 @@ config :pleroma, Pleroma.Emails.UserEmail,
config :pleroma, Pleroma.Emails.NewUsersDigestEmail, enabled: false
-config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, path: "/api/pleroma/app_metrics"
+config :prometheus, Pleroma.Web.Endpoint.MetricsExporter,
+ enabled: false,
+ auth: false,
+ ip_whitelist: [],
+ path: "/api/pleroma/app_metrics",
+ format: :text
config :pleroma, Pleroma.ScheduledActivity,
daily_user_limit: 25,
@@ -656,9 +681,20 @@ config :pleroma, :rate_limit,
account_confirmation_resend: {8_640_000, 5},
ap_routes: {60_000, 15}
-config :pleroma, Pleroma.ActivityExpiration, enabled: true
+config :pleroma, Pleroma.Workers.PurgeExpiredActivity, enabled: true, min_lifetime: 600
-config :pleroma, Pleroma.Plugs.RemoteIp, enabled: true
+config :pleroma, Pleroma.Web.Plugs.RemoteIp,
+ enabled: true,
+ headers: ["x-forwarded-for"],
+ proxies: [],
+ reserved: [
+ "127.0.0.0/8",
+ "::1/128",
+ "fc00::/7",
+ "10.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16"
+ ]
config :pleroma, :static_fe, enabled: false
@@ -670,7 +706,7 @@ config :pleroma, :static_fe, enabled: false
# With no frontend configuration, the bundled files from the `static` directory will
# be used.
#
-# config :pleroma, :frontends,
+# config :pleroma, :frontends,
# primary: %{"name" => "pleroma-fe", "ref" => "develop"},
# admin: %{"name" => "admin-fe", "ref" => "stable"},
# available: %{...}
@@ -734,28 +770,28 @@ config :pleroma, :connections_pool,
max_connections: 250,
max_idle_time: 30_000,
retry: 0,
- await_up_timeout: 5_000
+ connect_timeout: 5_000
config :pleroma, :pools,
federation: [
size: 50,
max_waiting: 10,
- timeout: 10_000
+ recv_timeout: 10_000
],
media: [
size: 50,
- max_waiting: 10,
- timeout: 10_000
+ max_waiting: 20,
+ recv_timeout: 15_000
],
upload: [
size: 25,
max_waiting: 5,
- timeout: 15_000
+ recv_timeout: 15_000
],
default: [
size: 10,
max_waiting: 2,
- timeout: 5_000
+ recv_timeout: 5_000
]
config :pleroma, :hackney_pools,
@@ -772,6 +808,8 @@ config :pleroma, :hackney_pools,
timeout: 300_000
]
+config :pleroma, :majic_pool, size: 2
+
private_instance? = :if_instance_is_private
config :pleroma, :restrict_unauthenticated,
@@ -790,6 +828,8 @@ config :tzdata, :http_client, Pleroma.HTTP.Tzdata
config :ex_aws, http_client: Pleroma.HTTP.ExAws
+config :web_push_encryption, http_client: Pleroma.HTTP.WebPush
+
config :pleroma, :instances_favicons, enabled: false
config :floki, :html_parser, Floki.HTMLParser.FastHtml
diff --git a/config/description.exs b/config/description.exs
index 5e08ba109..71b12326f 100644
--- a/config/description.exs
+++ b/config/description.exs
@@ -44,11 +44,13 @@ frontend_options = [
},
%{
key: "git",
+ label: "Git Repository URL",
type: :string,
description: "URL of the git repository of the frontend"
},
%{
key: "build_url",
+ label: "Build URL",
type: :string,
description:
"Either an url to a zip file containing the frontend or a template to build it by inserting the `ref`. The string `${ref}` will be replaced by the configured `ref`.",
@@ -56,6 +58,7 @@ frontend_options = [
},
%{
key: "build_dir",
+ label: "Build directory",
type: :string,
description: "The directory inside the zip file "
}
@@ -765,12 +768,6 @@ config :pleroma, :config_description, [
]
},
%{
- key: :managed_config,
- type: :boolean,
- description:
- "Whenether the config for pleroma-fe is configured in this config or in static/config.json"
- },
- %{
key: :static_dir,
type: :string,
description: "Instance static directory",
@@ -1880,6 +1877,7 @@ config :pleroma, :config_description, [
suggestions: [
redirect_on_failure: false,
max_body_length: 25 * 1_048_576,
+ max_read_duration: 30_000,
http: [
follow_redirect: true,
pool: :media
@@ -1901,6 +1899,11 @@ config :pleroma, :config_description, [
"specified length. It is validated with the `content-length` header and also verified when proxying."
},
%{
+ key: :max_read_duration,
+ type: :integer,
+ description: "Timeout (in milliseconds) of GET request to remote URI."
+ },
+ %{
key: :http,
label: "HTTP",
type: :keyword,
@@ -1948,6 +1951,43 @@ config :pleroma, :config_description, [
},
%{
group: :pleroma,
+ key: :media_preview_proxy,
+ type: :group,
+ description: "Media preview proxy",
+ children: [
+ %{
+ key: :enabled,
+ type: :boolean,
+ description:
+ "Enables proxying of remote media preview to the instance's proxy. Requires enabled media proxy."
+ },
+ %{
+ key: :thumbnail_max_width,
+ type: :integer,
+ description:
+ "Max width of preview thumbnail for images (video preview always has original dimensions)."
+ },
+ %{
+ key: :thumbnail_max_height,
+ type: :integer,
+ description:
+ "Max height of preview thumbnail for images (video preview always has original dimensions)."
+ },
+ %{
+ key: :image_quality,
+ type: :integer,
+ description: "Quality of the output. Ranges from 0 (min quality) to 100 (max quality)."
+ },
+ %{
+ key: :min_content_length,
+ type: :integer,
+ description:
+ "Min content length to perform preview, in bytes. If greater than 0, media smaller in size will be served as is, without thumbnailing."
+ }
+ ]
+ },
+ %{
+ group: :pleroma,
key: Pleroma.Web.MediaProxy.Invalidation.Http,
type: :group,
description: "HTTP invalidate settings",
@@ -2290,9 +2330,6 @@ config :pleroma, :config_description, [
type: {:list, :tuple},
description: "Settings for cron background jobs",
suggestions: [
- {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
- {"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
- {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
]
@@ -2398,7 +2435,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: Pleroma.Formatter,
- label: "Auto Linker",
+ label: "Linkify",
type: :group,
description:
"Configuration for Pleroma's link formatter which parses mentions, hashtags, and URLs.",
@@ -2475,14 +2512,20 @@ config :pleroma, :config_description, [
},
%{
group: :pleroma,
- key: Pleroma.ActivityExpiration,
+ key: Pleroma.Workers.PurgeExpiredActivity,
type: :group,
- description: "Expired activity settings",
+ description: "Expired activities settings",
children: [
%{
key: :enabled,
type: :boolean,
- description: "Whether expired activities will be sent to the job queue to be deleted"
+ description: "Enables expired activities addition & deletion"
+ },
+ %{
+ key: :min_lifetime,
+ type: :integer,
+ description: "Minimum lifetime for ephemeral activity (in seconds)",
+ suggestions: [600]
}
]
},
@@ -3194,10 +3237,10 @@ config :pleroma, :config_description, [
},
%{
group: :pleroma,
- key: Pleroma.Plugs.RemoteIp,
+ key: Pleroma.Web.Plugs.RemoteIp,
type: :group,
description: """
- `Pleroma.Plugs.RemoteIp` is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
+ `Pleroma.Web.Plugs.RemoteIp` is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
**If your instance is not behind at least one reverse proxy, you should not enable this plug.**
""",
children: [
@@ -3209,20 +3252,22 @@ config :pleroma, :config_description, [
%{
key: :headers,
type: {:list, :string},
- description:
- "A list of strings naming the `req_headers` to use when deriving the `remote_ip`. Order does not matter. Default: `~w[forwarded x-forwarded-for x-client-ip x-real-ip]`."
+ description: """
+ A list of strings naming the HTTP headers to use when deriving the true client IP. Default: `["x-forwarded-for"]`.
+ """
},
%{
key: :proxies,
type: {:list, :string},
description:
- "A list of strings in [CIDR](https://en.wikipedia.org/wiki/CIDR) notation specifying the IPs of known proxies. Default: `[]`."
+ "A list of upstream proxy IP subnets in CIDR notation from which we will parse the content of `headers`. Defaults to `[]`. IPv4 entries without a bitmask will be assumed to be /32 and IPv6 /128."
},
%{
key: :reserved,
type: {:list, :string},
- description:
- "Defaults to [localhost](https://en.wikipedia.org/wiki/Localhost) and [private network](https://en.wikipedia.org/wiki/Private_network)."
+ description: """
+ A list of reserved IP subnets in CIDR notation which should be ignored if found in `headers`. Defaults to `["127.0.0.0/8", "::1/128", "fc00::/7", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]`
+ """
}
]
},
@@ -3378,7 +3423,7 @@ config :pleroma, :config_description, [
suggestions: [250]
},
%{
- key: :await_up_timeout,
+ key: :connect_timeout,
type: :integer,
description: "Timeout while `gun` will wait until connection is up. Default: 5000ms.",
suggestions: [5000]
@@ -3416,6 +3461,12 @@ config :pleroma, :config_description, [
description:
"Maximum number of requests waiting for other requests to finish. After this number is reached, the pool will start returning errrors when a new request is made",
suggestions: [10]
+ },
+ %{
+ key: :recv_timeout,
+ type: :integer,
+ description: "Timeout for the pool while gun will wait for response",
+ suggestions: [10_000]
}
]
}
@@ -3622,9 +3673,7 @@ config :pleroma, :config_description, [
type: :map,
description:
"A map containing available frontends and parameters for their installation.",
- children: [
- frontend_options
- ]
+ children: frontend_options
}
]
},
@@ -3646,5 +3695,56 @@ config :pleroma, :config_description, [
]
}
]
+ },
+ %{
+ group: :pleroma,
+ key: :majic_pool,
+ type: :group,
+ description: "Majic/libmagic configuration",
+ children: [
+ %{
+ key: :size,
+ type: :integer,
+ description: "Number of majic workers to start.",
+ suggestions: [2]
+ }
+ ]
+ },
+ %{
+ group: :prometheus,
+ key: Pleroma.Web.Endpoint.MetricsExporter,
+ type: :group,
+ description: "Prometheus app metrics endpoint configuration",
+ children: [
+ %{
+ key: :enabled,
+ type: :boolean,
+ description: "[Pleroma extension] Enables app metrics endpoint."
+ },
+ %{
+ key: :ip_whitelist,
+ type: [{:list, :string}, {:list, :charlist}, {:list, :tuple}],
+ description:
+ "[Pleroma extension] If non-empty, restricts access to app metrics endpoint to specified IP addresses."
+ },
+ %{
+ key: :auth,
+ type: [:boolean, :tuple],
+ description: "Enables HTTP Basic Auth for app metrics endpoint.",
+ suggestion: [false, {:basic, "myusername", "mypassword"}]
+ },
+ %{
+ key: :path,
+ type: :string,
+ description: "App metrics endpoint URI path.",
+ suggestions: ["/api/pleroma/app_metrics"]
+ },
+ %{
+ key: :format,
+ type: :atom,
+ description: "App metrics endpoint output format.",
+ suggestions: [:text, :protobuf]
+ }
+ ]
}
]
diff --git a/config/test.exs b/config/test.exs
index e9c2273e8..7cc660e3c 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -19,6 +19,11 @@ config :logger, :console,
level: :warn,
format: "\n[$level] $message\n"
+config :pleroma, :fed_sockets,
+ enabled: false,
+ connection_duration: 5,
+ rejection_duration: 5
+
config :pleroma, :auth, oauth_consumer_strategies: []
config :pleroma, Pleroma.Upload,
@@ -78,8 +83,6 @@ config :web_push_encryption, :vapid_details,
"BLH1qVhJItRGCfxgTtONfsOKDc9VRAraXw-3NsmjMngWSh7NxOizN6bkuRA7iLTMPS82PjwJAr3UoK9EC1IFrz4",
private_key: "_-XZ0iebPrRfZ_o0-IatTdszYa8VCH1yLN-JauK7HHA"
-config :web_push_encryption, :http_client, Pleroma.Web.WebPushHttpClientMock
-
config :pleroma, Oban,
queues: false,
crontab: false,
@@ -110,12 +113,10 @@ config :pleroma, Pleroma.Gun, Pleroma.GunMock
config :pleroma, Pleroma.Emails.NewUsersDigestEmail, enabled: true
-config :pleroma, Pleroma.Plugs.RemoteIp, enabled: false
+config :pleroma, Pleroma.Web.Plugs.RemoteIp, enabled: false
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
-config :pleroma, :instances_favicons, enabled: false
-
config :pleroma, Pleroma.Uploaders.S3,
bucket: nil,
streaming_enabled: true,
diff --git a/coveralls.json b/coveralls.json
index 75e845ade..8652591ef 100644
--- a/coveralls.json
+++ b/coveralls.json
@@ -1,6 +1,7 @@
{
"skip_files": [
"test/support",
- "lib/mix/tasks/pleroma/benchmark.ex"
+ "lib/mix/tasks/pleroma/benchmark.ex",
+ "lib/credo/check/consistency/file_location.ex"
]
} \ No newline at end of file
diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md
index c0ea074f0..7bf13daef 100644
--- a/docs/API/admin_api.md
+++ b/docs/API/admin_api.md
@@ -349,9 +349,9 @@ Response:
### Unfollow a Relay
-Params:
-
-* `relay_url`
+- Params:
+ - `relay_url`
+ - *optional* `force`: forcefully unfollow a relay even when the relay is not available. (default is `false`)
Response:
@@ -1334,3 +1334,166 @@ Loads json generated from `config/descriptions.exs`.
{ }
```
+
+## GET /api/pleroma/admin/users/:nickname/chats
+
+### List a user's chats
+
+- Params: None
+
+- Response:
+
+```json
+[
+ {
+ "sender": {
+ "id": "someflakeid",
+ "username": "somenick",
+ ...
+ },
+ "receiver": {
+ "id": "someflakeid",
+ "username": "somenick",
+ ...
+ },
+ "id" : "1",
+ "unread" : 2,
+ "last_message" : {...}, // The last message in that chat
+ "updated_at": "2020-04-21T15:11:46.000Z"
+ }
+]
+```
+
+## GET /api/pleroma/admin/chats/:chat_id
+
+### View a single chat
+
+- Params: None
+
+- Response:
+
+```json
+{
+ "sender": {
+ "id": "someflakeid",
+ "username": "somenick",
+ ...
+ },
+ "receiver": {
+ "id": "someflakeid",
+ "username": "somenick",
+ ...
+ },
+ "id" : "1",
+ "unread" : 2,
+ "last_message" : {...}, // The last message in that chat
+ "updated_at": "2020-04-21T15:11:46.000Z"
+}
+```
+
+## GET /api/pleroma/admin/chats/:chat_id/messages
+
+### List the messages in a chat
+
+- Params: `max_id`, `min_id`
+
+- Response:
+
+```json
+[
+ {
+ "account_id": "someflakeid",
+ "chat_id": "1",
+ "content": "Check this out :firefox:",
+ "created_at": "2020-04-21T15:11:46.000Z",
+ "emojis": [
+ {
+ "shortcode": "firefox",
+ "static_url": "https://dontbulling.me/emoji/Firefox.gif",
+ "url": "https://dontbulling.me/emoji/Firefox.gif",
+ "visible_in_picker": false
+ }
+ ],
+ "id": "13",
+ "unread": true
+ },
+ {
+ "account_id": "someflakeid",
+ "chat_id": "1",
+ "content": "Whats' up?",
+ "created_at": "2020-04-21T15:06:45.000Z",
+ "emojis": [],
+ "id": "12",
+ "unread": false
+ }
+]
+```
+
+## DELETE /api/pleroma/admin/chats/:chat_id/messages/:message_id
+
+### Delete a single message
+
+- Params: None
+
+- Response:
+
+```json
+{
+ "account_id": "someflakeid",
+ "chat_id": "1",
+ "content": "Check this out :firefox:",
+ "created_at": "2020-04-21T15:11:46.000Z",
+ "emojis": [
+ {
+ "shortcode": "firefox",
+ "static_url": "https://dontbulling.me/emoji/Firefox.gif",
+ "url": "https://dontbulling.me/emoji/Firefox.gif",
+ "visible_in_picker": false
+ }
+ ],
+ "id": "13",
+ "unread": false
+}
+```
+
+## `GET /api/pleroma/admin/instance_document/:document_name`
+
+### Get an instance document
+
+- Authentication: required
+
+- Response:
+
+Returns the content of the document
+
+```html
+<h1>Instance panel</h1>
+```
+
+## `PATCH /api/pleroma/admin/instance_document/:document_name`
+- Params:
+ - `file` (the file to be uploaded, using multipart form data.)
+
+### Update an instance document
+
+- Authentication: required
+
+- Response:
+
+``` json
+{
+ "url": "https://example.com/instance/panel.html"
+}
+```
+
+## `DELETE /api/pleroma/admin/instance_document/:document_name`
+
+### Delete an instance document
+
+- Response:
+
+``` json
+{
+ "url": "https://example.com/instance/panel.html"
+}
+```
diff --git a/docs/API/pleroma_api.md b/docs/API/pleroma_api.md
index 4e97d26c0..3fd141bd2 100644
--- a/docs/API/pleroma_api.md
+++ b/docs/API/pleroma_api.md
@@ -44,6 +44,22 @@ Request parameters can be passed via [query strings](https://en.wikipedia.org/wi
* Response: HTTP 200 on success, 500 on error
* Note: Users that can't be followed are silently skipped.
+## `/api/pleroma/blocks_import`
+### Imports your blocks.
+* Method: `POST`
+* Authentication: required
+* Params:
+ * `list`: STRING or FILE containing a whitespace-separated list of accounts to block
+* Response: HTTP 200 on success, 500 on error
+
+## `/api/pleroma/mutes_import`
+### Imports your mutes.
+* Method: `POST`
+* Authentication: required
+* Params:
+ * `list`: STRING or FILE containing a whitespace-separated list of accounts to mute
+* Response: HTTP 200 on success, 500 on error
+
## `/api/pleroma/captcha`
### Get a new captcha
* Method: `GET`
@@ -362,44 +378,43 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa
* Params: None
* Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy).
-## `GET /api/pleroma/emoji/packs/import`
-### Imports packs from filesystem
-* Method `GET`
-* Authentication: required
-* Params: None
-* Response: JSON, returns a list of imported packs.
+## `GET /api/pleroma/emoji/pack?name=:name`
+
+### Get pack.json for the pack
-## `GET /api/pleroma/emoji/packs/remote`
-### Make request to another instance for packs list
* Method `GET`
-* Authentication: required
+* Authentication: not required
* Params:
- * `url`: url of the instance to get packs from
-* Response: JSON with the pack list, hashmap with pack name and pack contents
+ * `page`: page number for files (default 1)
+ * `page_size`: page size for files (default 30)
+* Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist.
-## `POST /api/pleroma/emoji/packs/download`
-### Download pack from another instance
-* Method `POST`
-* Authentication: required
-* Params:
- * `url`: url of the instance to download from
- * `name`: pack to download from that instance
- * `as`: (*optional*) name how to save pack
-* Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were
- errors downloading the pack
+```json
+{
+ "files": {...},
+ "files_count": 0, // emoji count in pack
+ "pack": {...}
+}
+```
+
+## `POST /api/pleroma/emoji/pack?name=:name`
-## `POST /api/pleroma/emoji/packs/:name`
### Creates an empty pack
+
* Method `POST`
-* Authentication: required
-* Params: None
+* Authentication: required (admin)
+* Params:
+ * `name`: pack name
* Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists
-## `PATCH /api/pleroma/emoji/packs/:name`
+## `PATCH /api/pleroma/emoji/pack?name=:name`
+
### Updates (replaces) pack metadata
+
* Method `PATCH`
-* Authentication: required
+* Authentication: required (admin)
* Params:
+ * `name`: pack name
* `metadata`: metadata to replace the old one
* `license`: Pack license
* `homepage`: Pack home page url
@@ -410,39 +425,85 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa
* Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a
problem with the new metadata (the error is specified in the "error" part of the response JSON)
-## `DELETE /api/pleroma/emoji/packs/:name`
+## `DELETE /api/pleroma/emoji/pack?name=:name`
+
### Delete a custom emoji pack
+
* Method `DELETE`
-* Authentication: required
-* Params: None
+* Authentication: required (admin)
+* Params:
+ * `name`: pack name
* Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack
-## `POST /api/pleroma/emoji/packs/:name/files`
+## `GET /api/pleroma/emoji/packs/import`
+
+### Imports packs from filesystem
+
+* Method `GET`
+* Authentication: required (admin)
+* Params: None
+* Response: JSON, returns a list of imported packs.
+
+## `GET /api/pleroma/emoji/packs/remote`
+
+### Make request to another instance for packs list
+
+* Method `GET`
+* Authentication: required (admin)
+* Params:
+ * `url`: url of the instance to get packs from
+ * `page`: page number for packs (default 1)
+ * `page_size`: page size for packs (default 50)
+* Response: JSON with the pack list, hashmap with pack name and pack contents
+
+## `POST /api/pleroma/emoji/packs/download`
+
+### Download pack from another instance
+
+* Method `POST`
+* Authentication: required (admin)
+* Params:
+ * `url`: url of the instance to download from
+ * `name`: pack to download from that instance
+ * `as`: (*optional*) name how to save pack
+* Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were
+ errors downloading the pack
+
+## `POST /api/pleroma/emoji/packs/files?name=:name`
+
### Add new file to the pack
+
* Method `POST`
-* Authentication: required
+* Authentication: required (admin)
* Params:
+ * `name`: pack name
* `file`: file needs to be uploaded with the multipart request or link to remote file.
* `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename.
* `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename.
* Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
-## `PATCH /api/pleroma/emoji/packs/:name/files`
+## `PATCH /api/pleroma/emoji/packs/files?name=:name`
+
### Update emoji file from pack
+
* Method `PATCH`
-* Authentication: required
+* Authentication: required (admin)
* Params:
+ * `name`: pack name
* `shortcode`: emoji file shortcode
* `new_shortcode`: new emoji file shortcode
* `new_filename`: new filename for emoji file
* `force`: (*optional*) with true value to overwrite existing emoji with new shortcode
* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
-## `DELETE /api/pleroma/emoji/packs/:name/files`
+## `DELETE /api/pleroma/emoji/packs/files?name=:name`
+
### Delete emoji file from pack
+
* Method `DELETE`
-* Authentication: required
+* Authentication: required (admin)
* Params:
+ * `name`: pack name
* `shortcode`: emoji file shortcode
* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
@@ -467,30 +528,14 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa
}
```
-## `GET /api/pleroma/emoji/packs/:name`
+## `GET /api/pleroma/emoji/packs/archive?name=:name`
-### Get pack.json for the pack
+### Requests a local pack archive from the instance
* Method `GET`
* Authentication: not required
* Params:
- * `page`: page number for files (default 1)
- * `page_size`: page size for files (default 30)
-* Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist.
-
-```json
-{
- "files": {...},
- "files_count": 0, // emoji count in pack
- "pack": {...}
-}
-```
-
-## `GET /api/pleroma/emoji/packs/:name/archive`
-### Requests a local pack archive from the instance
-* Method `GET`
-* Authentication: not required
-* Params: None
+ * `name`: pack name
* Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared,
404 if the pack does not exist
diff --git a/docs/API/prometheus.md b/docs/API/prometheus.md
index 19c564e3c..a5158d905 100644
--- a/docs/API/prometheus.md
+++ b/docs/API/prometheus.md
@@ -2,15 +2,37 @@
Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library.
+Config example:
+
+```
+config :prometheus, Pleroma.Web.Endpoint.MetricsExporter,
+ enabled: true,
+ auth: {:basic, "myusername", "mypassword"},
+ ip_whitelist: ["127.0.0.1"],
+ path: "/api/pleroma/app_metrics",
+ format: :text
+```
+
+* `enabled` (Pleroma extension) enables the endpoint
+* `ip_whitelist` (Pleroma extension) could be used to restrict access only to specified IPs
+* `auth` sets the authentication (`false` for no auth; configurable to HTTP Basic Auth, see [prometheus-plugs](https://github.com/deadtrickster/prometheus-plugs#exporting) documentation)
+* `format` sets the output format (`:text` or `:protobuf`)
+* `path` sets the path to app metrics page
+
+
## `/api/pleroma/app_metrics`
+
### Exports Prometheus application metrics
+
* Method: `GET`
-* Authentication: not required
+* Authentication: not required by default (see configuration options above)
* Params: none
-* Response: JSON
+* Response: text
## Grafana
+
### Config example
+
The following is a config example to use with [Grafana](https://grafana.com)
```
diff --git a/docs/administration/CLI_tasks/email.md b/docs/administration/CLI_tasks/email.md
index 00d2e74f8..d9aa0e71b 100644
--- a/docs/administration/CLI_tasks/email.md
+++ b/docs/administration/CLI_tasks/email.md
@@ -1,4 +1,4 @@
-# Managing emails
+# EMail administration tasks
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
@@ -30,3 +30,17 @@ Example:
```sh
mix pleroma.email test --to root@example.org
```
+
+## Send confirmation emails to all unconfirmed user accounts
+
+=== "OTP"
+
+ ```sh
+ ./bin/pleroma_ctl email send_confirmation_mails
+ ```
+
+=== "From Source"
+
+ ```sh
+ mix pleroma.email send_confirmation_mails
+ ```
diff --git a/docs/administration/CLI_tasks/instance.md b/docs/administration/CLI_tasks/instance.md
index 989ecc55d..d6913280a 100644
--- a/docs/administration/CLI_tasks/instance.md
+++ b/docs/administration/CLI_tasks/instance.md
@@ -37,3 +37,6 @@ If any of the options are left unspecified, you will be prompted interactively.
- `--static-dir <path>` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)
- `--listen-ip <ip>` - the ip the app should listen to, defaults to 127.0.0.1
- `--listen-port <port>` - the port the app should listen to, defaults to 4000
+- `--strip-uploads <Y|N>` - use ExifTool to strip uploads of sensitive location data
+- `--anonymize-uploads <Y|N>` - randomize uploaded filenames
+- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
diff --git a/docs/administration/CLI_tasks/user.md b/docs/administration/CLI_tasks/user.md
index 3e7f028ba..c64ed4f22 100644
--- a/docs/administration/CLI_tasks/user.md
+++ b/docs/administration/CLI_tasks/user.md
@@ -224,9 +224,10 @@
```
### Options
+- `--admin`/`--no-admin` - whether the user should be an admin
+- `--confirmed`/`--no-confirmed` - whether the user account is confirmed
- `--locked`/`--no-locked` - whether the user should be locked
- `--moderator`/`--no-moderator` - whether the user should be a moderator
-- `--admin`/`--no-admin` - whether the user should be an admin
## Add tags to a user
@@ -271,3 +272,33 @@
```sh
mix pleroma.user toggle_confirmed <nickname>
```
+
+## Set confirmation status for all regular active users
+*Admins and moderators are excluded*
+
+=== "OTP"
+
+ ```sh
+ ./bin/pleroma_ctl user confirm_all
+ ```
+
+=== "From Source"
+
+ ```sh
+ mix pleroma.user confirm_all
+ ```
+
+## Revoke confirmation status for all regular active users
+*Admins and moderators are excluded*
+
+=== "OTP"
+
+ ```sh
+ ./bin/pleroma_ctl user unconfirm_all
+ ```
+
+=== "From Source"
+
+ ```sh
+ mix pleroma.user unconfirm_all
+ ```
diff --git a/docs/administration/backup.md b/docs/administration/backup.md
index be57bf74a..5f279ab97 100644
--- a/docs/administration/backup.md
+++ b/docs/administration/backup.md
@@ -5,20 +5,25 @@
1. Stop the Pleroma service.
2. Go to the working directory of Pleroma (default is `/opt/pleroma`)
3. Run `sudo -Hu postgres pg_dump -d <pleroma_db> --format=custom -f </path/to/backup_location/pleroma.pgdump>` (make sure the postgres user has write access to the destination file)
-4. Copy `pleroma.pgdump`, `config/prod.secret.exs` and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too.
+4. Copy `pleroma.pgdump`, `config/prod.secret.exs`, `config/setup_db.psql` (if still available) and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too.
5. Restart the Pleroma service.
## Restore/Move
-1. Optionally reinstall Pleroma (either on the same server or on another server if you want to move servers). Try to use the same database name.
+1. Optionally reinstall Pleroma (either on the same server or on another server if you want to move servers).
2. Stop the Pleroma service.
3. Go to the working directory of Pleroma (default is `/opt/pleroma`)
4. Copy the above mentioned files back to their original position.
-5. Drop the existing database and recreate an empty one `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'CREATE DATABASE <pleroma_db>;';`
-6. Run `sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>`
-7. If you installed a newer Pleroma version, you should run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any.
-8. Restart the Pleroma service.
-9. Run `sudo -Hu postgres vacuumdb --all --analyze-in-stages`. This will quickly generate the statistics so that postgres can properly plan queries.
+5. Drop the existing database and user if restoring in-place. `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'DROP USER <pleroma_db>;'`
+6. Restore the database schema and pleroma postgres role the with the original `setup_db.psql` if you have it: `sudo -Hu postgres psql -f config/setup_db.psql`.
+
+ Alternatively, run the `mix pleroma.instance gen` task again. You can ignore most of the questions, but make the database user, name, and password the same as found in your backup of `config/prod.secret.exs`. Then run the restoration of the pleroma role and schema with of the generated `config/setup_db.psql` as instructed above. You may delete the `config/generated_config.exs` file as it is not needed.
+
+7. Now restore the Pleroma instance's data into the empty database schema: `sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>`
+8. If you installed a newer Pleroma version, you should run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any.
+9. Restart the Pleroma service.
+10. Run `sudo -Hu postgres vacuumdb --all --analyze-in-stages`. This will quickly generate the statistics so that postgres can properly plan queries.
+11. If setting up on a new server configure Nginx by using the `installation/pleroma.nginx` config sample or reference the Pleroma installation guide for your OS which contains the Nginx configuration instructions.
[^1]: Prefix with `MIX_ENV=prod` to run it using the production config file.
@@ -31,6 +36,6 @@
3. Disable pleroma from systemd `systemctl disable pleroma`
4. Remove the files and folders you created during installation (see installation guide). This includes the pleroma, nginx and systemd files and folders.
5. Reload nginx now that the configuration is removed `systemctl reload nginx`
-6. Remove the database and database user `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'DROP USER <pleroma_db>;';`
+6. Remove the database and database user `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'DROP USER <pleroma_db>;'`
7. Remove the system user `userdel pleroma`
8. Remove the dependencies that you don't need anymore (see installation guide). Make sure you don't remove packages that are still needed for other software that you have running!
diff --git a/docs/administration/updating.md b/docs/administration/updating.md
index c994f3f16..ef2c9218c 100644
--- a/docs/administration/updating.md
+++ b/docs/administration/updating.md
@@ -18,9 +18,10 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
1. Go to the working directory of Pleroma (default is `/opt/pleroma`)
2. Run `git pull`. This pulls the latest changes from upstream.
-3. Run `mix deps.get`. This pulls in any new dependencies.
+3. Run `mix deps.get` [^1]. This pulls in any new dependencies.
4. Stop the Pleroma service.
-5. Run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any.
+5. Run `mix ecto.migrate` [^1] [^2]. This task performs database migrations, if there were any.
6. Start the Pleroma service.
-[^1]: Prefix with `MIX_ENV=prod` to run it using the production config file.
+[^1]: Depending on which install guide you followed (for example on Debian/Ubuntu), you want to run `mix` tasks as `pleroma` user by adding `sudo -Hu pleroma` before the command.
+[^2]: Prefix with `MIX_ENV=prod` to run it using the production config file.
diff --git a/docs/clients.md b/docs/clients.md
index f84295b1f..1e2c14f1b 100644
--- a/docs/clients.md
+++ b/docs/clients.md
@@ -71,7 +71,7 @@ Feel free to contact us to be added to this list!
### Indigenous
- Homepage: <https://indigenous.realize.be/>
- Source Code: <https://github.com/swentel/indigenous-android/>
-- Contact: [@realize.be@realize.be](@realize.be@realize.be)
+- Contact: [@swentel@realize.be](https://realize.be)
- Platforms: Android
- Features: No Streaming
diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md
index b2980793d..2c41ee932 100644
--- a/docs/configuration/cheatsheet.md
+++ b/docs/configuration/cheatsheet.md
@@ -18,7 +18,7 @@ To add configuration to your config file, you can copy it from the base config.
* `notify_email`: Email used for notifications.
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``.
* `limit`: Posts character limit (CW/Subject included in the counter).
-* `discription_limit`: The character limit for image descriptions.
+* `description_limit`: The character limit for image descriptions.
* `chat_limit`: Character limit of the instance chat messages.
* `remote_limit`: Hard character limit beyond which remote posts will be dropped.
* `upload_limit`: File size limit of uploads (except for avatar, background, banner).
@@ -40,7 +40,6 @@ To add configuration to your config file, you can copy it from the base config.
* `allow_relay`: Enable Pleroma’s Relay, which makes it possible to follow a whole instance.
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. Note that there is a dependent setting restricting or allowing unauthenticated access to specific resources, see `restrict_unauthenticated` for more details.
* `quarantined_instances`: List of ActivityPub instances where private (DMs, followers-only) activities will not be send.
-* `managed_config`: Whenether the config for pleroma-fe is configured in [:frontend_configurations](#frontend_configurations) or in ``static/config.json``.
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with
older software for theses nicknames.
@@ -114,7 +113,8 @@ To add configuration to your config file, you can copy it from the base config.
* `Pleroma.Web.ActivityPub.MRF.MentionPolicy`: Drops posts mentioning configurable users. (See [`:mrf_mention`](#mrf_mention)).
* `Pleroma.Web.ActivityPub.MRF.VocabularyPolicy`: Restricts activities to a configured set of vocabulary. (See [`:mrf_vocabulary`](#mrf_vocabulary)).
* `Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy`: Rejects or delists posts based on their age when received. (See [`:mrf_object_age`](#mrf_object_age)).
- * `Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy`: Sets a default expiration on all posts made by users of the local instance. Requires `Pleroma.ActivityExpiration` to be enabled for processing the scheduled delections.
+ * `Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy`: Sets a default expiration on all posts made by users of the local instance. Requires `Pleroma.Workers.PurgeExpiredActivity` to be enabled for processing the scheduled delections.
+ * `Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy`: Makes all bot posts to disappear from public timelines.
* `transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
* `transparency_exclusions`: Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.
@@ -219,12 +219,6 @@ config :pleroma, :mrf_user_allowlist, %{
* `total_user_limit`: the number of scheduled activities a user is allowed to create in total (Default: `300`)
* `enabled`: whether scheduled activities are sent to the job queue to be executed
-## Pleroma.ActivityExpiration
-
-Enables the worker which processes posts scheduled for deletion. Pinned posts are exempt from expiration.
-
-* `enabled`: whether expired activities will be sent to the job queue to be deleted
-
## Frontends
### :frontend_configurations
@@ -314,6 +308,14 @@ This section describe PWA manifest instance-specific values. Currently this opti
* `enabled`: Enables purge cache
* `provider`: Which one of the [purge cache strategy](#purge-cache-strategy) to use.
+## :media_preview_proxy
+
+* `enabled`: Enables proxying of remote media preview to the instance’s proxy. Requires enabled media proxy (`media_proxy/enabled`).
+* `thumbnail_max_width`: Max width of preview thumbnail for images (video preview always has original dimensions).
+* `thumbnail_max_height`: Max height of preview thumbnail for images (video preview always has original dimensions).
+* `image_quality`: Quality of the output. Ranges from 0 (min quality) to 100 (max quality).
+* `min_content_length`: Min content length to perform preview, in bytes. If greater than 0, media smaller in size will be served as is, without thumbnailing.
+
### Purge cache strategy
#### Pleroma.Web.MediaProxy.Invalidation.Script
@@ -398,25 +400,25 @@ This will make Pleroma listen on `127.0.0.1` port `8080` and generate urls start
* ``referrer_policy``: The referrer policy to use, either `"same-origin"` or `"no-referrer"`.
* ``report_uri``: Adds the specified url to `report-uri` and `report-to` group in CSP header.
-### Pleroma.Plugs.RemoteIp
+### Pleroma.Web.Plugs.RemoteIp
!!! warning
If your instance is not behind at least one reverse proxy, you should not enable this plug.
-`Pleroma.Plugs.RemoteIp` is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
+`Pleroma.Web.Plugs.RemoteIp` is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
Available options:
* `enabled` - Enable/disable the plug. Defaults to `false`.
-* `headers` - A list of strings naming the `req_headers` to use when deriving the `remote_ip`. Order does not matter. Defaults to `["x-forwarded-for"]`.
-* `proxies` - A list of strings in [CIDR](https://en.wikipedia.org/wiki/CIDR) notation specifying the IPs of known proxies. Defaults to `[]`.
-* `reserved` - Defaults to [localhost](https://en.wikipedia.org/wiki/Localhost) and [private network](https://en.wikipedia.org/wiki/Private_network).
+* `headers` - A list of strings naming the HTTP headers to use when deriving the true client IP address. Defaults to `["x-forwarded-for"]`.
+* `proxies` - A list of upstream proxy IP subnets in CIDR notation from which we will parse the content of `headers`. Defaults to `[]`. IPv4 entries without a bitmask will be assumed to be /32 and IPv6 /128.
+* `reserved` - A list of reserved IP subnets in CIDR notation which should be ignored if found in `headers`. Defaults to `["127.0.0.0/8", "::1/128", "fc00::/7", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]`.
### :rate_limit
!!! note
- If your instance is behind a reverse proxy ensure [`Pleroma.Plugs.RemoteIp`](#pleroma-plugs-remoteip) is enabled (it is enabled by default).
+ If your instance is behind a reverse proxy ensure [`Pleroma.Web.Plugs.RemoteIp`](#pleroma-plugs-remoteip) is enabled (it is enabled by default).
A keyword list of rate limiters where a key is a limiter name and value is the limiter configuration. The basic configuration is a tuple where:
@@ -496,7 +498,7 @@ Settings for HTTP connection pool.
* `:connection_acquisition_wait` - Timeout to acquire a connection from pool.The total max time is this value multiplied by the number of retries.
* `connection_acquisition_retries` - Number of attempts to acquire the connection from the pool if it is overloaded. Each attempt is timed `:connection_acquisition_wait` apart.
* `:max_connections` - Maximum number of connections in the pool.
-* `:await_up_timeout` - Timeout to connect to the host.
+* `:connect_timeout` - Timeout to connect to the host.
* `:reclaim_multiplier` - Multiplied by `:max_connections` this will be the maximum number of idle connections that will be reclaimed in case the pool is overloaded.
### :pools
@@ -515,7 +517,7 @@ There are four pools used:
For each pool, the options are:
* `:size` - limit to how much requests can be concurrently executed.
-* `:timeout` - timeout while `gun` will wait for response
+* `:recv_timeout` - timeout while `gun` will wait for response
* `:max_waiting` - limit to how much requests can be waiting for others to finish, after this is reached, subsequent requests will be dropped.
## Captcha
@@ -690,9 +692,8 @@ Pleroma has the following queues:
Pleroma has these periodic job workers:
-`Pleroma.Workers.Cron.ClearOauthTokenWorker` - a job worker to cleanup expired oauth tokens.
-
-Example:
+* `Pleroma.Workers.Cron.DigestEmailsWorker` - digest emails for users with new mentions and follows
+* `Pleroma.Workers.Cron.NewUsersDigestWorker` - digest emails for admins with new registrations
```elixir
config :pleroma, Oban,
@@ -704,7 +705,8 @@ config :pleroma, Oban,
federator_outgoing: 50
],
crontab: [
- {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}
+ {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
+ {"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
]
```
@@ -971,7 +973,7 @@ Configure OAuth 2 provider capabilities:
* `token_expires_in` - The lifetime in seconds of the access token.
* `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token.
-* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. Interval settings sets in configuration periodic jobs [`Oban.Cron`](#obancron)
+* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`.
## Link parsing
@@ -1090,3 +1092,10 @@ config :pleroma, :frontends,
```
This would serve the frontend from the the folder at `$instance_static/frontends/pleroma/stable`. You have to copy the frontend into this folder yourself. You can choose the name and ref any way you like, but they will be used by mix tasks to automate installation in the future, the name referring to the project and the ref referring to a commit.
+
+## Ephemeral activities (Pleroma.Workers.PurgeExpiredActivity)
+
+Settings to enable and configure expiration for ephemeral activities
+
+* `:enabled` - enables ephemeral activities creation
+* `:min_lifetime` - minimum lifetime for ephemeral activities (in seconds). Default: 10 minutes.
diff --git a/docs/dev.md b/docs/dev.md
index 9c749c17c..22e0691f1 100644
--- a/docs/dev.md
+++ b/docs/dev.md
@@ -6,7 +6,7 @@ This document contains notes and guidelines for Pleroma developers.
* Pleroma supports hierarchical OAuth scopes, just like Mastodon but with added granularity of admin scopes. For a reference, see [Mastodon OAuth scopes](https://docs.joinmastodon.org/api/oauth-scopes/).
-* It is important to either define OAuth scope restrictions or explicitly mark OAuth scope check as skipped, for every controller action. To define scopes, call `plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: [...]})`. To explicitly set OAuth scopes check skipped, call `plug(:skip_plug, Pleroma.Plugs.OAuthScopesPlug <when ...>)`.
+* It is important to either define OAuth scope restrictions or explicitly mark OAuth scope check as skipped, for every controller action. To define scopes, call `plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: [...]})`. To explicitly set OAuth scopes check skipped, call `plug(:skip_plug, Pleroma.Web.Plugs.OAuthScopesPlug <when ...>)`.
* In controllers, `use Pleroma.Web, :controller` will result in `action/2` (see `Pleroma.Web.controller/0` for definition) be called prior to actual controller action, and it'll perform security / privacy checks before passing control to actual controller action.
@@ -16,7 +16,7 @@ This document contains notes and guidelines for Pleroma developers.
## [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization)
-* With HTTP Basic Auth, OAuth scopes check is _not_ performed for any action (since password is provided during the auth, requester is able to obtain a token with full permissions anyways). `Pleroma.Plugs.AuthenticationPlug` and `Pleroma.Plugs.LegacyAuthenticationPlug` both call `Pleroma.Plugs.OAuthScopesPlug.skip_plug(conn)` when password is provided.
+* With HTTP Basic Auth, OAuth scopes check is _not_ performed for any action (since password is provided during the auth, requester is able to obtain a token with full permissions anyways). `Pleroma.Web.Plugs.AuthenticationPlug` and `Pleroma.Web.Plugs.LegacyAuthenticationPlug` both call `Pleroma.Web.Plugs.OAuthScopesPlug.skip_plug(conn)` when password is provided.
## Auth-related configuration, OAuth consumer mode etc.
diff --git a/docs/installation/alpine_linux_en.md b/docs/installation/alpine_linux_en.md
index a5683f18c..62f2fb778 100644
--- a/docs/installation/alpine_linux_en.md
+++ b/docs/installation/alpine_linux_en.md
@@ -13,6 +13,7 @@ It assumes that you have administrative rights, either as root or a user with [s
* `erlang-parsetools`
* `erlang-xmerl`
* `git`
+* `file-dev`
* Development Tools
* `cmake`
@@ -20,6 +21,9 @@ It assumes that you have administrative rights, either as root or a user with [s
* `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
* `certbot` (or any other ACME client for Let’s Encrypt certificates)
+* `ImageMagick`
+* `ffmpeg`
+* `exiftool`
### Prepare the system
@@ -29,7 +33,6 @@ It assumes that you have administrative rights, either as root or a user with [s
awk 'NR==2' /etc/apk/repositories | sed 's/main/community/' | tee -a /etc/apk/repositories
```
-
* Then update the system, if not already done:
```shell
@@ -40,7 +43,7 @@ sudo apk upgrade
* Install some tools, which are needed later:
```shell
-sudo apk add git build-base cmake
+sudo apk add git build-base cmake file-dev
```
### Install Elixir and Erlang
@@ -56,6 +59,7 @@ sudo apk add erlang erlang-runtime-tools erlang-xmerl elixir
```shell
sudo apk add erlang-eldap
```
+
### Install PostgreSQL
* Install Postgresql server:
@@ -76,6 +80,12 @@ sudo /etc/init.d/postgresql start
sudo rc-update add postgresql
```
+### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
+
+```shell
+sudo apk add ffmpeg imagemagick exiftool
+```
+
### Install PleromaBE
* Add a new system user for the Pleroma service:
diff --git a/docs/installation/arch_linux_en.md b/docs/installation/arch_linux_en.md
index 7fb69dd60..0eb6d2d5f 100644
--- a/docs/installation/arch_linux_en.md
+++ b/docs/installation/arch_linux_en.md
@@ -10,11 +10,15 @@ This guide will assume that you have administrative rights, either as root or a
* `git`
* `base-devel`
* `cmake`
+* `file`
#### Optional packages used in this guide
* `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
* `certbot` (or any other ACME client for Let’s Encrypt certificates)
+* `ImageMagick`
+* `ffmpeg`
+* `exiftool`
### Prepare the system
@@ -27,7 +31,7 @@ sudo pacman -Syu
* Install some of the above mentioned programs:
```shell
-sudo pacman -S git base-devel elixir cmake
+sudo pacman -S git base-devel elixir cmake file
```
### Install PostgreSQL
@@ -52,6 +56,12 @@ sudo -iu postgres initdb -D /var/lib/postgres/data
sudo systemctl enable --now postgresql.service
```
+### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
+
+```shell
+sudo pacman -S ffmpeg imagemagick perl-image-exiftool
+```
+
### Install PleromaBE
* Add a new system user for the Pleroma service:
diff --git a/docs/installation/debian_based_en.md b/docs/installation/debian_based_en.md
index 60c2f47e5..6a9026d94 100644
--- a/docs/installation/debian_based_en.md
+++ b/docs/installation/debian_based_en.md
@@ -10,6 +10,7 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
* `erlang-dev`
* `erlang-nox`
+* `libmagic-dev`
* `git`
* `build-essential`
* `cmake`
@@ -18,6 +19,9 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
* `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
* `certbot` (or any other ACME client for Let’s Encrypt certificates)
+* `ImageMagick`
+* `ffmpeg`
+* `exiftool`
### Prepare the system
@@ -31,7 +35,7 @@ sudo apt full-upgrade
* Install some of the above mentioned programs:
```shell
-sudo apt install git build-essential postgresql postgresql-contrib cmake
+sudo apt install git build-essential postgresql postgresql-contrib cmake libmagic-devel
```
### Install Elixir and Erlang
@@ -50,6 +54,12 @@ sudo apt update
sudo apt install elixir erlang-dev erlang-nox
```
+### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)
+
+```shell
+sudo apt install imagemagick ffmpeg libimage-exiftool-perl
+```
+
### Install PleromaBE
* Add a new system user for the Pleroma service:
diff --git a/docs/installation/debian_based_jp.md b/docs/installation/debian_based_jp.md
index c2dd840d3..94e22325c 100644
--- a/docs/installation/debian_based_jp.md
+++ b/docs/installation/debian_based_jp.md
@@ -17,11 +17,15 @@
- `git`
- `build-essential`
- `cmake`
+- `libmagic-dev`
#### このガイドで利用している追加パッケージ
- `nginx` (おすすめです。他のリバースプロキシを使う場合は、参考となる設定をこのリポジトリから探してください)
- `certbot` (または何らかのLet's Encrypt向けACMEクライアント)
+- `ImageMagick`
+- `ffmpeg`
+- `exiftool`
### システムを準備する
@@ -33,10 +37,9 @@ sudo apt full-upgrade
* 上記に挙げたパッケージをインストールしておきます。
```
-sudo apt install git build-essential postgresql postgresql-contrib cmake
+sudo apt install git build-essential postgresql postgresql-contrib cmake ffmpeg imagemagick libmagic-dev
```
-
### ElixirとErlangをインストールします
* Erlangのリポジトリをダウンロードおよびインストールします。
@@ -51,6 +54,12 @@ sudo apt update
sudo apt install elixir erlang-dev erlang-nox
```
+### オプションパッケージ: [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)
+
+```shell
+sudo apt install imagemagick ffmpeg libimage-exiftool-perl
+```
+
### Pleroma BE (バックエンド) をインストールします
* Pleroma用に新しいユーザーを作ります。
diff --git a/docs/installation/freebsd_en.md b/docs/installation/freebsd_en.md
index ca2575d9b..fdcb06c53 100644
--- a/docs/installation/freebsd_en.md
+++ b/docs/installation/freebsd_en.md
@@ -26,6 +26,12 @@ Setup the required services to automatically start at boot, using `sysrc(8)`.
# service postgresql start
```
+### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
+
+```shell
+# pkg install imagemagick ffmpeg p5-Image-ExifTool
+```
+
## Configuring Pleroma
Create a user for Pleroma:
diff --git a/docs/installation/gentoo_en.md b/docs/installation/gentoo_en.md
index 5a676380c..f2380ab72 100644
--- a/docs/installation/gentoo_en.md
+++ b/docs/installation/gentoo_en.md
@@ -29,12 +29,16 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
* `dev-lang/elixir`
* `dev-vcs/git`
* `dev-util/cmake`
+* `sys-apps/file`
#### Optional ebuilds used in this guide
* `www-servers/nginx` (preferred, example configs for other reverse proxies can be found in the repo)
* `app-crypt/certbot` (or any other ACME client for Let’s Encrypt certificates)
* `app-crypt/certbot-nginx` (nginx certbot plugin that allows use of the all-powerful `--nginx` flag on certbot)
+* `media-gfx/imagemagick`
+* `media-video/ffmpeg`
+* `media-libs/exiftool`
### Prepare the system
@@ -47,7 +51,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
* Emerge all required the required and suggested software in one go:
```shell
- # emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake
+ # emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake sys-apps/file
```
If you would not like to install the optional packages, remove them from this line.
@@ -87,6 +91,12 @@ If you do not plan to make any modifications to your Pleroma instance, cloning d
Not only does this make it much easier to deploy changes you make, as you can commit and pull from upstream and all that good stuff from the comfort of your local machine then simply `git pull` on your instance server when you're ready to deploy, it also ensures you are compliant with the Affero General Public Licence that Pleroma is licenced under, which stipulates that all network services provided with modified AGPL code must publish their changes on a publicly available internet service and for free. It also makes it much easier to ask for help from and provide help to your fellow Pleroma admins if your public repo always reflects what you are running because it is part of your deployment procedure.
+### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
+
+```shell
+# emerge --ask media-video/ffmpeg media-gfx/imagemagick media-libs/exiftool
+```
+
### Install PleromaBE
* Add a new system user for the Pleroma service and set up default directories:
diff --git a/docs/installation/netbsd_en.md b/docs/installation/netbsd_en.md
index 6ad0de2f6..d5fa04fdf 100644
--- a/docs/installation/netbsd_en.md
+++ b/docs/installation/netbsd_en.md
@@ -10,7 +10,7 @@ Pleroma uses.
The `mksh` shell is needed to run the Elixir `mix` script.
-`# pkgin install acmesh elixir git-base git-docs mksh nginx postgresql11-server postgresql11-client postgresql11-contrib sudo`
+`# pkgin install acmesh elixir git-base git-docs mksh nginx postgresql11-server postgresql11-client postgresql11-contrib sudo ffmpeg4 ImageMagick`
You can also build these packages using pkgsrc:
```
@@ -44,6 +44,10 @@ pgsql=YES
First, run `# /etc/rc.d/pgsql start`. Then, `$ sudo -Hu pgsql -g pgsql createdb`.
+### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
+
+`# pkgin install ImageMagick ffmpeg4 p5-Image-ExifTool`
+
## Configuring Pleroma
Create a user for Pleroma:
diff --git a/docs/installation/openbsd_en.md b/docs/installation/openbsd_en.md
index eee452845..8092ac379 100644
--- a/docs/installation/openbsd_en.md
+++ b/docs/installation/openbsd_en.md
@@ -10,20 +10,34 @@ The following packages need to be installed:
* elixir
* gmake
- * ImageMagick
* git
* postgresql-server
* postgresql-contrib
* cmake
+ * ffmpeg
+ * ImageMagick
To install them, run the following command (with doas or as root):
```
-pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib cmake
+pkg_add elixir gmake git postgresql-server postgresql-contrib cmake ffmpeg ImageMagick
```
Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
+#### Optional software
+
+Per [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md):
+ * ImageMagick
+ * ffmpeg
+ * exiftool
+
+To install the above:
+
+```
+pkg_add ImageMagick ffmpeg p5-Image-ExifTool
+```
+
#### Creating the pleroma user
Pleroma will be run by a dedicated user, \_pleroma. Before creating it, insert the following lines in login.conf:
```
diff --git a/docs/installation/openbsd_fi.md b/docs/installation/openbsd_fi.md
index b5b5056a9..01cf34ab4 100644
--- a/docs/installation/openbsd_fi.md
+++ b/docs/installation/openbsd_fi.md
@@ -16,7 +16,18 @@ Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
Asenna tarvittava ohjelmisto:
-`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3 cmake`
+`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3 cmake ffmpeg ImageMagick`
+
+#### Optional software
+
+[`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md):
+ * ImageMagick
+ * ffmpeg
+ * exiftool
+
+Asenna tarvittava ohjelmisto:
+
+`# pkg_add ImageMagick ffmpeg p5-Image-ExifTool`
Luo postgresql-tietokanta:
diff --git a/docs/installation/optional/media_graphics_packages.md b/docs/installation/optional/media_graphics_packages.md
new file mode 100644
index 000000000..cb3d71188
--- /dev/null
+++ b/docs/installation/optional/media_graphics_packages.md
@@ -0,0 +1,32 @@
+# Optional software packages needed for specific functionality
+
+For specific Pleroma functionality (which is disabled by default) some or all of the below packages are required:
+ * `ImageMagic`
+ * `ffmpeg`
+ * `exiftool`
+
+Please refer to documentation in `docs/installation` on how to install them on specific OS.
+
+Note: the packages are not required with the current default settings of Pleroma.
+
+## `ImageMagick`
+
+`ImageMagick` is a set of tools to create, edit, compose, or convert bitmap images.
+
+It is required for the following Pleroma features:
+ * `Pleroma.Upload.Filters.Mogrify`, `Pleroma.Upload.Filters.Mogrifun` upload filters (related config: `Plaroma.Upload/filters` in `config/config.exs`)
+ * Media preview proxy for still images (related config: `media_preview_proxy/enabled` in `config/config.exs`)
+
+## `ffmpeg`
+
+`ffmpeg` is software to record, convert and stream audio and video.
+
+It is required for the following Pleroma features:
+ * Media preview proxy for videos (related config: `media_preview_proxy/enabled` in `config/config.exs`)
+
+## `exiftool`
+
+`exiftool` is media files metadata reader/writer.
+
+It is required for the following Pleroma features:
+ * `Pleroma.Upload.Filters.Exiftool` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md
index b7e3bb2ac..62d4c8a72 100644
--- a/docs/installation/otp_en.md
+++ b/docs/installation/otp_en.md
@@ -27,17 +27,37 @@ Other than things bundled in the OTP release Pleroma depends on:
* PostgreSQL (also utilizes extensions in postgresql-contrib)
* nginx (could be swapped with another reverse proxy but this guide covers only it)
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
+* libmagic/file
=== "Alpine"
```
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
apk update
- apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
+ apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
```
=== "Debian/Ubuntu"
```
- apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
+ apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot libmagic-dev
+ ```
+
+### Installing optional packages
+
+Per [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md):
+ * ImageMagick
+ * ffmpeg
+ * exiftool
+
+=== "Alpine"
+ ```
+ echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
+ apk update
+ apk add imagemagick ffmpeg exiftool
+ ```
+
+=== "Debian/Ubuntu"
+ ```
+ apt install imagemagick ffmpeg libimage-exiftool-perl
```
## Setup
@@ -82,6 +102,8 @@ It is encouraged to check [Optimizing your PostgreSQL performance](../configurat
If you are using PostgreSQL 12 or higher, add this to your Ecto database configuration
```elixir
+#
+config :pleroma, Pleroma.Repo,
prepare: :named,
parameters: [
plan_cache_mode: "force_custom_plan"
diff --git a/installation/pleroma.nginx b/installation/pleroma.nginx
index d301ca615..d613befd2 100644
--- a/installation/pleroma.nginx
+++ b/installation/pleroma.nginx
@@ -9,6 +9,12 @@
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g
inactive=720m use_temp_path=off;
+# this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only
+# and `localhost.` resolves to [::0] on some systems: see issue #930
+upstream phoenix {
+ server 127.0.0.1:4000 max_fails=5 fail_timeout=60s;
+}
+
server {
server_name example.tld;
@@ -63,19 +69,16 @@ server {
# the nginx default is 1m, not enough for large media uploads
client_max_body_size 16m;
+ ignore_invalid_headers off;
- location / {
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- proxy_set_header Host $http_host;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- # this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only
- # and `localhost.` resolves to [::0] on some systems: see issue #930
- proxy_pass http://127.0.0.1:4000;
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- client_max_body_size 16m;
+ location / {
+ proxy_pass http://phoenix;
}
location ~ ^/(media|proxy) {
@@ -83,12 +86,16 @@ server {
slice 1m;
proxy_cache_key $host$uri$is_args$args$slice_range;
proxy_set_header Range $slice_range;
- proxy_http_version 1.1;
proxy_cache_valid 200 206 301 304 1h;
proxy_cache_lock on;
proxy_ignore_client_abort on;
proxy_buffering on;
chunked_transfer_encoding on;
- proxy_pass http://127.0.0.1:4000;
+ proxy_pass http://phoenix;
+ }
+
+ location /api/fedsocket/v1 {
+ proxy_request_buffering off;
+ proxy_pass http://phoenix/api/fedsocket/v1;
}
}
diff --git a/installation/pleroma.vcl b/installation/pleroma.vcl
index 154747aa6..13dad784c 100644
--- a/installation/pleroma.vcl
+++ b/installation/pleroma.vcl
@@ -1,3 +1,4 @@
+# Recommended varnishncsa logging format: '%h %l %u %t "%m %{X-Forwarded-Proto}i://%{Host}i%U%q %H" %s %b "%{Referer}i" "%{User-agent}i"'
vcl 4.1;
import std;
@@ -14,8 +15,11 @@ acl purge {
sub vcl_recv {
# Redirect HTTP to HTTPS
if (std.port(server.ip) != 443) {
+ set req.http.X-Forwarded-Proto = "http";
set req.http.x-redir = "https://" + req.http.host + req.url;
return (synth(750, ""));
+ } else {
+ set req.http.X-Forwarded-Proto = "https";
}
# CHUNKED SUPPORT
@@ -105,7 +109,7 @@ sub vcl_hash {
sub vcl_backend_fetch {
# Be more lenient for slow servers on the fediverse
- if bereq.url ~ "^/proxy/" {
+ if (bereq.url ~ "^/proxy/") {
set bereq.first_byte_timeout = 300s;
}
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex
index fe9b0d16c..49ba2aae4 100644
--- a/lib/mix/pleroma.ex
+++ b/lib/mix/pleroma.ex
@@ -18,6 +18,7 @@ defmodule Mix.Pleroma do
@doc "Common functions to be reused in mix tasks"
def start_pleroma do
Pleroma.Config.Holder.save_default()
+ Pleroma.Config.Oban.warn()
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
if Pleroma.Config.get(:env) != :test do
diff --git a/lib/mix/tasks/pleroma/benchmark.ex b/lib/mix/tasks/pleroma/benchmark.ex
index dd2b9c8f2..a607d5d4f 100644
--- a/lib/mix/tasks/pleroma/benchmark.ex
+++ b/lib/mix/tasks/pleroma/benchmark.ex
@@ -91,20 +91,17 @@ defmodule Mix.Tasks.Pleroma.Benchmark do
"Without conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [pool: :no_pool, receive_conn: false]
+ pool: :no_pool,
+ receive_conn: false
)
end,
"Without conn and with pool" => fn ->
{:ok, %Tesla.Env{}} =
- Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [receive_conn: false]
- )
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], receive_conn: false)
end,
"With reused conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
- Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [pool: :no_pool]
- )
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], pool: :no_pool)
end,
"With reused conn and with pool" => fn ->
{:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")
diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex
index 904c5a74b..18f99318d 100644
--- a/lib/mix/tasks/pleroma/config.ex
+++ b/lib/mix/tasks/pleroma/config.ex
@@ -32,7 +32,8 @@ defmodule Mix.Tasks.Pleroma.Config do
@spec migrate_to_db(Path.t() | nil) :: any()
def migrate_to_db(file_path \\ nil) do
- if Pleroma.Config.get([:configurable_from_database]) do
+ with true <- Pleroma.Config.get([:configurable_from_database]),
+ :ok <- Pleroma.Config.DeprecationWarnings.warn() do
config_file =
if file_path do
file_path
@@ -46,7 +47,8 @@ defmodule Mix.Tasks.Pleroma.Config do
do_migrate_to_db(config_file)
else
- migration_error()
+ :error -> deprecation_error()
+ _ -> migration_error()
end
end
@@ -120,6 +122,10 @@ defmodule Mix.Tasks.Pleroma.Config do
)
end
+ defp deprecation_error do
+ shell_error("Migration is not allowed until all deprecation warnings have been resolved.")
+ end
+
if Code.ensure_loaded?(Config.Reader) do
defp config_header, do: "import Config\r\n\r\n"
defp read_file(config_file), do: Config.Reader.read_imports!(config_file)
diff --git a/lib/mix/tasks/pleroma/count_statuses.ex b/lib/mix/tasks/pleroma/count_statuses.ex
index e1e8195dd..8761d8f17 100644
--- a/lib/mix/tasks/pleroma/count_statuses.ex
+++ b/lib/mix/tasks/pleroma/count_statuses.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Mix.Tasks.Pleroma.CountStatuses do
@shortdoc "Re-counts statuses for all users"
diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex
index 7d8f00b08..a01c36ece 100644
--- a/lib/mix/tasks/pleroma/database.ex
+++ b/lib/mix/tasks/pleroma/database.ex
@@ -99,7 +99,7 @@ defmodule Mix.Tasks.Pleroma.Database do
where: fragment("(?)->>'likes' is not null", object.data),
select: %{id: object.id, likes: fragment("(?)->>'likes'", object.data)}
)
- |> Pleroma.RepoStreamer.chunk_stream(100)
+ |> Pleroma.Repo.chunk_stream(100, :batches)
|> Stream.each(fn objects ->
ids =
objects
@@ -133,8 +133,7 @@ defmodule Mix.Tasks.Pleroma.Database do
days = Pleroma.Config.get([:mrf_activity_expiration, :days], 365)
Pleroma.Activity
- |> join(:left, [a], u in assoc(a, :expiration))
- |> join(:inner, [a, _u], o in Object,
+ |> join(:inner, [a], o in Object,
on:
fragment(
"(?->>'id') = COALESCE((?)->'object'->> 'id', (?)->>'object')",
@@ -144,14 +143,20 @@ defmodule Mix.Tasks.Pleroma.Database do
)
)
|> where(local: true)
- |> where([a, u], is_nil(u))
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
- |> where([_a, _u, o], fragment("?->>'type' = 'Note'", o.data))
- |> Pleroma.RepoStreamer.chunk_stream(100)
+ |> where([_a, o], fragment("?->>'type' = 'Note'", o.data))
+ |> Pleroma.Repo.chunk_stream(100, :batches)
|> Stream.each(fn activities ->
Enum.each(activities, fn activity ->
- expires_at = Timex.shift(activity.inserted_at, days: days)
- Pleroma.ActivityExpiration.create(activity, expires_at, false)
+ expires_at =
+ activity.inserted_at
+ |> DateTime.from_naive!("Etc/UTC")
+ |> Timex.shift(days: days)
+
+ Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
+ activity_id: activity.id,
+ expires_at: expires_at
+ })
end)
end)
|> Stream.run()
diff --git a/lib/mix/tasks/pleroma/digest.ex b/lib/mix/tasks/pleroma/digest.ex
index 3595f912d..cac148b88 100644
--- a/lib/mix/tasks/pleroma/digest.ex
+++ b/lib/mix/tasks/pleroma/digest.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Mix.Tasks.Pleroma.Digest do
use Mix.Task
import Mix.Pleroma
diff --git a/lib/mix/tasks/pleroma/docs.ex b/lib/mix/tasks/pleroma/docs.ex
index 6088fc71d..ad5c37fc9 100644
--- a/lib/mix/tasks/pleroma/docs.ex
+++ b/lib/mix/tasks/pleroma/docs.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Mix.Tasks.Pleroma.Docs do
use Mix.Task
import Mix.Pleroma
diff --git a/lib/mix/tasks/pleroma/ecto/ecto.ex b/lib/mix/tasks/pleroma/ecto.ex
index 3363cd45f..3363cd45f 100644
--- a/lib/mix/tasks/pleroma/ecto/ecto.ex
+++ b/lib/mix/tasks/pleroma/ecto.ex
diff --git a/lib/mix/tasks/pleroma/email.ex b/lib/mix/tasks/pleroma/email.ex
index d3fac6ec8..bc5facc09 100644
--- a/lib/mix/tasks/pleroma/email.ex
+++ b/lib/mix/tasks/pleroma/email.ex
@@ -1,12 +1,16 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Mix.Tasks.Pleroma.Email do
use Mix.Task
import Mix.Pleroma
- @shortdoc "Simple Email test"
+ @shortdoc "Email administrative tasks"
@moduledoc File.read!("docs/administration/CLI_tasks/email.md")
def run(["test" | args]) do
- Mix.Pleroma.start_pleroma()
+ start_pleroma()
{options, [], []} =
OptionParser.parse(
@@ -21,4 +25,20 @@ defmodule Mix.Tasks.Pleroma.Email do
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
end
+
+ def run(["resend_confirmation_emails"]) do
+ start_pleroma()
+
+ shell_info("Sending emails to all unconfirmed users")
+
+ Pleroma.User.Query.build(%{
+ local: true,
+ deactivated: false,
+ confirmation_pending: true,
+ invisible: false
+ })
+ |> Pleroma.Repo.chunk_stream(500)
+ |> Stream.each(&Pleroma.User.try_send_confirmation_email(&1))
+ |> Stream.run()
+ end
end
diff --git a/lib/mix/tasks/pleroma/emoji.ex b/lib/mix/tasks/pleroma/emoji.ex
index 8f52ee98d..1750373f9 100644
--- a/lib/mix/tasks/pleroma/emoji.ex
+++ b/lib/mix/tasks/pleroma/emoji.ex
@@ -183,7 +183,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
IO.puts("Downloading the pack and generating SHA256")
- binary_archive = Tesla.get!(client(), src).body
+ {:ok, %{body: binary_archive}} = Pleroma.HTTP.get(src)
archive_sha = :crypto.hash(:sha256, binary_archive) |> Base.encode16()
IO.puts("SHA256 is #{archive_sha}")
@@ -252,7 +252,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
end
defp fetch("http" <> _ = from) do
- with {:ok, %{body: body}} <- Tesla.get(client(), from) do
+ with {:ok, %{body: body}} <- Pleroma.HTTP.get(from) do
{:ok, body}
end
end
@@ -271,13 +271,5 @@ defmodule Mix.Tasks.Pleroma.Emoji do
)
end
- defp client do
- middleware = [
- {Tesla.Middleware.FollowRedirects, [max_redirects: 3]}
- ]
-
- Tesla.client(middleware)
- end
-
defp default_manifest, do: Pleroma.Config.get!([:emoji, :default_manifest])
end
diff --git a/lib/mix/tasks/pleroma/frontend.ex b/lib/mix/tasks/pleroma/frontend.ex
index 484af6da7..cbce81ab9 100644
--- a/lib/mix/tasks/pleroma/frontend.ex
+++ b/lib/mix/tasks/pleroma/frontend.ex
@@ -69,7 +69,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
fe_label = "#{frontend} (#{ref})"
- tmp_dir = Path.join(dest, "tmp")
+ tmp_dir = Path.join([instance_static_dir, "frontends", "tmp"])
with {_, :ok} <-
{:download_or_unzip, download_or_unzip(frontend_info, tmp_dir, options[:file])},
@@ -124,9 +124,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
url = String.replace(frontend_info["build_url"], "${ref}", frontend_info["ref"])
with {:ok, %{status: 200, body: zip_body}} <-
- Pleroma.HTTP.get(url, [],
- adapter: [pool: :media, timeout: 120_000, recv_timeout: 120_000]
- ) do
+ Pleroma.HTTP.get(url, [], pool: :media, recv_timeout: 120_000) do
unzip(zip_body, dest)
else
e -> {:error, e}
@@ -135,6 +133,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
defp install_frontend(frontend_info, source, dest) do
from = frontend_info["build_dir"] || "dist"
+ File.rm_rf!(dest)
File.mkdir_p!(dest)
File.cp_r!(Path.join([source, from]), dest)
:ok
diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex
index 91440b453..fc21ae062 100644
--- a/lib/mix/tasks/pleroma/instance.ex
+++ b/lib/mix/tasks/pleroma/instance.ex
@@ -33,7 +33,10 @@ defmodule Mix.Tasks.Pleroma.Instance do
uploads_dir: :string,
static_dir: :string,
listen_ip: :string,
- listen_port: :string
+ listen_port: :string,
+ strip_uploads: :string,
+ anonymize_uploads: :string,
+ dedupe_uploads: :string
],
aliases: [
o: :output,
@@ -158,6 +161,30 @@ defmodule Mix.Tasks.Pleroma.Instance do
)
|> Path.expand()
+ strip_uploads =
+ get_option(
+ options,
+ :strip_uploads,
+ "Do you want to strip location (GPS) data from uploaded images? (y/n)",
+ "y"
+ ) === "y"
+
+ anonymize_uploads =
+ get_option(
+ options,
+ :anonymize_uploads,
+ "Do you want to anonymize the filenames of uploads? (y/n)",
+ "n"
+ ) === "y"
+
+ dedupe_uploads =
+ get_option(
+ options,
+ :dedupe_uploads,
+ "Do you want to deduplicate uploaded files? (y/n)",
+ "n"
+ ) === "y"
+
Config.put([:instance, :static_dir], static_dir)
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
@@ -188,7 +215,13 @@ defmodule Mix.Tasks.Pleroma.Instance do
uploads_dir: uploads_dir,
rum_enabled: rum_enabled,
listen_ip: listen_ip,
- listen_port: listen_port
+ listen_port: listen_port,
+ upload_filters:
+ upload_filters(%{
+ strip: strip_uploads,
+ anonymize: anonymize_uploads,
+ dedupe: dedupe_uploads
+ })
)
result_psql =
@@ -247,4 +280,31 @@ defmodule Mix.Tasks.Pleroma.Instance do
File.write(robots_txt_path, robots_txt)
shell_info("Writing #{robots_txt_path}.")
end
+
+ defp upload_filters(filters) when is_map(filters) do
+ enabled_filters =
+ if filters.strip do
+ [Pleroma.Upload.Filter.ExifTool]
+ else
+ []
+ end
+
+ enabled_filters =
+ if filters.anonymize do
+ enabled_filters ++ [Pleroma.Upload.Filter.AnonymizeFilename]
+ else
+ enabled_filters
+ end
+
+ enabled_filters =
+ if filters.dedupe do
+ enabled_filters ++ [Pleroma.Upload.Filter.Dedupe]
+ else
+ enabled_filters
+ end
+
+ enabled_filters
+ end
+
+ defp upload_filters(_), do: []
end
diff --git a/lib/mix/tasks/pleroma/notification_settings.ex b/lib/mix/tasks/pleroma/notification_settings.ex
index 00f5ba7bf..f99275de1 100644
--- a/lib/mix/tasks/pleroma/notification_settings.ex
+++ b/lib/mix/tasks/pleroma/notification_settings.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Mix.Tasks.Pleroma.NotificationSettings do
@shortdoc "Enable&Disable privacy option for push notifications"
@moduledoc """
diff --git a/lib/mix/tasks/pleroma/relay.ex b/lib/mix/tasks/pleroma/relay.ex
index a6d8d6c1c..bb808ca47 100644
--- a/lib/mix/tasks/pleroma/relay.ex
+++ b/lib/mix/tasks/pleroma/relay.ex
@@ -21,10 +21,19 @@ defmodule Mix.Tasks.Pleroma.Relay do
end
end
- def run(["unfollow", target]) do
+ def run(["unfollow", target | rest]) do
start_pleroma()
- with {:ok, _activity} <- Relay.unfollow(target) do
+ {options, [], []} =
+ OptionParser.parse(
+ rest,
+ strict: [force: :boolean],
+ aliases: [f: :force]
+ )
+
+ force = Keyword.get(options, :force, false)
+
+ with {:ok, _activity} <- Relay.unfollow(target, %{force: force}) do
# put this task to sleep to allow the genserver to push out the messages
:timer.sleep(500)
else
diff --git a/lib/mix/tasks/pleroma/robotstxt.ex b/lib/mix/tasks/pleroma/robots_txt.ex
index 24f08180e..24f08180e 100644
--- a/lib/mix/tasks/pleroma/robotstxt.ex
+++ b/lib/mix/tasks/pleroma/robots_txt.ex
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index 01824aa18..a8d251411 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -179,7 +179,7 @@ defmodule Mix.Tasks.Pleroma.User do
start_pleroma()
Pleroma.User.Query.build(%{nickname: "@#{instance}"})
- |> Pleroma.RepoStreamer.chunk_stream(500)
+ |> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user ->
@@ -196,17 +196,24 @@ defmodule Mix.Tasks.Pleroma.User do
OptionParser.parse(
rest,
strict: [
- moderator: :boolean,
admin: :boolean,
- locked: :boolean
+ confirmed: :boolean,
+ locked: :boolean,
+ moderator: :boolean
]
)
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
user =
- case Keyword.get(options, :moderator) do
+ case Keyword.get(options, :admin) do
nil -> user
- value -> set_moderator(user, value)
+ value -> set_admin(user, value)
+ end
+
+ user =
+ case Keyword.get(options, :confirmed) do
+ nil -> user
+ value -> set_confirmed(user, value)
end
user =
@@ -216,9 +223,9 @@ defmodule Mix.Tasks.Pleroma.User do
end
_user =
- case Keyword.get(options, :admin) do
+ case Keyword.get(options, :moderator) do
nil -> user
- value -> set_admin(user, value)
+ value -> set_moderator(user, value)
end
else
_ ->
@@ -353,6 +360,42 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
+ def run(["confirm_all"]) do
+ start_pleroma()
+
+ Pleroma.User.Query.build(%{
+ local: true,
+ deactivated: false,
+ is_moderator: false,
+ is_admin: false,
+ invisible: false
+ })
+ |> Pleroma.Repo.chunk_stream(500, :batches)
+ |> Stream.each(fn users ->
+ users
+ |> Enum.each(fn user -> User.need_confirmation(user, false) end)
+ end)
+ |> Stream.run()
+ end
+
+ def run(["unconfirm_all"]) do
+ start_pleroma()
+
+ Pleroma.User.Query.build(%{
+ local: true,
+ deactivated: false,
+ is_moderator: false,
+ is_admin: false,
+ invisible: false
+ })
+ |> Pleroma.Repo.chunk_stream(500, :batches)
+ |> Stream.each(fn users ->
+ users
+ |> Enum.each(fn user -> User.need_confirmation(user, true) end)
+ end)
+ |> Stream.run()
+ end
+
def run(["sign_out", nickname]) do
start_pleroma()
@@ -370,13 +413,13 @@ defmodule Mix.Tasks.Pleroma.User do
start_pleroma()
Pleroma.User.Query.build(%{local: true})
- |> Pleroma.RepoStreamer.chunk_stream(500)
+ |> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user ->
shell_info(
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
- user.locked
+ user.is_locked
}, deactivated: #{user.deactivated}"
)
end)
@@ -404,10 +447,17 @@ defmodule Mix.Tasks.Pleroma.User do
defp set_locked(user, value) do
{:ok, user} =
user
- |> Changeset.change(%{locked: value})
+ |> Changeset.change(%{is_locked: value})
|> User.update_and_set_cache()
- shell_info("Locked status of #{user.nickname}: #{user.locked}")
+ shell_info("Locked status of #{user.nickname}: #{user.is_locked}")
+ user
+ end
+
+ defp set_confirmed(user, value) do
+ {:ok, user} = User.need_confirmation(user, !value)
+
+ shell_info("Confirmation pending status of #{user.nickname}: #{user.confirmation_pending}")
user
end
end
diff --git a/lib/phoenix/transports/web_socket/raw.ex b/lib/phoenix/transports/web_socket/raw.ex
new file mode 100644
index 000000000..c3665bebe
--- /dev/null
+++ b/lib/phoenix/transports/web_socket/raw.ex
@@ -0,0 +1,94 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Phoenix.Transports.WebSocket.Raw do
+ import Plug.Conn,
+ only: [
+ fetch_query_params: 1,
+ send_resp: 3
+ ]
+
+ alias Phoenix.Socket.Transport
+
+ def default_config do
+ [
+ timeout: 60_000,
+ transport_log: false,
+ cowboy: Phoenix.Endpoint.CowboyWebSocket
+ ]
+ end
+
+ def init(%Plug.Conn{method: "GET"} = conn, {endpoint, handler, transport}) do
+ {_, opts} = handler.__transport__(transport)
+
+ conn =
+ conn
+ |> fetch_query_params
+ |> Transport.transport_log(opts[:transport_log])
+ |> Transport.force_ssl(handler, endpoint, opts)
+ |> Transport.check_origin(handler, endpoint, opts)
+
+ case conn do
+ %{halted: false} = conn ->
+ case handler.connect(%{
+ endpoint: endpoint,
+ transport: transport,
+ options: [serializer: nil],
+ params: conn.params
+ }) do
+ {:ok, socket} ->
+ {:ok, conn, {__MODULE__, {socket, opts}}}
+
+ :error ->
+ send_resp(conn, :forbidden, "")
+ {:error, conn}
+ end
+
+ _ ->
+ {:error, conn}
+ end
+ end
+
+ def init(conn, _) do
+ send_resp(conn, :bad_request, "")
+ {:error, conn}
+ end
+
+ def ws_init({socket, config}) do
+ Process.flag(:trap_exit, true)
+ {:ok, %{socket: socket}, config[:timeout]}
+ end
+
+ def ws_handle(op, data, state) do
+ state.socket.handler
+ |> apply(:handle, [op, data, state])
+ |> case do
+ {op, data} ->
+ {:reply, {op, data}, state}
+
+ {op, data, state} ->
+ {:reply, {op, data}, state}
+
+ %{} = state ->
+ {:ok, state}
+
+ _ ->
+ {:ok, state}
+ end
+ end
+
+ def ws_info({_, _} = tuple, state) do
+ {:reply, tuple, state}
+ end
+
+ def ws_info(_tuple, state), do: {:ok, state}
+
+ def ws_close(state) do
+ ws_handle(:closed, :normal, state)
+ end
+
+ def ws_terminate(reason, state) do
+ ws_handle(:closed, reason, state)
+ end
+end
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 97feebeaa..17af04257 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -7,7 +7,6 @@ defmodule Pleroma.Activity do
alias Pleroma.Activity
alias Pleroma.Activity.Queries
- alias Pleroma.ActivityExpiration
alias Pleroma.Bookmark
alias Pleroma.Notification
alias Pleroma.Object
@@ -60,8 +59,6 @@ defmodule Pleroma.Activity do
# typical case.
has_one(:object, Object, on_delete: :nothing, foreign_key: :id)
- has_one(:expiration, ActivityExpiration, on_delete: :delete_all)
-
timestamps()
end
@@ -304,14 +301,14 @@ defmodule Pleroma.Activity do
|> Repo.all()
end
- def follow_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
+ def follow_requests_for_actor(%User{ap_id: ap_id}) do
ap_id
|> Queries.by_object_id()
|> Queries.by_type("Follow")
|> where([a], fragment("? ->> 'state' = 'pending'", a.data))
end
- def following_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
+ def following_requests_for_actor(%User{ap_id: ap_id}) do
Queries.by_type("Follow")
|> where([a], fragment("?->>'state' = 'pending'", a.data))
|> where([a], a.actor == ^ap_id)
diff --git a/lib/pleroma/activity_expiration.ex b/lib/pleroma/activity_expiration.ex
deleted file mode 100644
index 955f0578e..000000000
--- a/lib/pleroma/activity_expiration.ex
+++ /dev/null
@@ -1,74 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.ActivityExpiration do
- use Ecto.Schema
-
- alias Pleroma.Activity
- alias Pleroma.ActivityExpiration
- alias Pleroma.Repo
-
- import Ecto.Changeset
- import Ecto.Query
-
- @type t :: %__MODULE__{}
- @min_activity_lifetime :timer.hours(1)
-
- schema "activity_expirations" do
- belongs_to(:activity, Activity, type: FlakeId.Ecto.CompatType)
- field(:scheduled_at, :naive_datetime)
- end
-
- def changeset(%ActivityExpiration{} = expiration, attrs, validate_scheduled_at) do
- expiration
- |> cast(attrs, [:scheduled_at])
- |> validate_required([:scheduled_at])
- |> validate_scheduled_at(validate_scheduled_at)
- end
-
- def get_by_activity_id(activity_id) do
- ActivityExpiration
- |> where([exp], exp.activity_id == ^activity_id)
- |> Repo.one()
- end
-
- def create(%Activity{} = activity, scheduled_at, validate_scheduled_at \\ true) do
- %ActivityExpiration{activity_id: activity.id}
- |> changeset(%{scheduled_at: scheduled_at}, validate_scheduled_at)
- |> Repo.insert()
- end
-
- def due_expirations(offset \\ 0) do
- naive_datetime =
- NaiveDateTime.utc_now()
- |> NaiveDateTime.add(offset, :millisecond)
-
- ActivityExpiration
- |> where([exp], exp.scheduled_at < ^naive_datetime)
- |> limit(50)
- |> preload(:activity)
- |> Repo.all()
- |> Enum.reject(fn %{activity: activity} ->
- Activity.pinned_by_actor?(activity)
- end)
- end
-
- def validate_scheduled_at(changeset, false), do: changeset
-
- def validate_scheduled_at(changeset, true) do
- validate_change(changeset, :scheduled_at, fn _, scheduled_at ->
- if not expires_late_enough?(scheduled_at) do
- [scheduled_at: "an ephemeral activity must live for at least one hour"]
- else
- []
- end
- end)
- end
-
- def expires_late_enough?(scheduled_at) do
- now = NaiveDateTime.utc_now()
- diff = NaiveDateTime.diff(scheduled_at, now, :millisecond)
- diff > @min_activity_lifetime
- end
-end
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index c0b5db9f1..51e9dda3b 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -22,13 +22,18 @@ defmodule Pleroma.Application do
def repository, do: @repository
def user_agent do
- case Config.get([:http, :user_agent], :default) do
- :default ->
- info = "#{Pleroma.Web.base_url()} <#{Config.get([:instance, :email], "")}>"
- named_version() <> "; " <> info
-
- custom ->
- custom
+ if Process.whereis(Pleroma.Web.Endpoint) do
+ case Config.get([:http, :user_agent], :default) do
+ :default ->
+ info = "#{Pleroma.Web.base_url()} <#{Config.get([:instance, :email], "")}>"
+ named_version() <> "; " <> info
+
+ custom ->
+ custom
+ end
+ else
+ # fallback, if endpoint is not started yet
+ "Pleroma Data Loader"
end
end
@@ -39,15 +44,18 @@ defmodule Pleroma.Application do
# every time the application is restarted, so we disable module
# conflicts at runtime
Code.compiler_options(ignore_module_conflict: true)
+ # Disable warnings_as_errors at runtime, it breaks Phoenix live reload
+ # due to protocol consolidation warnings
+ Code.compiler_options(warnings_as_errors: false)
Pleroma.Telemetry.Logger.attach()
Config.Holder.save_default()
Pleroma.HTML.compile_scrubbers()
+ Pleroma.Config.Oban.warn()
Config.DeprecationWarnings.warn()
- Pleroma.Plugs.HTTPSecurityPlug.warn_if_disabled()
+ Pleroma.Web.Plugs.HTTPSecurityPlug.warn_if_disabled()
Pleroma.ApplicationRequirements.verify!()
setup_instrumenters()
load_custom_modules()
- check_system_commands()
Pleroma.Docs.JSON.compile()
adapter = Application.get_env(:tesla, :adapter)
@@ -80,18 +88,19 @@ defmodule Pleroma.Application do
Pleroma.Repo,
Config.TransferTask,
Pleroma.Emoji,
- Pleroma.Plugs.RateLimiter.Supervisor
+ Pleroma.Web.Plugs.RateLimiter.Supervisor
] ++
cachex_children() ++
http_children(adapter, @env) ++
[
Pleroma.Stats,
Pleroma.JobQueueMonitor,
+ {Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
{Oban, Config.get(Oban)}
] ++
task_children(@env) ++
- streamer_child(@env) ++
- chat_child(@env, chat_enabled?()) ++
+ dont_run_in_test(@env) ++
+ chat_child(chat_enabled?()) ++
[
Pleroma.Web.Endpoint,
Pleroma.Gopher.Server
@@ -142,7 +151,10 @@ defmodule Pleroma.Application do
Pleroma.Web.Endpoint.MetricsExporter.setup()
Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
- Pleroma.Web.Endpoint.Instrumenter.setup()
+
+ # Note: disabled until prometheus-phx is integrated into prometheus-phoenix:
+ # Pleroma.Web.Endpoint.Instrumenter.setup()
+ PrometheusPhx.setup()
end
defp cachex_children do
@@ -179,24 +191,28 @@ defmodule Pleroma.Application do
defp chat_enabled?, do: Config.get([:chat, :enabled])
- defp streamer_child(env) when env in [:test, :benchmark], do: []
+ defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
- defp streamer_child(_) do
+ defp dont_run_in_test(_) do
[
{Registry,
[
name: Pleroma.Web.Streamer.registry(),
keys: :duplicate,
partitions: System.schedulers_online()
- ]}
+ ]},
+ Pleroma.Web.FedSockets.Supervisor
]
end
- defp chat_child(_env, true) do
- [Pleroma.Web.ChatChannel.ChatChannelState]
+ defp chat_child(true) do
+ [
+ Pleroma.Web.ChatChannel.ChatChannelState,
+ {Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
+ ]
end
- defp chat_child(_, _), do: []
+ defp chat_child(_), do: []
defp task_children(:test) do
[
@@ -250,21 +266,4 @@ defmodule Pleroma.Application do
end
defp http_children(_, _), do: []
-
- defp check_system_commands do
- filters = Config.get([Pleroma.Upload, :filters])
-
- check_filter = fn filter, command_required ->
- with true <- filter in filters,
- false <- Pleroma.Utils.command_available?(command_required) do
- Logger.error(
- "#{filter} is specified in list of Pleroma.Upload filters, but the #{command_required} command is not found"
- )
- end
- end
-
- check_filter.(Pleroma.Upload.Filters.Exiftool, "exiftool")
- check_filter.(Pleroma.Upload.Filters.Mogrify, "mogrify")
- check_filter.(Pleroma.Upload.Filters.Mogrifun, "mogrify")
- end
end
diff --git a/lib/pleroma/application_requirements.ex b/lib/pleroma/application_requirements.ex
index 16f62b6f5..b977257a3 100644
--- a/lib/pleroma/application_requirements.ex
+++ b/lib/pleroma/application_requirements.ex
@@ -9,6 +9,9 @@ defmodule Pleroma.ApplicationRequirements do
defmodule VerifyError, do: defexception([:message])
+ alias Pleroma.Config
+ alias Pleroma.Helpers.MediaHelper
+
import Ecto.Query
require Logger
@@ -16,7 +19,8 @@ defmodule Pleroma.ApplicationRequirements do
@spec verify!() :: :ok | VerifyError.t()
def verify! do
:ok
- |> check_confirmation_accounts!
+ |> check_system_commands!()
+ |> check_confirmation_accounts!()
|> check_migrations_applied!()
|> check_welcome_message_config!()
|> check_rum!()
@@ -48,7 +52,9 @@ defmodule Pleroma.ApplicationRequirements do
if Pleroma.Config.get([:instance, :account_activation_required]) &&
not Pleroma.Config.get([Pleroma.Emails.Mailer, :enabled]) do
Logger.error(
- "Account activation enabled, but no Mailer settings enabled.\nPlease set config :pleroma, :instance, account_activation_required: false\nOtherwise setup and enable Mailer."
+ "Account activation enabled, but no Mailer settings enabled.\n" <>
+ "Please set config :pleroma, :instance, account_activation_required: false\n" <>
+ "Otherwise setup and enable Mailer."
)
{:error,
@@ -81,7 +87,9 @@ defmodule Pleroma.ApplicationRequirements do
Enum.map(down_migrations, fn {:down, id, name} -> "- #{name} (#{id})\n" end)
Logger.error(
- "The following migrations were not applied:\n#{down_migrations_text}If you want to start Pleroma anyway, set\nconfig :pleroma, :i_am_aware_this_may_cause_data_loss, disable_migration_check: true"
+ "The following migrations were not applied:\n#{down_migrations_text}" <>
+ "If you want to start Pleroma anyway, set\n" <>
+ "config :pleroma, :i_am_aware_this_may_cause_data_loss, disable_migration_check: true"
)
{:error, "Unapplied Migrations detected"}
@@ -124,14 +132,22 @@ defmodule Pleroma.ApplicationRequirements do
case {setting, migrate} do
{true, false} ->
Logger.error(
- "Use `RUM` index is enabled, but were not applied migrations for it.\nIf you want to start Pleroma anyway, set\nconfig :pleroma, :database, rum_enabled: false\nOtherwise apply the following migrations:\n`mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/`"
+ "Use `RUM` index is enabled, but were not applied migrations for it.\n" <>
+ "If you want to start Pleroma anyway, set\n" <>
+ "config :pleroma, :database, rum_enabled: false\n" <>
+ "Otherwise apply the following migrations:\n" <>
+ "`mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/`"
)
{:error, "Unapplied RUM Migrations detected"}
{false, true} ->
Logger.error(
- "Detected applied migrations to use `RUM` index, but `RUM` isn't enable in settings.\nIf you want to use `RUM`, set\nconfig :pleroma, :database, rum_enabled: true\nOtherwise roll `RUM` migrations back.\n`mix ecto.rollback --migrations-path priv/repo/optional_migrations/rum_indexing/`"
+ "Detected applied migrations to use `RUM` index, but `RUM` isn't enable in settings.\n" <>
+ "If you want to use `RUM`, set\n" <>
+ "config :pleroma, :database, rum_enabled: true\n" <>
+ "Otherwise roll `RUM` migrations back.\n" <>
+ "`mix ecto.rollback --migrations-path priv/repo/optional_migrations/rum_indexing/`"
)
{:error, "RUM Migrations detected"}
@@ -140,4 +156,50 @@ defmodule Pleroma.ApplicationRequirements do
:ok
end
end
+
+ defp check_system_commands!(:ok) do
+ filter_commands_statuses = [
+ check_filter(Pleroma.Upload.Filters.Exiftool, "exiftool"),
+ check_filter(Pleroma.Upload.Filters.Mogrify, "mogrify"),
+ check_filter(Pleroma.Upload.Filters.Mogrifun, "mogrify")
+ ]
+
+ preview_proxy_commands_status =
+ if !Config.get([:media_preview_proxy, :enabled]) or
+ MediaHelper.missing_dependencies() == [] do
+ true
+ else
+ Logger.error(
+ "The following dependencies required by Media preview proxy " <>
+ "(which is currently enabled) are not installed: " <>
+ inspect(MediaHelper.missing_dependencies())
+ )
+
+ false
+ end
+
+ if Enum.all?([preview_proxy_commands_status | filter_commands_statuses], & &1) do
+ :ok
+ else
+ {:error,
+ "System commands missing. Check logs and see `docs/installation` for more details."}
+ end
+ end
+
+ defp check_system_commands!(result), do: result
+
+ defp check_filter(filter, command_required) do
+ filters = Config.get([Pleroma.Upload, :filters])
+
+ if filter in filters and not Pleroma.Utils.command_available?(command_required) do
+ Logger.error(
+ "#{filter} is specified in list of Pleroma.Upload filters, but the " <>
+ "#{command_required} command is not found"
+ )
+
+ false
+ else
+ true
+ end
+ end
end
diff --git a/lib/pleroma/bbs/authenticator.ex b/lib/pleroma/bbs/authenticator.ex
index 815de7002..83ebb756d 100644
--- a/lib/pleroma/bbs/authenticator.ex
+++ b/lib/pleroma/bbs/authenticator.ex
@@ -4,8 +4,8 @@
defmodule Pleroma.BBS.Authenticator do
use Sshd.PasswordAuthenticator
- alias Pleroma.Plugs.AuthenticationPlug
alias Pleroma.User
+ alias Pleroma.Web.Plugs.AuthenticationPlug
def authenticate(username, password) do
username = to_string(username)
diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha.ex
index 6ab754b6f..6ab754b6f 100644
--- a/lib/pleroma/captcha/captcha.ex
+++ b/lib/pleroma/captcha.ex
diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex
index 337506647..201b55ab4 100644
--- a/lib/pleroma/captcha/kocaptcha.ex
+++ b/lib/pleroma/captcha/kocaptcha.ex
@@ -10,7 +10,7 @@ defmodule Pleroma.Captcha.Kocaptcha do
def new do
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
- case Tesla.get(endpoint <> "/new") do
+ case Pleroma.HTTP.get(endpoint <> "/new") do
{:error, _} ->
%{error: :kocaptcha_service_unavailable}
diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/service.ex
index 959038cef..959038cef 100644
--- a/lib/pleroma/captcha/captcha_service.ex
+++ b/lib/pleroma/captcha/service.ex
diff --git a/lib/pleroma/chat.ex b/lib/pleroma/chat.ex
index 24a86371e..28007cd9f 100644
--- a/lib/pleroma/chat.ex
+++ b/lib/pleroma/chat.ex
@@ -6,7 +6,9 @@ defmodule Pleroma.Chat do
use Ecto.Schema
import Ecto.Changeset
+ import Ecto.Query
+ alias Pleroma.Chat
alias Pleroma.Repo
alias Pleroma.User
@@ -16,6 +18,7 @@ defmodule Pleroma.Chat do
It is a helper only, to make it easy to display a list of chats with other people, ordered by last bump. The actual messages are retrieved by querying the recipients of the ChatMessages.
"""
+ @type t :: %__MODULE__{}
@primary_key {:id, FlakeId.Ecto.CompatType, autogenerate: true}
schema "chats" do
@@ -39,16 +42,28 @@ defmodule Pleroma.Chat do
|> unique_constraint(:user_id, name: :chats_user_id_recipient_index)
end
+ @spec get_by_user_and_id(User.t(), FlakeId.Ecto.CompatType.t()) ::
+ {:ok, t()} | {:error, :not_found}
+ def get_by_user_and_id(%User{id: user_id}, id) do
+ from(c in __MODULE__,
+ where: c.id == ^id,
+ where: c.user_id == ^user_id
+ )
+ |> Repo.find_resource()
+ end
+
+ @spec get_by_id(FlakeId.Ecto.CompatType.t()) :: t() | nil
def get_by_id(id) do
- __MODULE__
- |> Repo.get(id)
+ Repo.get(__MODULE__, id)
end
+ @spec get(FlakeId.Ecto.CompatType.t(), String.t()) :: t() | nil
def get(user_id, recipient) do
- __MODULE__
- |> Repo.get_by(user_id: user_id, recipient: recipient)
+ Repo.get_by(__MODULE__, user_id: user_id, recipient: recipient)
end
+ @spec get_or_create(FlakeId.Ecto.CompatType.t(), String.t()) ::
+ {:ok, t()} | {:error, Ecto.Changeset.t()}
def get_or_create(user_id, recipient) do
%__MODULE__{}
|> changeset(%{user_id: user_id, recipient: recipient})
@@ -60,6 +75,8 @@ defmodule Pleroma.Chat do
)
end
+ @spec bump_or_create(FlakeId.Ecto.CompatType.t(), String.t()) ::
+ {:ok, t()} | {:error, Ecto.Changeset.t()}
def bump_or_create(user_id, recipient) do
%__MODULE__{}
|> changeset(%{user_id: user_id, recipient: recipient})
@@ -69,4 +86,12 @@ defmodule Pleroma.Chat do
conflict_target: [:user_id, :recipient]
)
end
+
+ @spec for_user_query(FlakeId.Ecto.CompatType.t()) :: Ecto.Query.t()
+ def for_user_query(user_id) do
+ from(c in Chat,
+ where: c.user_id == ^user_id,
+ order_by: [desc: c.updated_at]
+ )
+ end
end
diff --git a/lib/pleroma/config/deprecation_warnings.ex b/lib/pleroma/config/deprecation_warnings.ex
index 0f52eb210..59c6b0f58 100644
--- a/lib/pleroma/config/deprecation_warnings.ex
+++ b/lib/pleroma/config/deprecation_warnings.ex
@@ -8,7 +8,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
require Logger
alias Pleroma.Config
- @type config_namespace() :: [atom()]
+ @type config_namespace() :: atom() | [atom()]
@type config_map() :: {config_namespace(), config_namespace(), String.t()}
@mrf_config_map [
@@ -26,36 +26,26 @@ defmodule Pleroma.Config.DeprecationWarnings do
!!!DEPRECATION WARNING!!!
You are using the old configuration mechanism for the hellthread filter. Please check config.md.
""")
- end
- end
-
- def mrf_user_allowlist do
- config = Config.get(:mrf_user_allowlist)
-
- if config && Enum.any?(config, fn {k, _} -> is_atom(k) end) do
- rewritten =
- Enum.reduce(Config.get(:mrf_user_allowlist), Map.new(), fn {k, v}, acc ->
- Map.put(acc, to_string(k), v)
- end)
-
- Config.put(:mrf_user_allowlist, rewritten)
- Logger.error("""
- !!!DEPRECATION WARNING!!!
- As of Pleroma 2.0.7, the `mrf_user_allowlist` setting changed of format.
- Pleroma 2.1 will remove support for the old format. Please change your configuration to match this:
-
- config :pleroma, :mrf_user_allowlist, #{inspect(rewritten, pretty: true)}
- """)
+ :error
+ else
+ :ok
end
end
def warn do
- check_hellthread_threshold()
- mrf_user_allowlist()
- check_old_mrf_config()
- check_media_proxy_whitelist_config()
- check_welcome_message_config()
+ with :ok <- check_hellthread_threshold(),
+ :ok <- check_old_mrf_config(),
+ :ok <- check_media_proxy_whitelist_config(),
+ :ok <- check_welcome_message_config(),
+ :ok <- check_gun_pool_options(),
+ :ok <- check_activity_expiration_config(),
+ :ok <- check_remote_ip_plug_name() do
+ :ok
+ else
+ _ ->
+ :error
+ end
end
def check_welcome_message_config do
@@ -68,10 +58,14 @@ defmodule Pleroma.Config.DeprecationWarnings do
if use_old_config do
Logger.error("""
!!!DEPRECATION WARNING!!!
- Your config is using the old namespace for Welcome messages configuration. You need to change to the new namespace:
- \n* `config :pleroma, :instance, welcome_user_nickname` is now `config :pleroma, :welcome, :direct_message, :sender_nickname`
- \n* `config :pleroma, :instance, welcome_message` is now `config :pleroma, :welcome, :direct_message, :message`
+ Your config is using the old namespace for Welcome messages configuration. You need to convert to the new namespace. e.g.,
+ \n* `config :pleroma, :instance, welcome_user_nickname` and `config :pleroma, :instance, welcome_message` are now equal to:
+ \n* `config :pleroma, :welcome, direct_message: [enabled: true, sender_nickname: "NICKNAME", message: "Your welcome message"]`"
""")
+
+ :error
+ else
+ :ok
end
end
@@ -99,8 +93,11 @@ defmodule Pleroma.Config.DeprecationWarnings do
end
end)
- if warning != "" do
+ if warning == "" do
+ :ok
+ else
Logger.warn(warning_preface <> warning)
+ :error
end
end
@@ -113,6 +110,87 @@ defmodule Pleroma.Config.DeprecationWarnings do
!!!DEPRECATION WARNING!!!
Your config is using old format (only domain) for MediaProxy whitelist option. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
""")
+
+ :error
+ else
+ :ok
end
end
+
+ def check_gun_pool_options do
+ pool_config = Config.get(:connections_pool)
+
+ if timeout = pool_config[:await_up_timeout] do
+ Logger.warn("""
+ !!!DEPRECATION WARNING!!!
+ Your config is using old setting `config :pleroma, :connections_pool, await_up_timeout`. Please change to `config :pleroma, :connections_pool, connect_timeout` to ensure compatibility with future releases.
+ """)
+
+ Config.put(:connections_pool, Keyword.put_new(pool_config, :connect_timeout, timeout))
+ end
+
+ pools_configs = Config.get(:pools)
+
+ warning_preface = """
+ !!!DEPRECATION WARNING!!!
+ Your config is using old setting name `timeout` instead of `recv_timeout` in pool settings. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
+ """
+
+ updated_config =
+ Enum.reduce(pools_configs, [], fn {pool_name, config}, acc ->
+ if timeout = config[:timeout] do
+ Keyword.put(acc, pool_name, Keyword.put_new(config, :recv_timeout, timeout))
+ else
+ acc
+ end
+ end)
+
+ if updated_config != [] do
+ pool_warnings =
+ updated_config
+ |> Keyword.keys()
+ |> Enum.map(fn pool_name ->
+ "\n* `:timeout` options in #{pool_name} pool is now `:recv_timeout`"
+ end)
+
+ Logger.warn(Enum.join([warning_preface | pool_warnings]))
+
+ Config.put(:pools, updated_config)
+ :error
+ else
+ :ok
+ end
+ end
+
+ @spec check_activity_expiration_config() :: :ok | nil
+ def check_activity_expiration_config do
+ warning_preface = """
+ !!!DEPRECATION WARNING!!!
+ Your config is using old namespace for activity expiration configuration. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
+ """
+
+ move_namespace_and_warn(
+ [
+ {Pleroma.ActivityExpiration, Pleroma.Workers.PurgeExpiredActivity,
+ "\n* `config :pleroma, Pleroma.ActivityExpiration` is now `config :pleroma, Pleroma.Workers.PurgeExpiredActivity`"}
+ ],
+ warning_preface
+ )
+ end
+
+ @spec check_remote_ip_plug_name() :: :ok | nil
+ def check_remote_ip_plug_name do
+ warning_preface = """
+ !!!DEPRECATION WARNING!!!
+ Your config is using old namespace for RemoteIp Plug. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
+ """
+
+ move_namespace_and_warn(
+ [
+ {Pleroma.Plugs.RemoteIp, Pleroma.Web.Plugs.RemoteIp,
+ "\n* `config :pleroma, Pleroma.Plugs.RemoteIp` is now `config :pleroma, Pleroma.Web.Plugs.RemoteIp`"}
+ ],
+ warning_preface
+ )
+ end
end
diff --git a/lib/pleroma/config/oban.ex b/lib/pleroma/config/oban.ex
new file mode 100644
index 000000000..8e0351d52
--- /dev/null
+++ b/lib/pleroma/config/oban.ex
@@ -0,0 +1,38 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Config.Oban do
+ require Logger
+
+ def warn do
+ oban_config = Pleroma.Config.get(Oban)
+
+ crontab =
+ [
+ Pleroma.Workers.Cron.StatsWorker,
+ Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker,
+ Pleroma.Workers.Cron.ClearOauthTokenWorker
+ ]
+ |> Enum.reduce(oban_config[:crontab], fn removed_worker, acc ->
+ with acc when is_list(acc) <- acc,
+ setting when is_tuple(setting) <-
+ Enum.find(acc, fn {_, worker} -> worker == removed_worker end) do
+ """
+ !!!OBAN CONFIG WARNING!!!
+ You are using old workers in Oban crontab settings, which were removed.
+ Please, remove setting from crontab in your config file (prod.secret.exs): #{
+ inspect(setting)
+ }
+ """
+ |> Logger.warn()
+
+ List.delete(acc, setting)
+ else
+ _ -> acc
+ end
+ end)
+
+ Pleroma.Config.put(Oban, Keyword.put(oban_config, :crontab, crontab))
+ end
+end
diff --git a/lib/pleroma/config/config_db.ex b/lib/pleroma/config_db.ex
index e5b7811aa..e5b7811aa 100644
--- a/lib/pleroma/config/config_db.ex
+++ b/lib/pleroma/config_db.ex
diff --git a/lib/pleroma/conversation/participation_recipient_ship.ex b/lib/pleroma/conversation/participation/recipient_ship.ex
index de40bacac..de40bacac 100644
--- a/lib/pleroma/conversation/participation_recipient_ship.ex
+++ b/lib/pleroma/conversation/participation/recipient_ship.ex
diff --git a/lib/pleroma/docs/generator.ex b/lib/pleroma/docs/generator.ex
index a671a6278..a70f83b73 100644
--- a/lib/pleroma/docs/generator.ex
+++ b/lib/pleroma/docs/generator.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Docs.Generator do
@callback process(keyword()) :: {:ok, String.t()}
diff --git a/lib/pleroma/docs/json.ex b/lib/pleroma/docs/json.ex
index feeb4320e..13618b509 100644
--- a/lib/pleroma/docs/json.ex
+++ b/lib/pleroma/docs/json.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Docs.JSON do
@behaviour Pleroma.Docs.Generator
@external_resource "config/description.exs"
diff --git a/lib/pleroma/docs/markdown.ex b/lib/pleroma/docs/markdown.ex
index da3f20f43..eac0789a6 100644
--- a/lib/pleroma/docs/markdown.ex
+++ b/lib/pleroma/docs/markdown.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Docs.Markdown do
@behaviour Pleroma.Docs.Generator
diff --git a/lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex b/lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex
new file mode 100644
index 000000000..4aacc5c88
--- /dev/null
+++ b/lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex
@@ -0,0 +1,34 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji do
+ use Ecto.Type
+
+ def type, do: :map
+
+ def cast(data) when is_map(data) do
+ has_invalid_emoji? =
+ Enum.find(data, fn
+ {name, uri} when is_binary(name) and is_binary(uri) ->
+ # based on ObjectValidators.Uri.cast()
+ case URI.parse(uri) do
+ %URI{host: nil} -> true
+ %URI{host: ""} -> true
+ %URI{scheme: scheme} when scheme in ["https", "http"] -> false
+ _ -> true
+ end
+
+ {_name, _uri} ->
+ true
+ end)
+
+ if has_invalid_emoji?, do: :error, else: {:ok, data}
+ end
+
+ def cast(_data), do: :error
+
+ def dump(data), do: {:ok, data}
+
+ def load(data), do: {:ok, data}
+end
diff --git a/lib/pleroma/emails/admin_email.ex b/lib/pleroma/emails/admin_email.ex
index c27ad1065..8979db2f8 100644
--- a/lib/pleroma/emails/admin_email.ex
+++ b/lib/pleroma/emails/admin_email.ex
@@ -88,7 +88,7 @@ defmodule Pleroma.Emails.AdminEmail do
html_body = """
<p>New account for review: <a href="#{user_url(account)}">@#{account.nickname}</a></p>
<blockquote>#{HTML.strip_tags(account.registration_reason)}</blockquote>
- <a href="#{Pleroma.Web.base_url()}/pleroma/admin">Visit AdminFE</a>
+ <a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
"""
new()
diff --git a/lib/pleroma/emails/mailer.ex b/lib/pleroma/emails/mailer.ex
index 8b1bdef75..5108c71c8 100644
--- a/lib/pleroma/emails/mailer.ex
+++ b/lib/pleroma/emails/mailer.ex
@@ -35,6 +35,11 @@ defmodule Pleroma.Emails.Mailer do
def deliver(email, config \\ [])
def deliver(email, config) do
+ # temporary hackney fix until hackney max_connections bug is fixed
+ # https://git.pleroma.social/pleroma/pleroma/-/issues/2101
+ email =
+ Swoosh.Email.put_private(email, :hackney_options, ssl_options: [versions: [:"tlsv1.2"]])
+
case enabled?() do
true -> Swoosh.Mailer.deliver(email, parse_config(config))
false -> {:error, :deliveries_disabled}
diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex
index f6016d73f..04936155b 100644
--- a/lib/pleroma/emoji.ex
+++ b/lib/pleroma/emoji.ex
@@ -56,6 +56,9 @@ defmodule Pleroma.Emoji do
end
end
+ @spec exist?(String.t()) :: boolean()
+ def exist?(name), do: not is_nil(get(name))
+
@doc "Returns all the emojos!!"
@spec get_all() :: list({String.t(), String.t(), String.t()})
def get_all do
diff --git a/lib/pleroma/emoji/pack.ex b/lib/pleroma/emoji/pack.ex
index d076ae312..ca58e5432 100644
--- a/lib/pleroma/emoji/pack.ex
+++ b/lib/pleroma/emoji/pack.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Emoji.Pack do
@derive {Jason.Encoder, only: [:files, :pack, :files_count]}
defstruct files: %{},
@@ -17,6 +21,7 @@ defmodule Pleroma.Emoji.Pack do
}
alias Pleroma.Emoji
+ alias Pleroma.Emoji.Pack
@spec create(String.t()) :: {:ok, t()} | {:error, File.posix()} | {:error, :empty_values}
def create(name) do
@@ -64,24 +69,93 @@ defmodule Pleroma.Emoji.Pack do
end
end
- @spec add_file(String.t(), String.t(), Path.t(), Plug.Upload.t() | String.t()) ::
- {:ok, t()} | {:error, File.posix() | atom()}
- def add_file(name, shortcode, filename, file) do
- with :ok <- validate_not_empty([name, shortcode, filename]),
+ @spec unpack_zip_emojies(list(tuple())) :: list(map())
+ defp unpack_zip_emojies(zip_files) do
+ Enum.reduce(zip_files, [], fn
+ {_, path, s, _, _, _}, acc when elem(s, 2) == :regular ->
+ with(
+ filename <- Path.basename(path),
+ shortcode <- Path.basename(filename, Path.extname(filename)),
+ false <- Emoji.exist?(shortcode)
+ ) do
+ [%{path: path, filename: path, shortcode: shortcode} | acc]
+ else
+ _ -> acc
+ end
+
+ _, acc ->
+ acc
+ end)
+ end
+
+ @spec add_file(t(), String.t(), Path.t(), Plug.Upload.t()) ::
+ {:ok, t()}
+ | {:error, File.posix() | atom()}
+ def add_file(%Pack{} = pack, _, _, %Plug.Upload{content_type: "application/zip"} = file) do
+ with {:ok, zip_files} <- :zip.table(to_charlist(file.path)),
+ [_ | _] = emojies <- unpack_zip_emojies(zip_files),
+ {:ok, tmp_dir} <- Pleroma.Utils.tmp_dir("emoji") do
+ try do
+ {:ok, _emoji_files} =
+ :zip.unzip(
+ to_charlist(file.path),
+ [{:file_list, Enum.map(emojies, & &1[:path])}, {:cwd, tmp_dir}]
+ )
+
+ {_, updated_pack} =
+ Enum.map_reduce(emojies, pack, fn item, emoji_pack ->
+ emoji_file = %Plug.Upload{
+ filename: item[:filename],
+ path: Path.join(tmp_dir, item[:path])
+ }
+
+ {:ok, updated_pack} =
+ do_add_file(
+ emoji_pack,
+ item[:shortcode],
+ to_string(item[:filename]),
+ emoji_file
+ )
+
+ {item, updated_pack}
+ end)
+
+ Emoji.reload()
+
+ {:ok, updated_pack}
+ after
+ File.rm_rf(tmp_dir)
+ end
+ else
+ {:error, _} = error ->
+ error
+
+ _ ->
+ {:ok, pack}
+ end
+ end
+
+ def add_file(%Pack{} = pack, shortcode, filename, %Plug.Upload{} = file) do
+ with :ok <- validate_not_empty([shortcode, filename]),
:ok <- validate_emoji_not_exists(shortcode),
- {:ok, pack} <- load_pack(name),
- :ok <- save_file(file, pack, filename),
- {:ok, updated_pack} <- pack |> put_emoji(shortcode, filename) |> save_pack() do
+ {:ok, updated_pack} <- do_add_file(pack, shortcode, filename, file) do
Emoji.reload()
{:ok, updated_pack}
end
end
- @spec delete_file(String.t(), String.t()) ::
+ defp do_add_file(pack, shortcode, filename, file) do
+ with :ok <- save_file(file, pack, filename) do
+ pack
+ |> put_emoji(shortcode, filename)
+ |> save_pack()
+ end
+ end
+
+ @spec delete_file(t(), String.t()) ::
{:ok, t()} | {:error, File.posix() | atom()}
- def delete_file(name, shortcode) do
- with :ok <- validate_not_empty([name, shortcode]),
- {:ok, pack} <- load_pack(name),
+ def delete_file(%Pack{} = pack, shortcode) do
+ with :ok <- validate_not_empty([shortcode]),
:ok <- remove_file(pack, shortcode),
{:ok, updated_pack} <- pack |> delete_emoji(shortcode) |> save_pack() do
Emoji.reload()
@@ -89,11 +163,10 @@ defmodule Pleroma.Emoji.Pack do
end
end
- @spec update_file(String.t(), String.t(), String.t(), String.t(), boolean()) ::
+ @spec update_file(t(), String.t(), String.t(), String.t(), boolean()) ::
{:ok, t()} | {:error, File.posix() | atom()}
- def update_file(name, shortcode, new_shortcode, new_filename, force) do
- with :ok <- validate_not_empty([name, shortcode, new_shortcode, new_filename]),
- {:ok, pack} <- load_pack(name),
+ def update_file(%Pack{} = pack, shortcode, new_shortcode, new_filename, force) do
+ with :ok <- validate_not_empty([shortcode, new_shortcode, new_filename]),
{:ok, filename} <- get_filename(pack, shortcode),
:ok <- validate_emoji_not_exists(new_shortcode, force),
:ok <- rename_file(pack, filename, new_filename),
@@ -129,13 +202,13 @@ defmodule Pleroma.Emoji.Pack do
end
end
- @spec list_remote(String.t()) :: {:ok, map()} | {:error, atom()}
- def list_remote(url) do
- uri = url |> String.trim() |> URI.parse()
+ @spec list_remote(keyword()) :: {:ok, map()} | {:error, atom()}
+ def list_remote(opts) do
+ uri = opts[:url] |> String.trim() |> URI.parse()
with :ok <- validate_shareable_packs_available(uri) do
uri
- |> URI.merge("/api/pleroma/emoji/packs")
+ |> URI.merge("/api/pleroma/emoji/packs?page=#{opts[:page]}&page_size=#{opts[:page_size]}")
|> http_get()
end
end
@@ -175,7 +248,8 @@ defmodule Pleroma.Emoji.Pack do
uri = url |> String.trim() |> URI.parse()
with :ok <- validate_shareable_packs_available(uri),
- {:ok, remote_pack} <- uri |> URI.merge("/api/pleroma/emoji/packs/#{name}") |> http_get(),
+ {:ok, remote_pack} <-
+ uri |> URI.merge("/api/pleroma/emoji/pack?name=#{name}") |> http_get(),
{:ok, %{sha: sha, url: url} = pack_info} <- fetch_pack_info(remote_pack, uri, name),
{:ok, archive} <- download_archive(url, sha),
pack <- copy_as(remote_pack, as || name),
@@ -243,9 +317,10 @@ defmodule Pleroma.Emoji.Pack do
defp validate_emoji_not_exists(_shortcode, true), do: :ok
defp validate_emoji_not_exists(shortcode, _) do
- case Emoji.get(shortcode) do
- nil -> :ok
- _ -> {:error, :already_exists}
+ if Emoji.exist?(shortcode) do
+ {:error, :already_exists}
+ else
+ :ok
end
end
@@ -386,25 +461,18 @@ defmodule Pleroma.Emoji.Pack do
end
end
- defp save_file(file, pack, filename) do
+ defp save_file(%Plug.Upload{path: upload_path}, pack, filename) do
file_path = Path.join(pack.path, filename)
create_subdirs(file_path)
- case file do
- %Plug.Upload{path: upload_path} ->
- # Copy the uploaded file from the temporary directory
- with {:ok, _} <- File.copy(upload_path, file_path), do: :ok
-
- url when is_binary(url) ->
- # Download and write the file
- file_contents = Tesla.get!(url).body
- File.write(file_path, file_contents)
+ with {:ok, _} <- File.copy(upload_path, file_path) do
+ :ok
end
end
defp put_emoji(pack, shortcode, filename) do
files = Map.put(pack.files, shortcode, filename)
- %{pack | files: files}
+ %{pack | files: files, files_count: length(Map.keys(files))}
end
defp delete_emoji(pack, shortcode) do
@@ -460,7 +528,7 @@ defmodule Pleroma.Emoji.Pack do
defp http_get(%URI{} = url), do: url |> to_string() |> http_get()
defp http_get(url) do
- with {:ok, %{body: body}} <- url |> Pleroma.HTTP.get() do
+ with {:ok, %{body: body}} <- Pleroma.HTTP.get(url, [], pool: :default) do
Jason.decode(body)
end
end
@@ -509,7 +577,7 @@ defmodule Pleroma.Emoji.Pack do
{:ok,
%{
sha: sha,
- url: URI.merge(uri, "/api/pleroma/emoji/packs/#{name}/archive") |> to_string()
+ url: URI.merge(uri, "/api/pleroma/emoji/packs/archive?name=#{name}") |> to_string()
}}
%{"fallback-src" => src, "fallback-src-sha256" => sha} when is_binary(src) ->
@@ -526,7 +594,7 @@ defmodule Pleroma.Emoji.Pack do
end
defp download_archive(url, sha) do
- with {:ok, %{body: archive}} <- Tesla.get(url) do
+ with {:ok, %{body: archive}} <- Pleroma.HTTP.get(url) do
if Base.decode16!(sha) == :crypto.hash(:sha256, archive) do
{:ok, archive}
else
@@ -549,7 +617,7 @@ defmodule Pleroma.Emoji.Pack do
end
defp update_sha_and_save_metadata(pack, data) do
- with {:ok, %{body: zip}} <- Tesla.get(data[:"fallback-src"]),
+ with {:ok, %{body: zip}} <- Pleroma.HTTP.get(data[:"fallback-src"]),
:ok <- validate_has_all_files(pack, zip) do
fallback_sha = :sha256 |> :crypto.hash(zip) |> Base.encode16()
diff --git a/lib/pleroma/gun/gun.ex b/lib/pleroma/gun.ex
index 4043e4880..4043e4880 100644
--- a/lib/pleroma/gun/gun.ex
+++ b/lib/pleroma/gun.ex
diff --git a/lib/pleroma/gun/conn.ex b/lib/pleroma/gun/conn.ex
index a3f75a4bb..477e19c6e 100644
--- a/lib/pleroma/gun/conn.ex
+++ b/lib/pleroma/gun/conn.ex
@@ -13,7 +13,7 @@ defmodule Pleroma.Gun.Conn do
opts =
opts
|> Enum.into(%{})
- |> Map.put_new(:await_up_timeout, pool_opts[:await_up_timeout] || 5_000)
+ |> Map.put_new(:connect_timeout, pool_opts[:connect_timeout] || 5_000)
|> Map.put_new(:supervise, false)
|> maybe_add_tls_opts(uri)
@@ -50,10 +50,10 @@ defmodule Pleroma.Gun.Conn do
with open_opts <- Map.delete(opts, :tls_opts),
{:ok, conn} <- Gun.open(proxy_host, proxy_port, open_opts),
- {:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]),
+ {:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]),
stream <- Gun.connect(conn, connect_opts),
{:response, :fin, 200, _} <- Gun.await(conn, stream) do
- {:ok, conn}
+ {:ok, conn, protocol}
else
error ->
Logger.warn(
@@ -88,8 +88,8 @@ defmodule Pleroma.Gun.Conn do
|> Map.put(:socks_opts, socks_opts)
with {:ok, conn} <- Gun.open(proxy_host, proxy_port, opts),
- {:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]) do
- {:ok, conn}
+ {:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]) do
+ {:ok, conn, protocol}
else
error ->
Logger.warn(
@@ -106,8 +106,8 @@ defmodule Pleroma.Gun.Conn do
host = Pleroma.HTTP.AdapterHelper.parse_host(host)
with {:ok, conn} <- Gun.open(host, port, opts),
- {:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]) do
- {:ok, conn}
+ {:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]) do
+ {:ok, conn, protocol}
else
error ->
Logger.warn(
diff --git a/lib/pleroma/gun/connection_pool.ex b/lib/pleroma/gun/connection_pool.ex
index f34602b73..e322f192a 100644
--- a/lib/pleroma/gun/connection_pool.ex
+++ b/lib/pleroma/gun/connection_pool.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Gun.ConnectionPool do
@registry __MODULE__
diff --git a/lib/pleroma/gun/connection_pool/reclaimer.ex b/lib/pleroma/gun/connection_pool/reclaimer.ex
index cea800882..241e8b04f 100644
--- a/lib/pleroma/gun/connection_pool/reclaimer.ex
+++ b/lib/pleroma/gun/connection_pool/reclaimer.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Gun.ConnectionPool.Reclaimer do
use GenServer, restart: :temporary
diff --git a/lib/pleroma/gun/connection_pool/worker.ex b/lib/pleroma/gun/connection_pool/worker.ex
index c36332817..b71816bed 100644
--- a/lib/pleroma/gun/connection_pool/worker.ex
+++ b/lib/pleroma/gun/connection_pool/worker.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Gun.ConnectionPool.Worker do
alias Pleroma.Gun
use GenServer, restart: :temporary
@@ -15,7 +19,7 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
@impl true
def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
- with {:ok, conn_pid} <- Gun.Conn.open(uri, opts),
+ with {:ok, conn_pid, protocol} <- Gun.Conn.open(uri, opts),
Process.link(conn_pid) do
time = :erlang.monotonic_time(:millisecond)
@@ -27,8 +31,12 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
send(client_pid, {:conn_pid, conn_pid})
{:noreply,
- %{key: key, timer: nil, client_monitors: %{client_pid => Process.monitor(client_pid)}},
- :hibernate}
+ %{
+ key: key,
+ timer: nil,
+ client_monitors: %{client_pid => Process.monitor(client_pid)},
+ protocol: protocol
+ }, :hibernate}
else
err ->
{:stop, {:shutdown, err}, nil}
@@ -53,14 +61,20 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
end
@impl true
- def handle_call(:add_client, {client_pid, _}, %{key: key} = state) do
+ def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} = state) do
time = :erlang.monotonic_time(:millisecond)
- {{conn_pid, _, _, _}, _} =
+ {{conn_pid, used_by, _, _}, _} =
Registry.update_value(@registry, key, fn {conn_pid, used_by, crf, last_reference} ->
{conn_pid, [client_pid | used_by], crf(time - last_reference, crf), time}
end)
+ :telemetry.execute(
+ [:pleroma, :connection_pool, :client, :add],
+ %{client_pid: client_pid, clients: used_by},
+ %{key: state.key, protocol: protocol}
+ )
+
state =
if state.timer != nil do
Process.cancel_timer(state[:timer])
@@ -83,25 +97,18 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
end)
{ref, state} = pop_in(state.client_monitors[client_pid])
- # DOWN message can receive right after `remove_client` call and cause worker to terminate
- state =
- if is_nil(ref) do
- state
- else
- Process.demonitor(ref)
- timer =
- if used_by == [] do
- max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
- Process.send_after(self(), :idle_close, max_idle)
- else
- nil
- end
+ Process.demonitor(ref, [:flush])
- %{state | timer: timer}
+ timer =
+ if used_by == [] do
+ max_idle = Pleroma.Config.get([:connections_pool, :max_idle_time], 30_000)
+ Process.send_after(self(), :idle_close, max_idle)
+ else
+ nil
end
- {:reply, :ok, state, :hibernate}
+ {:reply, :ok, %{state | timer: timer}, :hibernate}
end
@impl true
@@ -131,7 +138,7 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
@impl true
def handle_info({:DOWN, _ref, :process, pid, reason}, state) do
:telemetry.execute(
- [:pleroma, :connection_pool, :client_death],
+ [:pleroma, :connection_pool, :client, :dead],
%{client_pid: pid, reason: reason},
%{key: state.key}
)
diff --git a/lib/pleroma/gun/connection_pool/worker_supervisor.ex b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
index 39615c956..4c23bcbd9 100644
--- a/lib/pleroma/gun/connection_pool/worker_supervisor.ex
+++ b/lib/pleroma/gun/connection_pool/worker_supervisor.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Gun.ConnectionPool.WorkerSupervisor do
@moduledoc "Supervisor for pool workers. Does not do anything except enforce max connection limit"
diff --git a/lib/pleroma/helpers/inet_helper.ex b/lib/pleroma/helpers/inet_helper.ex
new file mode 100644
index 000000000..126f82381
--- /dev/null
+++ b/lib/pleroma/helpers/inet_helper.ex
@@ -0,0 +1,19 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Helpers.InetHelper do
+ def parse_address(ip) when is_tuple(ip) do
+ {:ok, ip}
+ end
+
+ def parse_address(ip) when is_binary(ip) do
+ ip
+ |> String.to_charlist()
+ |> parse_address()
+ end
+
+ def parse_address(ip) do
+ :inet.parse_address(ip)
+ end
+end
diff --git a/lib/pleroma/helpers/media_helper.ex b/lib/pleroma/helpers/media_helper.ex
new file mode 100644
index 000000000..6b799173e
--- /dev/null
+++ b/lib/pleroma/helpers/media_helper.ex
@@ -0,0 +1,162 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Helpers.MediaHelper do
+ @moduledoc """
+ Handles common media-related operations.
+ """
+
+ alias Pleroma.HTTP
+
+ require Logger
+
+ def missing_dependencies do
+ Enum.reduce([imagemagick: "convert", ffmpeg: "ffmpeg"], [], fn {sym, executable}, acc ->
+ if Pleroma.Utils.command_available?(executable) do
+ acc
+ else
+ [sym | acc]
+ end
+ end)
+ end
+
+ def image_resize(url, options) do
+ with executable when is_binary(executable) <- System.find_executable("convert"),
+ {:ok, args} <- prepare_image_resize_args(options),
+ {:ok, env} <- HTTP.get(url, [], pool: :media),
+ {:ok, fifo_path} <- mkfifo() do
+ args = List.flatten([fifo_path, args])
+ run_fifo(fifo_path, env, executable, args)
+ else
+ nil -> {:error, {:convert, :command_not_found}}
+ {:error, _} = error -> error
+ end
+ end
+
+ defp prepare_image_resize_args(
+ %{max_width: max_width, max_height: max_height, format: "png"} = options
+ ) do
+ quality = options[:quality] || 85
+ resize = Enum.join([max_width, "x", max_height, ">"])
+
+ args = [
+ "-resize",
+ resize,
+ "-quality",
+ to_string(quality),
+ "png:-"
+ ]
+
+ {:ok, args}
+ end
+
+ defp prepare_image_resize_args(%{max_width: max_width, max_height: max_height} = options) do
+ quality = options[:quality] || 85
+ resize = Enum.join([max_width, "x", max_height, ">"])
+
+ args = [
+ "-interlace",
+ "Plane",
+ "-resize",
+ resize,
+ "-quality",
+ to_string(quality),
+ "jpg:-"
+ ]
+
+ {:ok, args}
+ end
+
+ defp prepare_image_resize_args(_), do: {:error, :missing_options}
+
+ # Note: video thumbnail is intentionally not resized (always has original dimensions)
+ def video_framegrab(url) do
+ with executable when is_binary(executable) <- System.find_executable("ffmpeg"),
+ {:ok, env} <- HTTP.get(url, [], pool: :media),
+ {:ok, fifo_path} <- mkfifo(),
+ args = [
+ "-y",
+ "-i",
+ fifo_path,
+ "-vframes",
+ "1",
+ "-f",
+ "mjpeg",
+ "-loglevel",
+ "error",
+ "-"
+ ] do
+ run_fifo(fifo_path, env, executable, args)
+ else
+ nil -> {:error, {:ffmpeg, :command_not_found}}
+ {:error, _} = error -> error
+ end
+ end
+
+ defp run_fifo(fifo_path, env, executable, args) do
+ pid =
+ Port.open({:spawn_executable, executable}, [
+ :use_stdio,
+ :stream,
+ :exit_status,
+ :binary,
+ args: args
+ ])
+
+ fifo = Port.open(to_charlist(fifo_path), [:eof, :binary, :stream, :out])
+ fix = Pleroma.Helpers.QtFastStart.fix(env.body)
+ true = Port.command(fifo, fix)
+ :erlang.port_close(fifo)
+ loop_recv(pid)
+ after
+ File.rm(fifo_path)
+ end
+
+ defp mkfifo do
+ path = Path.join(System.tmp_dir!(), "pleroma-media-preview-pipe-#{Ecto.UUID.generate()}")
+
+ case System.cmd("mkfifo", [path]) do
+ {_, 0} ->
+ spawn(fifo_guard(path))
+ {:ok, path}
+
+ {_, err} ->
+ {:error, {:fifo_failed, err}}
+ end
+ end
+
+ defp fifo_guard(path) do
+ pid = self()
+
+ fn ->
+ ref = Process.monitor(pid)
+
+ receive do
+ {:DOWN, ^ref, :process, ^pid, _} ->
+ File.rm(path)
+ end
+ end
+ end
+
+ defp loop_recv(pid) do
+ loop_recv(pid, <<>>)
+ end
+
+ defp loop_recv(pid, acc) do
+ receive do
+ {^pid, {:data, data}} ->
+ loop_recv(pid, acc <> data)
+
+ {^pid, {:exit_status, 0}} ->
+ {:ok, acc}
+
+ {^pid, {:exit_status, status}} ->
+ {:error, status}
+ after
+ 5000 ->
+ :erlang.port_close(pid)
+ {:error, :timeout}
+ end
+ end
+end
diff --git a/lib/pleroma/helpers/qt_fast_start.ex b/lib/pleroma/helpers/qt_fast_start.ex
new file mode 100644
index 000000000..bb93224b5
--- /dev/null
+++ b/lib/pleroma/helpers/qt_fast_start.ex
@@ -0,0 +1,131 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Helpers.QtFastStart do
+ @moduledoc """
+ (WIP) Converts a "slow start" (data before metadatas) mov/mp4 file to a "fast start" one (metadatas before data).
+ """
+
+ # TODO: Cleanup and optimizations
+ # Inspirations: https://www.ffmpeg.org/doxygen/3.4/qt-faststart_8c_source.html
+ # https://github.com/danielgtaylor/qtfaststart/blob/master/qtfaststart/processor.py
+ # ISO/IEC 14496-12:2015, ISO/IEC 15444-12:2015
+ # Paracetamol
+
+ def fix(<<0x00, 0x00, 0x00, _, 0x66, 0x74, 0x79, 0x70, _::bits>> = binary) do
+ index = fix(binary, 0, nil, nil, [])
+
+ case index do
+ :abort -> binary
+ [{"ftyp", _, _, _, _}, {"mdat", _, _, _, _} | _] -> faststart(index)
+ [{"ftyp", _, _, _, _}, {"free", _, _, _, _}, {"mdat", _, _, _, _} | _] -> faststart(index)
+ _ -> binary
+ end
+ end
+
+ def fix(binary) do
+ binary
+ end
+
+ # MOOV have been seen before MDAT- abort
+ defp fix(<<_::bits>>, _, true, false, _) do
+ :abort
+ end
+
+ defp fix(
+ <<size::integer-big-size(32), fourcc::bits-size(32), rest::bits>>,
+ pos,
+ got_moov,
+ got_mdat,
+ acc
+ ) do
+ full_size = (size - 8) * 8
+ <<data::bits-size(full_size), rest::bits>> = rest
+
+ acc = [
+ {fourcc, pos, pos + size, size,
+ <<size::integer-big-size(32), fourcc::bits-size(32), data::bits>>}
+ | acc
+ ]
+
+ fix(rest, pos + size, got_moov || fourcc == "moov", got_mdat || fourcc == "mdat", acc)
+ end
+
+ defp fix(<<>>, _pos, _, _, acc) do
+ :lists.reverse(acc)
+ end
+
+ defp faststart(index) do
+ {{_ftyp, _, _, _, ftyp}, index} = List.keytake(index, "ftyp", 0)
+
+ # Skip re-writing the free fourcc as it's kind of useless.
+ # Why stream useless bytes when you can do without?
+ {free_size, index} =
+ case List.keytake(index, "free", 0) do
+ {{_, _, _, size, _}, index} -> {size, index}
+ _ -> {0, index}
+ end
+
+ {{_moov, _, _, moov_size, moov}, index} = List.keytake(index, "moov", 0)
+ offset = -free_size + moov_size
+ rest = for {_, _, _, _, data} <- index, do: data, into: []
+ <<moov_head::bits-size(64), moov_data::bits>> = moov
+ [ftyp, moov_head, fix_moov(moov_data, offset, []), rest]
+ end
+
+ defp fix_moov(
+ <<size::integer-big-size(32), fourcc::bits-size(32), rest::bits>>,
+ offset,
+ acc
+ ) do
+ full_size = (size - 8) * 8
+ <<data::bits-size(full_size), rest::bits>> = rest
+
+ data =
+ cond do
+ fourcc in ["trak", "mdia", "minf", "stbl"] ->
+ # Theses contains sto or co64 part
+ [<<size::integer-big-size(32), fourcc::bits-size(32)>>, fix_moov(data, offset, [])]
+
+ fourcc in ["stco", "co64"] ->
+ # fix the damn thing
+ <<version::integer-big-size(32), count::integer-big-size(32), rest::bits>> = data
+
+ entry_size =
+ case fourcc do
+ "stco" -> 32
+ "co64" -> 64
+ end
+
+ [
+ <<size::integer-big-size(32), fourcc::bits-size(32), version::integer-big-size(32),
+ count::integer-big-size(32)>>,
+ rewrite_entries(entry_size, offset, rest, [])
+ ]
+
+ true ->
+ [<<size::integer-big-size(32), fourcc::bits-size(32)>>, data]
+ end
+
+ acc = [acc | data]
+ fix_moov(rest, offset, acc)
+ end
+
+ defp fix_moov(<<>>, _, acc), do: acc
+
+ for size <- [32, 64] do
+ defp rewrite_entries(
+ unquote(size),
+ offset,
+ <<pos::integer-big-size(unquote(size)), rest::bits>>,
+ acc
+ ) do
+ rewrite_entries(unquote(size), offset, rest, [
+ acc | <<pos + offset::integer-big-size(unquote(size))>>
+ ])
+ end
+ end
+
+ defp rewrite_entries(_, _, <<>>, acc), do: acc
+end
diff --git a/lib/pleroma/helpers/uri_helper.ex b/lib/pleroma/helpers/uri_helper.ex
index 6d205a636..f1301f055 100644
--- a/lib/pleroma/helpers/uri_helper.ex
+++ b/lib/pleroma/helpers/uri_helper.ex
@@ -3,18 +3,22 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Helpers.UriHelper do
- def append_uri_params(uri, appended_params) do
+ def modify_uri_params(uri, overridden_params, deleted_params \\ []) do
uri = URI.parse(uri)
- appended_params = for {k, v} <- appended_params, into: %{}, do: {to_string(k), v}
- existing_params = URI.query_decoder(uri.query || "") |> Enum.into(%{})
- updated_params_keys = Enum.uniq(Map.keys(existing_params) ++ Map.keys(appended_params))
+
+ existing_params = URI.query_decoder(uri.query || "") |> Map.new()
+ overridden_params = Map.new(overridden_params, fn {k, v} -> {to_string(k), v} end)
+ deleted_params = Enum.map(deleted_params, &to_string/1)
updated_params =
- for k <- updated_params_keys, do: {k, appended_params[k] || existing_params[k]}
+ existing_params
+ |> Map.merge(overridden_params)
+ |> Map.drop(deleted_params)
uri
|> Map.put(:query, URI.encode_query(updated_params))
|> URI.to_string()
+ |> String.replace_suffix("?", "")
end
def maybe_add_base("/" <> uri, base), do: Path.join([base, uri])
diff --git a/lib/pleroma/http.ex b/lib/pleroma/http.ex
new file mode 100644
index 000000000..052597191
--- /dev/null
+++ b/lib/pleroma/http.ex
@@ -0,0 +1,110 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HTTP do
+ @moduledoc """
+ Wrapper for `Tesla.request/2`.
+ """
+
+ alias Pleroma.HTTP.AdapterHelper
+ alias Pleroma.HTTP.Request
+ alias Pleroma.HTTP.RequestBuilder, as: Builder
+ alias Tesla.Client
+ alias Tesla.Env
+
+ require Logger
+
+ @type t :: __MODULE__
+ @type method() :: :get | :post | :put | :delete | :head
+
+ @doc """
+ Performs GET request.
+
+ See `Pleroma.HTTP.request/5`
+ """
+ @spec get(Request.url() | nil, Request.headers(), keyword()) ::
+ nil | {:ok, Env.t()} | {:error, any()}
+ def get(url, headers \\ [], options \\ [])
+ def get(nil, _, _), do: nil
+ def get(url, headers, options), do: request(:get, url, "", headers, options)
+
+ @spec head(Request.url(), Request.headers(), keyword()) :: {:ok, Env.t()} | {:error, any()}
+ def head(url, headers \\ [], options \\ []), do: request(:head, url, "", headers, options)
+
+ @doc """
+ Performs POST request.
+
+ See `Pleroma.HTTP.request/5`
+ """
+ @spec post(Request.url(), String.t(), Request.headers(), keyword()) ::
+ {:ok, Env.t()} | {:error, any()}
+ def post(url, body, headers \\ [], options \\ []),
+ do: request(:post, url, body, headers, options)
+
+ @doc """
+ Builds and performs http request.
+
+ # Arguments:
+ `method` - :get, :post, :put, :delete, :head
+ `url` - full url
+ `body` - request body
+ `headers` - a keyworld list of headers, e.g. `[{"content-type", "text/plain"}]`
+ `options` - custom, per-request middleware or adapter options
+
+ # Returns:
+ `{:ok, %Tesla.Env{}}` or `{:error, error}`
+
+ """
+ @spec request(method(), Request.url(), String.t(), Request.headers(), keyword()) ::
+ {:ok, Env.t()} | {:error, any()}
+ def request(method, url, body, headers, options) when is_binary(url) do
+ uri = URI.parse(url)
+ adapter_opts = AdapterHelper.options(uri, options || [])
+
+ options = put_in(options[:adapter], adapter_opts)
+ params = options[:params] || []
+ request = build_request(method, headers, options, url, body, params)
+
+ adapter = Application.get_env(:tesla, :adapter)
+
+ client = Tesla.client(adapter_middlewares(adapter), adapter)
+
+ maybe_limit(
+ fn ->
+ request(client, request)
+ end,
+ adapter,
+ adapter_opts
+ )
+ end
+
+ @spec request(Client.t(), keyword()) :: {:ok, Env.t()} | {:error, any()}
+ def request(client, request), do: Tesla.request(client, request)
+
+ defp build_request(method, headers, options, url, body, params) do
+ Builder.new()
+ |> Builder.method(method)
+ |> Builder.headers(headers)
+ |> Builder.opts(options)
+ |> Builder.url(url)
+ |> Builder.add_param(:body, :body, body)
+ |> Builder.add_param(:query, :query, params)
+ |> Builder.convert_to_keyword()
+ end
+
+ @prefix Pleroma.Gun.ConnectionPool
+ defp maybe_limit(fun, Tesla.Adapter.Gun, opts) do
+ ConcurrentLimiter.limit(:"#{@prefix}.#{opts[:pool] || :default}", fun)
+ end
+
+ defp maybe_limit(fun, _, _) do
+ fun.()
+ end
+
+ defp adapter_middlewares(Tesla.Adapter.Gun) do
+ [Tesla.Middleware.FollowRedirects, Pleroma.Tesla.Middleware.ConnectionPool]
+ end
+
+ defp adapter_middlewares(_), do: []
+end
diff --git a/lib/pleroma/http/adapter_helper.ex b/lib/pleroma/http/adapter_helper.ex
index 0728cbaa2..08b51578a 100644
--- a/lib/pleroma/http/adapter_helper.ex
+++ b/lib/pleroma/http/adapter_helper.ex
@@ -6,7 +6,7 @@ defmodule Pleroma.HTTP.AdapterHelper do
@moduledoc """
Configure Tesla.Client with default and customized adapter options.
"""
- @defaults [pool: :federation]
+ @defaults [pool: :federation, connect_timeout: 5_000, recv_timeout: 5_000]
@type proxy_type() :: :socks4 | :socks5
@type host() :: charlist() | :inet.ip_address()
@@ -19,7 +19,6 @@ defmodule Pleroma.HTTP.AdapterHelper do
| {Connection.proxy_type(), Connection.host(), pos_integer()}
@callback options(keyword(), URI.t()) :: keyword()
- @callback get_conn(URI.t(), keyword()) :: {:ok, term()} | {:error, term()}
@spec format_proxy(String.t() | tuple() | nil) :: proxy() | nil
def format_proxy(nil), do: nil
@@ -47,9 +46,6 @@ defmodule Pleroma.HTTP.AdapterHelper do
|> adapter_helper().options(uri)
end
- @spec get_conn(URI.t(), keyword()) :: {:ok, keyword()} | {:error, atom()}
- def get_conn(uri, opts), do: adapter_helper().get_conn(uri, opts)
-
defp adapter, do: Application.get_env(:tesla, :adapter)
defp adapter_helper do
diff --git a/lib/pleroma/http/adapter_helper/default.ex b/lib/pleroma/http/adapter_helper/default.ex
index e13441316..8567a616b 100644
--- a/lib/pleroma/http/adapter_helper/default.ex
+++ b/lib/pleroma/http/adapter_helper/default.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.HTTP.AdapterHelper.Default do
alias Pleroma.HTTP.AdapterHelper
diff --git a/lib/pleroma/http/adapter_helper/gun.ex b/lib/pleroma/http/adapter_helper/gun.ex
index 02e20f2d1..1dbb71362 100644
--- a/lib/pleroma/http/adapter_helper/gun.ex
+++ b/lib/pleroma/http/adapter_helper/gun.ex
@@ -6,18 +6,13 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do
@behaviour Pleroma.HTTP.AdapterHelper
alias Pleroma.Config
- alias Pleroma.Gun.ConnectionPool
alias Pleroma.HTTP.AdapterHelper
require Logger
@defaults [
- connect_timeout: 5_000,
- domain_lookup_timeout: 5_000,
- tls_handshake_timeout: 5_000,
retry: 1,
- retry_timeout: 1000,
- await_up_timeout: 5_000
+ retry_timeout: 1_000
]
@type pool() :: :federation | :upload | :media | :default
@@ -46,23 +41,17 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do
end
defp put_timeout(opts) do
+ {recv_timeout, opts} = Keyword.pop(opts, :recv_timeout, pool_timeout(opts[:pool]))
# this is the timeout to receive a message from Gun
- Keyword.put_new(opts, :timeout, pool_timeout(opts[:pool]))
+ # `:timeout` key is used in Tesla
+ Keyword.put(opts, :timeout, recv_timeout)
end
@spec pool_timeout(pool()) :: non_neg_integer()
def pool_timeout(pool) do
- default = Config.get([:pools, :default, :timeout], 5_000)
+ default = Config.get([:pools, :default, :recv_timeout], 5_000)
- Config.get([:pools, pool, :timeout], default)
- end
-
- @spec get_conn(URI.t(), keyword()) :: {:ok, keyword()} | {:error, atom()}
- def get_conn(uri, opts) do
- case ConnectionPool.get_conn(uri, opts) do
- {:ok, conn_pid} -> {:ok, Keyword.merge(opts, conn: conn_pid, close_conn: false)}
- err -> err
- end
+ Config.get([:pools, pool, :recv_timeout], default)
end
@prefix Pleroma.Gun.ConnectionPool
diff --git a/lib/pleroma/http/adapter_helper/hackney.ex b/lib/pleroma/http/adapter_helper/hackney.ex
index 62bd42485..ff60513fd 100644
--- a/lib/pleroma/http/adapter_helper/hackney.ex
+++ b/lib/pleroma/http/adapter_helper/hackney.ex
@@ -1,12 +1,13 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.HTTP.AdapterHelper.Hackney do
@behaviour Pleroma.HTTP.AdapterHelper
@defaults [
- connect_timeout: 10_000,
- recv_timeout: 20_000,
follow_redirect: true,
- force_redirect: true,
- pool: :federation
+ force_redirect: true
]
@spec options(keyword(), URI.t()) :: keyword()
@@ -19,6 +20,7 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|> Keyword.merge(config_opts)
|> Keyword.merge(connection_opts)
|> add_scheme_opts(uri)
+ |> maybe_add_with_body()
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
end
@@ -28,6 +30,11 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
defp add_scheme_opts(opts, _), do: opts
- @spec get_conn(URI.t(), keyword()) :: {:ok, keyword()}
- def get_conn(_uri, opts), do: {:ok, opts}
+ defp maybe_add_with_body(opts) do
+ if opts[:max_body] do
+ Keyword.put(opts, :with_body, true)
+ else
+ opts
+ end
+ end
end
diff --git a/lib/pleroma/http/ex_aws.ex b/lib/pleroma/http/ex_aws.ex
index c3f335c73..5cac3532f 100644
--- a/lib/pleroma/http/ex_aws.ex
+++ b/lib/pleroma/http/ex_aws.ex
@@ -11,7 +11,7 @@ defmodule Pleroma.HTTP.ExAws do
@impl true
def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
- http_opts = Keyword.put_new(http_opts, :adapter, pool: :upload)
+ http_opts = Keyword.put_new(http_opts, :pool, :upload)
case HTTP.request(method, url, body, headers, http_opts) do
{:ok, env} ->
diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex
deleted file mode 100644
index b37b3fa89..000000000
--- a/lib/pleroma/http/http.ex
+++ /dev/null
@@ -1,117 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.HTTP do
- @moduledoc """
- Wrapper for `Tesla.request/2`.
- """
-
- alias Pleroma.HTTP.AdapterHelper
- alias Pleroma.HTTP.Request
- alias Pleroma.HTTP.RequestBuilder, as: Builder
- alias Tesla.Client
- alias Tesla.Env
-
- require Logger
-
- @type t :: __MODULE__
- @type method() :: :get | :post | :put | :delete | :head
-
- @doc """
- Performs GET request.
-
- See `Pleroma.HTTP.request/5`
- """
- @spec get(Request.url() | nil, Request.headers(), keyword()) ::
- nil | {:ok, Env.t()} | {:error, any()}
- def get(url, headers \\ [], options \\ [])
- def get(nil, _, _), do: nil
- def get(url, headers, options), do: request(:get, url, "", headers, options)
-
- @spec head(Request.url(), Request.headers(), keyword()) :: {:ok, Env.t()} | {:error, any()}
- def head(url, headers \\ [], options \\ []), do: request(:head, url, "", headers, options)
-
- @doc """
- Performs POST request.
-
- See `Pleroma.HTTP.request/5`
- """
- @spec post(Request.url(), String.t(), Request.headers(), keyword()) ::
- {:ok, Env.t()} | {:error, any()}
- def post(url, body, headers \\ [], options \\ []),
- do: request(:post, url, body, headers, options)
-
- @doc """
- Builds and performs http request.
-
- # Arguments:
- `method` - :get, :post, :put, :delete, :head
- `url` - full url
- `body` - request body
- `headers` - a keyworld list of headers, e.g. `[{"content-type", "text/plain"}]`
- `options` - custom, per-request middleware or adapter options
-
- # Returns:
- `{:ok, %Tesla.Env{}}` or `{:error, error}`
-
- """
- @spec request(method(), Request.url(), String.t(), Request.headers(), keyword()) ::
- {:ok, Env.t()} | {:error, any()}
- def request(method, url, body, headers, options) when is_binary(url) do
- uri = URI.parse(url)
- adapter_opts = AdapterHelper.options(uri, options[:adapter] || [])
-
- case AdapterHelper.get_conn(uri, adapter_opts) do
- {:ok, adapter_opts} ->
- options = put_in(options[:adapter], adapter_opts)
- params = options[:params] || []
- request = build_request(method, headers, options, url, body, params)
-
- adapter = Application.get_env(:tesla, :adapter)
-
- client = Tesla.client(adapter_middlewares(adapter), adapter)
-
- maybe_limit(
- fn ->
- request(client, request)
- end,
- adapter,
- adapter_opts
- )
-
- # Connection release is handled in a custom FollowRedirects middleware
- err ->
- err
- end
- end
-
- @spec request(Client.t(), keyword()) :: {:ok, Env.t()} | {:error, any()}
- def request(client, request), do: Tesla.request(client, request)
-
- defp build_request(method, headers, options, url, body, params) do
- Builder.new()
- |> Builder.method(method)
- |> Builder.headers(headers)
- |> Builder.opts(options)
- |> Builder.url(url)
- |> Builder.add_param(:body, :body, body)
- |> Builder.add_param(:query, :query, params)
- |> Builder.convert_to_keyword()
- end
-
- @prefix Pleroma.Gun.ConnectionPool
- defp maybe_limit(fun, Tesla.Adapter.Gun, opts) do
- ConcurrentLimiter.limit(:"#{@prefix}.#{opts[:pool] || :default}", fun)
- end
-
- defp maybe_limit(fun, _, _) do
- fun.()
- end
-
- defp adapter_middlewares(Tesla.Adapter.Gun) do
- [Pleroma.HTTP.Middleware.FollowRedirects]
- end
-
- defp adapter_middlewares(_), do: []
-end
diff --git a/lib/pleroma/http/tzdata.ex b/lib/pleroma/http/tzdata.ex
index 4539ac359..09cfdadf7 100644
--- a/lib/pleroma/http/tzdata.ex
+++ b/lib/pleroma/http/tzdata.ex
@@ -11,7 +11,7 @@ defmodule Pleroma.HTTP.Tzdata do
@impl true
def get(url, headers, options) do
- options = Keyword.put_new(options, :adapter, pool: :default)
+ options = Keyword.put_new(options, :pool, :default)
with {:ok, %Tesla.Env{} = env} <- HTTP.get(url, headers, options) do
{:ok, {env.status, env.headers, env.body}}
@@ -20,7 +20,7 @@ defmodule Pleroma.HTTP.Tzdata do
@impl true
def head(url, headers, options) do
- options = Keyword.put_new(options, :adapter, pool: :default)
+ options = Keyword.put_new(options, :pool, :default)
with {:ok, %Tesla.Env{} = env} <- HTTP.head(url, headers, options) do
{:ok, {env.status, env.headers}}
diff --git a/lib/pleroma/http/web_push.ex b/lib/pleroma/http/web_push.ex
new file mode 100644
index 000000000..78148a12e
--- /dev/null
+++ b/lib/pleroma/http/web_push.ex
@@ -0,0 +1,12 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HTTP.WebPush do
+ @moduledoc false
+
+ def post(url, payload, headers) do
+ list_headers = Map.to_list(headers)
+ Pleroma.HTTP.post(url, payload, list_headers)
+ end
+end
diff --git a/lib/pleroma/instances/instance.ex b/lib/pleroma/instances/instance.ex
index 8bf53c090..f0f601469 100644
--- a/lib/pleroma/instances/instance.ex
+++ b/lib/pleroma/instances/instance.ex
@@ -156,16 +156,12 @@ defmodule Pleroma.Instances.Instance do
defp scrape_favicon(%URI{} = instance_uri) do
try do
with {:ok, %Tesla.Env{body: html}} <-
- Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}],
- adapter: [pool: :media]
- ),
- favicon_rel <-
- html
- |> Floki.parse_document!()
- |> Floki.attribute("link[rel=icon]", "href")
- |> List.first(),
- favicon <- URI.merge(instance_uri, favicon_rel) |> to_string(),
- true <- is_binary(favicon) do
+ Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], pool: :media),
+ {_, [favicon_rel | _]} when is_binary(favicon_rel) <-
+ {:parse,
+ html |> Floki.parse_document!() |> Floki.attribute("link[rel=icon]", "href")},
+ {_, favicon} when is_binary(favicon) <-
+ {:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do
favicon
else
_ -> nil
diff --git a/lib/pleroma/jwt.ex b/lib/pleroma/jwt.ex
index 10102ff5d..faeb77781 100644
--- a/lib/pleroma/jwt.ex
+++ b/lib/pleroma/jwt.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.JWT do
use Joken.Config
diff --git a/lib/pleroma/mfa/token.ex b/lib/pleroma/mfa/token.ex
index 0b2449971..69b64c0e8 100644
--- a/lib/pleroma/mfa/token.ex
+++ b/lib/pleroma/mfa/token.ex
@@ -10,10 +10,11 @@ defmodule Pleroma.MFA.Token do
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.OAuth.Authorization
- alias Pleroma.Web.OAuth.Token, as: OAuthToken
@expires 300
+ @type t() :: %__MODULE__{}
+
schema "mfa_tokens" do
field(:token, :string)
field(:valid_until, :naive_datetime_usec)
@@ -24,6 +25,7 @@ defmodule Pleroma.MFA.Token do
timestamps()
end
+ @spec get_by_token(String.t()) :: {:ok, t()} | {:error, :not_found}
def get_by_token(token) do
from(
t in __MODULE__,
@@ -33,33 +35,40 @@ defmodule Pleroma.MFA.Token do
|> Repo.find_resource()
end
- def validate(token) do
- with {:fetch_token, {:ok, token}} <- {:fetch_token, get_by_token(token)},
- {:expired, false} <- {:expired, is_expired?(token)} do
+ @spec validate(String.t()) :: {:ok, t()} | {:error, :not_found} | {:error, :expired_token}
+ def validate(token_str) do
+ with {:ok, token} <- get_by_token(token_str),
+ false <- expired?(token) do
{:ok, token}
- else
- {:expired, _} -> {:error, :expired_token}
- {:fetch_token, _} -> {:error, :not_found}
- error -> {:error, error}
end
end
- def create_token(%User{} = user) do
- %__MODULE__{}
- |> change
- |> assign_user(user)
- |> put_token
- |> put_valid_until
- |> Repo.insert()
+ defp expired?(%__MODULE__{valid_until: valid_until}) do
+ with true <- NaiveDateTime.diff(NaiveDateTime.utc_now(), valid_until) > 0 do
+ {:error, :expired_token}
+ end
+ end
+
+ @spec create(User.t(), Authorization.t() | nil) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
+ def create(user, authorization \\ nil) do
+ with {:ok, token} <- do_create(user, authorization) do
+ Pleroma.Workers.PurgeExpiredToken.enqueue(%{
+ token_id: token.id,
+ valid_until: DateTime.from_naive!(token.valid_until, "Etc/UTC"),
+ mod: __MODULE__
+ })
+
+ {:ok, token}
+ end
end
- def create_token(user, authorization) do
+ defp do_create(user, authorization) do
%__MODULE__{}
- |> change
+ |> change()
|> assign_user(user)
- |> assign_authorization(authorization)
- |> put_token
- |> put_valid_until
+ |> maybe_assign_authorization(authorization)
+ |> put_token()
+ |> put_valid_until()
|> Repo.insert()
end
@@ -69,15 +78,19 @@ defmodule Pleroma.MFA.Token do
|> validate_required([:user])
end
- defp assign_authorization(changeset, authorization) do
+ defp maybe_assign_authorization(changeset, %Authorization{} = authorization) do
changeset
|> put_assoc(:authorization, authorization)
|> validate_required([:authorization])
end
+ defp maybe_assign_authorization(changeset, _), do: changeset
+
defp put_token(changeset) do
+ token = Pleroma.Web.OAuth.Token.Utils.generate_token()
+
changeset
- |> change(%{token: OAuthToken.Utils.generate_token()})
+ |> change(%{token: token})
|> validate_required([:token])
|> unique_constraint(:token)
end
@@ -89,18 +102,4 @@ defmodule Pleroma.MFA.Token do
|> change(%{valid_until: expires_in})
|> validate_required([:valid_until])
end
-
- def is_expired?(%__MODULE__{valid_until: valid_until}) do
- NaiveDateTime.diff(NaiveDateTime.utc_now(), valid_until) > 0
- end
-
- def is_expired?(_), do: false
-
- def delete_expired_tokens do
- from(
- q in __MODULE__,
- where: fragment("?", q.valid_until) < ^Timex.now()
- )
- |> Repo.delete_all()
- end
end
diff --git a/lib/pleroma/migration_helper/notification_backfill.ex b/lib/pleroma/migration_helper/notification_backfill.ex
index d260e62ca..24f4733fe 100644
--- a/lib/pleroma/migration_helper/notification_backfill.ex
+++ b/lib/pleroma/migration_helper/notification_backfill.ex
@@ -19,13 +19,13 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
query
|> Repo.chunk_stream(100)
|> Enum.each(fn notification ->
- type =
- notification.activity
- |> type_from_activity()
+ if notification.activity do
+ type = type_from_activity(notification.activity)
- notification
- |> Ecto.Changeset.change(%{type: type})
- |> Repo.update()
+ notification
+ |> Ecto.Changeset.change(%{type: type})
+ |> Repo.update()
+ end
end)
end
@@ -72,8 +72,7 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
"pleroma:emoji_reaction"
"Create" ->
- activity
- |> type_from_activity_object()
+ type_from_activity_object(activity)
t ->
raise "No notification type for activity type #{t}"
diff --git a/lib/pleroma/mime.ex b/lib/pleroma/mime.ex
deleted file mode 100644
index 6ee055f50..000000000
--- a/lib/pleroma/mime.ex
+++ /dev/null
@@ -1,120 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.MIME do
- @moduledoc """
- Returns the mime-type of a binary and optionally a normalized file-name.
- """
- @default "application/octet-stream"
- @read_bytes 35
-
- @spec file_mime_type(String.t(), String.t()) ::
- {:ok, content_type :: String.t(), filename :: String.t()} | {:error, any()} | :error
- def file_mime_type(path, filename) do
- with {:ok, content_type} <- file_mime_type(path),
- filename <- fix_extension(filename, content_type) do
- {:ok, content_type, filename}
- end
- end
-
- @spec file_mime_type(String.t()) :: {:ok, String.t()} | {:error, any()} | :error
- def file_mime_type(filename) do
- File.open(filename, [:read], fn f ->
- check_mime_type(IO.binread(f, @read_bytes))
- end)
- end
-
- def bin_mime_type(binary, filename) do
- with {:ok, content_type} <- bin_mime_type(binary),
- filename <- fix_extension(filename, content_type) do
- {:ok, content_type, filename}
- end
- end
-
- @spec bin_mime_type(binary()) :: {:ok, String.t()} | :error
- def bin_mime_type(<<head::binary-size(@read_bytes), _::binary>>) do
- {:ok, check_mime_type(head)}
- end
-
- def bin_mime_type(_), do: :error
-
- def mime_type(<<_::binary>>), do: {:ok, @default}
-
- defp fix_extension(filename, content_type) do
- parts = String.split(filename, ".")
-
- new_filename =
- if length(parts) > 1 do
- Enum.drop(parts, -1) |> Enum.join(".")
- else
- Enum.join(parts)
- end
-
- cond do
- content_type == "application/octet-stream" ->
- filename
-
- ext = List.first(MIME.extensions(content_type)) ->
- new_filename <> "." <> ext
-
- true ->
- Enum.join([new_filename, String.split(content_type, "/") |> List.last()], ".")
- end
- end
-
- defp check_mime_type(<<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _::binary>>) do
- "image/png"
- end
-
- defp check_mime_type(<<0x47, 0x49, 0x46, 0x38, _, 0x61, _::binary>>) do
- "image/gif"
- end
-
- defp check_mime_type(<<0xFF, 0xD8, 0xFF, _::binary>>) do
- "image/jpeg"
- end
-
- defp check_mime_type(<<0x1A, 0x45, 0xDF, 0xA3, _::binary>>) do
- "video/webm"
- end
-
- defp check_mime_type(<<0x00, 0x00, 0x00, _, 0x66, 0x74, 0x79, 0x70, _::binary>>) do
- "video/mp4"
- end
-
- defp check_mime_type(<<0x49, 0x44, 0x33, _::binary>>) do
- "audio/mpeg"
- end
-
- defp check_mime_type(<<255, 251, _, 68, 0, 0, 0, 0, _::binary>>) do
- "audio/mpeg"
- end
-
- defp check_mime_type(
- <<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::size(160), 0x80, 0x74, 0x68, 0x65,
- 0x6F, 0x72, 0x61, _::binary>>
- ) do
- "video/ogg"
- end
-
- defp check_mime_type(<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::binary>>) do
- "audio/ogg"
- end
-
- defp check_mime_type(<<"RIFF", _::binary-size(4), "WAVE", _::binary>>) do
- "audio/wav"
- end
-
- defp check_mime_type(<<"RIFF", _::binary-size(4), "WEBP", _::binary>>) do
- "image/webp"
- end
-
- defp check_mime_type(<<"RIFF", _::binary-size(4), "AVI.", _::binary>>) do
- "video/avi"
- end
-
- defp check_mime_type(_) do
- @default
- end
-end
diff --git a/lib/pleroma/moderation_log.ex b/lib/pleroma/moderation_log.ex
index 31c9afe2a..38a863443 100644
--- a/lib/pleroma/moderation_log.ex
+++ b/lib/pleroma/moderation_log.ex
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.ModerationLog do
use Ecto.Schema
@@ -320,6 +324,19 @@ defmodule Pleroma.ModerationLog do
|> insert_log_entry_with_message()
end
+ @spec insert_log(%{actor: User, action: String.t(), subject_id: String.t()}) ::
+ {:ok, ModerationLog} | {:error, any}
+ def insert_log(%{actor: %User{} = actor, action: "chat_message_delete", subject_id: subject_id}) do
+ %ModerationLog{
+ data: %{
+ "actor" => %{"nickname" => actor.nickname},
+ "action" => "chat_message_delete",
+ "subject_id" => subject_id
+ }
+ }
+ |> insert_log_entry_with_message()
+ end
+
@spec insert_log_entry_with_message(ModerationLog) :: {:ok, ModerationLog} | {:error, any}
defp insert_log_entry_with_message(entry) do
entry.data["message"]
@@ -627,6 +644,17 @@ defmodule Pleroma.ModerationLog do
"@#{actor_nickname} updated users: #{users_to_nicknames_string(subjects)}"
end
+ @spec get_log_entry_message(ModerationLog) :: String.t()
+ def get_log_entry_message(%ModerationLog{
+ data: %{
+ "actor" => %{"nickname" => actor_nickname},
+ "action" => "chat_message_delete",
+ "subject_id" => subject_id
+ }
+ }) do
+ "@#{actor_nickname} deleted chat message ##{subject_id}"
+ end
+
defp nicknames_to_string(nicknames) do
nicknames
|> Enum.map(&"@#{&1}")
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index c1825f810..8868a910e 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -648,4 +648,16 @@ defmodule Pleroma.Notification do
)
|> Repo.one()
end
+
+ @spec mark_context_as_read(User.t(), String.t()) :: {integer(), nil | [term()]}
+ def mark_context_as_read(%User{id: id}, context) do
+ from(
+ n in Notification,
+ join: a in assoc(n, :activity),
+ where: n.user_id == ^id,
+ where: n.seen == false,
+ where: fragment("?->>'context'", a.data) == ^context
+ )
+ |> Repo.update_all(set: [seen: true])
+ end
end
diff --git a/lib/pleroma/object/containment.ex b/lib/pleroma/object/containment.ex
index bc88e8a0c..29cb3d672 100644
--- a/lib/pleroma/object/containment.ex
+++ b/lib/pleroma/object/containment.ex
@@ -44,13 +44,6 @@ defmodule Pleroma.Object.Containment do
nil
end
- # TODO: We explicitly allow 'tag' URIs through, due to references to legacy OStatus
- # objects being present in the test suite environment. Once these objects are
- # removed, please also remove this.
- if Mix.env() == :test do
- defp compare_uris(_, %URI{scheme: "tag"}), do: :ok
- end
-
defp compare_uris(%URI{host: host} = _id_uri, %URI{host: host} = _other_uri), do: :ok
defp compare_uris(_id_uri, _other_uri), do: :error
diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex
index 374d8704a..ae4301738 100644
--- a/lib/pleroma/object/fetcher.ex
+++ b/lib/pleroma/object/fetcher.ex
@@ -12,6 +12,7 @@ defmodule Pleroma.Object.Fetcher do
alias Pleroma.Web.ActivityPub.ObjectValidator
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.Federator
+ alias Pleroma.Web.FedSockets
require Logger
require Pleroma.Constants
@@ -36,8 +37,7 @@ defmodule Pleroma.Object.Fetcher do
defp reinject_object(%Object{data: %{"type" => "Question"}} = object, new_data) do
Logger.debug("Reinjecting object #{new_data["id"]}")
- with new_data <- Transmogrifier.fix_object(new_data),
- data <- maybe_reinject_internal_fields(object, new_data),
+ with data <- maybe_reinject_internal_fields(object, new_data),
{:ok, data, _} <- ObjectValidator.validate(data, %{}),
changeset <- Object.change(object, %{data: data}),
changeset <- touch_changeset(changeset),
@@ -99,8 +99,8 @@ defmodule Pleroma.Object.Fetcher do
{:containment, _} ->
{:error, "Object containment failed."}
- {:transmogrifier, {:error, {:reject, nil}}} ->
- {:reject, nil}
+ {:transmogrifier, {:error, {:reject, e}}} ->
+ {:reject, e}
{:transmogrifier, _} = e ->
{:error, e}
@@ -183,9 +183,47 @@ defmodule Pleroma.Object.Fetcher do
end
end
- def fetch_and_contain_remote_object_from_id(id) when is_binary(id) do
+ def fetch_and_contain_remote_object_from_id(prm, opts \\ [])
+
+ def fetch_and_contain_remote_object_from_id(%{"id" => id}, opts),
+ do: fetch_and_contain_remote_object_from_id(id, opts)
+
+ def fetch_and_contain_remote_object_from_id(id, opts) when is_binary(id) do
Logger.debug("Fetching object #{id} via AP")
+ with {:scheme, true} <- {:scheme, String.starts_with?(id, "http")},
+ {:ok, body} <- get_object(id, opts),
+ {:ok, data} <- safe_json_decode(body),
+ :ok <- Containment.contain_origin_from_id(id, data) do
+ {:ok, data}
+ else
+ {:scheme, _} ->
+ {:error, "Unsupported URI scheme"}
+
+ {:error, e} ->
+ {:error, e}
+
+ e ->
+ {:error, e}
+ end
+ end
+
+ def fetch_and_contain_remote_object_from_id(_id, _opts),
+ do: {:error, "id must be a string"}
+
+ defp get_object(id, opts) do
+ with false <- Keyword.get(opts, :force_http, false),
+ {:ok, fedsocket} <- FedSockets.get_or_create_fed_socket(id) do
+ Logger.debug("fetching via fedsocket - #{inspect(id)}")
+ FedSockets.fetch(fedsocket, id)
+ else
+ _other ->
+ Logger.debug("fetching via http - #{inspect(id)}")
+ get_object_http(id)
+ end
+ end
+
+ defp get_object_http(id) do
date = Pleroma.Signature.signed_date()
headers =
@@ -193,20 +231,29 @@ defmodule Pleroma.Object.Fetcher do
|> maybe_date_fetch(date)
|> sign_fetch(id, date)
- Logger.debug("Fetch headers: #{inspect(headers)}")
+ case HTTP.get(id, headers) do
+ {:ok, %{body: body, status: code, headers: headers}} when code in 200..299 ->
+ case List.keyfind(headers, "content-type", 0) do
+ {_, content_type} ->
+ case Plug.Conn.Utils.media_type(content_type) do
+ {:ok, "application", "activity+json", _} ->
+ {:ok, body}
+
+ {:ok, "application", "ld+json",
+ %{"profile" => "https://www.w3.org/ns/activitystreams"}} ->
+ {:ok, body}
+
+ _ ->
+ {:error, {:content_type, content_type}}
+ end
+
+ _ ->
+ {:error, {:content_type, nil}}
+ end
- with {:scheme, true} <- {:scheme, String.starts_with?(id, "http")},
- {:ok, %{body: body, status: code}} when code in 200..299 <- HTTP.get(id, headers),
- {:ok, data} <- Jason.decode(body),
- :ok <- Containment.contain_origin_from_id(id, data) do
- {:ok, data}
- else
{:ok, %{status: code}} when code in [404, 410] ->
{:error, "Object has been deleted"}
- {:scheme, _} ->
- {:error, "Unsupported URI scheme"}
-
{:error, e} ->
{:error, e}
@@ -215,8 +262,6 @@ defmodule Pleroma.Object.Fetcher do
end
end
- def fetch_and_contain_remote_object_from_id(%{"id" => id}),
- do: fetch_and_contain_remote_object_from_id(id)
-
- def fetch_and_contain_remote_object_from_id(_id), do: {:error, "id must be a string"}
+ defp safe_json_decode(nil), do: {:ok, nil}
+ defp safe_json_decode(json), do: Jason.decode(json)
end
diff --git a/lib/pleroma/plugs/admin_secret_authentication_plug.ex b/lib/pleroma/plugs/admin_secret_authentication_plug.ex
deleted file mode 100644
index 2e54df47a..000000000
--- a/lib/pleroma/plugs/admin_secret_authentication_plug.ex
+++ /dev/null
@@ -1,60 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.AdminSecretAuthenticationPlug do
- import Plug.Conn
-
- alias Pleroma.Plugs.OAuthScopesPlug
- alias Pleroma.Plugs.RateLimiter
- alias Pleroma.User
-
- def init(options) do
- options
- end
-
- def secret_token do
- case Pleroma.Config.get(:admin_token) do
- blank when blank in [nil, ""] -> nil
- token -> token
- end
- end
-
- def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
-
- def call(conn, _) do
- if secret_token() do
- authenticate(conn)
- else
- conn
- end
- end
-
- def authenticate(%{params: %{"admin_token" => admin_token}} = conn) do
- if admin_token == secret_token() do
- assign_admin_user(conn)
- else
- handle_bad_token(conn)
- end
- end
-
- def authenticate(conn) do
- token = secret_token()
-
- case get_req_header(conn, "x-admin-token") do
- blank when blank in [[], [""]] -> conn
- [^token] -> assign_admin_user(conn)
- _ -> handle_bad_token(conn)
- end
- end
-
- defp assign_admin_user(conn) do
- conn
- |> assign(:user, %User{is_admin: true})
- |> OAuthScopesPlug.skip_plug()
- end
-
- defp handle_bad_token(conn) do
- RateLimiter.call(conn, name: :authentication)
- end
-end
diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex
deleted file mode 100644
index 057ea42f1..000000000
--- a/lib/pleroma/plugs/authentication_plug.ex
+++ /dev/null
@@ -1,80 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.AuthenticationPlug do
- alias Pleroma.Plugs.OAuthScopesPlug
- alias Pleroma.User
-
- import Plug.Conn
-
- require Logger
-
- def init(options), do: options
-
- def checkpw(password, "$6" <> _ = password_hash) do
- :crypt.crypt(password, password_hash) == password_hash
- end
-
- def checkpw(password, "$2" <> _ = password_hash) do
- # Handle bcrypt passwords for Mastodon migration
- Bcrypt.verify_pass(password, password_hash)
- end
-
- def checkpw(password, "$pbkdf2" <> _ = password_hash) do
- Pbkdf2.verify_pass(password, password_hash)
- end
-
- def checkpw(_password, _password_hash) do
- Logger.error("Password hash not recognized")
- false
- end
-
- def maybe_update_password(%User{password_hash: "$2" <> _} = user, password) do
- do_update_password(user, password)
- end
-
- def maybe_update_password(%User{password_hash: "$6" <> _} = user, password) do
- do_update_password(user, password)
- end
-
- def maybe_update_password(user, _), do: {:ok, user}
-
- defp do_update_password(user, password) do
- user
- |> User.password_update_changeset(%{
- "password" => password,
- "password_confirmation" => password
- })
- |> Pleroma.Repo.update()
- end
-
- def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
-
- def call(
- %{
- assigns: %{
- auth_user: %{password_hash: password_hash} = auth_user,
- auth_credentials: %{password: password}
- }
- } = conn,
- _
- ) do
- if checkpw(password, password_hash) do
- {:ok, auth_user} = maybe_update_password(auth_user, password)
-
- conn
- |> assign(:user, auth_user)
- |> OAuthScopesPlug.skip_plug()
- else
- conn
- end
- end
-
- def call(%{assigns: %{auth_credentials: %{password: _}}} = conn, _) do
- Pbkdf2.no_user_verify()
- conn
- end
-
- def call(conn, _), do: conn
-end
diff --git a/lib/pleroma/plugs/basic_auth_decoder_plug.ex b/lib/pleroma/plugs/basic_auth_decoder_plug.ex
deleted file mode 100644
index af7ecb0d8..000000000
--- a/lib/pleroma/plugs/basic_auth_decoder_plug.ex
+++ /dev/null
@@ -1,25 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.BasicAuthDecoderPlug do
- import Plug.Conn
-
- def init(options) do
- options
- end
-
- def call(conn, _opts) do
- with ["Basic " <> header] <- get_req_header(conn, "authorization"),
- {:ok, userinfo} <- Base.decode64(header),
- [username, password] <- String.split(userinfo, ":", parts: 2) do
- conn
- |> assign(:auth_credentials, %{
- username: username,
- password: password
- })
- else
- _ -> conn
- end
- end
-end
diff --git a/lib/pleroma/plugs/cache.ex b/lib/pleroma/plugs/cache.ex
deleted file mode 100644
index f65c2a189..000000000
--- a/lib/pleroma/plugs/cache.ex
+++ /dev/null
@@ -1,136 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.Cache do
- @moduledoc """
- Caches successful GET responses.
-
- To enable the cache add the plug to a router pipeline or controller:
-
- plug(Pleroma.Plugs.Cache)
-
- ## Configuration
-
- To configure the plug you need to pass settings as the second argument to the `plug/2` macro:
-
- plug(Pleroma.Plugs.Cache, [ttl: nil, query_params: true])
-
- Available options:
-
- - `ttl`: An expiration time (time-to-live). This value should be in milliseconds or `nil` to disable expiration. Defaults to `nil`.
- - `query_params`: Take URL query string into account (`true`), ignore it (`false`) or limit to specific params only (list). Defaults to `true`.
- - `tracking_fun`: A function that is called on successfull responses, no matter if the request is cached or not. It should accept a conn as the first argument and the value assigned to `tracking_fun_data` as the second.
-
- Additionally, you can overwrite the TTL inside a controller action by assigning `cache_ttl` to the connection struct:
-
- def index(conn, _params) do
- ttl = 60_000 # one minute
-
- conn
- |> assign(:cache_ttl, ttl)
- |> render("index.html")
- end
-
- """
-
- import Phoenix.Controller, only: [current_path: 1, json: 2]
- import Plug.Conn
-
- @behaviour Plug
-
- @defaults %{ttl: nil, query_params: true}
-
- @impl true
- def init([]), do: @defaults
-
- def init(opts) do
- opts = Map.new(opts)
- Map.merge(@defaults, opts)
- end
-
- @impl true
- def call(%{method: "GET"} = conn, opts) do
- key = cache_key(conn, opts)
-
- case Cachex.get(:web_resp_cache, key) do
- {:ok, nil} ->
- cache_resp(conn, opts)
-
- {:ok, {content_type, body, tracking_fun_data}} ->
- conn = opts.tracking_fun.(conn, tracking_fun_data)
-
- send_cached(conn, {content_type, body})
-
- {:ok, record} ->
- send_cached(conn, record)
-
- {atom, message} when atom in [:ignore, :error] ->
- render_error(conn, message)
- end
- end
-
- def call(conn, _), do: conn
-
- # full path including query params
- defp cache_key(conn, %{query_params: true}), do: current_path(conn)
-
- # request path without query params
- defp cache_key(conn, %{query_params: false}), do: conn.request_path
-
- # request path with specific query params
- defp cache_key(conn, %{query_params: query_params}) when is_list(query_params) do
- query_string =
- conn.params
- |> Map.take(query_params)
- |> URI.encode_query()
-
- conn.request_path <> "?" <> query_string
- end
-
- defp cache_resp(conn, opts) do
- register_before_send(conn, fn
- %{status: 200, resp_body: body} = conn ->
- ttl = Map.get(conn.assigns, :cache_ttl, opts.ttl)
- key = cache_key(conn, opts)
- content_type = content_type(conn)
-
- conn =
- unless opts[:tracking_fun] do
- Cachex.put(:web_resp_cache, key, {content_type, body}, ttl: ttl)
- conn
- else
- tracking_fun_data = Map.get(conn.assigns, :tracking_fun_data, nil)
- Cachex.put(:web_resp_cache, key, {content_type, body, tracking_fun_data}, ttl: ttl)
-
- opts.tracking_fun.(conn, tracking_fun_data)
- end
-
- put_resp_header(conn, "x-cache", "MISS from Pleroma")
-
- conn ->
- conn
- end)
- end
-
- defp content_type(conn) do
- conn
- |> Plug.Conn.get_resp_header("content-type")
- |> hd()
- end
-
- defp send_cached(conn, {content_type, body}) do
- conn
- |> put_resp_content_type(content_type, nil)
- |> put_resp_header("x-cache", "HIT from Pleroma")
- |> send_resp(:ok, body)
- |> halt()
- end
-
- defp render_error(conn, message) do
- conn
- |> put_status(:internal_server_error)
- |> json(%{error: message})
- |> halt()
- end
-end
diff --git a/lib/pleroma/plugs/ensure_authenticated_plug.ex b/lib/pleroma/plugs/ensure_authenticated_plug.ex
deleted file mode 100644
index 3fe550806..000000000
--- a/lib/pleroma/plugs/ensure_authenticated_plug.ex
+++ /dev/null
@@ -1,41 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.EnsureAuthenticatedPlug do
- import Plug.Conn
- import Pleroma.Web.TranslationHelpers
-
- alias Pleroma.User
-
- use Pleroma.Web, :plug
-
- def init(options) do
- options
- end
-
- @impl true
- def perform(
- %{
- assigns: %{
- auth_credentials: %{password: _},
- user: %User{multi_factor_authentication_settings: %{enabled: true}}
- }
- } = conn,
- _
- ) do
- conn
- |> render_error(:forbidden, "Two-factor authentication enabled, you must use a access token.")
- |> halt()
- end
-
- def perform(%{assigns: %{user: %User{}}} = conn, _) do
- conn
- end
-
- def perform(conn, _) do
- conn
- |> render_error(:forbidden, "Invalid credentials.")
- |> halt()
- end
-end
diff --git a/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex b/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex
deleted file mode 100644
index 7265bb87a..000000000
--- a/lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex
+++ /dev/null
@@ -1,35 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug do
- import Pleroma.Web.TranslationHelpers
- import Plug.Conn
-
- alias Pleroma.Config
- alias Pleroma.User
-
- use Pleroma.Web, :plug
-
- def init(options) do
- options
- end
-
- @impl true
- def perform(conn, _) do
- public? = Config.get!([:instance, :public])
-
- case {public?, conn} do
- {true, _} ->
- conn
-
- {false, %{assigns: %{user: %User{}}}} ->
- conn
-
- {false, _} ->
- conn
- |> render_error(:forbidden, "This resource requires authentication.")
- |> halt
- end
- end
-end
diff --git a/lib/pleroma/plugs/ensure_user_key_plug.ex b/lib/pleroma/plugs/ensure_user_key_plug.ex
deleted file mode 100644
index 9795cdbde..000000000
--- a/lib/pleroma/plugs/ensure_user_key_plug.ex
+++ /dev/null
@@ -1,18 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.EnsureUserKeyPlug do
- import Plug.Conn
-
- def init(opts) do
- opts
- end
-
- def call(%{assigns: %{user: _}} = conn, _), do: conn
-
- def call(conn, _) do
- conn
- |> assign(:user, nil)
- end
-end
diff --git a/lib/pleroma/plugs/expect_authenticated_check_plug.ex b/lib/pleroma/plugs/expect_authenticated_check_plug.ex
deleted file mode 100644
index 66b8d5de5..000000000
--- a/lib/pleroma/plugs/expect_authenticated_check_plug.ex
+++ /dev/null
@@ -1,20 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.ExpectAuthenticatedCheckPlug do
- @moduledoc """
- Marks `Pleroma.Plugs.EnsureAuthenticatedPlug` as expected to be executed later in plug chain.
-
- No-op plug which affects `Pleroma.Web` operation (is checked with `PlugHelper.plug_called?/2`).
- """
-
- use Pleroma.Web, :plug
-
- def init(options), do: options
-
- @impl true
- def perform(conn, _) do
- conn
- end
-end
diff --git a/lib/pleroma/plugs/expect_public_or_authenticated_check_plug.ex b/lib/pleroma/plugs/expect_public_or_authenticated_check_plug.ex
deleted file mode 100644
index ba0ef76bd..000000000
--- a/lib/pleroma/plugs/expect_public_or_authenticated_check_plug.ex
+++ /dev/null
@@ -1,21 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.ExpectPublicOrAuthenticatedCheckPlug do
- @moduledoc """
- Marks `Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug` as expected to be executed later in plug
- chain.
-
- No-op plug which affects `Pleroma.Web` operation (is checked with `PlugHelper.plug_called?/2`).
- """
-
- use Pleroma.Web, :plug
-
- def init(options), do: options
-
- @impl true
- def perform(conn, _) do
- conn
- end
-end
diff --git a/lib/pleroma/plugs/federating_plug.ex b/lib/pleroma/plugs/federating_plug.ex
deleted file mode 100644
index 09038f3c6..000000000
--- a/lib/pleroma/plugs/federating_plug.ex
+++ /dev/null
@@ -1,32 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Web.FederatingPlug do
- import Plug.Conn
-
- def init(options) do
- options
- end
-
- def call(conn, _opts) do
- if federating?() do
- conn
- else
- fail(conn)
- end
- end
-
- def federating?, do: Pleroma.Config.get([:instance, :federating])
-
- # Definition for the use in :if_func / :unless_func plug options
- def federating?(_conn), do: federating?()
-
- defp fail(conn) do
- conn
- |> put_status(404)
- |> Phoenix.Controller.put_view(Pleroma.Web.ErrorView)
- |> Phoenix.Controller.render("404.json")
- |> halt()
- end
-end
diff --git a/lib/pleroma/plugs/frontend_static.ex b/lib/pleroma/plugs/frontend_static.ex
deleted file mode 100644
index 11a0d5382..000000000
--- a/lib/pleroma/plugs/frontend_static.ex
+++ /dev/null
@@ -1,55 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.FrontendStatic do
- require Pleroma.Constants
-
- @moduledoc """
- This is a shim to call `Plug.Static` but with runtime `from` configuration`. It dispatches to the different frontends.
- """
- @behaviour Plug
-
- def file_path(path, frontend_type \\ :primary) do
- if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
- instance_static_path = Pleroma.Config.get([:instance, :static_dir], "instance/static")
-
- Path.join([
- instance_static_path,
- "frontends",
- configuration["name"],
- configuration["ref"],
- path
- ])
- else
- nil
- end
- end
-
- def init(opts) do
- opts
- |> Keyword.put(:from, "__unconfigured_frontend_static_plug")
- |> Plug.Static.init()
- |> Map.put(:frontend_type, opts[:frontend_type])
- end
-
- def call(conn, opts) do
- frontend_type = Map.get(opts, :frontend_type, :primary)
- path = file_path("", frontend_type)
-
- if path do
- conn
- |> call_static(opts, path)
- else
- conn
- end
- end
-
- defp call_static(conn, opts, from) do
- opts =
- opts
- |> Map.put(:from, from)
-
- Plug.Static.call(conn, opts)
- end
-end
diff --git a/lib/pleroma/plugs/http_security_plug.ex b/lib/pleroma/plugs/http_security_plug.ex
deleted file mode 100644
index c363b193b..000000000
--- a/lib/pleroma/plugs/http_security_plug.ex
+++ /dev/null
@@ -1,225 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.HTTPSecurityPlug do
- alias Pleroma.Config
- import Plug.Conn
-
- require Logger
-
- def init(opts), do: opts
-
- def call(conn, _options) do
- if Config.get([:http_security, :enabled]) do
- conn
- |> merge_resp_headers(headers())
- |> maybe_send_sts_header(Config.get([:http_security, :sts]))
- else
- conn
- end
- end
-
- defp headers do
- referrer_policy = Config.get([:http_security, :referrer_policy])
- report_uri = Config.get([:http_security, :report_uri])
-
- headers = [
- {"x-xss-protection", "1; mode=block"},
- {"x-permitted-cross-domain-policies", "none"},
- {"x-frame-options", "DENY"},
- {"x-content-type-options", "nosniff"},
- {"referrer-policy", referrer_policy},
- {"x-download-options", "noopen"},
- {"content-security-policy", csp_string()}
- ]
-
- if report_uri do
- report_group = %{
- "group" => "csp-endpoint",
- "max-age" => 10_886_400,
- "endpoints" => [
- %{"url" => report_uri}
- ]
- }
-
- [{"reply-to", Jason.encode!(report_group)} | headers]
- else
- headers
- end
- end
-
- static_csp_rules = [
- "default-src 'none'",
- "base-uri 'self'",
- "frame-ancestors 'none'",
- "style-src 'self' 'unsafe-inline'",
- "font-src 'self'",
- "manifest-src 'self'"
- ]
-
- @csp_start [Enum.join(static_csp_rules, ";") <> ";"]
-
- defp csp_string do
- scheme = Config.get([Pleroma.Web.Endpoint, :url])[:scheme]
- static_url = Pleroma.Web.Endpoint.static_url()
- websocket_url = Pleroma.Web.Endpoint.websocket_url()
- report_uri = Config.get([:http_security, :report_uri])
-
- img_src = "img-src 'self' data: blob:"
- media_src = "media-src 'self'"
-
- # Strict multimedia CSP enforcement only when MediaProxy is enabled
- {img_src, media_src} =
- if Config.get([:media_proxy, :enabled]) &&
- !Config.get([:media_proxy, :proxy_opts, :redirect_on_failure]) do
- sources = build_csp_multimedia_source_list()
- {[img_src, sources], [media_src, sources]}
- else
- {[img_src, " https:"], [media_src, " https:"]}
- end
-
- connect_src = ["connect-src 'self' blob: ", static_url, ?\s, websocket_url]
-
- connect_src =
- if Config.get(:env) == :dev do
- [connect_src, " http://localhost:3035/"]
- else
- connect_src
- end
-
- script_src =
- if Config.get(:env) == :dev do
- "script-src 'self' 'unsafe-eval'"
- else
- "script-src 'self'"
- end
-
- report = if report_uri, do: ["report-uri ", report_uri, ";report-to csp-endpoint"]
- insecure = if scheme == "https", do: "upgrade-insecure-requests"
-
- @csp_start
- |> add_csp_param(img_src)
- |> add_csp_param(media_src)
- |> add_csp_param(connect_src)
- |> add_csp_param(script_src)
- |> add_csp_param(insecure)
- |> add_csp_param(report)
- |> :erlang.iolist_to_binary()
- end
-
- defp build_csp_from_whitelist([], acc), do: acc
-
- defp build_csp_from_whitelist([last], acc) do
- [build_csp_param_from_whitelist(last) | acc]
- end
-
- defp build_csp_from_whitelist([head | tail], acc) do
- build_csp_from_whitelist(tail, [[?\s, build_csp_param_from_whitelist(head)] | acc])
- end
-
- # TODO: use `build_csp_param/1` after removing support bare domains for media proxy whitelist
- defp build_csp_param_from_whitelist("http" <> _ = url) do
- build_csp_param(url)
- end
-
- defp build_csp_param_from_whitelist(url), do: url
-
- defp build_csp_multimedia_source_list do
- media_proxy_whitelist =
- [:media_proxy, :whitelist]
- |> Config.get()
- |> build_csp_from_whitelist([])
-
- captcha_method = Config.get([Pleroma.Captcha, :method])
- captcha_endpoint = Config.get([captcha_method, :endpoint])
-
- base_endpoints =
- [
- [:media_proxy, :base_url],
- [Pleroma.Upload, :base_url],
- [Pleroma.Uploaders.S3, :public_endpoint]
- ]
- |> Enum.map(&Config.get/1)
-
- [captcha_endpoint | base_endpoints]
- |> Enum.map(&build_csp_param/1)
- |> Enum.reduce([], &add_source(&2, &1))
- |> add_source(media_proxy_whitelist)
- end
-
- defp add_source(iodata, nil), do: iodata
- defp add_source(iodata, []), do: iodata
- defp add_source(iodata, source), do: [[?\s, source] | iodata]
-
- defp add_csp_param(csp_iodata, nil), do: csp_iodata
-
- defp add_csp_param(csp_iodata, param), do: [[param, ?;] | csp_iodata]
-
- defp build_csp_param(nil), do: nil
-
- defp build_csp_param(url) when is_binary(url) do
- %{host: host, scheme: scheme} = URI.parse(url)
-
- if scheme do
- [scheme, "://", host]
- end
- end
-
- def warn_if_disabled do
- unless Config.get([:http_security, :enabled]) do
- Logger.warn("
- .i;;;;i.
- iYcviii;vXY:
- .YXi .i1c.
- .YC. . in7.
- .vc. ...... ;1c.
- i7, .. .;1;
- i7, .. ... .Y1i
- ,7v .6MMM@; .YX,
- .7;. ..IMMMMMM1 :t7.
- .;Y. ;$MMMMMM9. :tc.
- vY. .. .nMMM@MMU. ;1v.
- i7i ... .#MM@M@C. .....:71i
- it: .... $MMM@9;.,i;;;i,;tti
- :t7. ..... 0MMMWv.,iii:::,,;St.
- .nC. ..... IMMMQ..,::::::,.,czX.
- .ct: ....... .ZMMMI..,:::::::,,:76Y.
- c2: ......,i..Y$M@t..:::::::,,..inZY
- vov ......:ii..c$MBc..,,,,,,,,,,..iI9i
- i9Y ......iii:..7@MA,..,,,,,,,,,....;AA:
- iIS. ......:ii::..;@MI....,............;Ez.
- .I9. ......:i::::...8M1..................C0z.
- .z9; ......:i::::,.. .i:...................zWX.
- vbv ......,i::::,,. ................. :AQY
- c6Y. .,...,::::,,..:t0@@QY. ................ :8bi
- :6S. ..,,...,:::,,,..EMMMMMMI. ............... .;bZ,
- :6o, .,,,,..:::,,,..i#MMMMMM#v................. YW2.
- .n8i ..,,,,,,,::,,,,.. tMMMMM@C:.................. .1Wn
- 7Uc. .:::,,,,,::,,,,.. i1t;,..................... .UEi
- 7C...::::::::::::,,,,.. .................... vSi.
- ;1;...,,::::::,......... .................. Yz:
- v97,......... .voC.
- izAotX7777777777777777777777777777777777777777Y7n92:
- .;CoIIIIIUAA666666699999ZZZZZZZZZZZZZZZZZZZZ6ov.
-
-HTTP Security is disabled. Please re-enable it to prevent users from attacking
-your instance and your users via malicious posts:
-
- config :pleroma, :http_security, enabled: true
- ")
- end
- end
-
- defp maybe_send_sts_header(conn, true) do
- max_age_sts = Config.get([:http_security, :sts_max_age])
- max_age_ct = Config.get([:http_security, :ct_max_age])
-
- merge_resp_headers(conn, [
- {"strict-transport-security", "max-age=#{max_age_sts}; includeSubDomains"},
- {"expect-ct", "enforce, max-age=#{max_age_ct}"}
- ])
- end
-
- defp maybe_send_sts_header(conn, _), do: conn
-end
diff --git a/lib/pleroma/plugs/idempotency_plug.ex b/lib/pleroma/plugs/idempotency_plug.ex
deleted file mode 100644
index f41397075..000000000
--- a/lib/pleroma/plugs/idempotency_plug.ex
+++ /dev/null
@@ -1,84 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.IdempotencyPlug do
- import Phoenix.Controller, only: [json: 2]
- import Plug.Conn
-
- @behaviour Plug
-
- @impl true
- def init(opts), do: opts
-
- # Sending idempotency keys in `GET` and `DELETE` requests has no effect
- # and should be avoided, as these requests are idempotent by definition.
-
- @impl true
- def call(%{method: method} = conn, _) when method in ["POST", "PUT", "PATCH"] do
- case get_req_header(conn, "idempotency-key") do
- [key] -> process_request(conn, key)
- _ -> conn
- end
- end
-
- def call(conn, _), do: conn
-
- def process_request(conn, key) do
- case Cachex.get(:idempotency_cache, key) do
- {:ok, nil} ->
- cache_resposnse(conn, key)
-
- {:ok, record} ->
- send_cached(conn, key, record)
-
- {atom, message} when atom in [:ignore, :error] ->
- render_error(conn, message)
- end
- end
-
- defp cache_resposnse(conn, key) do
- register_before_send(conn, fn conn ->
- [request_id] = get_resp_header(conn, "x-request-id")
- content_type = get_content_type(conn)
-
- record = {request_id, content_type, conn.status, conn.resp_body}
- {:ok, _} = Cachex.put(:idempotency_cache, key, record)
-
- conn
- |> put_resp_header("idempotency-key", key)
- |> put_resp_header("x-original-request-id", request_id)
- end)
- end
-
- defp send_cached(conn, key, record) do
- {request_id, content_type, status, body} = record
-
- conn
- |> put_resp_header("idempotency-key", key)
- |> put_resp_header("idempotent-replayed", "true")
- |> put_resp_header("x-original-request-id", request_id)
- |> put_resp_content_type(content_type)
- |> send_resp(status, body)
- |> halt()
- end
-
- defp render_error(conn, message) do
- conn
- |> put_status(:unprocessable_entity)
- |> json(%{error: message})
- |> halt()
- end
-
- defp get_content_type(conn) do
- [content_type] = get_resp_header(conn, "content-type")
-
- if String.contains?(content_type, ";") do
- content_type
- |> String.split(";")
- |> hd()
- else
- content_type
- end
- end
-end
diff --git a/lib/pleroma/plugs/instance_static.ex b/lib/pleroma/plugs/instance_static.ex
deleted file mode 100644
index 0fb57e422..000000000
--- a/lib/pleroma/plugs/instance_static.ex
+++ /dev/null
@@ -1,53 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.InstanceStatic do
- require Pleroma.Constants
-
- @moduledoc """
- This is a shim to call `Plug.Static` but with runtime `from` configuration.
-
- Mountpoints are defined directly in the module to avoid calling the configuration for every request including non-static ones.
- """
- @behaviour Plug
-
- def file_path(path) do
- instance_path =
- Path.join(Pleroma.Config.get([:instance, :static_dir], "instance/static/"), path)
-
- frontend_path = Pleroma.Plugs.FrontendStatic.file_path(path, :primary)
-
- (File.exists?(instance_path) && instance_path) ||
- (frontend_path && File.exists?(frontend_path) && frontend_path) ||
- Path.join(Application.app_dir(:pleroma, "priv/static/"), path)
- end
-
- def init(opts) do
- opts
- |> Keyword.put(:from, "__unconfigured_instance_static_plug")
- |> Plug.Static.init()
- end
-
- for only <- Pleroma.Constants.static_only_files() do
- def call(%{request_path: "/" <> unquote(only) <> _} = conn, opts) do
- call_static(
- conn,
- opts,
- Pleroma.Config.get([:instance, :static_dir], "instance/static")
- )
- end
- end
-
- def call(conn, _) do
- conn
- end
-
- defp call_static(conn, opts, from) do
- opts =
- opts
- |> Map.put(:from, from)
-
- Plug.Static.call(conn, opts)
- end
-end
diff --git a/lib/pleroma/plugs/legacy_authentication_plug.ex b/lib/pleroma/plugs/legacy_authentication_plug.ex
deleted file mode 100644
index d346e01a6..000000000
--- a/lib/pleroma/plugs/legacy_authentication_plug.ex
+++ /dev/null
@@ -1,42 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.LegacyAuthenticationPlug do
- import Plug.Conn
-
- alias Pleroma.Plugs.OAuthScopesPlug
- alias Pleroma.User
-
- def init(options) do
- options
- end
-
- def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
-
- def call(
- %{
- assigns: %{
- auth_user: %{password_hash: "$6$" <> _ = password_hash} = auth_user,
- auth_credentials: %{password: password}
- }
- } = conn,
- _
- ) do
- with ^password_hash <- :crypt.crypt(password, password_hash),
- {:ok, user} <-
- User.reset_password(auth_user, %{password: password, password_confirmation: password}) do
- conn
- |> assign(:auth_user, user)
- |> assign(:user, user)
- |> OAuthScopesPlug.skip_plug()
- else
- _ ->
- conn
- end
- end
-
- def call(conn, _) do
- conn
- end
-end
diff --git a/lib/pleroma/plugs/oauth_plug.ex b/lib/pleroma/plugs/oauth_plug.ex
deleted file mode 100644
index 6fa71ef47..000000000
--- a/lib/pleroma/plugs/oauth_plug.ex
+++ /dev/null
@@ -1,120 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.OAuthPlug do
- import Plug.Conn
- import Ecto.Query
-
- alias Pleroma.Repo
- alias Pleroma.User
- alias Pleroma.Web.OAuth.App
- alias Pleroma.Web.OAuth.Token
-
- @realm_reg Regex.compile!("Bearer\:?\s+(.*)$", "i")
-
- def init(options), do: options
-
- def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
-
- def call(%{params: %{"access_token" => access_token}} = conn, _) do
- with {:ok, user, token_record} <- fetch_user_and_token(access_token) do
- conn
- |> assign(:token, token_record)
- |> assign(:user, user)
- else
- _ ->
- # token found, but maybe only with app
- with {:ok, app, token_record} <- fetch_app_and_token(access_token) do
- conn
- |> assign(:token, token_record)
- |> assign(:app, app)
- else
- _ -> conn
- end
- end
- end
-
- def call(conn, _) do
- case fetch_token_str(conn) do
- {:ok, token} ->
- with {:ok, user, token_record} <- fetch_user_and_token(token) do
- conn
- |> assign(:token, token_record)
- |> assign(:user, user)
- else
- _ ->
- # token found, but maybe only with app
- with {:ok, app, token_record} <- fetch_app_and_token(token) do
- conn
- |> assign(:token, token_record)
- |> assign(:app, app)
- else
- _ -> conn
- end
- end
-
- _ ->
- conn
- end
- end
-
- # Gets user by token
- #
- @spec fetch_user_and_token(String.t()) :: {:ok, User.t(), Token.t()} | nil
- defp fetch_user_and_token(token) do
- query =
- from(t in Token,
- where: t.token == ^token,
- join: user in assoc(t, :user),
- preload: [user: user]
- )
-
- # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
- with %Token{user: user} = token_record <- Repo.one(query) do
- {:ok, user, token_record}
- end
- end
-
- @spec fetch_app_and_token(String.t()) :: {:ok, App.t(), Token.t()} | nil
- defp fetch_app_and_token(token) do
- query =
- from(t in Token, where: t.token == ^token, join: app in assoc(t, :app), preload: [app: app])
-
- with %Token{app: app} = token_record <- Repo.one(query) do
- {:ok, app, token_record}
- end
- end
-
- # Gets token from session by :oauth_token key
- #
- @spec fetch_token_from_session(Plug.Conn.t()) :: :no_token_found | {:ok, String.t()}
- defp fetch_token_from_session(conn) do
- case get_session(conn, :oauth_token) do
- nil -> :no_token_found
- token -> {:ok, token}
- end
- end
-
- # Gets token from headers
- #
- @spec fetch_token_str(Plug.Conn.t()) :: :no_token_found | {:ok, String.t()}
- defp fetch_token_str(%Plug.Conn{} = conn) do
- headers = get_req_header(conn, "authorization")
-
- with :no_token_found <- fetch_token_str(headers),
- do: fetch_token_from_session(conn)
- end
-
- @spec fetch_token_str(Keyword.t()) :: :no_token_found | {:ok, String.t()}
- defp fetch_token_str([]), do: :no_token_found
-
- defp fetch_token_str([token | tail]) do
- trimmed_token = String.trim(token)
-
- case Regex.run(@realm_reg, trimmed_token) do
- [_, match] -> {:ok, String.trim(match)}
- _ -> fetch_token_str(tail)
- end
- end
-end
diff --git a/lib/pleroma/plugs/oauth_scopes_plug.ex b/lib/pleroma/plugs/oauth_scopes_plug.ex
deleted file mode 100644
index efc25b79f..000000000
--- a/lib/pleroma/plugs/oauth_scopes_plug.ex
+++ /dev/null
@@ -1,77 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.OAuthScopesPlug do
- import Plug.Conn
- import Pleroma.Web.Gettext
-
- alias Pleroma.Config
-
- use Pleroma.Web, :plug
-
- def init(%{scopes: _} = options), do: options
-
- @impl true
- def perform(%Plug.Conn{assigns: assigns} = conn, %{scopes: scopes} = options) do
- op = options[:op] || :|
- token = assigns[:token]
-
- scopes = transform_scopes(scopes, options)
- matched_scopes = (token && filter_descendants(scopes, token.scopes)) || []
-
- cond do
- token && op == :| && Enum.any?(matched_scopes) ->
- conn
-
- token && op == :& && matched_scopes == scopes ->
- conn
-
- options[:fallback] == :proceed_unauthenticated ->
- drop_auth_info(conn)
-
- true ->
- missing_scopes = scopes -- matched_scopes
- permissions = Enum.join(missing_scopes, " #{op} ")
-
- error_message =
- dgettext("errors", "Insufficient permissions: %{permissions}.", permissions: permissions)
-
- conn
- |> put_resp_content_type("application/json")
- |> send_resp(:forbidden, Jason.encode!(%{error: error_message}))
- |> halt()
- end
- end
-
- @doc "Drops authentication info from connection"
- def drop_auth_info(conn) do
- # To simplify debugging, setting a private variable on `conn` if auth info is dropped
- conn
- |> put_private(:authentication_ignored, true)
- |> assign(:user, nil)
- |> assign(:token, nil)
- end
-
- @doc "Filters descendants of supported scopes"
- def filter_descendants(scopes, supported_scopes) do
- Enum.filter(
- scopes,
- fn scope ->
- Enum.find(
- supported_scopes,
- &(scope == &1 || String.starts_with?(scope, &1 <> ":"))
- )
- end
- )
- end
-
- @doc "Transforms scopes by applying supported options (e.g. :admin)"
- def transform_scopes(scopes, options) do
- if options[:admin] do
- Config.oauth_admin_scopes(scopes)
- else
- scopes
- end
- end
-end
diff --git a/lib/pleroma/plugs/plug_helper.ex b/lib/pleroma/plugs/plug_helper.ex
deleted file mode 100644
index 9c67be8ef..000000000
--- a/lib/pleroma/plugs/plug_helper.ex
+++ /dev/null
@@ -1,40 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.PlugHelper do
- @moduledoc "Pleroma Plug helper"
-
- @called_plugs_list_id :called_plugs
- def called_plugs_list_id, do: @called_plugs_list_id
-
- @skipped_plugs_list_id :skipped_plugs
- def skipped_plugs_list_id, do: @skipped_plugs_list_id
-
- @doc "Returns `true` if specified plug was called."
- def plug_called?(conn, plug_module) do
- contained_in_private_list?(conn, @called_plugs_list_id, plug_module)
- end
-
- @doc "Returns `true` if specified plug was explicitly marked as skipped."
- def plug_skipped?(conn, plug_module) do
- contained_in_private_list?(conn, @skipped_plugs_list_id, plug_module)
- end
-
- @doc "Returns `true` if specified plug was either called or explicitly marked as skipped."
- def plug_called_or_skipped?(conn, plug_module) do
- plug_called?(conn, plug_module) || plug_skipped?(conn, plug_module)
- end
-
- # Appends plug to known list (skipped, called). Intended to be used from within plug code only.
- def append_to_private_list(conn, list_id, value) do
- list = conn.private[list_id] || []
- modified_list = Enum.uniq(list ++ [value])
- Plug.Conn.put_private(conn, list_id, modified_list)
- end
-
- defp contained_in_private_list?(conn, private_variable, value) do
- list = conn.private[private_variable] || []
- value in list
- end
-end
diff --git a/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex b/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex
deleted file mode 100644
index 884268d96..000000000
--- a/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex
+++ /dev/null
@@ -1,50 +0,0 @@
-defmodule Pleroma.Plugs.RateLimiter.LimiterSupervisor do
- use DynamicSupervisor
-
- import Cachex.Spec
-
- def start_link(init_arg) do
- DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__)
- end
-
- def add_or_return_limiter(limiter_name, expiration) do
- result =
- DynamicSupervisor.start_child(
- __MODULE__,
- %{
- id: String.to_atom("rl_#{limiter_name}"),
- start:
- {Cachex, :start_link,
- [
- limiter_name,
- [
- expiration:
- expiration(
- default: expiration,
- interval: check_interval(expiration),
- lazy: true
- )
- ]
- ]}
- }
- )
-
- case result do
- {:ok, _pid} = result -> result
- {:error, {:already_started, pid}} -> {:ok, pid}
- _ -> result
- end
- end
-
- @impl true
- def init(_init_arg) do
- DynamicSupervisor.init(strategy: :one_for_one)
- end
-
- defp check_interval(exp) do
- (exp / 2)
- |> Kernel.trunc()
- |> Kernel.min(5000)
- |> Kernel.max(1)
- end
-end
diff --git a/lib/pleroma/plugs/rate_limiter/rate_limiter.ex b/lib/pleroma/plugs/rate_limiter/rate_limiter.ex
deleted file mode 100644
index c51e2c634..000000000
--- a/lib/pleroma/plugs/rate_limiter/rate_limiter.ex
+++ /dev/null
@@ -1,267 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.RateLimiter do
- @moduledoc """
-
- ## Configuration
-
- A keyword list of rate limiters where a key is a limiter name and value is the limiter configuration.
- The basic configuration is a tuple where:
-
- * The first element: `scale` (Integer). The time scale in milliseconds.
- * The second element: `limit` (Integer). How many requests to limit in the time scale provided.
-
- It is also possible to have different limits for unauthenticated and authenticated users: the keyword value must be a
- list of two tuples where the first one is a config for unauthenticated users and the second one is for authenticated.
-
- To disable a limiter set its value to `nil`.
-
- ### Example
-
- config :pleroma, :rate_limit,
- one: {1000, 10},
- two: [{10_000, 10}, {10_000, 50}],
- foobar: nil
-
- Here we have three limiters:
-
- * `one` which is not over 10req/1s
- * `two` which has two limits: 10req/10s for unauthenticated users and 50req/10s for authenticated users
- * `foobar` which is disabled
-
- ## Usage
-
- AllowedSyntax:
-
- plug(Pleroma.Plugs.RateLimiter, name: :limiter_name)
- plug(Pleroma.Plugs.RateLimiter, options) # :name is a required option
-
- Allowed options:
-
- * `name` required, always used to fetch the limit values from the config
- * `bucket_name` overrides name for counting purposes (e.g. to have a separate limit for a set of actions)
- * `params` appends values of specified request params (e.g. ["id"]) to bucket name
-
- Inside a controller:
-
- plug(Pleroma.Plugs.RateLimiter, [name: :one] when action == :one)
- plug(Pleroma.Plugs.RateLimiter, [name: :two] when action in [:two, :three])
-
- plug(
- Pleroma.Plugs.RateLimiter,
- [name: :status_id_action, bucket_name: "status_id_action:fav_unfav", params: ["id"]]
- when action in ~w(fav_status unfav_status)a
- )
-
- or inside a router pipeline:
-
- pipeline :api do
- ...
- plug(Pleroma.Plugs.RateLimiter, name: :one)
- ...
- end
- """
- import Pleroma.Web.TranslationHelpers
- import Plug.Conn
-
- alias Pleroma.Config
- alias Pleroma.Plugs.RateLimiter.LimiterSupervisor
- alias Pleroma.User
-
- require Logger
-
- @doc false
- def init(plug_opts) do
- plug_opts
- end
-
- def call(conn, plug_opts) do
- if disabled?(conn) do
- handle_disabled(conn)
- else
- action_settings = action_settings(plug_opts)
- handle(conn, action_settings)
- end
- end
-
- defp handle_disabled(conn) do
- Logger.warn(
- "Rate limiter disabled due to forwarded IP not being found. Please ensure your reverse proxy is providing the X-Forwarded-For header or disable the RemoteIP plug/rate limiter."
- )
-
- conn
- end
-
- defp handle(conn, nil), do: conn
-
- defp handle(conn, action_settings) do
- action_settings
- |> incorporate_conn_info(conn)
- |> check_rate()
- |> case do
- {:ok, _count} ->
- conn
-
- {:error, _count} ->
- render_throttled_error(conn)
- end
- end
-
- def disabled?(conn) do
- if Map.has_key?(conn.assigns, :remote_ip_found),
- do: !conn.assigns.remote_ip_found,
- else: false
- end
-
- @inspect_bucket_not_found {:error, :not_found}
-
- def inspect_bucket(conn, bucket_name_root, plug_opts) do
- with %{name: _} = action_settings <- action_settings(plug_opts) do
- action_settings = incorporate_conn_info(action_settings, conn)
- bucket_name = make_bucket_name(%{action_settings | name: bucket_name_root})
- key_name = make_key_name(action_settings)
- limit = get_limits(action_settings)
-
- case Cachex.get(bucket_name, key_name) do
- {:error, :no_cache} ->
- @inspect_bucket_not_found
-
- {:ok, nil} ->
- {0, limit}
-
- {:ok, value} ->
- {value, limit - value}
- end
- else
- _ -> @inspect_bucket_not_found
- end
- end
-
- def action_settings(plug_opts) do
- with limiter_name when is_atom(limiter_name) <- plug_opts[:name],
- limits when not is_nil(limits) <- Config.get([:rate_limit, limiter_name]) do
- bucket_name_root = Keyword.get(plug_opts, :bucket_name, limiter_name)
-
- %{
- name: bucket_name_root,
- limits: limits,
- opts: plug_opts
- }
- end
- end
-
- defp check_rate(action_settings) do
- bucket_name = make_bucket_name(action_settings)
- key_name = make_key_name(action_settings)
- limit = get_limits(action_settings)
-
- case Cachex.get_and_update(bucket_name, key_name, &increment_value(&1, limit)) do
- {:commit, value} ->
- {:ok, value}
-
- {:ignore, value} ->
- {:error, value}
-
- {:error, :no_cache} ->
- initialize_buckets!(action_settings)
- check_rate(action_settings)
- end
- end
-
- defp increment_value(nil, _limit), do: {:commit, 1}
-
- defp increment_value(val, limit) when val >= limit, do: {:ignore, val}
-
- defp increment_value(val, _limit), do: {:commit, val + 1}
-
- defp incorporate_conn_info(action_settings, %{
- assigns: %{user: %User{id: user_id}},
- params: params
- }) do
- Map.merge(action_settings, %{
- mode: :user,
- conn_params: params,
- conn_info: "#{user_id}"
- })
- end
-
- defp incorporate_conn_info(action_settings, %{params: params} = conn) do
- Map.merge(action_settings, %{
- mode: :anon,
- conn_params: params,
- conn_info: "#{ip(conn)}"
- })
- end
-
- defp ip(%{remote_ip: remote_ip}) do
- remote_ip
- |> Tuple.to_list()
- |> Enum.join(".")
- end
-
- defp render_throttled_error(conn) do
- conn
- |> render_error(:too_many_requests, "Throttled")
- |> halt()
- end
-
- defp make_key_name(action_settings) do
- ""
- |> attach_selected_params(action_settings)
- |> attach_identity(action_settings)
- end
-
- defp get_scale(_, {scale, _}), do: scale
-
- defp get_scale(:anon, [{scale, _}, {_, _}]), do: scale
-
- defp get_scale(:user, [{_, _}, {scale, _}]), do: scale
-
- defp get_limits(%{limits: {_scale, limit}}), do: limit
-
- defp get_limits(%{mode: :user, limits: [_, {_, limit}]}), do: limit
-
- defp get_limits(%{limits: [{_, limit}, _]}), do: limit
-
- defp make_bucket_name(%{mode: :user, name: bucket_name_root}),
- do: user_bucket_name(bucket_name_root)
-
- defp make_bucket_name(%{mode: :anon, name: bucket_name_root}),
- do: anon_bucket_name(bucket_name_root)
-
- defp attach_selected_params(input, %{conn_params: conn_params, opts: plug_opts}) do
- params_string =
- plug_opts
- |> Keyword.get(:params, [])
- |> Enum.sort()
- |> Enum.map(&Map.get(conn_params, &1, ""))
- |> Enum.join(":")
-
- [input, params_string]
- |> Enum.join(":")
- |> String.replace_leading(":", "")
- end
-
- defp initialize_buckets!(%{name: _name, limits: nil}), do: :ok
-
- defp initialize_buckets!(%{name: name, limits: limits}) do
- {:ok, _pid} =
- LimiterSupervisor.add_or_return_limiter(anon_bucket_name(name), get_scale(:anon, limits))
-
- {:ok, _pid} =
- LimiterSupervisor.add_or_return_limiter(user_bucket_name(name), get_scale(:user, limits))
-
- :ok
- end
-
- defp attach_identity(base, %{mode: :user, conn_info: conn_info}),
- do: "user:#{base}:#{conn_info}"
-
- defp attach_identity(base, %{mode: :anon, conn_info: conn_info}),
- do: "ip:#{base}:#{conn_info}"
-
- defp user_bucket_name(bucket_name_root), do: "user:#{bucket_name_root}" |> String.to_atom()
- defp anon_bucket_name(bucket_name_root), do: "anon:#{bucket_name_root}" |> String.to_atom()
-end
diff --git a/lib/pleroma/plugs/rate_limiter/supervisor.ex b/lib/pleroma/plugs/rate_limiter/supervisor.ex
deleted file mode 100644
index 9672f7876..000000000
--- a/lib/pleroma/plugs/rate_limiter/supervisor.ex
+++ /dev/null
@@ -1,16 +0,0 @@
-defmodule Pleroma.Plugs.RateLimiter.Supervisor do
- use Supervisor
-
- def start_link(opts) do
- Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
- end
-
- def init(_args) do
- children = [
- Pleroma.Plugs.RateLimiter.LimiterSupervisor
- ]
-
- opts = [strategy: :one_for_one, name: Pleroma.Web.Streamer.Supervisor]
- Supervisor.init(children, opts)
- end
-end
diff --git a/lib/pleroma/plugs/remote_ip.ex b/lib/pleroma/plugs/remote_ip.ex
deleted file mode 100644
index 0ac9050d0..000000000
--- a/lib/pleroma/plugs/remote_ip.ex
+++ /dev/null
@@ -1,54 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.RemoteIp do
- @moduledoc """
- This is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
- """
-
- import Plug.Conn
-
- @behaviour Plug
-
- @headers ~w[
- x-forwarded-for
- ]
-
- # https://en.wikipedia.org/wiki/Localhost
- # https://en.wikipedia.org/wiki/Private_network
- @reserved ~w[
- 127.0.0.0/8
- ::1/128
- fc00::/7
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- ]
-
- def init(_), do: nil
-
- def call(%{remote_ip: original_remote_ip} = conn, _) do
- config = Pleroma.Config.get(__MODULE__, [])
-
- if Keyword.get(config, :enabled, false) do
- %{remote_ip: new_remote_ip} = conn = RemoteIp.call(conn, remote_ip_opts(config))
- assign(conn, :remote_ip_found, original_remote_ip != new_remote_ip)
- else
- conn
- end
- end
-
- defp remote_ip_opts(config) do
- headers = config |> Keyword.get(:headers, @headers) |> MapSet.new()
- reserved = Keyword.get(config, :reserved, @reserved)
-
- proxies =
- config
- |> Keyword.get(:proxies, [])
- |> Enum.concat(reserved)
- |> Enum.map(&InetCidr.parse/1)
-
- {headers, proxies}
- end
-end
diff --git a/lib/pleroma/plugs/session_authentication_plug.ex b/lib/pleroma/plugs/session_authentication_plug.ex
deleted file mode 100644
index 0f83a5e53..000000000
--- a/lib/pleroma/plugs/session_authentication_plug.ex
+++ /dev/null
@@ -1,21 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.SessionAuthenticationPlug do
- import Plug.Conn
-
- def init(options) do
- options
- end
-
- def call(conn, _) do
- with saved_user_id <- get_session(conn, :user_id),
- %{auth_user: %{id: ^saved_user_id}} <- conn.assigns do
- conn
- |> assign(:user, conn.assigns.auth_user)
- else
- _ -> conn
- end
- end
-end
diff --git a/lib/pleroma/plugs/set_fo