Merge remote-tracking branch 'origin/develop' into notice-routes
This commit is contained in:
commit
db2bf55e9b
|
@ -28,6 +28,7 @@ erl_crash.dump
|
||||||
# variables.
|
# variables.
|
||||||
/config/*.secret.exs
|
/config/*.secret.exs
|
||||||
/config/generated_config.exs
|
/config/generated_config.exs
|
||||||
|
/config/runtime.exs
|
||||||
/config/*.env
|
/config/*.env
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ stages:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- echo $MIX_ENV
|
||||||
- rm -rf _build/*/lib/pleroma
|
- rm -rf _build/*/lib/pleroma
|
||||||
- apt-get update && apt-get install -y cmake
|
- apt-get update && apt-get install -y cmake
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
|
@ -37,11 +38,20 @@ after_script:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
script:
|
script:
|
||||||
- mix compile --force
|
- mix compile --force
|
||||||
|
|
||||||
spec-build:
|
spec-build:
|
||||||
stage: test
|
stage: test
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "lib/pleroma/web/api_spec/**/*.ex"
|
||||||
|
- "lib/pleroma/web/api_spec.ex"
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- spec.json
|
- spec.json
|
||||||
|
@ -64,6 +74,11 @@ benchmark:
|
||||||
|
|
||||||
unit-testing:
|
unit-testing:
|
||||||
stage: test
|
stage: test
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
retry: 2
|
retry: 2
|
||||||
cache: &testing_cache_policy
|
cache: &testing_cache_policy
|
||||||
<<: *global_cache_policy
|
<<: *global_cache_policy
|
||||||
|
@ -97,6 +112,11 @@ unit-testing:
|
||||||
|
|
||||||
unit-testing-rum:
|
unit-testing-rum:
|
||||||
stage: test
|
stage: test
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
retry: 2
|
retry: 2
|
||||||
cache: *testing_cache_policy
|
cache: *testing_cache_policy
|
||||||
services:
|
services:
|
||||||
|
@ -114,17 +134,42 @@ unit-testing-rum:
|
||||||
- mix test --preload-modules
|
- mix test --preload-modules
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
image: elixir:1.12
|
||||||
stage: test
|
stage: test
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
cache: *testing_cache_policy
|
cache: *testing_cache_policy
|
||||||
script:
|
script:
|
||||||
- mix format --check-formatted
|
- mix format --check-formatted
|
||||||
|
|
||||||
analysis:
|
analysis:
|
||||||
stage: test
|
stage: test
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
cache: *testing_cache_policy
|
cache: *testing_cache_policy
|
||||||
script:
|
script:
|
||||||
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
|
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
|
||||||
|
|
||||||
|
cycles:
|
||||||
|
stage: test
|
||||||
|
image: elixir:1.11
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- "**/*.ex"
|
||||||
|
- "**/*.exs"
|
||||||
|
- "mix.lock"
|
||||||
|
cache: {}
|
||||||
|
script:
|
||||||
|
- mix deps.get
|
||||||
|
- mix compile
|
||||||
|
- mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
|
||||||
|
|
||||||
docs-deploy:
|
docs-deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
cache: *testing_cache_policy
|
cache: *testing_cache_policy
|
||||||
|
@ -199,7 +244,7 @@ stop_review_app:
|
||||||
|
|
||||||
amd64:
|
amd64:
|
||||||
stage: release
|
stage: release
|
||||||
image: elixir:1.10.3
|
image: elixir:1.10.4
|
||||||
only: &release-only
|
only: &release-only
|
||||||
- stable@pleroma/pleroma
|
- stable@pleroma/pleroma
|
||||||
- develop@pleroma/pleroma
|
- develop@pleroma/pleroma
|
||||||
|
@ -237,7 +282,7 @@ amd64-musl:
|
||||||
stage: release
|
stage: release
|
||||||
artifacts: *release-artifacts
|
artifacts: *release-artifacts
|
||||||
only: *release-only
|
only: *release-only
|
||||||
image: elixir:1.10.3-alpine
|
image: elixir:1.10.4-alpine
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: &before-release-musl
|
before_script: &before-release-musl
|
||||||
|
@ -253,7 +298,7 @@ arm:
|
||||||
only: *release-only
|
only: *release-only
|
||||||
tags:
|
tags:
|
||||||
- arm32-specified
|
- arm32-specified
|
||||||
image: arm32v7/elixir:1.10.3
|
image: arm32v7/elixir:1.10.4
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: *before-release
|
before_script: *before-release
|
||||||
|
@ -265,7 +310,7 @@ arm-musl:
|
||||||
only: *release-only
|
only: *release-only
|
||||||
tags:
|
tags:
|
||||||
- arm32-specified
|
- arm32-specified
|
||||||
image: arm32v7/elixir:1.10.3-alpine
|
image: arm32v7/elixir:1.10.4-alpine
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: *before-release-musl
|
before_script: *before-release-musl
|
||||||
|
@ -277,7 +322,7 @@ arm64:
|
||||||
only: *release-only
|
only: *release-only
|
||||||
tags:
|
tags:
|
||||||
- arm
|
- arm
|
||||||
image: arm64v8/elixir:1.10.3
|
image: arm64v8/elixir:1.10.4
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: *before-release
|
before_script: *before-release
|
||||||
|
@ -289,7 +334,7 @@ arm64-musl:
|
||||||
only: *release-only
|
only: *release-only
|
||||||
tags:
|
tags:
|
||||||
- arm
|
- arm
|
||||||
image: arm64v8/elixir:1.10.3-alpine
|
image: arm64v8/elixir:1.10.4-alpine
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: *before-release-musl
|
before_script: *before-release-musl
|
||||||
|
@ -307,8 +352,8 @@ docker:
|
||||||
IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||||
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
|
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
|
||||||
IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
|
IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
|
||||||
DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
|
DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
|
||||||
DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
|
DOCKER_BUILDX_HASH: 980e6b9655f971991fbbb5fd6cd19f1672386195
|
||||||
before_script: &before-docker
|
before_script: &before-docker
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
- docker pull $IMAGE_TAG_SLUG || true
|
- docker pull $IMAGE_TAG_SLUG || true
|
||||||
|
|
75
CHANGELOG.md
75
CHANGELOG.md
|
@ -6,32 +6,90 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- MastoFE
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Allow users to remove their emails if instance does not need email to register
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `activeMonth` and `activeHalfyear` fields in NodeInfo usage.users object
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
|
||||||
|
- Handle Reject for already-accepted Follows properly
|
||||||
|
- Display OpenGraph data on alternative notice routes.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
## 2.4.1 - 2021-08-29
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Make `mix pleroma.database set_text_search_config` run concurrently and indefinitely
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- AdminAPI: Missing configuration description for StealEmojiPolicy
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- MastodonAPI: Stream out Create activities
|
||||||
|
- MRF ObjectAgePolicy: Fix pattern matching on "published"
|
||||||
|
- TwitterAPI: Make `change_password` and `change_email` require params on body instead of query
|
||||||
|
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
|
||||||
|
- AdminAPI: Fix rendering reports containing a `nil` object
|
||||||
|
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
|
||||||
|
- Mastodon API: Fix crash in Streamer related to reblogging
|
||||||
|
- AdminAPI: List available frontends when `static/frontends` folder is missing
|
||||||
|
- Make activity search properly use language-aware GIN indexes
|
||||||
|
- AdminAPI: Fix suggestions for MRF Policies
|
||||||
|
|
||||||
|
## 2.4.0 - 2021-08-08
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- **Breaking:** Configuration: `:chat, enabled` moved to `:shout, enabled` and `:instance, chat_limit` moved to `:shout, limit`
|
||||||
|
- **Breaking** Entries for simple_policy, transparency_exclusions and quarantined_instances now list both the instance and a reason.
|
||||||
|
- Support for Erlang/OTP 24
|
||||||
- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
|
- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
|
||||||
- HTTPSecurityPlug now sends a response header to opt out of Google's FLoC (Federated Learning of Cohorts) targeted advertising.
|
- HTTPSecurityPlug now sends a response header to opt out of Google's FLoC (Federated Learning of Cohorts) targeted advertising.
|
||||||
|
- Email address is now returned if requesting user is the owner of the user account so it can be exposed in client and FE user settings UIs.
|
||||||
|
- Improved Twittercard and OpenGraph meta tag generation including thumbnails and image dimension metadata when available.
|
||||||
|
- AdminAPI: sort users so the newest are at the top.
|
||||||
|
- ActivityPub Client-to-Server(C2S): Limitation on the type of Activity/Object are lifted as they are now passed through ObjectValidators
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- MRF (`FollowBotPolicy`): New MRF Policy which makes a designated local Bot account attempt to follow all users in public Notes received by your instance. Users who require approving follower requests or have #nobot in their profile are excluded.
|
- MRF (`FollowBotPolicy`): New MRF Policy which makes a designated local Bot account attempt to follow all users in public Notes received by your instance. Users who require approving follower requests or have #nobot in their profile are excluded.
|
||||||
- Return OAuth token `id` (primary key) in POST `/oauth/token`.
|
- Return OAuth token `id` (primary key) in POST `/oauth/token`.
|
||||||
|
- AdminAPI: return `created_at` date with users.
|
||||||
|
- AdminAPI: add DELETE `/api/v1/pleroma/admin/instances/:instance` to delete all content from a remote instance.
|
||||||
|
- `AnalyzeMetadata` upload filter for extracting image/video attachment dimensions and generating blurhashes for images. Blurhashes for videos are not generated at this time.
|
||||||
|
- Attachment dimensions and blurhashes are federated when available.
|
||||||
|
- Mastodon API: support `poll` notification.
|
||||||
|
- Pinned posts federation
|
||||||
|
- AdminAPI: allow moderators to manage reports, users, invites, and custom emojis
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Don't crash so hard when email settings are invalid.
|
- Don't crash so hard when email settings are invalid.
|
||||||
- Display OpenGraph data on alternative notice routes.
|
- Checking activated Upload Filters for required commands.
|
||||||
|
- Remote users can no longer reappear after being deleted.
|
||||||
## Unreleased (Patch)
|
- Deactivated users may now be deleted.
|
||||||
|
- Deleting an activity with a lot of likes/boosts no longer causes a database timeout.
|
||||||
### Fixed
|
- Mix task `pleroma.database prune_objects`
|
||||||
|
- Fixed rendering of JSON errors on ActivityPub endpoints.
|
||||||
|
- Linkify: Parsing crash with URLs ending in unbalanced closed paren, no path separator, and no query parameters
|
||||||
- Try to save exported ConfigDB settings (migrate_from_db) in the system temp directory if default location is not writable.
|
- Try to save exported ConfigDB settings (migrate_from_db) in the system temp directory if default location is not writable.
|
||||||
- Uploading custom instance thumbnail via AdminAPI/AdminFE generated invalid URL to the image
|
- Uploading custom instance thumbnail via AdminAPI/AdminFE generated invalid URL to the image
|
||||||
- Applying ConcurrentLimiter settings via AdminAPI
|
- Applying ConcurrentLimiter settings via AdminAPI
|
||||||
- User login failures if their `notification_settings` were in a NULL state.
|
- User login failures if their `notification_settings` were in a NULL state.
|
||||||
- Mix task `pleroma.user delete_activities` query transaction timeout is now :infinity
|
- Mix task `pleroma.user delete_activities` query transaction timeout is now :infinity
|
||||||
|
- MRF (`SimplePolicy`): Embedded objects are now checked. If any embedded object would be rejected, its parent is rejected. This fixes Announces leaking posts from blocked domains.
|
||||||
- Fixed some Markdown issues, including trailing slash in links.
|
- Fixed some Markdown issues, including trailing slash in links.
|
||||||
|
|
||||||
## [2.3.0] - 2020-03-01
|
### Removed
|
||||||
|
- **Breaking**: Remove deprecated `/api/qvitter/statuses/notifications/read` (replaced by `/api/v1/pleroma/notifications/read`)
|
||||||
|
|
||||||
|
## [2.3.0] - 2021-03-01
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
|
@ -81,6 +139,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Support pagination of blocks and mutes.
|
- Support pagination of blocks and mutes.
|
||||||
- Account backup.
|
- Account backup.
|
||||||
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
|
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
|
||||||
|
- `[:activitypub, :blockers_visible]` config to control visibility of blockers.
|
||||||
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
|
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
|
||||||
- The site title is now injected as a `title` tag like preloads or metadata.
|
- The site title is now injected as a `title` tag like preloads or metadata.
|
||||||
- Password reset tokens now are not accepted after a certain age.
|
- Password reset tokens now are not accepted after a certain age.
|
||||||
|
@ -132,7 +191,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Support for expires_in/expires_at in the Filters.
|
- Mastodon API: Support for expires_in/expires_at in the Filters.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## [2.2.2] - 2020-01-18
|
## [2.2.2] - 2021-01-18
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ RUN apk add git gcc g++ musl-dev make cmake file-dev &&\
|
||||||
mkdir release &&\
|
mkdir release &&\
|
||||||
mix release --path release
|
mix release --path release
|
||||||
|
|
||||||
FROM alpine:3.11
|
FROM alpine:3.14
|
||||||
|
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
ARG VCS_REF
|
ARG VCS_REF
|
||||||
|
@ -31,9 +31,8 @@ LABEL maintainer="ops@pleroma.social" \
|
||||||
ARG HOME=/opt/pleroma
|
ARG HOME=/opt/pleroma
|
||||||
ARG DATA=/var/lib/pleroma
|
ARG DATA=/var/lib/pleroma
|
||||||
|
|
||||||
RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories &&\
|
RUN apk update &&\
|
||||||
apk update &&\
|
apk add exiftool ffmpeg imagemagick libmagic ncurses postgresql-client &&\
|
||||||
apk add exiftool imagemagick libmagic ncurses postgresql-client &&\
|
|
||||||
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
|
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
|
||||||
mkdir -p ${DATA}/uploads &&\
|
mkdir -p ${DATA}/uploads &&\
|
||||||
mkdir -p ${DATA}/static &&\
|
mkdir -p ${DATA}/static &&\
|
||||||
|
|
|
@ -30,11 +30,14 @@ If your platform is not supported, or you just want to be able to edit the sourc
|
||||||
- [OpenBSD (fi)](https://docs-develop.pleroma.social/backend/installation/openbsd_fi/)
|
- [OpenBSD (fi)](https://docs-develop.pleroma.social/backend/installation/openbsd_fi/)
|
||||||
|
|
||||||
### OS/Distro packages
|
### 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**.
|
Currently Pleroma is packaged for [YunoHost](https://yunohost.org). If you want to package Pleroma for any OS/Distros, 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**.
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
While we don’t provide docker files, other people have written very good ones. Take a look at <https://github.com/angristan/docker-pleroma> or <https://glitch.sh/sn0w/pleroma-docker>.
|
While we don’t provide docker files, other people have written very good ones. Take a look at <https://github.com/angristan/docker-pleroma> or <https://glitch.sh/sn0w/pleroma-docker>.
|
||||||
|
|
||||||
|
### Raspberry Pi
|
||||||
|
Community maintained Raspberry Pi image that you can flash and run Pleroma on your Raspberry Pi. Available here <https://github.com/guysoft/PleromaPi>.
|
||||||
|
|
||||||
### Compilation Troubleshooting
|
### Compilation Troubleshooting
|
||||||
If you ever encounter compilation issues during the updating of Pleroma, you can try these commands and see if they fix things:
|
If you ever encounter compilation issues during the updating of Pleroma, you can try these commands and see if they fix things:
|
||||||
|
|
||||||
|
@ -50,5 +53,5 @@ If you are not developing Pleroma, it is better to use the OTP release, which co
|
||||||
- Latest Git revision: <https://docs-develop.pleroma.social>
|
- Latest Git revision: <https://docs-develop.pleroma.social>
|
||||||
|
|
||||||
## Community Channels
|
## Community Channels
|
||||||
* IRC: **#pleroma** and **#pleroma-dev** on freenode, webchat is available at <https://irc.pleroma.social>
|
* IRC: **#pleroma** and **#pleroma-dev** on libera.chat, webchat is available at <https://irc.pleroma.social>
|
||||||
* Matrix: <https://matrix.to/#/#freenode_#pleroma:matrix.org> and <https://matrix.to/#/#freenode_#pleroma-dev:matrix.org>
|
* Matrix: [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) and [#pleroma-dev:libera.chat](https://matrix.to/#/#pleroma-dev:libera.chat)
|
||||||
|
|
|
@ -299,7 +299,7 @@ defp insert_activity(:attachment, visibility, group, users, _opts) do
|
||||||
"url" => [
|
"url" => [
|
||||||
%{
|
%{
|
||||||
"href" =>
|
"href" =>
|
||||||
"#{Pleroma.Web.base_url()}/media/b1b873552422a07bf53af01f3c231c841db4dfc42c35efde681abaf0f2a4eab7.jpg",
|
"#{Pleroma.Web.Endpoint.url()}/media/b1b873552422a07bf53af01f3c231c841db4dfc42c35efde681abaf0f2a4eab7.jpg",
|
||||||
"mediaType" => "image/jpeg",
|
"mediaType" => "image/jpeg",
|
||||||
"type" => "Link"
|
"type" => "Link"
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ defp get_actor(group, users), do: Enum.random(users[group])
|
||||||
|
|
||||||
defp other_data(actor, content) do
|
defp other_data(actor, content) do
|
||||||
%{host: host} = URI.parse(actor.ap_id)
|
%{host: host} = URI.parse(actor.ap_id)
|
||||||
datetime = DateTime.utc_now()
|
datetime = DateTime.utc_now() |> to_string()
|
||||||
context_id = "https://#{host}/contexts/#{UUID.generate()}"
|
context_id = "https://#{host}/contexts/#{UUID.generate()}"
|
||||||
activity_id = "https://#{host}/activities/#{UUID.generate()}"
|
activity_id = "https://#{host}/activities/#{UUID.generate()}"
|
||||||
object_id = "https://#{host}/objects/#{UUID.generate()}"
|
object_id = "https://#{host}/objects/#{UUID.generate()}"
|
||||||
|
|
|
@ -99,15 +99,16 @@ defp hashtag_fetching(params, user, local_only) do
|
||||||
|> Enum.map(&String.downcase(&1))
|
|> Enum.map(&String.downcase(&1))
|
||||||
|
|
||||||
_activities =
|
_activities =
|
||||||
params
|
%{
|
||||||
|> Map.put(:type, "Create")
|
type: "Create",
|
||||||
|> Map.put(:local_only, local_only)
|
local_only: local_only,
|
||||||
|> Map.put(:blocking_user, user)
|
blocking_user: user,
|
||||||
|> Map.put(:muting_user, user)
|
muting_user: user,
|
||||||
|> Map.put(:user, user)
|
user: user,
|
||||||
|> Map.put(:tag, tags)
|
tag: tags,
|
||||||
|> Map.put(:tag_all, tag_all)
|
tag_all: tag_all,
|
||||||
|> Map.put(:tag_reject, tag_reject)
|
tag_reject: tag_reject,
|
||||||
|
}
|
||||||
|> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
|
|> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,14 +17,14 @@ def run(_args) do
|
||||||
# Let the user make 100 posts
|
# Let the user make 100 posts
|
||||||
|
|
||||||
1..100
|
1..100
|
||||||
|> Enum.each(fn i -> CommonAPI.post(user, %{"status" => to_string(i)}) end)
|
|> Enum.each(fn i -> CommonAPI.post(user, %{status: to_string(i)}) end)
|
||||||
|
|
||||||
# Let 10 random users post
|
# Let 10 random users post
|
||||||
posts =
|
posts =
|
||||||
users
|
users
|
||||||
|> Enum.take_random(10)
|
|> Enum.take_random(10)
|
||||||
|> Enum.map(fn {:ok, random_user} ->
|
|> Enum.map(fn {:ok, random_user} ->
|
||||||
{:ok, activity} = CommonAPI.post(random_user, %{"status" => "."})
|
{:ok, activity} = CommonAPI.post(random_user, %{status: "."})
|
||||||
activity
|
activity
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def run(_args) do
|
||||||
|> Conn.assign(:user, reading_user)
|
|> Conn.assign(:user, reading_user)
|
||||||
|> Conn.assign(:skip_link_headers, true)
|
|> Conn.assign(:skip_link_headers, true)
|
||||||
|
|
||||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{"id" => user.id})
|
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{id: user.id})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
inputs: %{"user" => user, "no user" => nil},
|
inputs: %{"user" => user, "no user" => nil},
|
||||||
|
@ -50,7 +50,7 @@ def run(_args) do
|
||||||
)
|
)
|
||||||
|
|
||||||
users
|
users
|
||||||
|> Enum.each(fn {:ok, follower, user} -> Pleroma.User.follow(follower, user) end)
|
|> Enum.each(fn {:ok, follower} -> Pleroma.User.follow(follower, user) end)
|
||||||
|
|
||||||
Benchee.run(
|
Benchee.run(
|
||||||
%{
|
%{
|
||||||
|
@ -60,7 +60,7 @@ def run(_args) do
|
||||||
|> Conn.assign(:user, reading_user)
|
|> Conn.assign(:user, reading_user)
|
||||||
|> Conn.assign(:skip_link_headers, true)
|
|> Conn.assign(:skip_link_headers, true)
|
||||||
|
|
||||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{"id" => user.id})
|
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{id: user.id})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
inputs: %{"user" => user, "no user" => nil},
|
inputs: %{"user" => user, "no user" => nil},
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
# We don't run a server during test. If one is required,
|
# We don't run a server during test. If one is required,
|
||||||
# you can enable the server option below.
|
# you can enable the server option below.
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
http: [port: 4001],
|
http: [port: 4001],
|
||||||
url: [port: 4001],
|
url: [port: 4001]
|
||||||
server: true
|
|
||||||
|
|
||||||
# Disable captha for tests
|
# Disable captha for tests
|
||||||
config :pleroma, Pleroma.Captcha,
|
config :pleroma, Pleroma.Captcha,
|
||||||
|
@ -44,7 +43,7 @@
|
||||||
pool_size: 10
|
pool_size: 10
|
||||||
|
|
||||||
# Reduce hash rounds for testing
|
# Reduce hash rounds for testing
|
||||||
config :pbkdf2_elixir, rounds: 1
|
config :pleroma, :password, iterations: 1
|
||||||
|
|
||||||
config :tesla, adapter: Tesla.Mock
|
config :tesla, adapter: Tesla.Mock
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#
|
#
|
||||||
# This configuration file is loaded before any dependency and
|
# This configuration file is loaded before any dependency and
|
||||||
# is restricted to this project.
|
# is restricted to this project.
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
# General application configuration
|
# General application configuration
|
||||||
config :pleroma, ecto_repos: [Pleroma.Repo]
|
config :pleroma, ecto_repos: [Pleroma.Repo]
|
||||||
|
@ -139,6 +139,7 @@
|
||||||
],
|
],
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
||||||
|
live_view: [signing_salt: "U5ELgdEwTD3n1+D5s0rY0AMg8/y1STxZ3Zvsl3bWh+oBcGrYdil0rXqPMRd3Glcq"],
|
||||||
signing_salt: "CqaoopA2",
|
signing_salt: "CqaoopA2",
|
||||||
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
||||||
pubsub_server: Pleroma.PubSub,
|
pubsub_server: Pleroma.PubSub,
|
||||||
|
@ -190,7 +191,6 @@
|
||||||
instance_thumbnail: "/instance/thumbnail.jpeg",
|
instance_thumbnail: "/instance/thumbnail.jpeg",
|
||||||
limit: 5_000,
|
limit: 5_000,
|
||||||
description_limit: 5_000,
|
description_limit: 5_000,
|
||||||
chat_limit: 5_000,
|
|
||||||
remote_limit: 100_000,
|
remote_limit: 100_000,
|
||||||
upload_limit: 16_000_000,
|
upload_limit: 16_000_000,
|
||||||
avatar_upload_limit: 2_000_000,
|
avatar_upload_limit: 2_000_000,
|
||||||
|
@ -322,9 +322,6 @@
|
||||||
subjectLineBehavior: "email",
|
subjectLineBehavior: "email",
|
||||||
theme: "pleroma-dark",
|
theme: "pleroma-dark",
|
||||||
webPushNotifications: false
|
webPushNotifications: false
|
||||||
},
|
|
||||||
masto_fe: %{
|
|
||||||
showInstanceSpecificPanel: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config :pleroma, :assets,
|
config :pleroma, :assets,
|
||||||
|
@ -353,6 +350,7 @@
|
||||||
config :pleroma, :activitypub,
|
config :pleroma, :activitypub,
|
||||||
unfollow_blocked: true,
|
unfollow_blocked: true,
|
||||||
outgoing_blocks: true,
|
outgoing_blocks: true,
|
||||||
|
blockers_visible: true,
|
||||||
follow_handshake_timeout: 500,
|
follow_handshake_timeout: 500,
|
||||||
note_replies_output_limit: 5,
|
note_replies_output_limit: 5,
|
||||||
sign_object_fetches: true,
|
sign_object_fetches: true,
|
||||||
|
@ -457,9 +455,11 @@
|
||||||
image_quality: 85,
|
image_quality: 85,
|
||||||
min_content_length: 100 * 1024
|
min_content_length: 100 * 1024
|
||||||
|
|
||||||
config :pleroma, :chat, enabled: true
|
config :pleroma, :shout,
|
||||||
|
enabled: true,
|
||||||
|
limit: 5_000
|
||||||
|
|
||||||
config :phoenix, :format_encoders, json: Jason
|
config :phoenix, :format_encoders, json: Jason, "activity+json": Jason
|
||||||
|
|
||||||
config :phoenix, :json_library, Jason
|
config :phoenix, :json_library, Jason
|
||||||
|
|
||||||
|
@ -559,6 +559,7 @@
|
||||||
mailer: 10,
|
mailer: 10,
|
||||||
transmogrifier: 20,
|
transmogrifier: 20,
|
||||||
scheduled_activities: 10,
|
scheduled_activities: 10,
|
||||||
|
poll_notifications: 10,
|
||||||
background: 5,
|
background: 5,
|
||||||
remote_fetcher: 2,
|
remote_fetcher: 2,
|
||||||
attachments_cleanup: 1,
|
attachments_cleanup: 1,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
websocket_config = [
|
websocket_config = [
|
||||||
path: "/websocket",
|
path: "/websocket",
|
||||||
|
@ -544,14 +544,6 @@
|
||||||
5_000
|
5_000
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
|
||||||
key: :chat_limit,
|
|
||||||
type: :integer,
|
|
||||||
description: "Character limit of the instance chat messages",
|
|
||||||
suggestions: [
|
|
||||||
5_000
|
|
||||||
]
|
|
||||||
},
|
|
||||||
%{
|
%{
|
||||||
key: :remote_limit,
|
key: :remote_limit,
|
||||||
type: :integer,
|
type: :integer,
|
||||||
|
@ -682,7 +674,8 @@
|
||||||
%{
|
%{
|
||||||
key: :allow_relay,
|
key: :allow_relay,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Enable Pleroma's Relay, which makes it possible to follow a whole instance"
|
description:
|
||||||
|
"Permits remote instances to subscribe to all public posts of your instance. (Important!) This may increase the visibility of your instance."
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :public,
|
key: :public,
|
||||||
|
@ -694,12 +687,14 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :quarantined_instances,
|
key: :quarantined_instances,
|
||||||
type: {:list, :string},
|
type: {:list, :tuple},
|
||||||
|
key_placeholder: "instance",
|
||||||
|
value_placeholder: "reason",
|
||||||
description:
|
description:
|
||||||
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent",
|
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"quarantined.com",
|
{"quarantined.com", "Reason"},
|
||||||
"*.quarantined.com"
|
{"*.quarantined.com", "Reason"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
|
@ -1169,7 +1164,7 @@
|
||||||
type: :group,
|
type: :group,
|
||||||
description:
|
description:
|
||||||
"This form can be used to configure a keyword list that keeps the configuration data for any " <>
|
"This form can be used to configure a keyword list that keeps the configuration data for any " <>
|
||||||
"kind of frontend. By default, settings for pleroma_fe and masto_fe are configured. If you want to " <>
|
"kind of frontend. By default, settings for pleroma_fe are configured. If you want to " <>
|
||||||
"add your own configuration your settings all fields must be complete.",
|
"add your own configuration your settings all fields must be complete.",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
|
@ -1182,7 +1177,6 @@
|
||||||
alwaysShowSubjectInput: true,
|
alwaysShowSubjectInput: true,
|
||||||
background: "/static/aurora_borealis.jpg",
|
background: "/static/aurora_borealis.jpg",
|
||||||
collapseMessageWithSubject: false,
|
collapseMessageWithSubject: false,
|
||||||
disableChat: false,
|
|
||||||
greentext: false,
|
greentext: false,
|
||||||
hideFilteredStatuses: false,
|
hideFilteredStatuses: false,
|
||||||
hideMutedPosts: false,
|
hideMutedPosts: false,
|
||||||
|
@ -1229,12 +1223,6 @@
|
||||||
description:
|
description:
|
||||||
"When a message has a subject (aka Content Warning), collapse it by default"
|
"When a message has a subject (aka Content Warning), collapse it by default"
|
||||||
},
|
},
|
||||||
%{
|
|
||||||
key: :disableChat,
|
|
||||||
label: "PleromaFE Chat",
|
|
||||||
type: :boolean,
|
|
||||||
description: "Disables PleromaFE Chat component"
|
|
||||||
},
|
|
||||||
%{
|
%{
|
||||||
key: :greentext,
|
key: :greentext,
|
||||||
label: "Greentext",
|
label: "Greentext",
|
||||||
|
@ -1376,25 +1364,6 @@
|
||||||
suggestions: ["pleroma-dark"]
|
suggestions: ["pleroma-dark"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
%{
|
|
||||||
key: :masto_fe,
|
|
||||||
label: "Masto FE",
|
|
||||||
type: :map,
|
|
||||||
description: "Settings for Masto FE",
|
|
||||||
suggestions: [
|
|
||||||
%{
|
|
||||||
showInstanceSpecificPanel: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
children: [
|
|
||||||
%{
|
|
||||||
key: :showInstanceSpecificPanel,
|
|
||||||
label: "Show instance specific panel",
|
|
||||||
type: :boolean,
|
|
||||||
description: "Whenether to show the instance's specific panel"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1701,6 +1670,11 @@
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Whether to federate blocks to other instances"
|
description: "Whether to federate blocks to other instances"
|
||||||
},
|
},
|
||||||
|
%{
|
||||||
|
key: :blockers_visible,
|
||||||
|
type: :boolean,
|
||||||
|
description: "Whether a user can see someone who has blocked them"
|
||||||
|
},
|
||||||
%{
|
%{
|
||||||
key: :sign_object_fetches,
|
key: :sign_object_fetches,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
|
@ -2652,13 +2626,22 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :chat,
|
key: :shout,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Pleroma chat settings",
|
description: "Pleroma shout settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean
|
type: :boolean,
|
||||||
|
description: "Enables the backend Shoutbox chat feature."
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :limit,
|
||||||
|
type: :integer,
|
||||||
|
description: "Shout message character limit.",
|
||||||
|
suggestions: [
|
||||||
|
5_000
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
# For development, we disable any cache and enable
|
# For development, we disable any cache and enable
|
||||||
# debugging and code reloading.
|
# debugging and code reloading.
|
||||||
|
@ -54,10 +54,15 @@
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
|
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
|
||||||
|
|
||||||
|
# Reduce recompilation time
|
||||||
|
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
||||||
|
config :phoenix, :plug_init_mode, :runtime
|
||||||
|
|
||||||
if File.exists?("./config/dev.secret.exs") do
|
if File.exists?("./config/dev.secret.exs") do
|
||||||
import_config "dev.secret.exs"
|
import_config "dev.secret.exs"
|
||||||
else
|
else
|
||||||
IO.puts(
|
IO.puts(
|
||||||
|
:stderr,
|
||||||
"!!! RUNNING IN LOCALHOST DEV MODE! !!!\nFEDERATION WON'T WORK UNTIL YOU CONFIGURE A dev.secret.exs"
|
"!!! RUNNING IN LOCALHOST DEV MODE! !!!\nFEDERATION WON'T WORK UNTIL YOU CONFIGURE A dev.secret.exs"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
http: [
|
http: [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
# For production, we often load configuration from external
|
# For production, we often load configuration from external
|
||||||
# sources, such as your system environment. For this reason,
|
# sources, such as your system environment. For this reason,
|
||||||
|
@ -63,7 +63,12 @@
|
||||||
|
|
||||||
# Finally import the config/prod.secret.exs
|
# Finally import the config/prod.secret.exs
|
||||||
# which should be versioned separately.
|
# which should be versioned separately.
|
||||||
|
if File.exists?("./config/prod.secret.exs") do
|
||||||
import_config "prod.secret.exs"
|
import_config "prod.secret.exs"
|
||||||
|
else
|
||||||
|
"`config/prod.secret.exs` not found. You may want to create one by running `mix pleroma.instance gen`"
|
||||||
|
|> IO.warn([])
|
||||||
|
end
|
||||||
|
|
||||||
if File.exists?("./config/prod.exported_from_db.secret.exs"),
|
if File.exists?("./config/prod.exported_from_db.secret.exs"),
|
||||||
do: import_config("prod.exported_from_db.secret.exs")
|
do: import_config("prod.exported_from_db.secret.exs")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use Mix.Config
|
import Config
|
||||||
|
|
||||||
# We don't run a server during test. If one is required,
|
# We don't run a server during test. If one is required,
|
||||||
# you can enable the server option below.
|
# you can enable the server option below.
|
||||||
|
@ -133,6 +133,10 @@
|
||||||
ap_streamer: Pleroma.Web.ActivityPub.ActivityPubMock,
|
ap_streamer: Pleroma.Web.ActivityPub.ActivityPubMock,
|
||||||
logger: Pleroma.LoggerMock
|
logger: Pleroma.LoggerMock
|
||||||
|
|
||||||
|
# Reduce recompilation time
|
||||||
|
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
||||||
|
config :phoenix, :plug_init_mode, :runtime
|
||||||
|
|
||||||
if File.exists?("./config/test.secret.exs") do
|
if File.exists?("./config/test.secret.exs") do
|
||||||
import_config "test.secret.exs"
|
import_config "test.secret.exs"
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,9 +8,10 @@ For from source installations Pleroma configuration works by first importing the
|
||||||
|
|
||||||
To add configuration to your config file, you can copy it from the base config. The latest version of it can be viewed [here](https://git.pleroma.social/pleroma/pleroma/blob/develop/config/config.exs). You can also use this file if you don't know how an option is supposed to be formatted.
|
To add configuration to your config file, you can copy it from the base config. The latest version of it can be viewed [here](https://git.pleroma.social/pleroma/pleroma/blob/develop/config/config.exs). You can also use this file if you don't know how an option is supposed to be formatted.
|
||||||
|
|
||||||
## :chat
|
## :shout
|
||||||
|
|
||||||
* `enabled` - Enables the backend chat. Defaults to `true`.
|
* `enabled` - Enables the backend Shoutbox chat feature. Defaults to `true`.
|
||||||
|
* `limit` - Shout character limit. Defaults to `5_000`
|
||||||
|
|
||||||
## :instance
|
## :instance
|
||||||
* `name`: The instance’s name.
|
* `name`: The instance’s name.
|
||||||
|
@ -19,7 +20,6 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``.
|
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``.
|
||||||
* `limit`: Posts character limit (CW/Subject included in the counter).
|
* `limit`: Posts character limit (CW/Subject included in the counter).
|
||||||
* `description_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.
|
* `remote_limit`: Hard character limit beyond which remote posts will be dropped.
|
||||||
* `upload_limit`: File size limit of uploads (except for avatar, background, banner).
|
* `upload_limit`: File size limit of uploads (except for avatar, background, banner).
|
||||||
* `avatar_upload_limit`: File size limit of user’s profile avatars.
|
* `avatar_upload_limit`: File size limit of user’s profile avatars.
|
||||||
|
@ -37,9 +37,9 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `federating`: Enable federation with other instances.
|
* `federating`: Enable federation with other instances.
|
||||||
* `federation_incoming_replies_max_depth`: Max. depth of reply-to activities fetching on incoming federation, to prevent out-of-memory situations while fetching very long threads. If set to `nil`, threads of any depth will be fetched. Lower this value if you experience out-of-memory crashes.
|
* `federation_incoming_replies_max_depth`: Max. depth of reply-to activities fetching on incoming federation, to prevent out-of-memory situations while fetching very long threads. If set to `nil`, threads of any depth will be fetched. Lower this value if you experience out-of-memory crashes.
|
||||||
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
||||||
* `allow_relay`: Enable Pleroma’s Relay, which makes it possible to follow a whole instance.
|
* `allow_relay`: Permits remote instances to subscribe to all public posts of your instance. This may increase the visibility of your 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.
|
* `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.
|
* `quarantined_instances`: ActivityPub instances where private (DMs, followers-only) activities will not be send.
|
||||||
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
* `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
|
* `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.
|
older software for theses nicknames.
|
||||||
|
@ -135,15 +135,16 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
Configuring MRF policies is not enough for them to take effect. You have to enable them by specifying their module in `policies` under [:mrf](#mrf) section.
|
Configuring MRF policies is not enough for them to take effect. You have to enable them by specifying their module in `policies` under [:mrf](#mrf) section.
|
||||||
|
|
||||||
#### :mrf_simple
|
#### :mrf_simple
|
||||||
* `media_removal`: List of instances to remove media from.
|
* `media_removal`: List of instances to strip media attachments from and the reason for doing so.
|
||||||
* `media_nsfw`: List of instances to put media as NSFW(sensitive) from.
|
* `media_nsfw`: List of instances to tag all media as NSFW (sensitive) from and the reason for doing so.
|
||||||
* `federated_timeline_removal`: List of instances to remove from Federated (aka The Whole Known Network) Timeline.
|
* `federated_timeline_removal`: List of instances to remove from the Federated Timeline (aka The Whole Known Network) and the reason for doing so.
|
||||||
* `reject`: List of instances to reject any activities from.
|
* `reject`: List of instances to reject activities (except deletes) from and the reason for doing so.
|
||||||
* `accept`: List of instances to accept any activities from.
|
* `accept`: List of instances to only accept activities (except deletes) from and the reason for doing so.
|
||||||
* `followers_only`: List of instances to decrease post visibility to only the followers, including for DM mentions.
|
* `followers_only`: Force posts from the given instances to be visible by followers only and the reason for doing so.
|
||||||
* `report_removal`: List of instances to reject reports from.
|
* `report_removal`: List of instances to reject reports from and the reason for doing so.
|
||||||
* `avatar_removal`: List of instances to strip avatars from.
|
* `avatar_removal`: List of instances to strip avatars from and the reason for doing so.
|
||||||
* `banner_removal`: List of instances to strip banners from.
|
* `banner_removal`: List of instances to strip banners from and the reason for doing so.
|
||||||
|
* `reject_deletes`: List of instances to reject deletions from and the reason for doing so.
|
||||||
|
|
||||||
#### :mrf_subchain
|
#### :mrf_subchain
|
||||||
This policy processes messages through an alternate pipeline when a given message matches certain criteria.
|
This policy processes messages through an alternate pipeline when a given message matches certain criteria.
|
||||||
|
@ -229,6 +230,7 @@ Notes:
|
||||||
### :activitypub
|
### :activitypub
|
||||||
* `unfollow_blocked`: Whether blocks result in people getting unfollowed
|
* `unfollow_blocked`: Whether blocks result in people getting unfollowed
|
||||||
* `outgoing_blocks`: Whether to federate blocks to other instances
|
* `outgoing_blocks`: Whether to federate blocks to other instances
|
||||||
|
* `blockers_visible`: Whether a user can see the posts of users who blocked them
|
||||||
* `deny_follow_blocked`: Whether to disallow following an account that has blocked the user in question
|
* `deny_follow_blocked`: Whether to disallow following an account that has blocked the user in question
|
||||||
* `sign_object_fetches`: Sign object fetches with HTTP signatures
|
* `sign_object_fetches`: Sign object fetches with HTTP signatures
|
||||||
* `authorized_fetch_mode`: Require HTTP signatures for AP fetches
|
* `authorized_fetch_mode`: Require HTTP signatures for AP fetches
|
||||||
|
@ -246,7 +248,7 @@ Notes:
|
||||||
|
|
||||||
### :frontend_configurations
|
### :frontend_configurations
|
||||||
|
|
||||||
This can be used to configure a keyword list that keeps the configuration data for any kind of frontend. By default, settings for `pleroma_fe` and `masto_fe` are configured. You can find the documentation for `pleroma_fe` configuration into [Pleroma-FE configuration and customization for instance administrators](/frontend/CONFIGURATION/#options).
|
This can be used to configure a keyword list that keeps the configuration data for any kind of frontend. By default, settings for `pleroma_fe` are configured. You can find the documentation for `pleroma_fe` configuration into [Pleroma-FE configuration and customization for instance administrators](/frontend/CONFIGURATION/#options).
|
||||||
|
|
||||||
Frontends can access these settings at `/api/v1/pleroma/frontend_configurations`
|
Frontends can access these settings at `/api/v1/pleroma/frontend_configurations`
|
||||||
|
|
||||||
|
@ -257,9 +259,6 @@ config :pleroma, :frontend_configurations,
|
||||||
pleroma_fe: %{
|
pleroma_fe: %{
|
||||||
theme: "pleroma-dark",
|
theme: "pleroma-dark",
|
||||||
# ... see /priv/static/static/config.json for the available keys.
|
# ... see /priv/static/static/config.json for the available keys.
|
||||||
},
|
|
||||||
masto_fe: %{
|
|
||||||
showInstanceSpecificPanel: true
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Pleroma's full text search feature is powered by PostgreSQL's native [text searc
|
||||||
|
|
||||||
## Setup and test the new search config
|
## Setup and test the new search config
|
||||||
|
|
||||||
In most cases, you would need an extension installed to support parsing CJK text. Here are a few extension you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
|
In most cases, you would need an extension installed to support parsing CJK text. Here are a few extensions you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
|
||||||
|
|
||||||
* [a generic n-gram parser](https://github.com/huangjimmy/pg_cjk_parser) supports Simplifed/Traditional Chinese, Japanese, and Korean
|
* [a generic n-gram parser](https://github.com/huangjimmy/pg_cjk_parser) supports Simplifed/Traditional Chinese, Japanese, and Korean
|
||||||
* [a Korean parser](https://github.com/i0seph/textsearch_ko) based on mecab
|
* [a Korean parser](https://github.com/i0seph/textsearch_ko) based on mecab
|
||||||
|
@ -34,7 +34,7 @@ Check output of the query, and see if it matches your expectation.
|
||||||
mix pleroma.database set_text_search_config YOUR.CONFIG
|
mix pleroma.database set_text_search_config YOUR.CONFIG
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: index update may take a while.
|
Note: index update may take a while, and it can be done while the instance is up and running, so you may restart db connection as soon as you see `Recreate index` in task output.
|
||||||
|
|
||||||
## Restart database connection
|
## Restart database connection
|
||||||
Since some changes above will only apply with a new database connection, you will have to restart either Pleroma or PostgreSQL process, or use `pg_terminate_backend` SQL command without restarting either.
|
Since some changes above will only apply with a new database connection, you will have to restart either Pleroma or PostgreSQL process, or use `pg_terminate_backend` SQL command without restarting either.
|
||||||
|
|
|
@ -55,18 +55,18 @@ Servers should be configured as lists.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
This example will enable `SimplePolicy`, block media from `illegalporn.biz`, mark media as NSFW from `porn.biz` and `porn.business`, reject messages from `spam.com`, remove messages from `spam.university` from the federated timeline and block reports (flags) from `whiny.whiner`:
|
This example will enable `SimplePolicy`, block media from `illegalporn.biz`, mark media as NSFW from `porn.biz` and `porn.business`, reject messages from `spam.com`, remove messages from `spam.university` from the federated timeline and block reports (flags) from `whiny.whiner`. We also give a reason why the moderation was done:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
config :pleroma, :mrf,
|
config :pleroma, :mrf,
|
||||||
policies: [Pleroma.Web.ActivityPub.MRF.SimplePolicy]
|
policies: [Pleroma.Web.ActivityPub.MRF.SimplePolicy]
|
||||||
|
|
||||||
config :pleroma, :mrf_simple,
|
config :pleroma, :mrf_simple,
|
||||||
media_removal: ["illegalporn.biz"],
|
media_removal: [{"illegalporn.biz", "Media can contain illegal contant"}],
|
||||||
media_nsfw: ["porn.biz", "porn.business"],
|
media_nsfw: [{"porn.biz", "unmarked nsfw media"}, {"porn.business", "A lot of unmarked nsfw media"}],
|
||||||
reject: ["spam.com"],
|
reject: [{"spam.com", "They keep spamming our users"}],
|
||||||
federated_timeline_removal: ["spam.university"],
|
federated_timeline_removal: [{"spam.university", "Annoying low-quality posts who otherwise fill up TWKN"}],
|
||||||
report_removal: ["whiny.whiner"]
|
report_removal: [{"whiny.whiner", "Keep spamming us with irrelevant reports"}]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use with Care
|
### Use with Care
|
||||||
|
@ -82,7 +82,7 @@ For example, here is a sample policy module which rewrites all messages to "new
|
||||||
```elixir
|
```elixir
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.RewritePolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.RewritePolicy do
|
||||||
@moduledoc "MRF policy which rewrites all Notes to have 'new message content'."
|
@moduledoc "MRF policy which rewrites all Notes to have 'new message content'."
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
# Catch messages which contain Note objects with actual data to filter.
|
# Catch messages which contain Note objects with actual data to filter.
|
||||||
# Capture the object as `object`, the message content as `content` and the
|
# Capture the object as `object`, the message content as `content` and the
|
||||||
|
|
|
@ -261,6 +261,46 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `PATCH /api/v1/pleroma/admin/users/suggest`
|
||||||
|
|
||||||
|
### Suggest a user
|
||||||
|
|
||||||
|
Adds the user(s) to follower recommendations.
|
||||||
|
|
||||||
|
- Params:
|
||||||
|
- `nicknames`: nicknames array
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
users: [
|
||||||
|
{
|
||||||
|
// user object
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `PATCH /api/v1/pleroma/admin/users/unsuggest`
|
||||||
|
|
||||||
|
### Unsuggest a user
|
||||||
|
|
||||||
|
Removes the user(s) from follower recommendations.
|
||||||
|
|
||||||
|
- Params:
|
||||||
|
- `nicknames`: nicknames array
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
users: [
|
||||||
|
{
|
||||||
|
// user object
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## `GET /api/v1/pleroma/admin/users/:nickname_or_id`
|
## `GET /api/v1/pleroma/admin/users/:nickname_or_id`
|
||||||
|
|
||||||
### Retrive the details of a user
|
### Retrive the details of a user
|
||||||
|
@ -319,6 +359,22 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `DELETE /api/v1/pleroma/admin/instances/:instance`
|
||||||
|
|
||||||
|
### Delete all users and activities from a remote instance
|
||||||
|
|
||||||
|
Note: this will trigger a job to remove instance content in the background.
|
||||||
|
It may take some time.
|
||||||
|
|
||||||
|
- Params:
|
||||||
|
- `instance`: remote instance host
|
||||||
|
- Response:
|
||||||
|
- The `instance` name as a string
|
||||||
|
|
||||||
|
```json
|
||||||
|
"lain.com"
|
||||||
|
```
|
||||||
|
|
||||||
## `GET /api/v1/pleroma/admin/statuses`
|
## `GET /api/v1/pleroma/admin/statuses`
|
||||||
|
|
||||||
### Retrives all latest statuses
|
### Retrives all latest statuses
|
||||||
|
|
|
@ -0,0 +1,347 @@
|
||||||
|
# Nodeinfo
|
||||||
|
|
||||||
|
See also [the Nodeinfo standard](https://nodeinfo.diaspora.software/).
|
||||||
|
|
||||||
|
## `/.well-known/nodeinfo`
|
||||||
|
### The well-known path
|
||||||
|
* Method: `GET`
|
||||||
|
* Authentication: not required
|
||||||
|
* Params: none
|
||||||
|
* Response: JSON
|
||||||
|
* Example response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"links":[
|
||||||
|
{
|
||||||
|
"href":"https://example.com/nodeinfo/2.0.json",
|
||||||
|
"rel":"http://nodeinfo.diaspora.software/ns/schema/2.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href":"https://example.com/nodeinfo/2.1.json",
|
||||||
|
"rel":"http://nodeinfo.diaspora.software/ns/schema/2.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `/nodeinfo/2.0.json`
|
||||||
|
### Nodeinfo 2.0
|
||||||
|
* Method: `GET`
|
||||||
|
* Authentication: not required
|
||||||
|
* Params: none
|
||||||
|
* Response: JSON
|
||||||
|
* Example response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"metadata":{
|
||||||
|
"accountActivationRequired":false,
|
||||||
|
"features":[
|
||||||
|
"pleroma_api",
|
||||||
|
"mastodon_api",
|
||||||
|
"mastodon_api_streaming",
|
||||||
|
"polls",
|
||||||
|
"pleroma_explicit_addressing",
|
||||||
|
"shareable_emoji_packs",
|
||||||
|
"multifetch",
|
||||||
|
"pleroma:api/v1/notifications:include_types_filter",
|
||||||
|
"chat",
|
||||||
|
"shout",
|
||||||
|
"relay",
|
||||||
|
"pleroma_emoji_reactions",
|
||||||
|
"pleroma_chat_messages"
|
||||||
|
],
|
||||||
|
"federation":{
|
||||||
|
"enabled":true,
|
||||||
|
"exclusions":false,
|
||||||
|
"mrf_hashtag":{
|
||||||
|
"federated_timeline_removal":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"reject":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"sensitive":[
|
||||||
|
"nsfw"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mrf_object_age":{
|
||||||
|
"actions":[
|
||||||
|
"delist",
|
||||||
|
"strip_followers"
|
||||||
|
],
|
||||||
|
"threshold":604800
|
||||||
|
},
|
||||||
|
"mrf_policies":[
|
||||||
|
"ObjectAgePolicy",
|
||||||
|
"TagPolicy",
|
||||||
|
"HashtagPolicy"
|
||||||
|
],
|
||||||
|
"quarantined_instances":[
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fieldsLimits":{
|
||||||
|
"maxFields":10,
|
||||||
|
"maxRemoteFields":20,
|
||||||
|
"nameLength":512,
|
||||||
|
"valueLength":2048
|
||||||
|
},
|
||||||
|
"invitesEnabled":false,
|
||||||
|
"mailerEnabled":false,
|
||||||
|
"nodeDescription":"Pleroma: An efficient and flexible fediverse server",
|
||||||
|
"nodeName":"Example",
|
||||||
|
"pollLimits":{
|
||||||
|
"max_expiration":31536000,
|
||||||
|
"max_option_chars":200,
|
||||||
|
"max_options":20,
|
||||||
|
"min_expiration":0
|
||||||
|
},
|
||||||
|
"postFormats":[
|
||||||
|
"text/plain",
|
||||||
|
"text/html",
|
||||||
|
"text/markdown",
|
||||||
|
"text/bbcode"
|
||||||
|
],
|
||||||
|
"private":false,
|
||||||
|
"restrictedNicknames":[
|
||||||
|
".well-known",
|
||||||
|
"~",
|
||||||
|
"about",
|
||||||
|
"activities",
|
||||||
|
"api",
|
||||||
|
"auth",
|
||||||
|
"check_password",
|
||||||
|
"dev",
|
||||||
|
"friend-requests",
|
||||||
|
"inbox",
|
||||||
|
"internal",
|
||||||
|
"main",
|
||||||
|
"media",
|
||||||
|
"nodeinfo",
|
||||||
|
"notice",
|
||||||
|
"oauth",
|
||||||
|
"objects",
|
||||||
|
"ostatus_subscribe",
|
||||||
|
"pleroma",
|
||||||
|
"proxy",
|
||||||
|
"push",
|
||||||
|
"registration",
|
||||||
|
"relay",
|
||||||
|
"settings",
|
||||||
|
"status",
|
||||||
|
"tag",
|
||||||
|
"user-search",
|
||||||
|
"user_exists",
|
||||||
|
"users",
|
||||||
|
"web",
|
||||||
|
"verify_credentials",
|
||||||
|
"update_credentials",
|
||||||
|
"relationships",
|
||||||
|
"search",
|
||||||
|
"confirmation_resend",
|
||||||
|
"mfa"
|
||||||
|
],
|
||||||
|
"skipThreadContainment":true,
|
||||||
|
"staffAccounts":[
|
||||||
|
"https://example.com/users/admin",
|
||||||
|
"https://example.com/users/staff"
|
||||||
|
],
|
||||||
|
"suggestions":{
|
||||||
|
"enabled":false
|
||||||
|
},
|
||||||
|
"uploadLimits":{
|
||||||
|
"avatar":2000000,
|
||||||
|
"background":4000000,
|
||||||
|
"banner":4000000,
|
||||||
|
"general":16000000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"openRegistrations":true,
|
||||||
|
"protocols":[
|
||||||
|
"activitypub"
|
||||||
|
],
|
||||||
|
"services":{
|
||||||
|
"inbound":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"outbound":[
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"software":{
|
||||||
|
"name":"pleroma",
|
||||||
|
"version":"2.4.1"
|
||||||
|
},
|
||||||
|
"usage":{
|
||||||
|
"localPosts":27,
|
||||||
|
"users":{
|
||||||
|
"activeHalfyear":129,
|
||||||
|
"activeMonth":70,
|
||||||
|
"total":235
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version":"2.0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `/nodeinfo/2.1.json`
|
||||||
|
### Nodeinfo 2.1
|
||||||
|
* Method: `GET`
|
||||||
|
* Authentication: not required
|
||||||
|
* Params: none
|
||||||
|
* Response: JSON
|
||||||
|
* Example response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"metadata":{
|
||||||
|
"accountActivationRequired":false,
|
||||||
|
"features":[
|
||||||
|
"pleroma_api",
|
||||||
|
"mastodon_api",
|
||||||
|
"mastodon_api_streaming",
|
||||||
|
"polls",
|
||||||
|
"pleroma_explicit_addressing",
|
||||||
|
"shareable_emoji_packs",
|
||||||
|
"multifetch",
|
||||||
|
"pleroma:api/v1/notifications:include_types_filter",
|
||||||
|
"chat",
|
||||||
|
"shout",
|
||||||
|
"relay",
|
||||||
|
"pleroma_emoji_reactions",
|
||||||
|
"pleroma_chat_messages"
|
||||||
|
],
|
||||||
|
"federation":{
|
||||||
|
"enabled":true,
|
||||||
|
"exclusions":false,
|
||||||
|
"mrf_hashtag":{
|
||||||
|
"federated_timeline_removal":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"reject":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"sensitive":[
|
||||||
|
"nsfw"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mrf_object_age":{
|
||||||
|
"actions":[
|
||||||
|
"delist",
|
||||||
|
"strip_followers"
|
||||||
|
],
|
||||||
|
"threshold":604800
|
||||||
|
},
|
||||||
|
"mrf_policies":[
|
||||||
|
"ObjectAgePolicy",
|
||||||
|
"TagPolicy",
|
||||||
|
"HashtagPolicy"
|
||||||
|
],
|
||||||
|
"quarantined_instances":[
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fieldsLimits":{
|
||||||
|
"maxFields":10,
|
||||||
|
"maxRemoteFields":20,
|
||||||
|
"nameLength":512,
|
||||||
|
"valueLength":2048
|
||||||
|
},
|
||||||
|
"invitesEnabled":false,
|
||||||
|
"mailerEnabled":false,
|
||||||
|
"nodeDescription":"Pleroma: An efficient and flexible fediverse server",
|
||||||
|
"nodeName":"Example",
|
||||||
|
"pollLimits":{
|
||||||
|
"max_expiration":31536000,
|
||||||
|
"max_option_chars":200,
|
||||||
|
"max_options":20,
|
||||||
|
"min_expiration":0
|
||||||
|
},
|
||||||
|
"postFormats":[
|
||||||
|
"text/plain",
|
||||||
|
"text/html",
|
||||||
|
"text/markdown",
|
||||||
|
"text/bbcode"
|
||||||
|
],
|
||||||
|
"private":false,
|
||||||
|
"restrictedNicknames":[
|
||||||
|
".well-known",
|
||||||
|
"~",
|
||||||
|
"about",
|
||||||
|
"activities",
|
||||||
|
"api",
|
||||||
|
"auth",
|
||||||
|
"check_password",
|
||||||
|
"dev",
|
||||||
|
"friend-requests",
|
||||||
|
"inbox",
|
||||||
|
"internal",
|
||||||
|
"main",
|
||||||
|
"media",
|
||||||
|
"nodeinfo",
|
||||||
|
"notice",
|
||||||
|
"oauth",
|
||||||
|
"objects",
|
||||||
|
"ostatus_subscribe",
|
||||||
|
"pleroma",
|
||||||
|
"proxy",
|
||||||
|
"push",
|
||||||
|
"registration",
|
||||||
|
"relay",
|
||||||
|
"settings",
|
||||||
|
"status",
|
||||||
|
"tag",
|
||||||
|
"user-search",
|
||||||
|
"user_exists",
|
||||||
|
"users",
|
||||||
|
"web",
|
||||||
|
"verify_credentials",
|
||||||
|
"update_credentials",
|
||||||
|
"relationships",
|
||||||
|
"search",
|
||||||
|
"confirmation_resend",
|
||||||
|
"mfa"
|
||||||
|
],
|
||||||
|
"skipThreadContainment":true,
|
||||||
|
"staffAccounts":[
|
||||||
|
"https://example.com/users/admin",
|
||||||
|
"https://example.com/users/staff"
|
||||||
|
],
|
||||||
|
"suggestions":{
|
||||||
|
"enabled":false
|
||||||
|
},
|
||||||
|
"uploadLimits":{
|
||||||
|
"avatar":2000000,
|
||||||
|
"background":4000000,
|
||||||
|
"banner":4000000,
|
||||||
|
"general":16000000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"openRegistrations":true,
|
||||||
|
"protocols":[
|
||||||
|
"activitypub"
|
||||||
|
],
|
||||||
|
"services":{
|
||||||
|
"inbound":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"outbound":[
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"software":{
|
||||||
|
"name":"pleroma",
|
||||||
|
"repository":"https://git.pleroma.social/pleroma/pleroma",
|
||||||
|
"version":"2.4.1"
|
||||||
|
},
|
||||||
|
"usage":{
|
||||||
|
"localPosts":27,
|
||||||
|
"users":{
|
||||||
|
"activeHalfyear":129,
|
||||||
|
"activeMonth":70,
|
||||||
|
"total":235
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version":"2.1"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -159,10 +159,12 @@ See [Admin-API](admin_api.md)
|
||||||
"muting": false,
|
"muting": false,
|
||||||
"muting_notifications": false,
|
"muting_notifications": false,
|
||||||
"subscribing": true,
|
"subscribing": true,
|
||||||
|
"notifying": true,
|
||||||
"requested": false,
|
"requested": false,
|
||||||
"domain_blocking": false,
|
"domain_blocking": false,
|
||||||
"showing_reblogs": true,
|
"showing_reblogs": true,
|
||||||
"endorsed": false
|
"endorsed": false,
|
||||||
|
"note": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -183,10 +185,12 @@ See [Admin-API](admin_api.md)
|
||||||
"muting": false,
|
"muting": false,
|
||||||
"muting_notifications": false,
|
"muting_notifications": false,
|
||||||
"subscribing": false,
|
"subscribing": false,
|
||||||
|
"notifying": false,
|
||||||
"requested": false,
|
"requested": false,
|
||||||
"domain_blocking": false,
|
"domain_blocking": false,
|
||||||
"showing_reblogs": true,
|
"showing_reblogs": true,
|
||||||
"endorsed": false
|
"endorsed": false,
|
||||||
|
"note": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -300,7 +304,7 @@ See [Admin-API](admin_api.md)
|
||||||
* Note: Behaves exactly the same as `POST /api/v1/upload`.
|
* Note: Behaves exactly the same as `POST /api/v1/upload`.
|
||||||
Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
|
Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
|
||||||
|
|
||||||
## `/api/v1/pleroma/notification_settings`
|
## `/api/pleroma/notification_settings`
|
||||||
### Updates user notification settings
|
### Updates user notification settings
|
||||||
* Method `PUT`
|
* Method `PUT`
|
||||||
* Authentication: required
|
* Authentication: required
|
||||||
|
|
|
@ -17,10 +17,3 @@ Great! Now you can explore the fediverse! Open the login page for your Pleroma i
|
||||||
|
|
||||||
### Pleroma-FE
|
### Pleroma-FE
|
||||||
The default front-end used by Pleroma is Pleroma-FE. You can find more information on what it is and how to use it in the [Introduction to Pleroma-FE](../frontend).
|
The default front-end used by Pleroma is Pleroma-FE. You can find more information on what it is and how to use it in the [Introduction to Pleroma-FE](../frontend).
|
||||||
|
|
||||||
### Mastodon interface
|
|
||||||
If the Pleroma interface isn't your thing, or you're just trying something new but you want to keep using the familiar Mastodon interface, we got that too!
|
|
||||||
Just add a "/web" after your instance url (e.g. <https://pleroma.soykaf.com/web>) and you'll end on the Mastodon web interface, but with a Pleroma backend! MAGIC!
|
|
||||||
The Mastodon interface is from the Glitch-soc fork. For more information on the Mastodon interface you can check the [Mastodon](https://docs.joinmastodon.org/) and [Glitch-soc](https://glitch-soc.github.io/docs/) documentation.
|
|
||||||
|
|
||||||
Remember, what you see is only the frontend part of Mastodon, the backend is still Pleroma.
|
|
||||||
|
|
|
@ -1,29 +1,14 @@
|
||||||
# Installing on Alpine Linux
|
# Installing on Alpine Linux
|
||||||
|
|
||||||
|
{! backend/installation/otp_vs_from_source_source.include !}
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
This guide is a step-by-step installation guide for Alpine Linux. The instructions were verified against Alpine v3.10 standard image. You might miss additional dependencies if you use `netboot` instead.
|
This guide is a step-by-step installation guide for Alpine Linux. The instructions were verified against Alpine v3.10 standard image. You might miss additional dependencies if you use `netboot` instead.
|
||||||
|
|
||||||
It assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/#configuration). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su -l <username> -s $SHELL -c 'command'` instead.
|
It assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/#configuration). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su -l <username> -s $SHELL -c 'command'` instead.
|
||||||
|
|
||||||
### Required packages
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
* `postgresql`
|
|
||||||
* `elixir`
|
|
||||||
* `erlang`
|
|
||||||
* `erlang-parsetools`
|
|
||||||
* `erlang-xmerl`
|
|
||||||
* `git`
|
|
||||||
* `file-dev`
|
|
||||||
* Development Tools
|
|
||||||
* `cmake`
|
|
||||||
|
|
||||||
#### 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
|
### Prepare the system
|
||||||
|
|
||||||
|
@ -117,7 +102,7 @@ cd /opt/pleroma
|
||||||
sudo -Hu pleroma mix deps.get
|
sudo -Hu pleroma mix deps.get
|
||||||
```
|
```
|
||||||
|
|
||||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||||
* Answer with `yes` if it asks you to install `rebar3`.
|
* Answer with `yes` if it asks you to install `rebar3`.
|
||||||
* This may take some time, because parts of pleroma get compiled first.
|
* This may take some time, because parts of pleroma get compiled first.
|
||||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||||
|
@ -240,4 +225,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
# Installing on Arch Linux
|
# Installing on Arch Linux
|
||||||
|
|
||||||
|
{! backend/installation/otp_vs_from_source_source.include !}
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.archlinux.org/index.php/Sudo). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.archlinux.org/index.php/Sudo). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
||||||
|
@ -92,7 +95,7 @@ cd /opt/pleroma
|
||||||
sudo -Hu pleroma mix deps.get
|
sudo -Hu pleroma mix deps.get
|
||||||
```
|
```
|
||||||
|
|
||||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||||
* Answer with `yes` if it asks you to install `rebar3`.
|
* Answer with `yes` if it asks you to install `rebar3`.
|
||||||
* This may take some time, because parts of pleroma get compiled first.
|
* This may take some time, because parts of pleroma get compiled first.
|
||||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||||
|
@ -215,4 +218,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -1,27 +1,12 @@
|
||||||
# Installing on Debian Based Distributions
|
# Installing on Debian Based Distributions
|
||||||
|
|
||||||
|
{! backend/installation/otp_vs_from_source_source.include !}
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
This guide will assume you are on Debian Stretch. This guide should also work with Ubuntu 16.04 and 18.04. It also assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
This guide will assume you are on Debian 11 (“bullseye”) or later. This guide should also work with Ubuntu 18.04 (“Bionic Beaver”) and later. It also assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
||||||
|
|
||||||
### Required packages
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
* `postgresql` (9.6+, Ubuntu 16.04 comes with 9.5, you can get a newer version from [here](https://www.postgresql.org/download/linux/ubuntu/))
|
|
||||||
* `postgresql-contrib` (9.6+, same situtation as above)
|
|
||||||
* `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`
|
|
||||||
|
|
||||||
#### 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
|
### Prepare the system
|
||||||
|
|
||||||
|
@ -40,20 +25,14 @@ sudo apt install git build-essential postgresql postgresql-contrib cmake libmagi
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
||||||
* Download and add the Erlang repository:
|
* Install Elixir and Erlang (you might need to use backports or [asdf](https://github.com/asdf-vm/asdf) on old systems):
|
||||||
|
|
||||||
```shell
|
|
||||||
wget -P /tmp/ https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
|
|
||||||
sudo dpkg -i /tmp/erlang-solutions_2.0_all.deb
|
|
||||||
```
|
|
||||||
|
|
||||||
* Install Elixir and Erlang:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install elixir erlang-dev erlang-nox
|
sudo apt install elixir erlang-dev erlang-nox
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
|
### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -90,7 +69,7 @@ cd /opt/pleroma
|
||||||
sudo -Hu pleroma mix deps.get
|
sudo -Hu pleroma mix deps.get
|
||||||
```
|
```
|
||||||
|
|
||||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||||
* Answer with `yes` if it asks you to install `rebar3`.
|
* Answer with `yes` if it asks you to install `rebar3`.
|
||||||
* This may take some time, because parts of pleroma get compiled first.
|
* This may take some time, because parts of pleroma get compiled first.
|
||||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||||
|
@ -202,4 +181,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -89,7 +89,7 @@ sudo -Hu pleroma mix deps.get
|
||||||
|
|
||||||
* コンフィギュレーションを生成します。
|
* コンフィギュレーションを生成します。
|
||||||
```
|
```
|
||||||
sudo -Hu pleroma mix pleroma.instance gen
|
sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen
|
||||||
```
|
```
|
||||||
* rebar3をインストールしてもよいか聞かれたら、yesを入力してください。
|
* rebar3をインストールしてもよいか聞かれたら、yesを入力してください。
|
||||||
* このときにpleromaの一部がコンパイルされるため、この処理には時間がかかります。
|
* このときにpleromaの一部がコンパイルされるため、この処理には時間がかかります。
|
||||||
|
@ -103,7 +103,7 @@ sudo -Hu pleroma mv config/{generated_config.exs,prod.secret.exs}
|
||||||
|
|
||||||
* 先程のコマンドで、すでに `config/setup_db.psql` というファイルが作られています。このファイルをもとに、データベースを作成します。
|
* 先程のコマンドで、すでに `config/setup_db.psql` というファイルが作られています。このファイルをもとに、データベースを作成します。
|
||||||
```
|
```
|
||||||
sudo -Hu pleroma mix pleroma.instance gen
|
sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen
|
||||||
```
|
```
|
||||||
|
|
||||||
* そして、データベースのマイグレーションを実行します。
|
* そして、データベースのマイグレーションを実行します。
|
||||||
|
@ -191,5 +191,5 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
||||||
|
|
||||||
インストールについて質問がある、もしくは、うまくいかないときは、以下のところで質問できます。
|
インストールについて質問がある、もしくは、うまくいかないときは、以下のところで質問できます。
|
||||||
|
|
||||||
* [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org)
|
* [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat)
|
||||||
* **Freenode** の **#pleroma** IRCチャンネル
|
* **libera.chat** の **#pleroma** IRCチャンネル
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
This document was written for FreeBSD 12.1, but should be work on future releases.
|
This document was written for FreeBSD 12.1, but should be work on future releases.
|
||||||
|
|
||||||
## Required software
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
|
## Installing software used in this guide
|
||||||
|
|
||||||
This assumes the target system has `pkg(8)`.
|
This assumes the target system has `pkg(8)`.
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ Configure Pleroma. Note that you need a domain name at this point:
|
||||||
```
|
```
|
||||||
$ cd /home/pleroma/pleroma
|
$ cd /home/pleroma/pleroma
|
||||||
$ mix deps.get # Enter "y" when asked to install Hex
|
$ mix deps.get # Enter "y" when asked to install Hex
|
||||||
$ mix pleroma.instance gen # You will be asked a few questions here.
|
$ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
|
||||||
$ cp config/generated_config.exs config/prod.secret.exs
|
$ cp config/generated_config.exs config/prod.secret.exs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -213,4 +215,4 @@ incorrect timestamps. You should have ntpd running.
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
## Required dependencies
|
||||||
|
|
||||||
|
* PostgreSQL 9.6+
|
||||||
|
* Elixir 1.9+
|
||||||
|
* Erlang OTP 22.2+
|
||||||
|
* git
|
||||||
|
* file / libmagic
|
||||||
|
* gcc (clang might also work)
|
||||||
|
* GNU make
|
||||||
|
* CMake
|
||||||
|
|
||||||
|
## Optional dependencies
|
||||||
|
|
||||||
|
* ImageMagick
|
||||||
|
* FFmpeg
|
||||||
|
* exiftool
|
|
@ -1,11 +1,12 @@
|
||||||
# Installing on Gentoo GNU/Linux
|
# Installing on Gentoo GNU/Linux
|
||||||
|
|
||||||
|
{! backend/installation/otp_vs_from_source_source.include !}
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.gentoo.org/wiki/Sudo). Lines that begin with `#` indicate that they should be run as the superuser. Lines using `$` should be run as the indicated user, e.g. `pleroma$` should be run as the `pleroma` user.
|
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.gentoo.org/wiki/Sudo). Lines that begin with `#` indicate that they should be run as the superuser. Lines using `$` should be run as the indicated user, e.g. `pleroma$` should be run as the `pleroma` user.
|
||||||
|
|
||||||
### Configuring your hostname (optional)
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
If you would like your prompt to permanently include your host/domain, change `/etc/conf.d/hostname` to your hostname. You can reboot or use the `hostname` command to make immediate changes.
|
|
||||||
|
|
||||||
### Your make.conf, package.use, and USE flags
|
### Your make.conf, package.use, and USE flags
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ pleroma$ mix deps.get
|
||||||
* Generate the configuration:
|
* Generate the configuration:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pleroma$ mix pleroma.instance gen
|
pleroma$ MIX_ENV=prod mix pleroma.instance gen
|
||||||
```
|
```
|
||||||
|
|
||||||
* Answer with `yes` if it asks you to install `rebar3`.
|
* Answer with `yes` if it asks you to install `rebar3`.
|
||||||
|
@ -298,4 +299,4 @@ If you opted to allow sudo for the `pleroma` user but would like to remove the a
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Switching a from-source install to OTP releases
|
# Switching a from-source install to OTP releases
|
||||||
|
|
||||||
## What are OTP releases?
|
{! backend/installation/otp_vs_from_source.include !}
|
||||||
OTP releases are as close as you can get to binary releases with Erlang/Elixir. The release is self-contained, and provides everything needed to boot it, it is easily administered via the provided shell script to open up a remote console, start/stop/restart the release, start in the background, send remote commands, and more.
|
|
||||||
|
In this guide we cover how you can migrate from a from source installation to one using OTP releases.
|
||||||
|
|
||||||
## Pre-requisites
|
## Pre-requisites
|
||||||
You will be running commands as root. If you aren't root already, please elevate your priviledges by executing `sudo su`/`su`.
|
You will be running commands as root. If you aren't root already, please elevate your priviledges by executing `sudo su`/`su`.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Installing on NetBSD
|
# Installing on NetBSD
|
||||||
|
|
||||||
## Required software
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
|
## Installing software used in this guide
|
||||||
|
|
||||||
pkgin should have been installed by the NetBSD installer if you selected
|
pkgin should have been installed by the NetBSD installer if you selected
|
||||||
the right options. If it isn't installed, install it using pkg_add.
|
the right options. If it isn't installed, install it using pkg_add.
|
||||||
|
@ -71,7 +73,7 @@ Configure Pleroma. Note that you need a domain name at this point:
|
||||||
```
|
```
|
||||||
$ cd /home/pleroma/pleroma
|
$ cd /home/pleroma/pleroma
|
||||||
$ mix deps.get
|
$ mix deps.get
|
||||||
$ mix pleroma.instance gen # You will be asked a few questions here.
|
$ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
|
||||||
```
|
```
|
||||||
|
|
||||||
Since Postgres is configured, we can now initialize the database. There should
|
Since Postgres is configured, we can now initialize the database. There should
|
||||||
|
@ -193,8 +195,6 @@ Run `# /etc/rc.d/pleroma start` to start Pleroma.
|
||||||
|
|
||||||
Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
|
Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
|
||||||
|
|
||||||
If you need further help, contact niaa on freenode.
|
|
||||||
|
|
||||||
Make sure your time is in sync, or other instances will receive your posts with
|
Make sure your time is in sync, or other instances will receive your posts with
|
||||||
incorrect timestamps. You should have ntpd running.
|
incorrect timestamps. You should have ntpd running.
|
||||||
|
|
||||||
|
@ -208,4 +208,4 @@ incorrect timestamps. You should have ntpd running.
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -4,19 +4,11 @@ This guide describes the installation and configuration of pleroma (and the requ
|
||||||
|
|
||||||
For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
|
For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
|
||||||
|
|
||||||
|
{! backend/installation/generic_dependencies.include !}
|
||||||
|
|
||||||
|
### Preparing the system
|
||||||
#### Required software
|
#### Required software
|
||||||
|
|
||||||
The following packages need to be installed:
|
|
||||||
|
|
||||||
* elixir
|
|
||||||
* gmake
|
|
||||||
* git
|
|
||||||
* postgresql-server
|
|
||||||
* postgresql-contrib
|
|
||||||
* cmake
|
|
||||||
* ffmpeg
|
|
||||||
* ImageMagick
|
|
||||||
|
|
||||||
To install them, run the following command (with doas or as root):
|
To install them, run the following command (with doas or as root):
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -239,7 +231,7 @@ Enter a shell as \_pleroma (as root `su _pleroma -`) and enter pleroma's install
|
||||||
Then follow the main installation guide:
|
Then follow the main installation guide:
|
||||||
|
|
||||||
* run `mix deps.get`
|
* run `mix deps.get`
|
||||||
* run `mix pleroma.instance gen` and enter your instance's information when asked
|
* run `MIX_ENV=prod mix pleroma.instance gen` and enter your instance's information when asked
|
||||||
* copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK.
|
* copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK.
|
||||||
* exit your current shell back to a root one and run `psql -U postgres -f /home/_pleroma/pleroma/config/setup_db.psql` to setup the database.
|
* exit your current shell back to a root one and run `psql -U postgres -f /home/_pleroma/pleroma/config/setup_db.psql` to setup the database.
|
||||||
* return to a \_pleroma shell into pleroma's installation directory (`su _pleroma -;cd ~/pleroma`) and run `MIX_ENV=prod mix ecto.migrate`
|
* return to a \_pleroma shell into pleroma's installation directory (`su _pleroma -;cd ~/pleroma`) and run `MIX_ENV=prod mix ecto.migrate`
|
||||||
|
@ -264,4 +256,4 @@ LC_ALL=en_US.UTF-8 MIX_ENV=prod mix pleroma.user new <username> <your@emailaddre
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||||
|
|
|
@ -10,8 +10,8 @@ suositeltavaa tehdä komennon `doas` avulla, katso `doas (1)` ja `doas.conf (5)`
|
||||||
Tästä eteenpäin oletuksena on, että domain "esimerkki.com" osoittaa
|
Tästä eteenpäin oletuksena on, että domain "esimerkki.com" osoittaa
|
||||||
serverin IP-osoitteeseen.
|
serverin IP-osoitteeseen.
|
||||||
|
|
||||||
Jos asennuksen kanssa on ongelmia, IRC-kanava #pleroma Freenodessa tai
|
Jos asennuksen kanssa on ongelmia, IRC-kanava #pleroma Libera.chat tai
|
||||||
Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
|
Matrix-kanava #pleroma:libera.chat ovat hyviä paikkoja löytää apua
|
||||||
(englanniksi), `/msg eal kukkuu` jos haluat välttämättä puhua härmää.
|
(englanniksi), `/msg eal kukkuu` jos haluat välttämättä puhua härmää.
|
||||||
|
|
||||||
Asenna tarvittava ohjelmisto:
|
Asenna tarvittava ohjelmisto:
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Installing on Linux using OTP releases
|
# Installing on Linux using OTP releases
|
||||||
|
|
||||||
|
{! backend/installation/otp_vs_from_source.include !}
|
||||||
|
|
||||||
|
This guide covers a installation using an OTP release. To install Pleroma from source, please check out the corresponding guide for your distro.
|
||||||
|
|
||||||
## Pre-requisites
|
## Pre-requisites
|
||||||
* A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and `x86_64`, `aarch64` or `armv7l` CPU, you have root access to. If you are not sure if it's compatible see [Detecting flavour section](#detecting-flavour) below
|
* A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and `x86_64`, `aarch64` or `armv7l` CPU, you have root access to. If you are not sure if it's compatible see [Detecting flavour section](#detecting-flavour) below
|
||||||
* A (sub)domain pointed to the machine
|
* A (sub)domain pointed to the machine
|
||||||
|
@ -31,7 +35,7 @@ Other than things bundled in the OTP release Pleroma depends on:
|
||||||
|
|
||||||
=== "Alpine"
|
=== "Alpine"
|
||||||
```
|
```
|
||||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
awk 'NR==2' /etc/apk/repositories | sed 's/main/community/' | tee -a /etc/apk/repositories
|
||||||
apk update
|
apk update
|
||||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
|
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
|
||||||
```
|
```
|
||||||
|
@ -50,7 +54,6 @@ Per [`docs/installation/optional/media_graphics_packages.md`](optional/media_gra
|
||||||
|
|
||||||
=== "Alpine"
|
=== "Alpine"
|
||||||
```
|
```
|
||||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
|
||||||
apk update
|
apk update
|
||||||
apk add imagemagick ffmpeg exiftool
|
apk add imagemagick ffmpeg exiftool
|
||||||
```
|
```
|
||||||
|
@ -232,7 +235,7 @@ At this point if you open your (sub)domain in a browser you should see a 502 err
|
||||||
|
|
||||||
If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors.
|
If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors.
|
||||||
|
|
||||||
Still doesn't work? Feel free to contact us on [#pleroma on freenode](https://irc.pleroma.social) or via matrix at <https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org>, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new)
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new).
|
||||||
|
|
||||||
## Post installation
|
## Post installation
|
||||||
|
|
||||||
|
@ -301,4 +304,4 @@ This will create an account withe the username of 'joeuser' with the email addre
|
||||||
|
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new).
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
## OTP releases vs from-source installations
|
||||||
|
|
||||||
|
There are two ways to install Pleroma. You can use OTP releases or do a from-source installation. OTP releases are as close as you can get to binary releases with Erlang/Elixir. The release is self-contained, and provides everything needed to boot it, it is easily administered via the provided shell script to open up a remote console, start/stop/restart the release, start in the background, send remote commands, and more. With from source installations you install Pleroma from source, meaning you have to install certain dependencies like Erlang+Elixir and compile Pleroma yourself.
|
|
@ -0,0 +1,3 @@
|
||||||
|
{! backend/installation/otp_vs_from_source.include !}
|
||||||
|
|
||||||
|
This guide covers a from-source installation. To install using OTP releases, please check out [the OTP guide](./otp_en.md).
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Installing on Yunohost
|
||||||
|
|
||||||
|
[YunoHost](https://yunohost.org) is a server operating system aimed at self-hosting. The YunoHost community maintains a package of Pleroma which allows you to install Pleroma on YunoHost. You can install it via the normal way through the admin web interface, or through the CLI. More information can be found at [the repo of the package](https://github.com/YunoHost-Apps/pleroma_ynh).
|
||||||
|
|
||||||
|
## Questions
|
||||||
|
|
||||||
|
Questions and problems related to the YunoHost parts can be done through the [regular YunoHost channels](https://yunohost.org/en/help).
|
||||||
|
|
||||||
|
For questions about Pleroma, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
|
@ -1,48 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
project_id="74"
|
|
||||||
project_branch="rebase/glitch-soc"
|
|
||||||
static_dir="instance/static"
|
|
||||||
# For bundling:
|
|
||||||
# project_branch="pleroma"
|
|
||||||
# static_dir="priv/static"
|
|
||||||
|
|
||||||
if [ ! -d "${static_dir}" ]
|
|
||||||
then
|
|
||||||
echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
|
|
||||||
|
|
||||||
echo "branch:${project_branch}"
|
|
||||||
echo "Last-Modified:${last_modified}"
|
|
||||||
|
|
||||||
artifact="mastofe.zip"
|
|
||||||
|
|
||||||
if [ "${last_modified}x" = "x" ]
|
|
||||||
then
|
|
||||||
echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
|
|
||||||
then
|
|
||||||
echo "MastoFE is up-to-date, exiting..."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
|
|
||||||
|
|
||||||
# TODO: Update the emoji as well
|
|
||||||
rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
|
|
||||||
unzip -q "${artifact}" || exit
|
|
||||||
|
|
||||||
cp public/assets/sw.js "${static_dir}/sw.js" || exit
|
|
||||||
cp -r public/packs "${static_dir}/packs" || exit
|
|
||||||
|
|
||||||
echo "${last_modified}" > mastofe.timestamp
|
|
||||||
rm -fr public
|
|
||||||
rm -i "${artifact}"
|
|
|
@ -286,9 +286,7 @@ defp migrate_from_db(opts) do
|
||||||
file = File.open!(tmp_config_path)
|
file = File.open!(tmp_config_path)
|
||||||
|
|
||||||
shell_info(
|
shell_info(
|
||||||
"Saving database configuration settings to #{tmp_config_path}. Copy it to the #{
|
"Saving database configuration settings to #{tmp_config_path}. Copy it to the #{Path.dirname(config_path)} manually."
|
||||||
Path.dirname(config_path)
|
|
||||||
} manually."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
write_config(file, tmp_config_path, opts)
|
write_config(file, tmp_config_path, opts)
|
||||||
|
|
|
@ -96,6 +96,15 @@ def run(["prune_objects" | args]) do
|
||||||
)
|
)
|
||||||
|> Repo.delete_all(timeout: :infinity)
|
|> Repo.delete_all(timeout: :infinity)
|
||||||
|
|
||||||
|
prune_hashtags_query = """
|
||||||
|
DELETE FROM hashtags AS ht
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM hashtags_objects hto
|
||||||
|
WHERE ht.id = hto.hashtag_id)
|
||||||
|
"""
|
||||||
|
|
||||||
|
Repo.query(prune_hashtags_query)
|
||||||
|
|
||||||
if Keyword.get(options, :vacuum) do
|
if Keyword.get(options, :vacuum) do
|
||||||
Maintenance.vacuum("full")
|
Maintenance.vacuum("full")
|
||||||
end
|
end
|
||||||
|
@ -200,7 +209,9 @@ def run(["set_text_search_config", tsconfig]) do
|
||||||
new.fts_content := to_tsvector(new.data->>'content');
|
new.fts_content := to_tsvector(new.data->>'content');
|
||||||
RETURN new;
|
RETURN new;
|
||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql"
|
$$ LANGUAGE plpgsql",
|
||||||
|
[],
|
||||||
|
timeout: :infinity
|
||||||
)
|
)
|
||||||
|
|
||||||
shell_info("Refresh RUM index")
|
shell_info("Refresh RUM index")
|
||||||
|
@ -210,7 +221,9 @@ def run(["set_text_search_config", tsconfig]) do
|
||||||
|
|
||||||
Ecto.Adapters.SQL.query!(
|
Ecto.Adapters.SQL.query!(
|
||||||
Pleroma.Repo,
|
Pleroma.Repo,
|
||||||
"CREATE INDEX objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); "
|
"CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); ",
|
||||||
|
[],
|
||||||
|
timeout: :infinity
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,7 @@ def run(["gen" | rest]) do
|
||||||
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||||
jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||||
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
||||||
|
lv_signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
||||||
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
|
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
|
||||||
template_dir = Application.app_dir(:pleroma, "priv") <> "/templates"
|
template_dir = Application.app_dir(:pleroma, "priv") <> "/templates"
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ def run(["gen" | rest]) do
|
||||||
secret: secret,
|
secret: secret,
|
||||||
jwt_secret: jwt_secret,
|
jwt_secret: jwt_secret,
|
||||||
signing_salt: signing_salt,
|
signing_salt: signing_salt,
|
||||||
|
lv_signing_salt: lv_signing_salt,
|
||||||
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
|
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
|
||||||
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
|
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
|
||||||
db_configurable?: db_configurable?,
|
db_configurable?: db_configurable?,
|
||||||
|
|
|
@ -51,9 +51,7 @@ def run(["new", nickname, email | rest]) do
|
||||||
A user will be created with the following information:
|
A user will be created with the following information:
|
||||||
- nickname: #{nickname}
|
- nickname: #{nickname}
|
||||||
- email: #{email}
|
- email: #{email}
|
||||||
- password: #{
|
- password: #{if(generated_password?, do: "[generated; a reset link will be created]", else: password)}
|
||||||
if(generated_password?, do: "[generated; a reset link will be created]", else: password)
|
|
||||||
}
|
|
||||||
- name: #{name}
|
- name: #{name}
|
||||||
- bio: #{bio}
|
- bio: #{bio}
|
||||||
- moderator: #{if(moderator?, do: "true", else: "false")}
|
- moderator: #{if(moderator?, do: "true", else: "false")}
|
||||||
|
@ -114,15 +112,9 @@ def run(["reset_password", nickname]) do
|
||||||
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
||||||
shell_info("Generated password reset token for #{user.nickname}")
|
shell_info("Generated password reset token for #{user.nickname}")
|
||||||
|
|
||||||
IO.puts(
|
IO.puts("URL: #{Pleroma.Web.Router.Helpers.reset_password_url(Pleroma.Web.Endpoint,
|
||||||
"URL: #{
|
|
||||||
Pleroma.Web.Router.Helpers.reset_password_url(
|
|
||||||
Pleroma.Web.Endpoint,
|
|
||||||
:reset,
|
:reset,
|
||||||
token.token
|
token.token)}")
|
||||||
)
|
|
||||||
}"
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
shell_error("No local user #{nickname}")
|
shell_error("No local user #{nickname}")
|
||||||
|
@ -321,9 +313,7 @@ def run(["invites"]) do
|
||||||
end
|
end
|
||||||
|
|
||||||
shell_info(
|
shell_info(
|
||||||
"ID: #{invite.id} | Token: #{invite.token} | Token type: #{invite.invite_type} | Used: #{
|
"ID: #{invite.id} | Token: #{invite.token} | Token type: #{invite.invite_type} | Used: #{invite.used}#{expire_info}#{using_info}"
|
||||||
invite.used
|
|
||||||
}#{expire_info}#{using_info}"
|
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -424,9 +414,7 @@ def run(["list"]) do
|
||||||
users
|
users
|
||||||
|> Enum.each(fn user ->
|
|> Enum.each(fn user ->
|
||||||
shell_info(
|
shell_info(
|
||||||
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{user.is_locked}, is_active: #{user.is_active}"
|
||||||
user.is_locked
|
|
||||||
}, is_active: #{user.is_active}"
|
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -292,7 +292,8 @@ def get_in_reply_to_activity(%Activity{} = activity) do
|
||||||
get_in_reply_to_activity_from_object(Object.normalize(activity, fetch: false))
|
get_in_reply_to_activity_from_object(Object.normalize(activity, fetch: false))
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize(obj) when is_map(obj), do: get_by_ap_id_with_object(obj["id"])
|
def normalize(%Activity{data: %{"id" => ap_id}}), do: get_by_ap_id_with_object(ap_id)
|
||||||
|
def normalize(%{"id" => ap_id}), do: get_by_ap_id_with_object(ap_id)
|
||||||
def normalize(ap_id) when is_binary(ap_id), do: get_by_ap_id_with_object(ap_id)
|
def normalize(ap_id) when is_binary(ap_id), do: get_by_ap_id_with_object(ap_id)
|
||||||
def normalize(_), do: nil
|
def normalize(_), do: nil
|
||||||
|
|
||||||
|
@ -301,7 +302,7 @@ def delete_all_by_object_ap_id(id) when is_binary(id) do
|
||||||
|> Queries.by_object_id()
|
|> Queries.by_object_id()
|
||||||
|> Queries.exclude_type("Delete")
|
|> Queries.exclude_type("Delete")
|
||||||
|> select([u], u)
|
|> select([u], u)
|
||||||
|> Repo.delete_all()
|
|> Repo.delete_all(timeout: :infinity)
|
||||||
|> elem(1)
|
|> elem(1)
|
||||||
|> Enum.find(fn
|
|> Enum.find(fn
|
||||||
%{data: %{"type" => "Create", "object" => ap_id}} when is_binary(ap_id) -> ap_id == id
|
%{data: %{"type" => "Create", "object" => ap_id}} when is_binary(ap_id) -> ap_id == id
|
||||||
|
@ -313,13 +314,15 @@ def delete_all_by_object_ap_id(id) when is_binary(id) do
|
||||||
|
|
||||||
def delete_all_by_object_ap_id(_), do: nil
|
def delete_all_by_object_ap_id(_), do: nil
|
||||||
|
|
||||||
defp purge_web_resp_cache(%Activity{} = activity) do
|
defp purge_web_resp_cache(%Activity{data: %{"id" => id}} = activity) when is_binary(id) do
|
||||||
%{path: path} = URI.parse(activity.data["id"])
|
with %{path: path} <- URI.parse(id) do
|
||||||
@cachex.del(:web_resp_cache, path)
|
@cachex.del(:web_resp_cache, path)
|
||||||
|
end
|
||||||
|
|
||||||
activity
|
activity
|
||||||
end
|
end
|
||||||
|
|
||||||
defp purge_web_resp_cache(nil), do: nil
|
defp purge_web_resp_cache(activity), do: activity
|
||||||
|
|
||||||
def follow_accepted?(
|
def follow_accepted?(
|
||||||
%Activity{data: %{"type" => "Follow", "object" => followed_ap_id}} = activity
|
%Activity{data: %{"type" => "Follow", "object" => followed_ap_id}} = activity
|
||||||
|
@ -359,11 +362,9 @@ def following_requests_for_actor(%User{ap_id: ap_id}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def restrict_deactivated_users(query) do
|
def restrict_deactivated_users(query) do
|
||||||
deactivated_users =
|
deactivated_users_query = from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
|
||||||
from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
|
|
||||||
|> Repo.all()
|
|
||||||
|
|
||||||
Activity.Queries.exclude_authors(query, deactivated_users)
|
from(activity in query, where: activity.actor not in subquery(deactivated_users_query))
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
|
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Activity.HTML do
|
||||||
|
alias Pleroma.HTML
|
||||||
|
alias Pleroma.Object
|
||||||
|
|
||||||
|
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
||||||
|
|
||||||
|
def get_cached_scrubbed_html_for_activity(
|
||||||
|
content,
|
||||||
|
scrubbers,
|
||||||
|
activity,
|
||||||
|
key \\ "",
|
||||||
|
callback \\ fn x -> x end
|
||||||
|
) do
|
||||||
|
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
|
||||||
|
|
||||||
|
@cachex.fetch!(:scrubber_cache, key, fn _key ->
|
||||||
|
object = Object.normalize(activity, fetch: false)
|
||||||
|
HTML.ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_cached_stripped_html_for_activity(content, activity, key) do
|
||||||
|
get_cached_scrubbed_html_for_activity(
|
||||||
|
content,
|
||||||
|
FastSanitize.Sanitizer.StripTags,
|
||||||
|
activity,
|
||||||
|
key,
|
||||||
|
&HtmlEntities.decode/1
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
|
||||||
|
generate_scrubber_signature([scrubber])
|
||||||
|
end
|
||||||
|
|
||||||
|
defp generate_scrubber_signature(scrubbers) do
|
||||||
|
Enum.reduce(scrubbers, "", fn scrubber, signature ->
|
||||||
|
"#{signature}#{to_string(scrubber)}"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,6 +26,7 @@ def search(user, search_query, options \\ []) do
|
||||||
:plain
|
:plain
|
||||||
end
|
end
|
||||||
|
|
||||||
|
try do
|
||||||
Activity
|
Activity
|
||||||
|> Activity.with_preloaded_object()
|
|> Activity.with_preloaded_object()
|
||||||
|> Activity.restrict_deactivated_users()
|
|> Activity.restrict_deactivated_users()
|
||||||
|
@ -39,6 +40,9 @@ def search(user, search_query, options \\ []) do
|
||||||
:offset
|
:offset
|
||||||
)
|
)
|
||||||
|> maybe_fetch(user, search_query)
|
|> maybe_fetch(user, search_query)
|
||||||
|
rescue
|
||||||
|
_ -> maybe_fetch([], user, search_query)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_restrict_author(query, %User{} = author) do
|
def maybe_restrict_author(query, %User{} = author) do
|
||||||
|
@ -61,10 +65,17 @@ defp restrict_public(q) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp query_with(q, :gin, search_query, :plain) do
|
defp query_with(q, :gin, search_query, :plain) do
|
||||||
|
%{rows: [[tsc]]} =
|
||||||
|
Ecto.Adapters.SQL.query!(
|
||||||
|
Pleroma.Repo,
|
||||||
|
"select current_setting('default_text_search_config')::regconfig::oid;"
|
||||||
|
)
|
||||||
|
|
||||||
from([a, o] in q,
|
from([a, o] in q,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"to_tsvector(?->>'content') @@ plainto_tsquery(?)",
|
"to_tsvector(?::oid::regconfig, ?->>'content') @@ plainto_tsquery(?)",
|
||||||
|
^tsc,
|
||||||
o.data,
|
o.data,
|
||||||
^search_query
|
^search_query
|
||||||
)
|
)
|
||||||
|
@ -72,10 +83,17 @@ defp query_with(q, :gin, search_query, :plain) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp query_with(q, :gin, search_query, :websearch) do
|
defp query_with(q, :gin, search_query, :websearch) do
|
||||||
|
%{rows: [[tsc]]} =
|
||||||
|
Ecto.Adapters.SQL.query!(
|
||||||
|
Pleroma.Repo,
|
||||||
|
"select current_setting('default_text_search_config')::regconfig::oid;"
|
||||||
|
)
|
||||||
|
|
||||||
from([a, o] in q,
|
from([a, o] in q,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"to_tsvector(?->>'content') @@ websearch_to_tsquery(?)",
|
"to_tsvector(?::oid::regconfig, ?->>'content') @@ websearch_to_tsquery(?)",
|
||||||
|
^tsc,
|
||||||
o.data,
|
o.data,
|
||||||
^search_query
|
^search_query
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,7 @@ def user_agent do
|
||||||
if Process.whereis(Pleroma.Web.Endpoint) do
|
if Process.whereis(Pleroma.Web.Endpoint) do
|
||||||
case Config.get([:http, :user_agent], :default) do
|
case Config.get([:http, :user_agent], :default) do
|
||||||
:default ->
|
:default ->
|
||||||
info = "#{Pleroma.Web.base_url()} <#{Config.get([:instance, :email], "")}>"
|
info = "#{Pleroma.Web.Endpoint.url()} <#{Config.get([:instance, :email], "")}>"
|
||||||
named_version() <> "; " <> info
|
named_version() <> "; " <> info
|
||||||
|
|
||||||
custom ->
|
custom ->
|
||||||
|
@ -102,7 +102,7 @@ def start(_type, _args) do
|
||||||
] ++
|
] ++
|
||||||
task_children(@mix_env) ++
|
task_children(@mix_env) ++
|
||||||
dont_run_in_test(@mix_env) ++
|
dont_run_in_test(@mix_env) ++
|
||||||
chat_child(chat_enabled?()) ++
|
shout_child(shout_enabled?()) ++
|
||||||
[Pleroma.Gopher.Server]
|
[Pleroma.Gopher.Server]
|
||||||
|
|
||||||
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
|
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
|
||||||
|
@ -216,7 +216,7 @@ def build_cachex(type, opts),
|
||||||
type: :worker
|
type: :worker
|
||||||
}
|
}
|
||||||
|
|
||||||
defp chat_enabled?, do: Config.get([:chat, :enabled])
|
defp shout_enabled?, do: Config.get([:shout, :enabled])
|
||||||
|
|
||||||
defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
|
defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
|
||||||
|
|
||||||
|
@ -237,14 +237,14 @@ defp background_migrators do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp chat_child(true) do
|
defp shout_child(true) do
|
||||||
[
|
[
|
||||||
Pleroma.Web.ChatChannel.ChatChannelState,
|
Pleroma.Web.ShoutChannel.ShoutChannelState,
|
||||||
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
|
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp chat_child(_), do: []
|
defp shout_child(_), do: []
|
||||||
|
|
||||||
defp task_children(:test) do
|
defp task_children(:test) do
|
||||||
[
|
[
|
||||||
|
|
|
@ -164,9 +164,12 @@ defp do_check_rum!(setting, migrate) do
|
||||||
|
|
||||||
defp check_system_commands!(:ok) do
|
defp check_system_commands!(:ok) do
|
||||||
filter_commands_statuses = [
|
filter_commands_statuses = [
|
||||||
check_filter(Pleroma.Upload.Filters.Exiftool, "exiftool"),
|
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
||||||
check_filter(Pleroma.Upload.Filters.Mogrify, "mogrify"),
|
check_filter(Pleroma.Upload.Filter.Mogrify, "mogrify"),
|
||||||
check_filter(Pleroma.Upload.Filters.Mogrifun, "mogrify")
|
check_filter(Pleroma.Upload.Filter.Mogrifun, "mogrify"),
|
||||||
|
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "mogrify"),
|
||||||
|
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "convert"),
|
||||||
|
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "ffprobe")
|
||||||
]
|
]
|
||||||
|
|
||||||
preview_proxy_commands_status =
|
preview_proxy_commands_status =
|
||||||
|
|
|
@ -19,9 +19,7 @@ def on_shell(username, _pubkey, _ip, _port) do
|
||||||
def on_connect(username, ip, port, method) do
|
def on_connect(username, ip, port, method) do
|
||||||
Logger.debug(fn ->
|
Logger.debug(fn ->
|
||||||
"""
|
"""
|
||||||
Incoming SSH shell #{inspect(self())} requested for #{username} from #{inspect(ip)}:#{
|
Incoming SSH shell #{inspect(self())} requested for #{username} from #{inspect(ip)}:#{inspect(port)} using #{inspect(method)}
|
||||||
inspect(port)
|
|
||||||
} using #{inspect(method)}
|
|
||||||
"""
|
"""
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,140 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
"\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
|
"\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def check_simple_policy_tuples do
|
||||||
|
has_strings =
|
||||||
|
Config.get([:mrf_simple])
|
||||||
|
|> Enum.any?(fn {_, v} -> Enum.any?(v, &is_binary/1) end)
|
||||||
|
|
||||||
|
if has_strings do
|
||||||
|
Logger.warn("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using strings in the SimplePolicy configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :mrf_simple,
|
||||||
|
media_removal: ["instance.tld"],
|
||||||
|
media_nsfw: ["instance.tld"],
|
||||||
|
federated_timeline_removal: ["instance.tld"],
|
||||||
|
report_removal: ["instance.tld"],
|
||||||
|
reject: ["instance.tld"],
|
||||||
|
followers_only: ["instance.tld"],
|
||||||
|
accept: ["instance.tld"],
|
||||||
|
avatar_removal: ["instance.tld"],
|
||||||
|
banner_removal: ["instance.tld"],
|
||||||
|
reject_deletes: ["instance.tld"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Is now
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :mrf_simple,
|
||||||
|
media_removal: [{"instance.tld", "Reason for media removal"}],
|
||||||
|
media_nsfw: [{"instance.tld", "Reason for media nsfw"}],
|
||||||
|
federated_timeline_removal: [{"instance.tld", "Reason for federated timeline removal"}],
|
||||||
|
report_removal: [{"instance.tld", "Reason for report removal"}],
|
||||||
|
reject: [{"instance.tld", "Reason for reject"}],
|
||||||
|
followers_only: [{"instance.tld", "Reason for followers only"}],
|
||||||
|
accept: [{"instance.tld", "Reason for accept"}],
|
||||||
|
avatar_removal: [{"instance.tld", "Reason for avatar removal"}],
|
||||||
|
banner_removal: [{"instance.tld", "Reason for banner removal"}],
|
||||||
|
reject_deletes: [{"instance.tld", "Reason for reject deletes"}]
|
||||||
|
```
|
||||||
|
""")
|
||||||
|
|
||||||
|
new_config =
|
||||||
|
Config.get([:mrf_simple])
|
||||||
|
|> Enum.map(fn {k, v} ->
|
||||||
|
{k,
|
||||||
|
Enum.map(v, fn
|
||||||
|
{instance, reason} -> {instance, reason}
|
||||||
|
instance -> {instance, ""}
|
||||||
|
end)}
|
||||||
|
end)
|
||||||
|
|
||||||
|
Config.put([:mrf_simple], new_config)
|
||||||
|
|
||||||
|
:error
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_quarantined_instances_tuples do
|
||||||
|
has_strings = Config.get([:instance, :quarantined_instances]) |> Enum.any?(&is_binary/1)
|
||||||
|
|
||||||
|
if has_strings do
|
||||||
|
Logger.warn("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using strings in the quarantined_instances configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :instance,
|
||||||
|
quarantined_instances: ["instance.tld"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Is now
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :instance,
|
||||||
|
quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
|
||||||
|
```
|
||||||
|
""")
|
||||||
|
|
||||||
|
new_config =
|
||||||
|
Config.get([:instance, :quarantined_instances])
|
||||||
|
|> Enum.map(fn
|
||||||
|
{instance, reason} -> {instance, reason}
|
||||||
|
instance -> {instance, ""}
|
||||||
|
end)
|
||||||
|
|
||||||
|
Config.put([:instance, :quarantined_instances], new_config)
|
||||||
|
|
||||||
|
:error
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_transparency_exclusions_tuples do
|
||||||
|
has_strings = Config.get([:mrf, :transparency_exclusions]) |> Enum.any?(&is_binary/1)
|
||||||
|
|
||||||
|
if has_strings do
|
||||||
|
Logger.warn("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using strings in the transparency_exclusions configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :mrf,
|
||||||
|
transparency_exclusions: ["instance.tld"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Is now
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
config :pleroma, :mrf,
|
||||||
|
transparency_exclusions: [{"instance.tld", "Reason to exlude transparency"}]
|
||||||
|
```
|
||||||
|
""")
|
||||||
|
|
||||||
|
new_config =
|
||||||
|
Config.get([:mrf, :transparency_exclusions])
|
||||||
|
|> Enum.map(fn
|
||||||
|
{instance, reason} -> {instance, reason}
|
||||||
|
instance -> {instance, ""}
|
||||||
|
end)
|
||||||
|
|
||||||
|
Config.put([:mrf, :transparency_exclusions], new_config)
|
||||||
|
|
||||||
|
:error
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def check_hellthread_threshold do
|
def check_hellthread_threshold do
|
||||||
if Config.get([:mrf_hellthread, :threshold]) do
|
if Config.get([:mrf_hellthread, :threshold]) do
|
||||||
Logger.warn("""
|
Logger.warn("""
|
||||||
|
@ -34,19 +168,24 @@ def check_hellthread_threshold do
|
||||||
end
|
end
|
||||||
|
|
||||||
def warn do
|
def warn do
|
||||||
with :ok <- check_hellthread_threshold(),
|
[
|
||||||
:ok <- check_old_mrf_config(),
|
check_hellthread_threshold(),
|
||||||
:ok <- check_media_proxy_whitelist_config(),
|
check_old_mrf_config(),
|
||||||
:ok <- check_welcome_message_config(),
|
check_media_proxy_whitelist_config(),
|
||||||
:ok <- check_gun_pool_options(),
|
check_welcome_message_config(),
|
||||||
:ok <- check_activity_expiration_config(),
|
check_gun_pool_options(),
|
||||||
:ok <- check_remote_ip_plug_name(),
|
check_activity_expiration_config(),
|
||||||
:ok <- check_uploders_s3_public_endpoint() do
|
check_remote_ip_plug_name(),
|
||||||
:ok
|
check_uploders_s3_public_endpoint(),
|
||||||
else
|
check_old_chat_shoutbox(),
|
||||||
_ ->
|
check_quarantined_instances_tuples(),
|
||||||
:error
|
check_transparency_exclusions_tuples(),
|
||||||
end
|
check_simple_policy_tuples()
|
||||||
|
]
|
||||||
|
|> Enum.reduce(:ok, fn
|
||||||
|
:ok, :ok -> :ok
|
||||||
|
_, _ -> :error
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_welcome_message_config do
|
def check_welcome_message_config do
|
||||||
|
@ -215,4 +354,27 @@ def check_uploders_s3_public_endpoint do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec check_old_chat_shoutbox() :: :ok | nil
|
||||||
|
def check_old_chat_shoutbox do
|
||||||
|
instance_config = Pleroma.Config.get([:instance])
|
||||||
|
chat_config = Pleroma.Config.get([:chat]) || []
|
||||||
|
|
||||||
|
use_old_config =
|
||||||
|
Keyword.has_key?(instance_config, :chat_limit) or
|
||||||
|
Keyword.has_key?(chat_config, :enabled)
|
||||||
|
|
||||||
|
if use_old_config do
|
||||||
|
Logger.error("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using the old namespace for the Shoutbox configuration. You need to convert to the new namespace. e.g.,
|
||||||
|
\n* `config :pleroma, :chat, enabled` and `config :pleroma, :instance, chat_limit` are now equal to:
|
||||||
|
\n* `config :pleroma, :shout, enabled` and `config :pleroma, :shout, limit`
|
||||||
|
""")
|
||||||
|
|
||||||
|
:error
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Config.Loader do
|
defmodule Pleroma.Config.Loader do
|
||||||
|
# These modules are only being used as keys here (for equality check),
|
||||||
|
# so it's okay to use `Module.concat/1` to have the compiler ignore them.
|
||||||
@reject_keys [
|
@reject_keys [
|
||||||
Pleroma.Repo,
|
Module.concat(["Pleroma.Repo"]),
|
||||||
Pleroma.Web.Endpoint,
|
Module.concat(["Pleroma.Web.Endpoint"]),
|
||||||
:env,
|
:env,
|
||||||
:configurable_from_database,
|
:configurable_from_database,
|
||||||
:database,
|
:database,
|
||||||
|
|
|
@ -21,9 +21,7 @@ def warn do
|
||||||
"""
|
"""
|
||||||
!!!OBAN CONFIG WARNING!!!
|
!!!OBAN CONFIG WARNING!!!
|
||||||
You are using old workers in Oban crontab settings, which were removed.
|
You are using old workers in Oban crontab settings, which were removed.
|
||||||
Please, remove setting from crontab in your config file (prod.secret.exs): #{
|
Please, remove setting from crontab in your config file (prod.secret.exs): #{inspect(setting)}
|
||||||
inspect(setting)
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
|> Logger.warn()
|
|> Logger.warn()
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,10 @@ defmodule Pleroma.Config.TransferTask do
|
||||||
|
|
||||||
@type env() :: :test | :benchmark | :dev | :prod
|
@type env() :: :test | :benchmark | :dev | :prod
|
||||||
|
|
||||||
@reboot_time_keys [
|
defp reboot_time_keys,
|
||||||
|
do: [
|
||||||
{:pleroma, :hackney_pools},
|
{:pleroma, :hackney_pools},
|
||||||
{:pleroma, :chat},
|
{:pleroma, :shout},
|
||||||
{:pleroma, Oban},
|
{:pleroma, Oban},
|
||||||
{:pleroma, :rate_limit},
|
{:pleroma, :rate_limit},
|
||||||
{:pleroma, :markup},
|
{:pleroma, :markup},
|
||||||
|
@ -24,7 +25,8 @@ defmodule Pleroma.Config.TransferTask do
|
||||||
{:pleroma, :connections_pool}
|
{:pleroma, :connections_pool}
|
||||||
]
|
]
|
||||||
|
|
||||||
@reboot_time_subkeys [
|
defp reboot_time_subkeys,
|
||||||
|
do: [
|
||||||
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
||||||
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
||||||
{:pleroma, :instance, [:upload_limit]},
|
{:pleroma, :instance, [:upload_limit]},
|
||||||
|
@ -146,9 +148,7 @@ defp update({group, key, value, merged}) do
|
||||||
rescue
|
rescue
|
||||||
error ->
|
error ->
|
||||||
error_msg =
|
error_msg =
|
||||||
"updating env causes error, group: #{inspect(group)}, key: #{inspect(key)}, value: #{
|
"updating env causes error, group: #{inspect(group)}, key: #{inspect(key)}, value: #{inspect(value)} error: #{inspect(error)}"
|
||||||
inspect(value)
|
|
||||||
} error: #{inspect(error)}"
|
|
||||||
|
|
||||||
Logger.warn(error_msg)
|
Logger.warn(error_msg)
|
||||||
|
|
||||||
|
@ -165,12 +165,12 @@ def pleroma_need_restart?(group, key, value) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp group_and_key_need_reboot?(group, key) do
|
defp group_and_key_need_reboot?(group, key) do
|
||||||
Enum.any?(@reboot_time_keys, fn {g, k} -> g == group and k == key end)
|
Enum.any?(reboot_time_keys(), fn {g, k} -> g == group and k == key end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp group_and_subkey_need_reboot?(group, key, value) do
|
defp group_and_subkey_need_reboot?(group, key, value) do
|
||||||
Keyword.keyword?(value) and
|
Keyword.keyword?(value) and
|
||||||
Enum.any?(@reboot_time_subkeys, fn {g, k, subkeys} ->
|
Enum.any?(reboot_time_subkeys(), fn {g, k, subkeys} ->
|
||||||
g == group and k == key and
|
g == group and k == key and
|
||||||
Enum.any?(Keyword.keys(value), &(&1 in subkeys))
|
Enum.any?(Keyword.keys(value), &(&1 in subkeys))
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -27,6 +27,4 @@ defmodule Pleroma.Constants do
|
||||||
do:
|
do:
|
||||||
~w(index.html robots.txt static static-fe finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc embed.js embed.css)
|
~w(index.html robots.txt static static-fe finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc embed.js embed.css)
|
||||||
)
|
)
|
||||||
|
|
||||||
def as_local_public, do: Pleroma.Web.base_url() <> "/#Public"
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
mute: 2,
|
mute: 2,
|
||||||
reblog_mute: 3,
|
reblog_mute: 3,
|
||||||
notification_mute: 4,
|
notification_mute: 4,
|
||||||
inverse_subscription: 5
|
inverse_subscription: 5,
|
||||||
|
suggestion_dismiss: 6
|
||||||
)
|
)
|
||||||
|
|
||||||
defenum(Pleroma.FollowingRelationship.State,
|
defenum(Pleroma.FollowingRelationship.State,
|
||||||
|
|
|
@ -13,21 +13,33 @@ def cast(object) when is_binary(object) do
|
||||||
cast([object])
|
cast([object])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cast(object) when is_map(object) do
|
||||||
|
case ObjectID.cast(object) do
|
||||||
|
{:ok, data} -> {:ok, [data]}
|
||||||
|
_ -> :error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cast(data) when is_list(data) do
|
def cast(data) when is_list(data) do
|
||||||
|
data =
|
||||||
data
|
data
|
||||||
|> Enum.reduce_while({:ok, []}, fn element, {:ok, list} ->
|
|> Enum.reduce_while([], fn element, list ->
|
||||||
case ObjectID.cast(element) do
|
case ObjectID.cast(element) do
|
||||||
{:ok, id} ->
|
{:ok, id} ->
|
||||||
{:cont, {:ok, [id | list]}}
|
{:cont, [id | list]}
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
{:halt, :error}
|
{:cont, list}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|> Enum.sort()
|
||||||
|
|> Enum.uniq()
|
||||||
|
|
||||||
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast(_) do
|
def cast(data) do
|
||||||
:error
|
{:error, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def dump(data) do
|
def dump(data) do
|
||||||
|
|
|
@ -73,7 +73,7 @@ def report(to, reporter, account, statuses, comment) do
|
||||||
#{comment_html}
|
#{comment_html}
|
||||||
#{statuses_html}
|
#{statuses_html}
|
||||||
<p>
|
<p>
|
||||||
<a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/reports/index">View Reports in AdminFE</a>
|
<a href="#{Pleroma.Web.Endpoint.url()}/pleroma/admin/#/reports/index">View Reports in AdminFE</a>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
new()
|
new()
|
||||||
|
@ -87,7 +87,7 @@ def new_unapproved_registration(to, account) do
|
||||||
html_body = """
|
html_body = """
|
||||||
<p>New account for review: <a href="#{account.ap_id}">@#{account.nickname}</a></p>
|
<p>New account for review: <a href="#{account.ap_id}">@#{account.nickname}</a></p>
|
||||||
<blockquote>#{HTML.strip_tags(account.registration_reason)}</blockquote>
|
<blockquote>#{HTML.strip_tags(account.registration_reason)}</blockquote>
|
||||||
<a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
<a href="#{Pleroma.Web.Endpoint.url()}/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
new()
|
new()
|
||||||
|
|
|
@ -5,15 +5,22 @@
|
||||||
defmodule Pleroma.Emails.UserEmail do
|
defmodule Pleroma.Emails.UserEmail do
|
||||||
@moduledoc "User emails"
|
@moduledoc "User emails"
|
||||||
|
|
||||||
use Phoenix.Swoosh, view: Pleroma.Web.EmailView, layout: {Pleroma.Web.LayoutView, :email}
|
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.Endpoint
|
alias Pleroma.Web.Endpoint
|
||||||
alias Pleroma.Web.Router
|
alias Pleroma.Web.Router
|
||||||
|
|
||||||
|
import Swoosh.Email
|
||||||
|
import Phoenix.Swoosh, except: [render_body: 3]
|
||||||
import Pleroma.Config.Helpers, only: [instance_name: 0, sender: 0]
|
import Pleroma.Config.Helpers, only: [instance_name: 0, sender: 0]
|
||||||
|
|
||||||
|
def render_body(email, template, assigns \\ %{}) do
|
||||||
|
email
|
||||||
|
|> put_new_layout({Pleroma.Web.LayoutView, :email})
|
||||||
|
|> put_new_view(Pleroma.Web.EmailView)
|
||||||
|
|> Phoenix.Swoosh.render_body(template, assigns)
|
||||||
|
end
|
||||||
|
|
||||||
defp recipient(email, nil), do: email
|
defp recipient(email, nil), do: email
|
||||||
defp recipient(email, name), do: {name, email}
|
defp recipient(email, name), do: {name, email}
|
||||||
defp recipient(%User{} = user), do: recipient(user.email, user.name)
|
defp recipient(%User{} = user), do: recipient(user.email, user.name)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
defmodule Pleroma.Emoji.Formatter do
|
defmodule Pleroma.Emoji.Formatter do
|
||||||
alias Pleroma.Emoji
|
alias Pleroma.Emoji
|
||||||
alias Pleroma.HTML
|
alias Pleroma.HTML
|
||||||
alias Pleroma.Web
|
alias Pleroma.Web.Endpoint
|
||||||
alias Pleroma.Web.MediaProxy
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
def emojify(text) do
|
def emojify(text) do
|
||||||
|
@ -44,7 +44,7 @@ def get_emoji_map(text) when is_binary(text) do
|
||||||
Emoji.get_all()
|
Emoji.get_all()
|
||||||
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|
||||||
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
|
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
|
||||||
Map.put(acc, name, to_string(URI.merge(Web.base_url(), file)))
|
Map.put(acc, name, to_string(URI.merge(Endpoint.url(), file)))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,7 @@ def load do
|
||||||
|
|
||||||
if not Enum.empty?(files) do
|
if not Enum.empty?(files) do
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
"Found files in the emoji folder. These will be ignored, please move them to a subdirectory\nFound files: #{
|
"Found files in the emoji folder. These will be ignored, please move them to a subdirectory\nFound files: #{Enum.join(files, ", ")}"
|
||||||
Enum.join(files, ", ")
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,6 +103,7 @@ defp load_pack(pack_dir, emoji_groups) do
|
||||||
pack_file = Path.join(pack_dir, "pack.json")
|
pack_file = Path.join(pack_dir, "pack.json")
|
||||||
|
|
||||||
if File.exists?(pack_file) do
|
if File.exists?(pack_file) do
|
||||||
|
Logger.info("Loading emoji pack from JSON: #{pack_file}")
|
||||||
contents = Jason.decode!(File.read!(pack_file))
|
contents = Jason.decode!(File.read!(pack_file))
|
||||||
|
|
||||||
contents["files"]
|
contents["files"]
|
||||||
|
@ -117,14 +116,13 @@ defp load_pack(pack_dir, emoji_groups) do
|
||||||
emoji_txt = Path.join(pack_dir, "emoji.txt")
|
emoji_txt = Path.join(pack_dir, "emoji.txt")
|
||||||
|
|
||||||
if File.exists?(emoji_txt) do
|
if File.exists?(emoji_txt) do
|
||||||
|
Logger.info("Loading emoji pack from emoji.txt: #{emoji_txt}")
|
||||||
load_from_file(emoji_txt, emoji_groups)
|
load_from_file(emoji_txt, emoji_groups)
|
||||||
else
|
else
|
||||||
extensions = Config.get([:emoji, :pack_extensions])
|
extensions = Config.get([:emoji, :pack_extensions])
|
||||||
|
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"No emoji.txt found for pack \"#{pack_name}\", assuming all #{
|
"No emoji.txt found for pack \"#{pack_name}\", assuming all #{Enum.join(extensions, ", ")} files are emoji"
|
||||||
Enum.join(extensions, ", ")
|
|
||||||
} files are emoji"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
make_shortcode_to_file_map(pack_dir, extensions)
|
make_shortcode_to_file_map(pack_dir, extensions)
|
||||||
|
|
|
@ -62,7 +62,7 @@ def mention_handler("@" <> nickname, buffer, opts, acc) do
|
||||||
|
|
||||||
def hashtag_handler("#" <> tag = tag_text, _buffer, _opts, acc) do
|
def hashtag_handler("#" <> tag = tag_text, _buffer, _opts, acc) do
|
||||||
tag = String.downcase(tag)
|
tag = String.downcase(tag)
|
||||||
url = "#{Pleroma.Web.base_url()}/tag/#{tag}"
|
url = "#{Pleroma.Web.Endpoint.url()}/tag/#{tag}"
|
||||||
|
|
||||||
link =
|
link =
|
||||||
Phoenix.HTML.Tag.content_tag(:a, tag_text,
|
Phoenix.HTML.Tag.content_tag(:a, tag_text,
|
||||||
|
|
|
@ -11,9 +11,7 @@ defmodule Pleroma.Gun do
|
||||||
@callback await(pid(), reference()) :: {:response, :fin, 200, []}
|
@callback await(pid(), reference()) :: {:response, :fin, 200, []}
|
||||||
@callback set_owner(pid(), pid()) :: :ok
|
@callback set_owner(pid(), pid()) :: :ok
|
||||||
|
|
||||||
@api Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
|
defp api, do: Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
|
||||||
|
|
||||||
defp api, do: @api
|
|
||||||
|
|
||||||
def open(host, port, opts), do: api().open(host, port, opts)
|
def open(host, port, opts), do: api().open(host, port, opts)
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,7 @@ defp do_open(uri, %{proxy: {proxy_host, proxy_port}} = opts) do
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
"Opening proxied connection to #{compose_uri_log(uri)} failed with error #{
|
"Opening proxied connection to #{compose_uri_log(uri)} failed with error #{inspect(error)}"
|
||||||
inspect(error)
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
error
|
error
|
||||||
|
@ -93,9 +91,7 @@ defp do_open(uri, %{proxy: {proxy_type, proxy_host, proxy_port}} = opts) do
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
"Opening socks proxied connection to #{compose_uri_log(uri)} failed with error #{
|
"Opening socks proxied connection to #{compose_uri_log(uri)} failed with error #{inspect(error)}"
|
||||||
inspect(error)
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
error
|
error
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
defmodule Pleroma.Gun.ConnectionPool.Reclaimer do
|
defmodule Pleroma.Gun.ConnectionPool.Reclaimer do
|
||||||
use GenServer, restart: :temporary
|
use GenServer, restart: :temporary
|
||||||
|
|
||||||
@registry Pleroma.Gun.ConnectionPool
|
defp registry, do: Pleroma.Gun.ConnectionPool
|
||||||
|
|
||||||
def start_monitor do
|
def start_monitor do
|
||||||
pid =
|
pid =
|
||||||
case :gen_server.start(__MODULE__, [], name: {:via, Registry, {@registry, "reclaimer"}}) do
|
case :gen_server.start(__MODULE__, [], name: {:via, Registry, {registry(), "reclaimer"}}) do
|
||||||
{:ok, pid} ->
|
{:ok, pid} ->
|
||||||
pid
|
pid
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ def handle_continue(:reclaim, _) do
|
||||||
# {worker_pid, crf, last_reference} end)
|
# {worker_pid, crf, last_reference} end)
|
||||||
unused_conns =
|
unused_conns =
|
||||||
Registry.select(
|
Registry.select(
|
||||||
@registry,
|
registry(),
|
||||||
[
|
[
|
||||||
{{:_, :"$1", {:_, :"$2", :"$3", :"$4"}}, [{:==, :"$2", []}], [{{:"$1", :"$3", :"$4"}}]}
|
{{:_, :"$1", {:_, :"$2", :"$3", :"$4"}}, [{:==, :"$2", []}], [{{:"$1", :"$3", :"$4"}}]}
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,10 +6,10 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
||||||
alias Pleroma.Gun
|
alias Pleroma.Gun
|
||||||
use GenServer, restart: :temporary
|
use GenServer, restart: :temporary
|
||||||
|
|
||||||
@registry Pleroma.Gun.ConnectionPool
|
defp registry, do: Pleroma.Gun.ConnectionPool
|
||||||
|
|
||||||
def start_link([key | _] = opts) do
|
def start_link([key | _] = opts) do
|
||||||
GenServer.start_link(__MODULE__, opts, name: {:via, Registry, {@registry, key}})
|
GenServer.start_link(__MODULE__, opts, name: {:via, Registry, {registry(), key}})
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
@ -24,7 +24,7 @@ def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
|
||||||
time = :erlang.monotonic_time(:millisecond)
|
time = :erlang.monotonic_time(:millisecond)
|
||||||
|
|
||||||
{_, _} =
|
{_, _} =
|
||||||
Registry.update_value(@registry, key, fn _ ->
|
Registry.update_value(registry(), key, fn _ ->
|
||||||
{conn_pid, [client_pid], 1, time}
|
{conn_pid, [client_pid], 1, time}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} =
|
||||||
time = :erlang.monotonic_time(:millisecond)
|
time = :erlang.monotonic_time(:millisecond)
|
||||||
|
|
||||||
{{conn_pid, used_by, _, _}, _} =
|
{{conn_pid, used_by, _, _}, _} =
|
||||||
Registry.update_value(@registry, key, fn {conn_pid, used_by, crf, last_reference} ->
|
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}
|
{conn_pid, [client_pid | used_by], crf(time - last_reference, crf), time}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} =
|
||||||
@impl true
|
@impl true
|
||||||
def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) do
|
def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) do
|
||||||
{{_conn_pid, used_by, _crf, _last_reference}, _} =
|
{{_conn_pid, used_by, _crf, _last_reference}, _} =
|
||||||
Registry.update_value(@registry, key, fn {conn_pid, used_by, crf, last_reference} ->
|
Registry.update_value(registry(), key, fn {conn_pid, used_by, crf, last_reference} ->
|
||||||
{conn_pid, List.delete(used_by, client_pid), crf, last_reference}
|
{conn_pid, List.delete(used_by, client_pid), crf, last_reference}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -49,31 +49,6 @@ def filter_tags(html, scrubber) do
|
||||||
def filter_tags(html), do: filter_tags(html, nil)
|
def filter_tags(html), do: filter_tags(html, nil)
|
||||||
def strip_tags(html), do: filter_tags(html, FastSanitize.Sanitizer.StripTags)
|
def strip_tags(html), do: filter_tags(html, FastSanitize.Sanitizer.StripTags)
|
||||||
|
|
||||||
def get_cached_scrubbed_html_for_activity(
|
|
||||||
content,
|
|
||||||
scrubbers,
|
|
||||||
activity,
|
|
||||||
key \\ "",
|
|
||||||
callback \\ fn x -> x end
|
|
||||||
) do
|
|
||||||
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
|
|
||||||
|
|
||||||
@cachex.fetch!(:scrubber_cache, key, fn _key ->
|
|
||||||
object = Pleroma.Object.normalize(activity, fetch: false)
|
|
||||||
ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_cached_stripped_html_for_activity(content, activity, key) do
|
|
||||||
get_cached_scrubbed_html_for_activity(
|
|
||||||
content,
|
|
||||||
FastSanitize.Sanitizer.StripTags,
|
|
||||||
activity,
|
|
||||||
key,
|
|
||||||
&HtmlEntities.decode/1
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_scrubbed_html(
|
def ensure_scrubbed_html(
|
||||||
content,
|
content,
|
||||||
scrubbers,
|
scrubbers,
|
||||||
|
@ -92,16 +67,6 @@ def ensure_scrubbed_html(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
|
|
||||||
generate_scrubber_signature([scrubber])
|
|
||||||
end
|
|
||||||
|
|
||||||
defp generate_scrubber_signature(scrubbers) do
|
|
||||||
Enum.reduce(scrubbers, "", fn scrubber, signature ->
|
|
||||||
"#{signature}#{to_string(scrubber)}"
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
def extract_first_external_url_from_object(%{data: %{"content" => content}} = object)
|
def extract_first_external_url_from_object(%{data: %{"content" => content}} = object)
|
||||||
when is_binary(content) do
|
when is_binary(content) do
|
||||||
unless object.data["fake"] do
|
unless object.data["fake"] do
|
||||||
|
|
|
@ -54,8 +54,8 @@ def pool_timeout(pool) do
|
||||||
Config.get([:pools, pool, :recv_timeout], default)
|
Config.get([:pools, pool, :recv_timeout], default)
|
||||||
end
|
end
|
||||||
|
|
||||||
@prefix Pleroma.Gun.ConnectionPool
|
|
||||||
def limiter_setup do
|
def limiter_setup do
|
||||||
|
prefix = Pleroma.Gun.ConnectionPool
|
||||||
wait = Config.get([:connections_pool, :connection_acquisition_wait])
|
wait = Config.get([:connections_pool, :connection_acquisition_wait])
|
||||||
retries = Config.get([:connections_pool, :connection_acquisition_retries])
|
retries = Config.get([:connections_pool, :connection_acquisition_retries])
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ def limiter_setup do
|
||||||
max_waiting = Keyword.get(opts, :max_waiting, 10)
|
max_waiting = Keyword.get(opts, :max_waiting, 10)
|
||||||
|
|
||||||
result =
|
result =
|
||||||
ConcurrentLimiter.new(:"#{@prefix}.#{name}", max_running, max_waiting,
|
ConcurrentLimiter.new(:"#{prefix}.#{name}", max_running, max_waiting,
|
||||||
wait: wait,
|
wait: wait,
|
||||||
max_retries: retries
|
max_retries: retries
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
defmodule Pleroma.HTTP.WebPush do
|
defmodule Pleroma.HTTP.WebPush do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
def post(url, payload, headers) do
|
def post(url, payload, headers, options \\ []) do
|
||||||
list_headers = Map.to_list(headers)
|
list_headers = Map.to_list(headers)
|
||||||
Pleroma.HTTP.post(url, payload, list_headers)
|
Pleroma.HTTP.post(url, payload, list_headers, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,13 +5,18 @@
|
||||||
defmodule Pleroma.Instances do
|
defmodule Pleroma.Instances do
|
||||||
@moduledoc "Instances context."
|
@moduledoc "Instances context."
|
||||||
|
|
||||||
@adapter Pleroma.Instances.Instance
|
alias Pleroma.Instances.Instance
|
||||||
|
|
||||||
defdelegate filter_reachable(urls_or_hosts), to: @adapter
|
def filter_reachable(urls_or_hosts), do: Instance.filter_reachable(urls_or_hosts)
|
||||||
defdelegate reachable?(url_or_host), to: @adapter
|
|
||||||
defdelegate set_reachable(url_or_host), to: @adapter
|
def reachable?(url_or_host), do: Instance.reachable?(url_or_host)
|
||||||
defdelegate set_unreachable(url_or_host, unreachable_since \\ nil), to: @adapter
|
|
||||||
defdelegate get_consistently_unreachable(), to: @adapter
|
def set_reachable(url_or_host), do: Instance.set_reachable(url_or_host)
|
||||||
|
|
||||||
|
def set_unreachable(url_or_host, unreachable_since \\ nil),
|
||||||
|
do: Instance.set_unreachable(url_or_host, unreachable_since)
|
||||||
|
|
||||||
|
def get_consistently_unreachable, do: Instance.get_consistently_unreachable()
|
||||||
|
|
||||||
def set_consistently_unreachable(url_or_host),
|
def set_consistently_unreachable(url_or_host),
|
||||||
do: set_unreachable(url_or_host, reachability_datetime_threshold())
|
do: set_unreachable(url_or_host, reachability_datetime_threshold())
|
||||||
|
|
|
@ -8,6 +8,8 @@ defmodule Pleroma.Instances.Instance do
|
||||||
alias Pleroma.Instances
|
alias Pleroma.Instances
|
||||||
alias Pleroma.Instances.Instance
|
alias Pleroma.Instances.Instance
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Workers.BackgroundWorker
|
||||||
|
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
|
|
||||||
|
@ -195,4 +197,24 @@ defp scrape_favicon(%URI{} = instance_uri) do
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes all users from an instance in a background task, thus also deleting
|
||||||
|
all of those users' activities and notifications.
|
||||||
|
"""
|
||||||
|
def delete_users_and_activities(host) when is_binary(host) do
|
||||||
|
BackgroundWorker.enqueue("delete_instance", %{"host" => host})
|
||||||
|
end
|
||||||
|
|
||||||
|
def perform(:delete_instance, host) when is_binary(host) do
|
||||||
|
User.Query.build(%{nickname: "@#{host}"})
|
||||||
|
|> Repo.chunk_stream(100, :batches)
|
||||||
|
|> Stream.each(fn users ->
|
||||||
|
users
|
||||||
|
|> Enum.each(fn user ->
|
||||||
|
User.perform(:delete, user)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Maintenance do
|
||||||
def vacuum(args) do
|
def vacuum(args) do
|
||||||
case args do
|
case args do
|
||||||
"analyze" ->
|
"analyze" ->
|
||||||
Logger.info("Runnning VACUUM ANALYZE.")
|
Logger.info("Running VACUUM ANALYZE.")
|
||||||
|
|
||||||
Repo.query!(
|
Repo.query!(
|
||||||
"vacuum analyze;",
|
"vacuum analyze;",
|
||||||
|
@ -18,7 +18,7 @@ def vacuum(args) do
|
||||||
)
|
)
|
||||||
|
|
||||||
"full" ->
|
"full" ->
|
||||||
Logger.info("Runnning VACUUM FULL.")
|
Logger.info("Running VACUUM FULL.")
|
||||||
|
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
"Re-packing your entire database may take a while and will consume extra disk space during the process."
|
"Re-packing your entire database may take a while and will consume extra disk space during the process."
|
||||||
|
|
|
@ -12,4 +12,10 @@ def put_if_present(map, key, value, value_function \\ &{:ok, &1}) when is_map(ma
|
||||||
_ -> map
|
_ -> map
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def safe_put_in(data, keys, value) when is_map(data) and is_list(keys) do
|
||||||
|
Kernel.put_in(data, keys, value)
|
||||||
|
rescue
|
||||||
|
_ -> data
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -338,6 +338,26 @@ def get_log_entry_message(%ModerationLog{
|
||||||
"@#{actor_nickname} approved users: #{users_to_nicknames_string(users)}"
|
"@#{actor_nickname} approved users: #{users_to_nicknames_string(users)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_log_entry_message(%ModerationLog{
|
||||||
|
data: %{
|
||||||
|
"actor" => %{"nickname" => actor_nickname},
|
||||||
|
"action" => "add_suggestion",
|
||||||
|
"subject" => users
|
||||||
|
}
|
||||||
|
}) do
|
||||||
|
"@#{actor_nickname} added suggested users: #{users_to_nicknames_string(users)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_log_entry_message(%ModerationLog{
|
||||||
|
data: %{
|
||||||
|
"actor" => %{"nickname" => actor_nickname},
|
||||||
|
"action" => "remove_suggestion",
|
||||||
|
"subject" => users
|
||||||
|
}
|
||||||
|
}) do
|
||||||
|
"@#{actor_nickname} removed suggested users: #{users_to_nicknames_string(users)}"
|
||||||
|
end
|
||||||
|
|
||||||
def get_log_entry_message(%ModerationLog{
|
def get_log_entry_message(%ModerationLog{
|
||||||
data: %{
|
data: %{
|
||||||
"actor" => %{"nickname" => actor_nickname},
|
"actor" => %{"nickname" => actor_nickname},
|
||||||
|
@ -481,9 +501,7 @@ def get_log_entry_message(%ModerationLog{
|
||||||
"visibility" => visibility
|
"visibility" => visibility
|
||||||
}
|
}
|
||||||
}) do
|
}) do
|
||||||
"@#{actor_nickname} updated status ##{subject_id}, set sensitive: '#{sensitive}', visibility: '#{
|
"@#{actor_nickname} updated status ##{subject_id}, set sensitive: '#{sensitive}', visibility: '#{visibility}'"
|
||||||
visibility
|
|
||||||
}'"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_log_entry_message(%ModerationLog{
|
def get_log_entry_message(%ModerationLog{
|
||||||
|
@ -523,9 +541,7 @@ def get_log_entry_message(%ModerationLog{
|
||||||
"subject" => subjects
|
"subject" => subjects
|
||||||
}
|
}
|
||||||
}) do
|
}) do
|
||||||
"@#{actor_nickname} re-sent confirmation email for users: #{
|
"@#{actor_nickname} re-sent confirmation email for users: #{users_to_nicknames_string(subjects)}"
|
||||||
users_to_nicknames_string(subjects)
|
|
||||||
}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_log_entry_message(%ModerationLog{
|
def get_log_entry_message(%ModerationLog{
|
||||||
|
|
|
@ -72,6 +72,7 @@ def unread_notifications_count(%User{id: user_id}) do
|
||||||
pleroma:emoji_reaction
|
pleroma:emoji_reaction
|
||||||
pleroma:report
|
pleroma:report
|
||||||
reblog
|
reblog
|
||||||
|
poll
|
||||||
}
|
}
|
||||||
|
|
||||||
def changeset(%Notification{} = notification, attrs) do
|
def changeset(%Notification{} = notification, attrs) do
|
||||||
|
@ -127,6 +128,7 @@ def for_user_query(user, opts \\ %{}) do
|
||||||
|> where([user_actor: user_actor], user_actor.is_active)
|
|> where([user_actor: user_actor], user_actor.is_active)
|
||||||
|> exclude_notification_muted(user, exclude_notification_muted_opts)
|
|> exclude_notification_muted(user, exclude_notification_muted_opts)
|
||||||
|> exclude_blocked(user, exclude_blocked_opts)
|
|> exclude_blocked(user, exclude_blocked_opts)
|
||||||
|
|> exclude_blockers(user)
|
||||||
|> exclude_filtered(user)
|
|> exclude_filtered(user)
|
||||||
|> exclude_visibility(opts)
|
|> exclude_visibility(opts)
|
||||||
end
|
end
|
||||||
|
@ -140,6 +142,17 @@ defp exclude_blocked(query, user, opts) do
|
||||||
|> FollowingRelationship.keep_following_or_not_domain_blocked(user)
|
|> FollowingRelationship.keep_following_or_not_domain_blocked(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp exclude_blockers(query, user) do
|
||||||
|
if Pleroma.Config.get([:activitypub, :blockers_visible]) == true do
|
||||||
|
query
|
||||||
|
else
|
||||||
|
blocker_ap_ids = User.incoming_relationships_ungrouped_ap_ids(user, [:block])
|
||||||
|
|
||||||
|
query
|
||||||
|
|> where([n, a], a.actor not in ^blocker_ap_ids)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp exclude_notification_muted(query, _, %{@include_muted_option => true}) do
|
defp exclude_notification_muted(query, _, %{@include_muted_option => true}) do
|
||||||
query
|
query
|
||||||
end
|
end
|
||||||
|
@ -379,7 +392,7 @@ defp do_create_notifications(%Activity{} = activity, options) do
|
||||||
notifications =
|
notifications =
|
||||||
Enum.map(potential_receivers, fn user ->
|
Enum.map(potential_receivers, fn user ->
|
||||||
do_send = do_send && user in enabled_receivers
|
do_send = do_send && user in enabled_receivers
|
||||||
create_notification(activity, user, do_send)
|
create_notification(activity, user, do_send: do_send)
|
||||||
end)
|
end)
|
||||||
|> Enum.reject(&is_nil/1)
|
|> Enum.reject(&is_nil/1)
|
||||||
|
|
||||||
|
@ -435,15 +448,18 @@ defp type_from_activity_object(%{data: %{"type" => "Create"}} = activity) do
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO move to sql, too.
|
# TODO move to sql, too.
|
||||||
def create_notification(%Activity{} = activity, %User{} = user, do_send \\ true) do
|
def create_notification(%Activity{} = activity, %User{} = user, opts \\ []) do
|
||||||
unless skip?(activity, user) do
|
do_send = Keyword.get(opts, :do_send, true)
|
||||||
|
type = Keyword.get(opts, :type, type_from_activity(activity))
|
||||||
|
|
||||||
|
unless skip?(activity, user, opts) do
|
||||||
{:ok, %{notification: notification}} =
|
{:ok, %{notification: notification}} =
|
||||||
Multi.new()
|
Multi.new()
|
||||||
|> Multi.insert(:notification, %Notification{
|
|> Multi.insert(:notification, %Notification{
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
activity: activity,
|
activity: activity,
|
||||||
seen: mark_as_read?(activity, user),
|
seen: mark_as_read?(activity, user),
|
||||||
type: type_from_activity(activity)
|
type: type
|
||||||
})
|
})
|
||||||
|> Marker.multi_set_last_read_id(user, "notifications")
|
|> Marker.multi_set_last_read_id(user, "notifications")
|
||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|
@ -457,6 +473,28 @@ def create_notification(%Activity{} = activity, %User{} = user, do_send \\ true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_poll_notifications(%Activity{} = activity) do
|
||||||
|
with %Object{data: %{"type" => "Question", "actor" => actor} = data} <-
|
||||||
|
Object.normalize(activity) do
|
||||||
|
voters =
|
||||||
|
case data do
|
||||||
|
%{"voters" => voters} when is_list(voters) -> voters
|
||||||
|
_ -> []
|
||||||
|
end
|
||||||
|
|
||||||
|
notifications =
|
||||||
|
Enum.reduce([actor | voters], [], fn ap_id, acc ->
|
||||||
|
with %User{local: true} = user <- User.get_by_ap_id(ap_id) do
|
||||||
|
[create_notification(activity, user, type: "poll") | acc]
|
||||||
|
else
|
||||||
|
_ -> acc
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
{:ok, notifications}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Returns a tuple with 2 elements:
|
Returns a tuple with 2 elements:
|
||||||
{notification-enabled receivers, currently disabled receivers (blocking / [thread] muting)}
|
{notification-enabled receivers, currently disabled receivers (blocking / [thread] muting)}
|
||||||
|
@ -572,8 +610,10 @@ def exclude_thread_muter_ap_ids(ap_ids, %Activity{} = activity) do
|
||||||
Enum.uniq(ap_ids) -- thread_muter_ap_ids
|
Enum.uniq(ap_ids) -- thread_muter_ap_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec skip?(Activity.t(), User.t()) :: boolean()
|
def skip?(activity, user, opts \\ [])
|
||||||
def skip?(%Activity{} = activity, %User{} = user) do
|
|
||||||
|
@spec skip?(Activity.t(), User.t(), Keyword.t()) :: boolean()
|
||||||
|
def skip?(%Activity{} = activity, %User{} = user, opts) do
|
||||||
[
|
[
|
||||||
:self,
|
:self,
|
||||||
:invisible,
|
:invisible,
|
||||||
|
@ -581,17 +621,21 @@ def skip?(%Activity{} = activity, %User{} = user) do
|
||||||
:recently_followed,
|
:recently_followed,
|
||||||
:filtered
|
:filtered
|
||||||
]
|
]
|
||||||
|> Enum.find(&skip?(&1, activity, user))
|
|> Enum.find(&skip?(&1, activity, user, opts))
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(_, _), do: false
|
def skip?(_activity, _user, _opts), do: false
|
||||||
|
|
||||||
@spec skip?(atom(), Activity.t(), User.t()) :: boolean()
|
@spec skip?(atom(), Activity.t(), User.t(), Keyword.t()) :: boolean()
|
||||||
def skip?(:self, %Activity{} = activity, %User{} = user) do
|
def skip?(:self, %Activity{} = activity, %User{} = user, opts) do
|
||||||
activity.data["actor"] == user.ap_id
|
cond do
|
||||||
|
opts[:type] == "poll" -> false
|
||||||
|
activity.data["actor"] == user.ap_id -> true
|
||||||
|
true -> false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(:invisible, %Activity{} = activity, _) do
|
def skip?(:invisible, %Activity{} = activity, _user, _opts) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
user = User.get_cached_by_ap_id(actor)
|
user = User.get_cached_by_ap_id(actor)
|
||||||
User.invisible?(user)
|
User.invisible?(user)
|
||||||
|
@ -600,15 +644,27 @@ def skip?(:invisible, %Activity{} = activity, _) do
|
||||||
def skip?(
|
def skip?(
|
||||||
:block_from_strangers,
|
:block_from_strangers,
|
||||||
%Activity{} = activity,
|
%Activity{} = activity,
|
||||||
%User{notification_settings: %{block_from_strangers: true}} = user
|
%User{notification_settings: %{block_from_strangers: true}} = user,
|
||||||
|
opts
|
||||||
) do
|
) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
follower = User.get_cached_by_ap_id(actor)
|
follower = User.get_cached_by_ap_id(actor)
|
||||||
!User.following?(follower, user)
|
|
||||||
|
cond do
|
||||||
|
opts[:type] == "poll" -> false
|
||||||
|
user.ap_id == actor -> false
|
||||||
|
!User.following?(follower, user) -> true
|
||||||
|
true -> false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# To do: consider defining recency in hours and checking FollowingRelationship with a single SQL
|
# To do: consider defining recency in hours and checking FollowingRelationship with a single SQL
|
||||||
def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity, %User{} = user) do
|
def skip?(
|
||||||
|
:recently_followed,
|
||||||
|
%Activity{data: %{"type" => "Follow"}} = activity,
|
||||||
|
%User{} = user,
|
||||||
|
_opts
|
||||||
|
) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
|
|
||||||
Notification.for_user(user)
|
Notification.for_user(user)
|
||||||
|
@ -618,9 +674,10 @@ def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity,
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(:filtered, %{data: %{"type" => type}}, _) when type in ["Follow", "Move"], do: false
|
def skip?(:filtered, %{data: %{"type" => type}}, _user, _opts) when type in ["Follow", "Move"],
|
||||||
|
do: false
|
||||||
|
|
||||||
def skip?(:filtered, activity, user) do
|
def skip?(:filtered, activity, user, _opts) do
|
||||||
object = Object.normalize(activity, fetch: false)
|
object = Object.normalize(activity, fetch: false)
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
|
@ -638,7 +695,7 @@ def skip?(:filtered, activity, user) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(_, _, _), do: false
|
def skip?(_type, _activity, _user, _opts), do: false
|
||||||
|
|
||||||
def mark_as_read?(activity, target_user) do
|
def mark_as_read?(activity, target_user) do
|
||||||
user = Activity.user_actor(activity)
|
user = Activity.user_actor(activity)
|
||||||
|
|
|
@ -366,7 +366,7 @@ def update_data(%Object{data: data} = object, attrs \\ %{}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def local?(%Object{data: %{"id" => id}}) do
|
def local?(%Object{data: %{"id" => id}}) do
|
||||||
String.starts_with?(id, Pleroma.Web.base_url() <> "/")
|
String.starts_with?(id, Pleroma.Web.Endpoint.url() <> "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
def replies(object, opts \\ []) do
|
def replies(object, opts \\ []) do
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.Object.Fetcher do
|
defmodule Pleroma.Object.Fetcher do
|
||||||
alias Pleroma.HTTP
|
alias Pleroma.HTTP
|
||||||
|
alias Pleroma.Maps
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Object.Containment
|
alias Pleroma.Object.Containment
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
@ -101,6 +102,9 @@ def fetch_object_from_id(id, options \\ []) do
|
||||||
{:transmogrifier, {:error, {:reject, e}}} ->
|
{:transmogrifier, {:error, {:reject, e}}} ->
|
||||||
{:reject, e}
|
{:reject, e}
|
||||||
|
|
||||||
|
{:transmogrifier, {:reject, e}} ->
|
||||||
|
{:reject, e}
|
||||||
|
|
||||||
{:transmogrifier, _} = e ->
|
{:transmogrifier, _} = e ->
|
||||||
{:error, e}
|
{:error, e}
|
||||||
|
|
||||||
|
@ -124,12 +128,14 @@ def fetch_object_from_id(id, options \\ []) do
|
||||||
defp prepare_activity_params(data) do
|
defp prepare_activity_params(data) do
|
||||||
%{
|
%{
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"to" => data["to"] || [],
|
|
||||||
"cc" => data["cc"] || [],
|
|
||||||
# Should we seriously keep this attributedTo thing?
|
# Should we seriously keep this attributedTo thing?
|
||||||
"actor" => data["actor"] || data["attributedTo"],
|
"actor" => data["actor"] || data["attributedTo"],
|
||||||
"object" => data
|
"object" => data
|
||||||
}
|
}
|
||||||
|
|> Maps.put_if_present("to", data["to"])
|
||||||
|
|> Maps.put_if_present("cc", data["cc"])
|
||||||
|
|> Maps.put_if_present("bto", data["bto"])
|
||||||
|
|> Maps.put_if_present("bcc", data["bcc"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_object_from_id!(id, options \\ []) do
|
def fetch_object_from_id!(id, options \\ []) do
|
||||||
|
|
|
@ -8,8 +8,6 @@ defmodule Pleroma.Repo do
|
||||||
adapter: Ecto.Adapters.Postgres,
|
adapter: Ecto.Adapters.Postgres,
|
||||||
migration_timestamps: [type: :naive_datetime_usec]
|
migration_timestamps: [type: :naive_datetime_usec]
|
||||||
|
|
||||||
use Ecto.Explain
|
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,7 @@ defp increase_read_duration(_) do
|
||||||
{:ok, :no_duration_limit, :no_duration_limit}
|
{:ok, :no_duration_limit, :no_duration_limit}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp client, do: Pleroma.ReverseProxy.Client
|
defp client, do: Pleroma.ReverseProxy.Client.Wrapper
|
||||||
|
|
||||||
defp track_failed_url(url, error, opts) do
|
defp track_failed_url(url, error, opts) do
|
||||||
ttl =
|
ttl =
|
||||||
|
|
|
@ -17,22 +17,4 @@ defmodule Pleroma.ReverseProxy.Client do
|
||||||
@callback stream_body(map()) :: {:ok, binary(), map()} | :done | {:error, atom() | String.t()}
|
@callback stream_body(map()) :: {:ok, binary(), map()} | :done | {:error, atom() | String.t()}
|
||||||
|
|
||||||
@callback close(reference() | pid() | map()) :: :ok
|
@callback close(reference() | pid() | map()) :: :ok
|
||||||
|
|
||||||
def request(method, url, headers, body \\ "", opts \\ []) do
|
|
||||||
client().request(method, url, headers, body, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
def stream_body(ref), do: client().stream_body(ref)
|
|
||||||
|
|
||||||
def close(ref), do: client().close(ref)
|
|
||||||
|
|
||||||
defp client do
|
|
||||||
:tesla
|
|
||||||
|> Application.get_env(:adapter)
|
|
||||||
|> client()
|
|
||||||
end
|
|
||||||
|
|
||||||
defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
|
|
||||||
defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
|
|
||||||
defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.ReverseProxy.Client.Wrapper do
|
||||||
|
@moduledoc "Meta-client that calls the appropriate client from the config."
|
||||||
|
@behaviour Pleroma.ReverseProxy.Client
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def request(method, url, headers, body \\ "", opts \\ []) do
|
||||||
|
client().request(method, url, headers, body, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def stream_body(ref), do: client().stream_body(ref)
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def close(ref), do: client().close(ref)
|
||||||
|
|
||||||
|
defp client do
|
||||||
|
:tesla
|
||||||
|
|> Application.get_env(:adapter)
|
||||||
|
|> client()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
|
||||||
|
defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
|
||||||
|
defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
|
||||||
|
end
|
|
@ -29,9 +29,7 @@ def handle_event(
|
||||||
_
|
_
|
||||||
) do
|
) do
|
||||||
Logger.debug(fn ->
|
Logger.debug(fn ->
|
||||||
"Connection pool is exhausted (reached #{max_connections} connections). Starting idle connection cleanup to reclaim as much as #{
|
"Connection pool is exhausted (reached #{max_connections} connections). Starting idle connection cleanup to reclaim as much as #{reclaim_max} connections"
|
||||||
reclaim_max
|
|
||||||
} connections"
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,9 +71,7 @@ def handle_event(
|
||||||
_
|
_
|
||||||
) do
|
) do
|
||||||
Logger.warn(fn ->
|
Logger.warn(fn ->
|
||||||
"Pool worker for #{key}: Client #{inspect(client_pid)} died before releasing the connection with #{
|
"Pool worker for #{key}: Client #{inspect(client_pid)} died before releasing the connection with #{inspect(reason)}"
|
||||||
inspect(reason)
|
|
||||||
}"
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ defmodule Pleroma.Tests.AuthTestController do
|
||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlug
|
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
# Serves only with proper OAuth token (:api and :authenticated_api)
|
# Serves only with proper OAuth token (:api and :authenticated_api)
|
||||||
|
@ -47,10 +46,7 @@ defmodule Pleroma.Tests.AuthTestController do
|
||||||
# Via :authenticated_api, serves if token is present and has requested scopes
|
# Via :authenticated_api, serves if token is present and has requested scopes
|
||||||
#
|
#
|
||||||
# Suggested use: as :fallback_oauth_check but open with nil :user for :api on private instances
|
# Suggested use: as :fallback_oauth_check but open with nil :user for :api on private instances
|
||||||
plug(
|
plug(:skip_public_check when action == :fallback_oauth_skip_publicity_check)
|
||||||
:skip_plug,
|
|
||||||
EnsurePublicOrAuthenticatedPlug when action == :fallback_oauth_skip_publicity_check
|
|
||||||
)
|
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
|
@ -62,11 +58,7 @@ defmodule Pleroma.Tests.AuthTestController do
|
||||||
# Via :authenticated_api, serves if :user is set (regardless of token presence and its scopes)
|
# Via :authenticated_api, serves if :user is set (regardless of token presence and its scopes)
|
||||||
#
|
#
|
||||||
# Suggested use: making an :api endpoint always accessible (e.g. email confirmation endpoint)
|
# Suggested use: making an :api endpoint always accessible (e.g. email confirmation endpoint)
|
||||||
plug(
|
plug(:skip_auth when action == :skip_oauth_skip_publicity_check)
|
||||||
:skip_plug,
|
|
||||||
[OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug]
|
|
||||||
when action == :skip_oauth_skip_publicity_check
|
|
||||||
)
|
|
||||||
|
|
||||||
# Via :authenticated_api, always fails with 403 (endpoint is insecure)
|
# Via :authenticated_api, always fails with 403 (endpoint is insecure)
|
||||||
# Via :api, drops :user if present and serves if public (private instance rejects on no user)
|
# Via :api, drops :user if present and serves if public (private instance rejects on no user)
|
||||||
|
|
|
@ -23,6 +23,9 @@ defmodule Pleroma.Upload do
|
||||||
is once created permanent and changing it (especially in uploaders) is probably a bad idea!
|
is once created permanent and changing it (especially in uploaders) is probably a bad idea!
|
||||||
* `:tempfile` - path to the temporary file. Prefer in-place changes on the file rather than changing the
|
* `:tempfile` - path to the temporary file. Prefer in-place changes on the file rather than changing the
|
||||||
path as the temporary file is also tracked by `Plug.Upload{}` and automatically deleted once the request is over.
|
path as the temporary file is also tracked by `Plug.Upload{}` and automatically deleted once the request is over.
|
||||||
|
* `:width` - width of the media in pixels
|
||||||
|
* `:height` - height of the media in pixels
|
||||||
|
* `:blurhash` - string hash of the image encoded with the blurhash algorithm (https://blurha.sh/)
|
||||||
|
|
||||||
Related behaviors:
|
Related behaviors:
|
||||||
|
|
||||||
|
@ -32,6 +35,7 @@ defmodule Pleroma.Upload do
|
||||||
"""
|
"""
|
||||||
alias Ecto.UUID
|
alias Ecto.UUID
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
alias Pleroma.Maps
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@type source ::
|
@type source ::
|
||||||
|
@ -53,9 +57,12 @@ defmodule Pleroma.Upload do
|
||||||
name: String.t(),
|
name: String.t(),
|
||||||
tempfile: String.t(),
|
tempfile: String.t(),
|
||||||
content_type: String.t(),
|
content_type: String.t(),
|
||||||
|
width: integer(),
|
||||||
|
height: integer(),
|
||||||
|
blurhash: String.t(),
|
||||||
path: String.t()
|
path: String.t()
|
||||||
}
|
}
|
||||||
defstruct [:id, :name, :tempfile, :content_type, :path]
|
defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path]
|
||||||
|
|
||||||
defp get_description(opts, upload) do
|
defp get_description(opts, upload) do
|
||||||
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||||
|
@ -89,9 +96,12 @@ def store(upload, opts \\ []) do
|
||||||
"mediaType" => upload.content_type,
|
"mediaType" => upload.content_type,
|
||||||
"href" => url_from_spec(upload, opts.base_url, url_spec)
|
"href" => url_from_spec(upload, opts.base_url, url_spec)
|
||||||
}
|
}
|
||||||
|
|> Maps.put_if_present("width", upload.width)
|
||||||
|
|> Maps.put_if_present("height", upload.height)
|
||||||
],
|
],
|
||||||
"name" => description
|
"name" => description
|
||||||
}}
|
}
|
||||||
|
|> Maps.put_if_present("blurhash", upload.blurhash)}
|
||||||
else
|
else
|
||||||
{:description_limit, _} ->
|
{:description_limit, _} ->
|
||||||
{:error, :description_too_long}
|
{:error, :description_too_long}
|
||||||
|
@ -225,7 +235,7 @@ def base_url do
|
||||||
|
|
||||||
case uploader do
|
case uploader do
|
||||||
Pleroma.Uploaders.Local ->
|
Pleroma.Uploaders.Local ->
|
||||||
upload_base_url || Pleroma.Web.base_url() <> "/media/"
|
upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
||||||
|
|
||||||
Pleroma.Uploaders.S3 ->
|
Pleroma.Uploaders.S3 ->
|
||||||
bucket = Config.get([Pleroma.Uploaders.S3, :bucket])
|
bucket = Config.get([Pleroma.Uploaders.S3, :bucket])
|
||||||
|
@ -251,7 +261,7 @@ def base_url do
|
||||||
end
|
end
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
public_endpoint || upload_base_url || Pleroma.Web.base_url() <> "/media/"
|
public_endpoint || upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,13 +15,13 @@ defmodule Pleroma.Upload.Filter do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@callback filter(Pleroma.Upload.t()) ::
|
@callback filter(upload :: struct()) ::
|
||||||
{:ok, :filtered}
|
{:ok, :filtered}
|
||||||
| {:ok, :noop}
|
| {:ok, :noop}
|
||||||
| {:ok, :filtered, Pleroma.Upload.t()}
|
| {:ok, :filtered, upload :: struct()}
|
||||||
| {:error, any()}
|
| {:error, any()}
|
||||||
|
|
||||||
@spec filter([module()], Pleroma.Upload.t()) :: {:ok, Pleroma.Upload.t()} | {:error, any()}
|
@spec filter([module()], upload :: struct()) :: {:ok, upload :: struct()} | {:error, any()}
|
||||||
|
|
||||||
def filter([], upload) do
|
def filter([], upload) do
|
||||||
{:ok, upload}
|
{:ok, upload}
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Upload.Filter.AnalyzeMetadata do
|
||||||
|
@moduledoc """
|
||||||
|
Extracts metadata about the upload, such as width/height
|
||||||
|
"""
|
||||||
|
require Logger
|
||||||
|
|
||||||
|
@behaviour Pleroma.Upload.Filter
|
||||||
|
|
||||||
|
@spec filter(Pleroma.Upload.t()) ::
|
||||||
|
{:ok, :filtered, Pleroma.Upload.t()} | {:ok, :noop} | {:error, String.t()}
|
||||||
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _} = upload) do
|
||||||
|
try do
|
||||||
|
image =
|
||||||
|
file
|
||||||
|
|> Mogrify.open()
|
||||||
|
|> Mogrify.verbose()
|
||||||
|
|
||||||
|
upload =
|
||||||
|
upload
|
||||||
|
|> Map.put(:width, image.width)
|
||||||
|
|> Map.put(:height, image.height)
|
||||||
|
|> Map.put(:blurhash, get_blurhash(file))
|
||||||
|
|
||||||
|
{:ok, :filtered, upload}
|
||||||
|
rescue
|
||||||
|
e in ErlangError ->
|
||||||
|
Logger.warn("#{__MODULE__}: #{inspect(e)}")
|
||||||
|
{:ok, :noop}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "video" <> _} = upload) do
|
||||||
|
try do
|
||||||
|
result = media_dimensions(file)
|
||||||
|
|
||||||
|
upload =
|
||||||
|
upload
|
||||||
|
|> Map.put(:width, result.width)
|
||||||
|
|> Map.put(:height, result.height)
|
||||||
|
|
||||||
|
{:ok, :filtered, upload}
|
||||||
|
rescue
|
||||||
|
e in ErlangError ->
|
||||||
|
Logger.warn("#{__MODULE__}: #{inspect(e)}")
|
||||||
|
{:ok, :noop}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter(_), do: {:ok, :noop}
|
||||||
|
|
||||||
|
defp get_blurhash(file) do
|
||||||
|
with {:ok, blurhash} <- :eblurhash.magick(file) do
|
||||||
|
blurhash
|
||||||
|
else
|
||||||
|
_ -> nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp media_dimensions(file) do
|
||||||
|
with executable when is_binary(executable) <- System.find_executable("ffprobe"),
|
||||||
|
args = [
|
||||||
|
"-v",
|
||||||
|
"error",
|
||||||
|
"-show_entries",
|
||||||
|
"stream=width,height",
|
||||||
|
"-of",
|
||||||
|
"csv=p=0:s=x",
|
||||||
|
file
|
||||||
|
],
|
||||||
|
{result, 0} <- System.cmd(executable, args),
|
||||||
|
[width, height] <-
|
||||||
|
String.split(String.trim(result), "x") |> Enum.map(&String.to_integer(&1)) do
|
||||||
|
%{width: width, height: height}
|
||||||
|
else
|
||||||
|
nil -> {:error, {:ffprobe, :command_not_found}}
|
||||||
|
{:error, _} = error -> error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -35,7 +35,7 @@ defmodule Pleroma.Uploaders.Uploader do
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@type file_spec :: {:file | :url, String.t()}
|
@type file_spec :: {:file | :url, String.t()}
|
||||||
@callback put_file(Pleroma.Upload.t()) ::
|
@callback put_file(upload :: struct()) ::
|
||||||
:ok | {:ok, file_spec()} | {:error, String.t()} | :wait_callback
|
:ok | {:ok, file_spec()} | {:error, String.t()} | :wait_callback
|
||||||
|
|
||||||
@callback delete_file(file :: String.t()) :: :ok | {:error, String.t()}
|
@callback delete_file(file :: String.t()) :: :ok | {:error, String.t()}
|
||||||
|
@ -46,7 +46,7 @@ defmodule Pleroma.Uploaders.Uploader do
|
||||||
| {:error, Plug.Conn.t(), String.t()}
|
| {:error, Plug.Conn.t(), String.t()}
|
||||||
@optional_callbacks http_callback: 2
|
@optional_callbacks http_callback: 2
|
||||||
|
|
||||||
@spec put_file(module(), Pleroma.Upload.t()) :: {:ok, file_spec()} | {:error, String.t()}
|
@spec put_file(module(), upload :: struct()) :: {:ok, file_spec()} | {:error, String.t()}
|
||||||
def put_file(uploader, upload) do
|
def put_file(uploader, upload) do
|
||||||
case uploader.put_file(upload) do
|
case uploader.put_file(upload) do
|
||||||
:ok -> {:ok, {:file, upload.path}}
|
:ok -> {:ok, {:file, upload.path}}
|
||||||
|
|
|
@ -27,13 +27,13 @@ defmodule Pleroma.User do
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.UserRelationship
|
alias Pleroma.UserRelationship
|
||||||
alias Pleroma.Web
|
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.Builder
|
alias Pleroma.Web.ActivityPub.Builder
|
||||||
alias Pleroma.Web.ActivityPub.Pipeline
|
alias Pleroma.Web.ActivityPub.Pipeline
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
|
alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
|
||||||
|
alias Pleroma.Web.Endpoint
|
||||||
alias Pleroma.Web.OAuth
|
alias Pleroma.Web.OAuth
|
||||||
alias Pleroma.Web.RelMe
|
alias Pleroma.Web.RelMe
|
||||||
alias Pleroma.Workers.BackgroundWorker
|
alias Pleroma.Workers.BackgroundWorker
|
||||||
|
@ -124,7 +124,6 @@ defmodule Pleroma.User do
|
||||||
field(:is_moderator, :boolean, default: false)
|
field(:is_moderator, :boolean, default: false)
|
||||||
field(:is_admin, :boolean, default: false)
|
field(:is_admin, :boolean, default: false)
|
||||||
field(:show_role, :boolean, default: true)
|
field(:show_role, :boolean, default: true)
|
||||||
field(:mastofe_settings, :map, default: nil)
|
|
||||||
field(:uri, ObjectValidators.Uri, default: nil)
|
field(:uri, ObjectValidators.Uri, default: nil)
|
||||||
field(:hide_followers_count, :boolean, default: false)
|
field(:hide_followers_count, :boolean, default: false)
|
||||||
field(:hide_follows_count, :boolean, default: false)
|
field(:hide_follows_count, :boolean, default: false)
|
||||||
|
@ -149,6 +148,7 @@ defmodule Pleroma.User do
|
||||||
field(:last_active_at, :naive_datetime)
|
field(:last_active_at, :naive_datetime)
|
||||||
field(:disclose_client, :boolean, default: true)
|
field(:disclose_client, :boolean, default: true)
|
||||||
field(:pinned_objects, :map, default: %{})
|
field(:pinned_objects, :map, default: %{})
|
||||||
|
field(:is_suggested, :boolean, default: false)
|
||||||
|
|
||||||
embeds_one(
|
embeds_one(
|
||||||
:notification_settings,
|
:notification_settings,
|
||||||
|
@ -360,7 +360,7 @@ def avatar_url(user, options \\ []) do
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
unless options[:no_default] do
|
unless options[:no_default] do
|
||||||
Config.get([:assets, :default_user_avatar], "#{Web.base_url()}/images/avi.png")
|
Config.get([:assets, :default_user_avatar], "#{Endpoint.url()}/images/avi.png")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -368,13 +368,13 @@ def avatar_url(user, options \\ []) do
|
||||||
def banner_url(user, options \\ []) do
|
def banner_url(user, options \\ []) do
|
||||||
case user.banner do
|
case user.banner do
|
||||||
%{"url" => [%{"href" => href} | _]} -> href
|
%{"url" => [%{"href" => href} | _]} -> href
|
||||||
_ -> !options[:no_default] && "#{Web.base_url()}/images/banner.png"
|
_ -> !options[:no_default] && "#{Endpoint.url()}/images/banner.png"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Should probably be renamed or removed
|
# Should probably be renamed or removed
|
||||||
@spec ap_id(User.t()) :: String.t()
|
@spec ap_id(User.t()) :: String.t()
|
||||||
def ap_id(%User{nickname: nickname}), do: "#{Web.base_url()}/users/#{nickname}"
|
def ap_id(%User{nickname: nickname}), do: "#{Endpoint.url()}/users/#{nickname}"
|
||||||
|
|
||||||
@spec ap_followers(User.t()) :: String.t()
|
@spec ap_followers(User.t()) :: String.t()
|
||||||
def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
|
def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
|
||||||
|
@ -1677,6 +1677,22 @@ def confirm(%User{is_confirmed: false} = user) do
|
||||||
|
|
||||||
def confirm(%User{} = user), do: {:ok, user}
|
def confirm(%User{} = user), do: {:ok, user}
|
||||||
|
|
||||||
|
def set_suggestion(users, is_suggested) when is_list(users) do
|
||||||
|
Repo.transaction(fn ->
|
||||||
|
Enum.map(users, fn user ->
|
||||||
|
with {:ok, user} <- set_suggestion(user, is_suggested), do: user
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_suggestion(%User{is_suggested: is_suggested} = user, is_suggested), do: {:ok, user}
|
||||||
|
|
||||||
|
def set_suggestion(%User{} = user, is_suggested) when is_boolean(is_suggested) do
|
||||||
|
user
|
||||||
|
|> change(is_suggested: is_suggested)
|
||||||
|
|> update_and_set_cache()
|
||||||
|
end
|
||||||
|
|
||||||
def update_notification_settings(%User{} = user, settings) do
|
def update_notification_settings(%User{} = user, settings) do
|
||||||
user
|
user
|
||||||
|> cast(%{notification_settings: settings}, [])
|
|> cast(%{notification_settings: settings}, [])
|
||||||
|
@ -1695,8 +1711,6 @@ def purge_user_changeset(user) do
|
||||||
email: nil,
|
email: nil,
|
||||||
name: nil,
|
name: nil,
|
||||||
password_hash: nil,
|
password_hash: nil,
|
||||||
keys: nil,
|
|
||||||
public_key: nil,
|
|
||||||
avatar: %{},
|
avatar: %{},
|
||||||
tags: [],
|
tags: [],
|
||||||
last_refreshed_at: nil,
|
last_refreshed_at: nil,
|
||||||
|
@ -1707,9 +1721,7 @@ def purge_user_changeset(user) do
|
||||||
follower_count: 0,
|
follower_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
is_locked: false,
|
is_locked: false,
|
||||||
is_confirmed: true,
|
|
||||||
password_reset_pending: false,
|
password_reset_pending: false,
|
||||||
is_approved: true,
|
|
||||||
registration_reason: nil,
|
registration_reason: nil,
|
||||||
confirmation_token: nil,
|
confirmation_token: nil,
|
||||||
domain_blocks: [],
|
domain_blocks: [],
|
||||||
|
@ -1717,7 +1729,6 @@ def purge_user_changeset(user) do
|
||||||
ap_enabled: false,
|
ap_enabled: false,
|
||||||
is_moderator: false,
|
is_moderator: false,
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
mastofe_settings: nil,
|
|
||||||
mascot: nil,
|
mascot: nil,
|
||||||
emoji: %{},
|
emoji: %{},
|
||||||
pleroma_settings_store: %{},
|
pleroma_settings_store: %{},
|
||||||
|
@ -1725,45 +1736,53 @@ def purge_user_changeset(user) do
|
||||||
raw_fields: [],
|
raw_fields: [],
|
||||||
is_discoverable: false,
|
is_discoverable: false,
|
||||||
also_known_as: []
|
also_known_as: []
|
||||||
|
# id: preserved
|
||||||
|
# ap_id: preserved
|
||||||
|
# nickname: preserved
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Purge doesn't delete the user from the database.
|
||||||
|
# It just nulls all its fields and deactivates it.
|
||||||
|
# See `User.purge_user_changeset/1` above.
|
||||||
|
defp purge(%User{} = user) do
|
||||||
|
user
|
||||||
|
|> purge_user_changeset()
|
||||||
|
|> update_and_set_cache()
|
||||||
|
end
|
||||||
|
|
||||||
def delete(users) when is_list(users) do
|
def delete(users) when is_list(users) do
|
||||||
for user <- users, do: delete(user)
|
for user <- users, do: delete(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(%User{} = user) do
|
def delete(%User{} = user) do
|
||||||
|
# Purge the user immediately
|
||||||
|
purge(user)
|
||||||
BackgroundWorker.enqueue("delete_user", %{"user_id" => user.id})
|
BackgroundWorker.enqueue("delete_user", %{"user_id" => user.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp delete_and_invalidate_cache(%User{} = user) do
|
# *Actually* delete the user from the DB
|
||||||
|
defp delete_from_db(%User{} = user) do
|
||||||
invalidate_cache(user)
|
invalidate_cache(user)
|
||||||
Repo.delete(user)
|
Repo.delete(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp delete_or_deactivate(%User{local: false} = user), do: delete_and_invalidate_cache(user)
|
# If the user never finalized their account, it's safe to delete them.
|
||||||
|
defp maybe_delete_from_db(%User{local: true, is_confirmed: false} = user),
|
||||||
|
do: delete_from_db(user)
|
||||||
|
|
||||||
defp delete_or_deactivate(%User{local: true} = user) do
|
defp maybe_delete_from_db(%User{local: true, is_approved: false} = user),
|
||||||
status = account_status(user)
|
do: delete_from_db(user)
|
||||||
|
|
||||||
case status do
|
defp maybe_delete_from_db(user), do: {:ok, user}
|
||||||
:confirmation_pending ->
|
|
||||||
delete_and_invalidate_cache(user)
|
|
||||||
|
|
||||||
:approval_pending ->
|
|
||||||
delete_and_invalidate_cache(user)
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
user
|
|
||||||
|> purge_user_changeset()
|
|
||||||
|> update_and_set_cache()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform(:force_password_reset, user), do: force_password_reset(user)
|
def perform(:force_password_reset, user), do: force_password_reset(user)
|
||||||
|
|
||||||
@spec perform(atom(), User.t()) :: {:ok, User.t()}
|
@spec perform(atom(), User.t()) :: {:ok, User.t()}
|
||||||
def perform(:delete, %User{} = user) do
|
def perform(:delete, %User{} = user) do
|
||||||
|
# Purge the user again, in case perform/2 is called directly
|
||||||
|
purge(user)
|
||||||
|
|
||||||
# Remove all relationships
|
# Remove all relationships
|
||||||
user
|
user
|
||||||
|> get_followers()
|
|> get_followers()
|
||||||
|
@ -1781,10 +1800,9 @@ def perform(:delete, %User{} = user) do
|
||||||
|
|
||||||
delete_user_activities(user)
|
delete_user_activities(user)
|
||||||
delete_notifications_from_user_activities(user)
|
delete_notifications_from_user_activities(user)
|
||||||
|
|
||||||
delete_outgoing_pending_follow_requests(user)
|
delete_outgoing_pending_follow_requests(user)
|
||||||
|
|
||||||
delete_or_deactivate(user)
|
maybe_delete_from_db(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform(:set_activation_async, user, status), do: set_activation(user, status)
|
def perform(:set_activation_async, user, status), do: set_activation(user, status)
|
||||||
|
@ -2245,7 +2263,7 @@ def get_delivered_users_by_object_id(object_id) do
|
||||||
def change_email(user, email) do
|
def change_email(user, email) do
|
||||||
user
|
user
|
||||||
|> cast(%{email: email}, [:email])
|
|> cast(%{email: email}, [:email])
|
||||||
|> validate_required([:email])
|
|> maybe_validate_required_email(false)
|
||||||
|> unique_constraint(:email)
|
|> unique_constraint(:email)
|
||||||
|> validate_format(:email, @email_regex)
|
|> validate_format(:email, @email_regex)
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
|
@ -2328,13 +2346,6 @@ def mascot_update(user, url) do
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
def mastodon_settings_update(user, settings) do
|
|
||||||
user
|
|
||||||
|> cast(%{mastofe_settings: settings}, [:mastofe_settings])
|
|
||||||
|> validate_required([:mastofe_settings])
|
|
||||||
|> update_and_set_cache()
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec confirmation_changeset(User.t(), keyword()) :: Changeset.t()
|
@spec confirmation_changeset(User.t(), keyword()) :: Changeset.t()
|
||||||
def confirmation_changeset(user, set_confirmation: confirmed?) do
|
def confirmation_changeset(user, set_confirmation: confirmed?) do
|
||||||
params =
|
params =
|
||||||
|
@ -2480,8 +2491,8 @@ def update_last_active_at(%__MODULE__{local: true} = user) do
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_user_count(weeks \\ 4) do
|
def active_user_count(days \\ 30) do
|
||||||
active_after = Timex.shift(NaiveDateTime.utc_now(), weeks: -weeks)
|
active_after = Timex.shift(NaiveDateTime.utc_now(), days: -days)
|
||||||
|
|
||||||
__MODULE__
|
__MODULE__
|
||||||
|> where([u], u.last_active_at >= ^active_after)
|
|> where([u], u.last_active_at >= ^active_after)
|
||||||
|
|
|
@ -27,7 +27,7 @@ defmodule Pleroma.User.Query do
|
||||||
- e.g. Pleroma.User.Query.build(%{ap_id: ["http://ap_id1", "http://ap_id2"]})
|
- e.g. Pleroma.User.Query.build(%{ap_id: ["http://ap_id1", "http://ap_id2"]})
|
||||||
"""
|
"""
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import Pleroma.Web.AdminAPI.Search, only: [not_empty_string: 1]
|
import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1]
|
||||||
|
|
||||||
alias Pleroma.FollowingRelationship
|
alias Pleroma.FollowingRelationship
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
@ -46,6 +46,7 @@ defmodule Pleroma.User.Query do
|
||||||
unconfirmed: boolean(),
|
unconfirmed: boolean(),
|
||||||
is_admin: boolean(),
|
is_admin: boolean(),
|
||||||
is_moderator: boolean(),
|
is_moderator: boolean(),
|
||||||
|
is_suggested: boolean(),
|
||||||
super_users: boolean(),
|
super_users: boolean(),
|
||||||
invisible: boolean(),
|
invisible: boolean(),
|
||||||
internal: boolean(),
|
internal: boolean(),
|
||||||
|
@ -167,6 +168,10 @@ defp compose_query({:unconfirmed, _}, query) do
|
||||||
where(query, [u], u.is_confirmed == false)
|
where(query, [u], u.is_confirmed == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp compose_query({:is_suggested, bool}, query) do
|
||||||
|
where(query, [u], u.is_suggested == ^bool)
|
||||||
|
end
|
||||||
|
|
||||||
defp compose_query({:followers, %User{id: id}}, query) do
|
defp compose_query({:followers, %User{id: id}}, query) do
|
||||||
query
|
query
|
||||||
|> where([u], u.id != ^id)
|
|> where([u], u.id != ^id)
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.UserNote do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
import Ecto.Query
|
||||||
|
|
||||||
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.User
|
||||||
|
alias Pleroma.UserNote
|
||||||
|
|
||||||
|
schema "user_notes" do
|
||||||
|
belongs_to(:source, User, type: FlakeId.Ecto.CompatType)
|
||||||
|
belongs_to(:target, User, type: FlakeId.Ecto.CompatType)
|
||||||
|
field(:comment, :string)
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(%UserNote{} = user_note, params \\ %{}) do
|
||||||
|
user_note
|
||||||
|
|> cast(params, [:source_id, :target_id, :comment])
|
||||||
|
|> validate_required([:source_id, :target_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(%User{} = source, %User{} = target) do
|
||||||
|
with %UserNote{} = note <-
|
||||||
|
UserNote
|
||||||
|
|> where(source_id: ^source.id, target_id: ^target.id)
|
||||||
|
|> Repo.one() do
|
||||||
|
note.comment
|
||||||
|
else
|
||||||
|
_ -> ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(%User{} = source, %User{} = target, comment) do
|
||||||
|
%UserNote{}
|
||||||
|
|> changeset(%{
|
||||||
|
source_id: source.id,
|
||||||
|
target_id: target.id,
|
||||||
|
comment: comment
|
||||||
|
})
|
||||||
|
|> Repo.insert(
|
||||||
|
on_conflict: {:replace, [:comment]},
|
||||||
|
conflict_target: [:source_id, :target_id]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
|
@ -35,9 +35,10 @@ def controller do
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
|
|
||||||
import Pleroma.Web.Gettext
|
import Pleroma.Web.Gettext
|
||||||
import Pleroma.Web.Router.Helpers
|
|
||||||
import Pleroma.Web.TranslationHelpers
|
import Pleroma.Web.TranslationHelpers
|
||||||
|
|
||||||
|
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
plug(:set_put_layout)
|
plug(:set_put_layout)
|
||||||
|
|
||||||
defp set_put_layout(conn, _) do
|
defp set_put_layout(conn, _) do
|
||||||
|
@ -61,6 +62,14 @@ defp skip_plug(conn, plug_modules) do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp skip_auth(conn, _) do
|
||||||
|
skip_plug(conn, [OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug])
|
||||||
|
end
|
||||||
|
|
||||||
|
defp skip_public_check(conn, _) do
|
||||||
|
skip_plug(conn, EnsurePublicOrAuthenticatedPlug)
|
||||||
|
end
|
||||||
|
|
||||||
# Executed just before actual controller action, invokes before-action hooks (callbacks)
|
# Executed just before actual controller action, invokes before-action hooks (callbacks)
|
||||||
defp action(conn, params) do
|
defp action(conn, params) do
|
||||||
with %{halted: false} = conn <-
|
with %{halted: false} = conn <-
|
||||||
|
@ -131,7 +140,8 @@ def view do
|
||||||
|
|
||||||
import Pleroma.Web.ErrorHelpers
|
import Pleroma.Web.ErrorHelpers
|
||||||
import Pleroma.Web.Gettext
|
import Pleroma.Web.Gettext
|
||||||
import Pleroma.Web.Router.Helpers
|
|
||||||
|
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
@ -229,20 +239,4 @@ def call(%Plug.Conn{} = conn, options) do
|
||||||
defmacro __using__(which) when is_atom(which) do
|
defmacro __using__(which) when is_atom(which) do
|
||||||
apply(__MODULE__, which, [])
|
apply(__MODULE__, which, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_url do
|
|
||||||
Pleroma.Web.Endpoint.url()
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
|
|
||||||
def get_api_routes do
|
|
||||||
Pleroma.Web.Router.__routes__()
|
|
||||||
|> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
|
|
||||||
|> Enum.map(fn r ->
|
|
||||||
r.path
|
|
||||||
|> String.split("/", trim: true)
|
|
||||||
|> List.first()
|
|
||||||
end)
|
|
||||||
|> Enum.uniq()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
alias Pleroma.Web.Streamer
|
alias Pleroma.Web.Streamer
|
||||||
alias Pleroma.Web.WebFinger
|
alias Pleroma.Web.WebFinger
|
||||||
alias Pleroma.Workers.BackgroundWorker
|
alias Pleroma.Workers.BackgroundWorker
|
||||||
|
alias Pleroma.Workers.PollWorker
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import Pleroma.Web.ActivityPub.Utils
|
import Pleroma.Web.ActivityPub.Utils
|
||||||
|
@ -53,15 +54,18 @@ defp get_recipients(data) do
|
||||||
{recipients, to, cc}
|
{recipients, to, cc}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_actor_is_active(nil), do: true
|
defp check_actor_can_insert(%{"type" => "Delete"}), do: true
|
||||||
|
defp check_actor_can_insert(%{"type" => "Undo"}), do: true
|
||||||
|
|
||||||
defp check_actor_is_active(actor) when is_binary(actor) do
|
defp check_actor_can_insert(%{"actor" => actor}) when is_binary(actor) do
|
||||||
case User.get_cached_by_ap_id(actor) do
|
case User.get_cached_by_ap_id(actor) do
|
||||||
%User{is_active: true} -> true
|
%User{is_active: true} -> true
|
||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp check_actor_can_insert(_), do: true
|
||||||
|
|
||||||
defp check_remote_limit(%{"object" => %{"content" => content}}) when not is_nil(content) do
|
defp check_remote_limit(%{"object" => %{"content" => content}}) when not is_nil(content) do
|
||||||
limit = Config.get([:instance, :remote_limit])
|
limit = Config.get([:instance, :remote_limit])
|
||||||
String.length(content) <= limit
|
String.length(content) <= limit
|
||||||
|
@ -88,7 +92,7 @@ defp increase_replies_count_if_reply(%{
|
||||||
|
|
||||||
defp increase_replies_count_if_reply(_create_data), do: :noop
|
defp increase_replies_count_if_reply(_create_data), do: :noop
|
||||||
|
|
||||||
@object_types ~w[ChatMessage Question Answer Audio Video Event Article]
|
@object_types ~w[ChatMessage Question Answer Audio Video Event Article Note Page]
|
||||||
@impl true
|
@impl true
|
||||||
def persist(%{"type" => type} = object, meta) when type in @object_types do
|
def persist(%{"type" => type} = object, meta) when type in @object_types do
|
||||||
with {:ok, object} <- Object.create(object) do
|
with {:ok, object} <- Object.create(object) do
|
||||||
|
@ -117,7 +121,7 @@ def persist(object, meta) do
|
||||||
def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
|
def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
|
||||||
with nil <- Activity.normalize(map),
|
with nil <- Activity.normalize(map),
|
||||||
map <- lazy_put_activity_defaults(map, fake),
|
map <- lazy_put_activity_defaults(map, fake),
|
||||||
{_, true} <- {:actor_check, bypass_actor_check || check_actor_is_active(map["actor"])},
|
{_, true} <- {:actor_check, bypass_actor_check || check_actor_can_insert(map)},
|
||||||
{_, true} <- {:remote_limit_pass, check_remote_limit(map)},
|
{_, true} <- {:remote_limit_pass, check_remote_limit(map)},
|
||||||
{:ok, map} <- MRF.filter(map),
|
{:ok, map} <- MRF.filter(map),
|
||||||
{recipients, _, _} = get_recipients(map),
|
{recipients, _, _} = get_recipients(map),
|
||||||
|
@ -285,6 +289,7 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
|
||||||
{:quick_insert, false, activity} <- {:quick_insert, quick_insert?, activity},
|
{:quick_insert, false, activity} <- {:quick_insert, quick_insert?, activity},
|
||||||
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
|
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
|
||||||
_ <- notify_and_stream(activity),
|
_ <- notify_and_stream(activity),
|
||||||
|
:ok <- maybe_schedule_poll_notifications(activity),
|
||||||
:ok <- maybe_federate(activity) do
|
:ok <- maybe_federate(activity) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
@ -299,6 +304,11 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp maybe_schedule_poll_notifications(activity) do
|
||||||
|
PollWorker.schedule_poll_end(activity)
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
@spec listen(map()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec listen(map()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def listen(%{to: to, actor: actor, context: context, object: object} = params) do
|
def listen(%{to: to, actor: actor, context: context, object: object} = params) do
|
||||||
additional = params[:additional] || %{}
|
additional = params[:additional] || %{}
|
||||||
|
@ -431,6 +441,7 @@ def fetch_activities_for_context_query(context, opts) do
|
||||||
|> maybe_preload_bookmarks(opts)
|
|> maybe_preload_bookmarks(opts)
|
||||||
|> maybe_set_thread_muted_field(opts)
|
|> maybe_set_thread_muted_field(opts)
|
||||||
|> restrict_blocked(opts)
|
|> restrict_blocked(opts)
|
||||||
|
|> restrict_blockers_visibility(opts)
|
||||||
|> restrict_recipients(recipients, opts[:user])
|
|> restrict_recipients(recipients, opts[:user])
|
||||||
|> restrict_filtered(opts)
|
|> restrict_filtered(opts)
|
||||||
|> where(
|
|> where(
|
||||||
|
@ -1018,7 +1029,10 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
||||||
|
|
||||||
from(
|
from(
|
||||||
[activity, object: o] in query,
|
[activity, object: o] in query,
|
||||||
|
# You don't block the author
|
||||||
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
|
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
|
||||||
|
|
||||||
|
# You don't block any recipients, and didn't author the post
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"((not (? && ?)) or ? = ?)",
|
"((not (? && ?)) or ? = ?)",
|
||||||
|
@ -1027,12 +1041,18 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
||||||
activity.actor,
|
activity.actor,
|
||||||
^user.ap_id
|
^user.ap_id
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# You don't block the domain of any recipients, and didn't author the post
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"recipients_contain_blocked_domains(?, ?) = false",
|
"(recipients_contain_blocked_domains(?, ?) = false) or ? = ?",
|
||||||
activity.recipients,
|
activity.recipients,
|
||||||
^domain_blocks
|
^domain_blocks,
|
||||||
|
activity.actor,
|
||||||
|
^user.ap_id
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# It's not a boost of a user you block
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
||||||
|
@ -1040,6 +1060,8 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
||||||
activity.data,
|
activity.data,
|
||||||
^blocked_ap_ids
|
^blocked_ap_ids
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# You don't block the author's domain, and also don't follow the author
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"(not (split_part(?, '/', 3) = ANY(?))) or ? = ANY(?)",
|
"(not (split_part(?, '/', 3) = ANY(?))) or ? = ANY(?)",
|
||||||
|
@ -1048,6 +1070,8 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
||||||
activity.actor,
|
activity.actor,
|
||||||
^following_ap_ids
|
^following_ap_ids
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# Same as above, but checks the Object
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
"(not (split_part(?->>'actor', '/', 3) = ANY(?))) or (?->>'actor') = ANY(?)",
|
"(not (split_part(?->>'actor', '/', 3) = ANY(?))) or (?->>'actor') = ANY(?)",
|
||||||
|
@ -1061,6 +1085,31 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
||||||
|
|
||||||
defp restrict_blocked(query, _), do: query
|
defp restrict_blocked(query, _), do: query
|
||||||
|
|
||||||
|
defp restrict_blockers_visibility(query, %{blocking_user: %User{} = user}) do
|
||||||
|
if Config.get([:activitypub, :blockers_visible]) == true do
|
||||||
|
query
|
||||||
|
else
|
||||||
|
blocker_ap_ids = User.incoming_relationships_ungrouped_ap_ids(user, [:block])
|
||||||
|
|
||||||
|
from(
|
||||||
|
activity in query,
|
||||||
|
# The author doesn't block you
|
||||||
|
where: fragment("not (? = ANY(?))", activity.actor, ^blocker_ap_ids),
|
||||||
|
|
||||||
|
# It's not a boost of a user that blocks you
|
||||||
|
where:
|
||||||
|
fragment(
|
||||||
|
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
||||||
|
activity.data,
|
||||||
|
activity.data,
|
||||||
|
^blocker_ap_ids
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp restrict_blockers_visibility(query, _), do: query
|
||||||
|
|
||||||
defp restrict_unlisted(query, %{restrict_unlisted: true}) do
|
defp restrict_unlisted(query, %{restrict_unlisted: true}) do
|
||||||
from(
|
from(
|
||||||
activity in query,
|
activity in query,
|
||||||
|
@ -1287,6 +1336,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do
|
||||||
|> restrict_state(opts)
|
|> restrict_state(opts)
|
||||||
|> restrict_favorited_by(opts)
|
|> restrict_favorited_by(opts)
|
||||||
|> restrict_blocked(restrict_blocked_opts)
|
|> restrict_blocked(restrict_blocked_opts)
|
||||||
|
|> restrict_blockers_visibility(opts)
|
||||||
|> restrict_muted(restrict_muted_opts)
|
|> restrict_muted(restrict_muted_opts)
|
||||||
|> restrict_filtered(opts)
|
|> restrict_filtered(opts)
|
||||||
|> restrict_media(opts)
|
|> restrict_media(opts)
|
||||||
|
@ -1587,9 +1637,7 @@ def maybe_handle_clashing_nickname(data) do
|
||||||
%User{} = old_user <- User.get_by_nickname(nickname),
|
%User{} = old_user <- User.get_by_nickname(nickname),
|
||||||
{_, false} <- {:ap_id_comparison, data[:ap_id] == old_user.ap_id} do
|
{_, false} <- {:ap_id_comparison, data[:ap_id] == old_user.ap_id} do
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{
|
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{data[:ap_id]}, renaming."
|
||||||
data[:ap_id]
|
|
||||||
}, renaming."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
old_user
|
old_user
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.ActivityPub.Persisting do
|
defmodule Pleroma.Web.ActivityPub.ActivityPub.Persisting do
|
||||||
@callback persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
@callback persist(map(), keyword()) :: {:ok, struct()}
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.ActivityPub.Streaming do
|
defmodule Pleroma.Web.ActivityPub.ActivityPub.Streaming do
|
||||||
alias Pleroma.Activity
|
@callback stream_out(struct()) :: any()
|
||||||
alias Pleroma.Object
|
@callback stream_out_participations(struct(), struct()) :: any()
|
||||||
alias Pleroma.User
|
|
||||||
|
|
||||||
@callback stream_out(Activity.t()) :: any()
|
|
||||||
@callback stream_out_participations(Object.t(), User.t()) :: any()
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
alias Pleroma.Object.Fetcher
|
alias Pleroma.Object.Fetcher
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.Builder
|
|
||||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||||
alias Pleroma.Web.ActivityPub.ObjectView
|
alias Pleroma.Web.ActivityPub.ObjectView
|
||||||
alias Pleroma.Web.ActivityPub.Pipeline
|
alias Pleroma.Web.ActivityPub.Pipeline
|
||||||
|
@ -284,15 +283,29 @@ def inbox(%{assigns: %{valid_signature: true}} = conn, params) do
|
||||||
json(conn, "ok")
|
json(conn, "ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inbox(%{assigns: %{valid_signature: false}} = conn, _params) do
|
||||||
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("Invalid HTTP Signature")
|
||||||
|
end
|
||||||
|
|
||||||
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
||||||
def inbox(conn, params) do
|
def inbox(conn, %{"type" => "Create"} = params) do
|
||||||
if params["type"] == "Create" && FederatingPlug.federating?() do
|
if FederatingPlug.federating?() do
|
||||||
post_inbox_relayed_create(conn, params)
|
post_inbox_relayed_create(conn, params)
|
||||||
else
|
else
|
||||||
post_inbox_fallback(conn, params)
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("Not federating")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inbox(conn, _params) do
|
||||||
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("error, missing HTTP Signature")
|
||||||
|
end
|
||||||
|
|
||||||
defp post_inbox_relayed_create(conn, params) do
|
defp post_inbox_relayed_create(conn, params) do
|
||||||
Logger.debug(
|
Logger.debug(
|
||||||
"Signature missing or not from author, relayed Create message, fetching object from source"
|
"Signature missing or not from author, relayed Create message, fetching object from source"
|
||||||
|
@ -303,23 +316,6 @@ defp post_inbox_relayed_create(conn, params) do
|
||||||
json(conn, "ok")
|
json(conn, "ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp post_inbox_fallback(conn, params) do
|
|
||||||
headers = Enum.into(conn.req_headers, %{})
|
|
||||||
|
|
||||||
if headers["signature"] && params["actor"] &&
|
|
||||||
String.contains?(headers["signature"], params["actor"]) do
|
|
||||||
Logger.debug(
|
|
||||||
"Signature validation error for: #{params["actor"]}, make sure you are forwarding the HTTP Host header!"
|
|
||||||
)
|
|
||||||
|
|
||||||
Logger.debug(inspect(conn.req_headers))
|
|
||||||
end
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_status(:bad_request)
|
|
||||||
|> json(dgettext("errors", "error"))
|
|
||||||
end
|
|
||||||
|
|
||||||
defp represent_service_actor(%User{} = user, conn) do
|
defp represent_service_actor(%User{} = user, conn) do
|
||||||
with {:ok, user} <- User.ensure_keys_present(user) do
|
with {:ok, user} <- User.ensure_keys_present(user) do
|
||||||
conn
|
conn
|
||||||
|
@ -403,83 +399,90 @@ def read_inbox(%{assigns: %{user: %User{nickname: as_nickname}}} = conn, %{
|
||||||
|> json(err)
|
|> json(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_user_activity(
|
defp fix_user_message(%User{ap_id: actor}, %{"type" => "Create", "object" => object} = activity)
|
||||||
%User{} = user,
|
when is_map(object) do
|
||||||
%{"type" => "Create", "object" => %{"type" => "Note"} = object} = params
|
length =
|
||||||
) do
|
[object["content"], object["summary"], object["name"]]
|
||||||
content = if is_binary(object["content"]), do: object["content"], else: ""
|
|> Enum.filter(&is_binary(&1))
|
||||||
name = if is_binary(object["name"]), do: object["name"], else: ""
|
|> Enum.join("")
|
||||||
summary = if is_binary(object["summary"]), do: object["summary"], else: ""
|
|> String.length()
|
||||||
length = String.length(content <> name <> summary)
|
|
||||||
|
|
||||||
if length > Pleroma.Config.get([:instance, :limit]) do
|
limit = Pleroma.Config.get([:instance, :limit])
|
||||||
{:error, dgettext("errors", "Note is over the character limit")}
|
|
||||||
else
|
if length < limit do
|
||||||
object =
|
object =
|
||||||
object
|
object
|
||||||
|> Map.merge(Map.take(params, ["to", "cc"]))
|
|> Transmogrifier.strip_internal_fields()
|
||||||
|> Map.put("attributedTo", user.ap_id)
|
|> Map.put("attributedTo", actor)
|
||||||
|> Transmogrifier.fix_object()
|
|> Map.put("actor", actor)
|
||||||
|
|> Map.put("id", Utils.generate_object_id())
|
||||||
|
|
||||||
ActivityPub.create(%{
|
{:ok, Map.put(activity, "object", object)}
|
||||||
to: params["to"],
|
|
||||||
actor: user,
|
|
||||||
context: object["context"],
|
|
||||||
object: object,
|
|
||||||
additional: Map.take(params, ["cc"])
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp handle_user_activity(%User{} = user, %{"type" => "Delete"} = params) do
|
|
||||||
with %Object{} = object <- Object.normalize(params["object"], fetch: false),
|
|
||||||
true <- user.is_moderator || user.ap_id == object.data["actor"],
|
|
||||||
{:ok, delete_data, _} <- Builder.delete(user, object.data["id"]),
|
|
||||||
{:ok, delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
|
|
||||||
{:ok, delete}
|
|
||||||
else
|
else
|
||||||
_ -> {:error, dgettext("errors", "Can't delete object")}
|
{:error,
|
||||||
|
dgettext(
|
||||||
|
"errors",
|
||||||
|
"Character limit (%{limit} characters) exceeded, contains %{length} characters",
|
||||||
|
limit: limit,
|
||||||
|
length: length
|
||||||
|
)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_user_activity(%User{} = user, %{"type" => "Like"} = params) do
|
defp fix_user_message(
|
||||||
with %Object{} = object <- Object.normalize(params["object"], fetch: false),
|
%User{ap_id: actor} = user,
|
||||||
{_, {:ok, like_object, meta}} <- {:build_object, Builder.like(user, object)},
|
%{"type" => "Delete", "object" => object} = activity
|
||||||
{_, {:ok, %Activity{} = activity, _meta}} <-
|
) do
|
||||||
{:common_pipeline,
|
with {_, %Object{data: object_data}} <- {:normalize, Object.normalize(object, fetch: false)},
|
||||||
Pipeline.common_pipeline(like_object, Keyword.put(meta, :local, true))} do
|
{_, true} <- {:permission, user.is_moderator || actor == object_data["actor"]} do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
_ -> {:error, dgettext("errors", "Can't like object")}
|
{:normalize, _} ->
|
||||||
|
{:error, "No such object found"}
|
||||||
|
|
||||||
|
{:permission, _} ->
|
||||||
|
{:forbidden, "You can't delete this object"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_user_activity(_, _) do
|
defp fix_user_message(%User{}, activity) do
|
||||||
{:error, dgettext("errors", "Unhandled activity type")}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_outbox(
|
def update_outbox(
|
||||||
%{assigns: %{user: %User{nickname: nickname} = user}} = conn,
|
%{assigns: %{user: %User{nickname: nickname, ap_id: actor} = user}} = conn,
|
||||||
%{"nickname" => nickname} = params
|
%{"nickname" => nickname} = params
|
||||||
) do
|
) do
|
||||||
actor = user.ap_id
|
|
||||||
|
|
||||||
params =
|
params =
|
||||||
params
|
params
|
||||||
|> Map.drop(["id"])
|
|> Map.drop(["nickname"])
|
||||||
|
|> Map.put("id", Utils.generate_activity_id())
|
||||||
|> Map.put("actor", actor)
|
|> Map.put("actor", actor)
|
||||||
|> Transmogrifier.fix_addressing()
|
|
||||||
|
|
||||||
with {:ok, %Activity{} = activity} <- handle_user_activity(user, params) do
|
with {:ok, params} <- fix_user_message(user, params),
|
||||||
|
{:ok, activity, _} <- Pipeline.common_pipeline(params, local: true),
|
||||||
|
%Activity{data: activity_data} <- Activity.normalize(activity) do
|
||||||
conn
|
conn
|
||||||
|> put_status(:created)
|
|> put_status(:created)
|
||||||
|> put_resp_header("location", activity.data["id"])
|
|> put_resp_header("location", activity_data["id"])
|
||||||
|> json(activity.data)
|
|> json(activity_data)
|
||||||
else
|
else
|
||||||
|
{:forbidden, message} ->
|
||||||
|
conn
|
||||||
|
|> put_status(:forbidden)
|
||||||
|
|> json(message)
|
||||||
|
|
||||||
{:error, message} ->
|
{:error, message} ->
|
||||||
conn
|
conn
|
||||||
|> put_status(:bad_request)
|
|> put_status(:bad_request)
|
||||||
|> json(message)
|
|> json(message)
|
||||||
|
|
||||||
|
e ->
|
||||||
|
Logger.warn(fn -> "AP C2S: #{inspect(e)}" end)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("Bad Request")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
alias Pleroma.Web.ActivityPub.Relay
|
alias Pleroma.Web.ActivityPub.Relay
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.ActivityPub.Visibility
|
alias Pleroma.Web.ActivityPub.Visibility
|
||||||
|
alias Pleroma.Web.CommonAPI.ActivityDraft
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
@ -125,6 +126,37 @@ def create(actor, object, recipients) do
|
||||||
|> Pleroma.Maps.put_if_present("context", context), []}
|
|> Pleroma.Maps.put_if_present("context", context), []}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec note(ActivityDraft.t()) :: {:ok, map(), keyword()}
|
||||||
|
def note(%ActivityDraft{} = draft) do
|
||||||
|
data =
|
||||||
|
%{
|
||||||
|
"type" => "Note",
|
||||||
|
"to" => draft.to,
|
||||||
|
"cc" => draft.cc,
|
||||||
|
"content" => draft.content_html,
|
||||||
|
"summary" => draft.summary,
|
||||||
|
"sensitive" => draft.sensitive,
|
||||||
|
"context" => draft.context,
|
||||||
|
"attachment" => draft.attachments,
|
||||||
|
"actor" => draft.user.ap_id,
|
||||||
|
"tag" => Keyword.values(draft.tags) |> Enum.uniq()
|
||||||
|
}
|
||||||
|
|> add_in_reply_to(draft.in_reply_to)
|
||||||
|
|> Map.merge(draft.extra)
|
||||||
|
|
||||||
|
{:ok, data, []}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp add_in_reply_to(object, nil), do: object
|
||||||
|
|
||||||
|
defp add_in_reply_to(object, in_reply_to) do
|
||||||
|
with %Object{} = in_reply_to_object <- Object.normalize(in_reply_to, fetch: false) do
|
||||||
|
Map.put(object, "inReplyTo", in_reply_to_object.data["id"])
|
||||||
|
else
|
||||||
|
_ -> object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def chat_message(actor, recipient, content, opts \\ []) do
|
def chat_message(actor, recipient, content, opts \\ []) do
|
||||||
basic = %{
|
basic = %{
|
||||||
"id" => Utils.generate_object_id(),
|
"id" => Utils.generate_object_id(),
|
||||||
|
@ -223,7 +255,7 @@ def announce(actor, object, options \\ []) do
|
||||||
[actor.follower_address]
|
[actor.follower_address]
|
||||||
|
|
||||||
public? and Visibility.is_local_public?(object) ->
|
public? and Visibility.is_local_public?(object) ->
|
||||||
[actor.follower_address, object.data["actor"], Pleroma.Constants.as_local_public()]
|
[actor.follower_address, object.data["actor"], Utils.as_local_public()]
|
||||||
|
|
||||||
public? ->
|
public? ->
|
||||||
[actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
|
[actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
|
||||||
|
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
||||||
type: [:module, {:list, :module}],
|
type: [:module, {:list, :module}],
|
||||||
description:
|
description:
|
||||||
"A list of MRF policies enabled. Module names are shortened (removed leading `Pleroma.Web.ActivityPub.MRF.` part), but on adding custom module you need to use full name.",
|
"A list of MRF policies enabled. Module names are shortened (removed leading `Pleroma.Web.ActivityPub.MRF.` part), but on adding custom module you need to use full name.",
|
||||||
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF}
|
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF.Policy}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :transparency,
|
key: :transparency,
|
||||||
|
@ -33,9 +33,11 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
||||||
%{
|
%{
|
||||||
key: :transparency_exclusions,
|
key: :transparency_exclusions,
|
||||||
label: "MRF transparency exclusions",
|
label: "MRF transparency exclusions",
|
||||||
type: {:list, :string},
|
type: {:list, :tuple},
|
||||||
|
key_placeholder: "instance",
|
||||||
|
value_placeholder: "reason",
|
||||||
description:
|
description:
|
||||||
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.",
|
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value. You can also provide a reason for excluding these instance names. The instances and reasons won't be publicly disclosed.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"exclusion.com"
|
"exclusion.com"
|
||||||
]
|
]
|
||||||
|
@ -51,17 +53,6 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
||||||
|
|
||||||
@required_description_keys [:key, :related_policy]
|
@required_description_keys [:key, :related_policy]
|
||||||
|
|
||||||
@callback filter(Map.t()) :: {:ok | :reject, Map.t()}
|
|
||||||
@callback describe() :: {:ok | :error, Map.t()}
|
|
||||||
@callback config_description() :: %{
|
|
||||||
optional(:children) => [map()],
|
|
||||||
key: atom(),
|
|
||||||
related_policy: String.t(),
|
|
||||||
label: String.t(),
|
|
||||||
description: String.t()
|
|
||||||
}
|
|
||||||
@optional_callbacks config_description: 0
|
|
||||||
|
|
||||||
def filter(policies, %{} = message) do
|
def filter(policies, %{} = message) do
|
||||||
policies
|
policies
|
||||||
|> Enum.reduce({:ok, message}, fn
|
|> Enum.reduce({:ok, message}, fn
|
||||||
|
@ -111,6 +102,11 @@ def subdomain_match?(domains, host) do
|
||||||
Enum.any?(domains, fn domain -> Regex.match?(domain, host) end)
|
Enum.any?(domains, fn domain -> Regex.match?(domain, host) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec instance_list_from_tuples([{String.t(), String.t()}]) :: [String.t()]
|
||||||
|
def instance_list_from_tuples(list) do
|
||||||
|
Enum.map(list, fn {instance, _} -> instance end)
|
||||||
|
end
|
||||||
|
|
||||||
def describe(policies) do
|
def describe(policies) do
|
||||||
{:ok, policy_configs} =
|
{:ok, policy_configs} =
|
||||||
policies
|
policies
|
||||||
|
@ -142,7 +138,7 @@ def describe(policies) do
|
||||||
def describe, do: get_policies() |> describe()
|
def describe, do: get_policies() |> describe()
|
||||||
|
|
||||||
def config_descriptions do
|
def config_descriptions do
|
||||||
Pleroma.Web.ActivityPub.MRF
|
Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|> Pleroma.Docs.Generator.list_behaviour_implementations()
|
|> Pleroma.Docs.Generator.list_behaviour_implementations()
|
||||||
|> config_descriptions()
|
|> config_descriptions()
|
||||||
end
|
end
|
||||||
|
@ -161,9 +157,7 @@ def config_descriptions(policies) do
|
||||||
[description | acc]
|
[description | acc]
|
||||||
else
|
else
|
||||||
Logger.warn(
|
Logger.warn(
|
||||||
"#{policy} config description doesn't have one or all required keys #{
|
"#{policy} config description doesn't have one or all required keys #{inspect(@required_description_keys)}"
|
||||||
inspect(@required_description_keys)
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
acc
|
acc
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
|
||||||
@moduledoc "Adds expiration to all local Create activities"
|
@moduledoc "Adds expiration to all local Create activities"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(activity) do
|
def filter(activity) do
|
||||||
|
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
|
||||||
|
|
||||||
@moduledoc "Prevent followbots from following with a bit of heuristic"
|
@moduledoc "Prevent followbots from following with a bit of heuristic"
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
# XXX: this should become User.normalize_by_ap_id() or similar, really.
|
# XXX: this should become User.normalize_by_ap_id() or similar, really.
|
||||||
defp normalize_by_ap_id(%{"id" => id}), do: User.get_cached_by_ap_id(id)
|
defp normalize_by_ap_id(%{"id" => id}), do: User.get_cached_by_ap_id(id)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
||||||
require Logger
|
require Logger
|
||||||
@moduledoc "Drop and log everything received"
|
@moduledoc "Drop and log everything received"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(object) do
|
def filter(object) do
|
||||||
|
|
|
@ -6,7 +6,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
|
|
||||||
@moduledoc "Ensure a re: is prepended on replies to a post with a Subject"
|
@moduledoc "Ensure a re: is prepended on replies to a post with a Subject"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
|
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue