Merge remote-tracking branch 'upstream/develop' into metadata_webfinger
This commit is contained in:
commit
7ff9c356f4
184 changed files with 18081 additions and 6032 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -73,6 +73,7 @@ pleroma.iml
|
|||
|
||||
# Generated documentation
|
||||
docs/site
|
||||
docs/venv
|
||||
|
||||
# docker stuff
|
||||
docker-db
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
platform: linux/amd64
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
variables:
|
||||
- &scw-secrets
|
||||
- SCW_ACCESS_KEY
|
||||
|
@ -12,8 +17,6 @@ variables:
|
|||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- refs/tags/v*
|
||||
- refs/tags/stable-*
|
||||
- &on-stable
|
||||
when:
|
||||
event:
|
||||
|
@ -21,14 +24,6 @@ variables:
|
|||
- tag
|
||||
branch:
|
||||
- stable
|
||||
- refs/tags/stable-*
|
||||
- &on-point-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- &on-pr-open
|
||||
when:
|
||||
event:
|
||||
|
@ -39,63 +34,10 @@ variables:
|
|||
- &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix)"
|
||||
- &mix-clean "mix deps.clean --all && mix clean"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
environment:
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
|
||||
pipeline:
|
||||
lint:
|
||||
<<: *on-pr-open
|
||||
image: akkoma/ci-base:1.14
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix format --check-formatted
|
||||
|
||||
build:
|
||||
image: akkoma/ci-base:1.14
|
||||
<<: *on-pr-open
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
DB_HOST: postgres
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get
|
||||
- mix compile
|
||||
|
||||
test:
|
||||
image: akkoma/ci-base:1.14
|
||||
<<: *on-pr-open
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
DB_HOST: postgres
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get
|
||||
- mix compile
|
||||
- mix ecto.drop -f -q
|
||||
- mix ecto.create
|
||||
- mix ecto.migrate
|
||||
- mix test --preload-modules --exclude erratic --exclude federated --max-cases 4
|
||||
|
||||
# Canonical amd64
|
||||
ubuntu22:
|
||||
image: hexpm/elixir:1.14.2-erlang-25.1.2-ubuntu-jammy-20220428
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-ubuntu-jammy-20221130
|
||||
<<: *on-release
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
|
@ -122,7 +64,7 @@ pipeline:
|
|||
- /bin/sh /entrypoint.sh
|
||||
|
||||
debian-bullseye:
|
||||
image: hexpm/elixir:1.14.2-erlang-25.1.2-debian-bullseye-20221004
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-debian-bullseye-20230109
|
||||
<<: *on-release
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
|
@ -151,7 +93,7 @@ pipeline:
|
|||
|
||||
# Canonical amd64-musl
|
||||
musl:
|
||||
image: hexpm/elixir:1.14.2-erlang-25.1.2-alpine-3.16.2
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-alpine-3.18.0
|
||||
<<: *on-stable
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
|
@ -173,25 +115,3 @@ pipeline:
|
|||
- export SOURCE=akkoma-amd64-musl.zip
|
||||
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-amd64-musl.zip
|
||||
- /bin/sh /entrypoint.sh
|
||||
|
||||
docs:
|
||||
<<: *on-point-release
|
||||
secrets:
|
||||
- SCW_ACCESS_KEY
|
||||
- SCW_SECRET_KEY
|
||||
- SCW_DEFAULT_ORGANIZATION_ID
|
||||
environment:
|
||||
CI: "true"
|
||||
image: python:3.10-slim
|
||||
commands:
|
||||
- apt-get update && apt-get install -y rclone wget git zip
|
||||
- wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64
|
||||
- mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli
|
||||
- chmod +x scaleway-cli
|
||||
- ./scaleway-cli object config install type=rclone
|
||||
- cd docs
|
||||
- pip install -r requirements.txt
|
||||
- mkdocs build
|
||||
- zip -r docs.zip site/*
|
||||
- cd site
|
||||
- rclone copy . scaleway:akkoma-docs/$CI_COMMIT_BRANCH/
|
115
.woodpecker/build-arm64.yml
Normal file
115
.woodpecker/build-arm64.yml
Normal file
|
@ -0,0 +1,115 @@
|
|||
platform: linux/arm64
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
variables:
|
||||
- &scw-secrets
|
||||
- SCW_ACCESS_KEY
|
||||
- SCW_SECRET_KEY
|
||||
- SCW_DEFAULT_ORGANIZATION_ID
|
||||
- &setup-hex "mix local.hex --force && mix local.rebar --force"
|
||||
- &on-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- stable
|
||||
- develop
|
||||
- &on-stable
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- stable
|
||||
- &on-pr-open
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- &tag-build "export BUILD_TAG=$${CI_COMMIT_TAG:-\"$CI_COMMIT_BRANCH\"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG"
|
||||
|
||||
- &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix)"
|
||||
- &mix-clean "mix deps.clean --all && mix clean"
|
||||
|
||||
pipeline:
|
||||
# Canonical arm64
|
||||
ubuntu22:
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-ubuntu-jammy-20221130
|
||||
<<: *on-release
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
commands:
|
||||
- apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev git build-essential g++ wget
|
||||
- *clean
|
||||
- echo "import Config" > config/prod.secret.exs
|
||||
- *setup-hex
|
||||
- *tag-build
|
||||
- mix deps.get --only prod
|
||||
- mix release --path release
|
||||
- zip akkoma-ubuntu-jammy.zip -r release
|
||||
|
||||
release-ubuntu22:
|
||||
image: akkoma/releaser:arm64
|
||||
<<: *on-release
|
||||
secrets: *scw-secrets
|
||||
commands:
|
||||
- export SOURCE=akkoma-ubuntu-jammy.zip
|
||||
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-arm64-ubuntu-jammy.zip
|
||||
- /bin/sh /entrypoint.sh
|
||||
|
||||
debian-bullseye:
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-debian-bullseye-20230109
|
||||
<<: *on-stable
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
commands:
|
||||
- apt-get update && apt-get install -y cmake libmagic-dev rclone zip imagemagick libmagic-dev git build-essential gcc make g++ wget
|
||||
- *clean
|
||||
- echo "import Config" > config/prod.secret.exs
|
||||
- *setup-hex
|
||||
- *tag-build
|
||||
- *mix-clean
|
||||
- mix deps.get --only prod
|
||||
- mix release --path release
|
||||
- zip akkoma-arm64.zip -r release
|
||||
|
||||
release-debian:
|
||||
image: akkoma/releaser:arm64
|
||||
<<: *on-stable
|
||||
secrets: *scw-secrets
|
||||
commands:
|
||||
- export SOURCE=akkoma-arm64.zip
|
||||
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-arm64.zip
|
||||
- /bin/sh /entrypoint.sh
|
||||
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-debian-stable.zip
|
||||
- /bin/sh /entrypoint.sh
|
||||
|
||||
# Canonical arm64-musl
|
||||
musl:
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-alpine-3.18.0
|
||||
<<: *on-stable
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
commands:
|
||||
- apk add git gcc g++ musl-dev make cmake file-dev rclone wget zip imagemagick
|
||||
- *clean
|
||||
- *setup-hex
|
||||
- *mix-clean
|
||||
- *tag-build
|
||||
- mix deps.get --only prod
|
||||
- mix release --path release
|
||||
- zip akkoma-arm64-musl.zip -r release
|
||||
|
||||
release-musl:
|
||||
image: akkoma/releaser:arm64
|
||||
<<: *on-stable
|
||||
secrets: *scw-secrets
|
||||
commands:
|
||||
- export SOURCE=akkoma-arm64-musl.zip
|
||||
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-arm64-musl.zip
|
||||
- /bin/sh /entrypoint.sh
|
69
.woodpecker/docs.yml
Normal file
69
.woodpecker/docs.yml
Normal file
|
@ -0,0 +1,69 @@
|
|||
platform: linux/amd64
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
- build-amd64
|
||||
|
||||
variables:
|
||||
- &scw-secrets
|
||||
- SCW_ACCESS_KEY
|
||||
- SCW_SECRET_KEY
|
||||
- SCW_DEFAULT_ORGANIZATION_ID
|
||||
- &setup-hex "mix local.hex --force && mix local.rebar --force"
|
||||
- &on-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- refs/tags/v*
|
||||
- refs/tags/stable-*
|
||||
- &on-stable
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- stable
|
||||
- refs/tags/stable-*
|
||||
- &on-point-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- &on-pr-open
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- &tag-build "export BUILD_TAG=$${CI_COMMIT_TAG:-\"$CI_COMMIT_BRANCH\"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG"
|
||||
|
||||
- &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix)"
|
||||
- &mix-clean "mix deps.clean --all && mix clean"
|
||||
|
||||
pipeline:
|
||||
docs:
|
||||
<<: *on-point-release
|
||||
secrets:
|
||||
- SCW_ACCESS_KEY
|
||||
- SCW_SECRET_KEY
|
||||
- SCW_DEFAULT_ORGANIZATION_ID
|
||||
environment:
|
||||
CI: "true"
|
||||
image: python:3.10-slim
|
||||
commands:
|
||||
- apt-get update && apt-get install -y rclone wget git zip
|
||||
- wget https://github.com/scaleway/scaleway-cli/releases/download/v2.5.1/scaleway-cli_2.5.1_linux_amd64
|
||||
- mv scaleway-cli_2.5.1_linux_amd64 scaleway-cli
|
||||
- chmod +x scaleway-cli
|
||||
- ./scaleway-cli object config install type=rclone
|
||||
- cd docs
|
||||
- pip install -r requirements.txt
|
||||
- mkdocs build
|
||||
- zip -r docs.zip site/*
|
||||
- cd site
|
||||
- rclone copy . scaleway:akkoma-docs/$CI_COMMIT_BRANCH/
|
96
.woodpecker/test.yml
Normal file
96
.woodpecker/test.yml
Normal file
|
@ -0,0 +1,96 @@
|
|||
platform: linux/amd64
|
||||
|
||||
variables:
|
||||
- &scw-secrets
|
||||
- SCW_ACCESS_KEY
|
||||
- SCW_SECRET_KEY
|
||||
- SCW_DEFAULT_ORGANIZATION_ID
|
||||
- &setup-hex "mix local.hex --force && mix local.rebar --force"
|
||||
- &on-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- refs/tags/v*
|
||||
- refs/tags/stable-*
|
||||
- &on-stable
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
branch:
|
||||
- stable
|
||||
- refs/tags/stable-*
|
||||
- &on-point-release
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- develop
|
||||
- stable
|
||||
- &on-pr-open
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- &tag-build "export BUILD_TAG=$${CI_COMMIT_TAG:-\"$CI_COMMIT_BRANCH\"} && export PLEROMA_BUILD_BRANCH=$BUILD_TAG"
|
||||
|
||||
- &clean "(rm -rf release || true) && (rm -rf _build || true) && (rm -rf /root/.mix)"
|
||||
- &mix-clean "mix deps.clean --all && mix clean"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
environment:
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
|
||||
pipeline:
|
||||
lint:
|
||||
<<: *on-pr-open
|
||||
image: akkoma/ci-base:1.14
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix format --check-formatted
|
||||
|
||||
build:
|
||||
image: akkoma/ci-base:1.14
|
||||
<<: *on-pr-open
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
DB_HOST: postgres
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get
|
||||
- mix compile
|
||||
|
||||
test:
|
||||
image: akkoma/ci-base:1.14
|
||||
<<: *on-pr-open
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
POSTGRES_DB: pleroma_test
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
DB_HOST: postgres
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get
|
||||
- mix compile
|
||||
- mix ecto.drop -f -q
|
||||
- mix ecto.create
|
||||
- mix ecto.migrate
|
||||
- mix test --preload-modules --exclude erratic --exclude federated --max-cases 4
|
74
CHANGELOG.md
74
CHANGELOG.md
|
@ -6,6 +6,79 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
## Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- Added a new configuration option to the MediaProxy feature that allows the blocking of specific domains from using the media proxy or being explicitly allowed by the Content-Security-Policy.
|
||||
- Please make sure instances you wanted to block media from are not in the MediaProxy `whitelist`, and instead use `blocklist`.
|
||||
- `OnlyMedia` Upload Filter to simplify restricting uploads to audio, image, and video types
|
||||
- ARM64 OTP builds
|
||||
- Ubuntu22 builds are available for develop and stable
|
||||
- other distributions are stable only
|
||||
|
||||
## Changed
|
||||
|
||||
- Alpine OTP builds are now from alpine 3.18, which is SSLv3 compatible.
|
||||
If you use alpine OTP builds you will have to update your local system.
|
||||
|
||||
## Fixed
|
||||
|
||||
- Deactivated users can no longer show up in the emoji reaction list
|
||||
- Embedded posts can no longer bypass `:restrict\_unauthenticated`
|
||||
|
||||
## Security
|
||||
|
||||
- Add `no_new_privs` hardening to OpenRC and systemd service files
|
||||
|
||||
## 2023.05
|
||||
|
||||
## Added
|
||||
- Custom options for users to accept/reject private messages
|
||||
- options: everybody, nobody, people\_i\_follow
|
||||
- MRF to reject notes from accounts newer than a given age
|
||||
- this will have the side-effect of rejecting legitimate messages if your
|
||||
post gets boosted outside of your local bubble and people your instance
|
||||
does not know about reply to it.
|
||||
|
||||
## Fixed
|
||||
- Support for `streams` public key URIs
|
||||
- Bookmarks are cleaned up on DB prune now
|
||||
|
||||
## Security
|
||||
- Fixed mediaproxy being a bit of a silly billy
|
||||
|
||||
## 2023.04
|
||||
|
||||
## Added
|
||||
- Nodeinfo keys for unauthenticated timeline visibility
|
||||
- Option to disable federated timeline
|
||||
- Option to make the bubble timeline publicly accessible
|
||||
- Ability to swap between installed standard frontends
|
||||
- *mastodon frontends are still not counted as standard frontends due to the complexity in serving them correctly*.
|
||||
|
||||
### Upgrade Notes
|
||||
- Elixir 1.14 is now required. If your distribution does not package this, you can
|
||||
use [asdf](https://asdf-vm.com/). At time of writing, elixir 1.14.3 / erlang 25.3
|
||||
is confirmed to work.
|
||||
|
||||
## 2023.03
|
||||
|
||||
## Fixed
|
||||
- Allowed contentMap to be updated on edit
|
||||
- Filter creation now accepts expires\_at
|
||||
|
||||
### Changed
|
||||
- Restoring the database from a dump now goes much faster without need for work-arounds
|
||||
- Misskey reaction matching uses `content` parameter now
|
||||
|
||||
### Added
|
||||
- Extend the mix task `prune_objects` with option `--prune-orphaned-activities` to also prune orphaned activities, allowing to reclaim even more database space
|
||||
|
||||
### Removed
|
||||
- Possibility of using the `style` parameter on `span` elements. This will break certain MFM parameters.
|
||||
- Option for "default" image description.
|
||||
|
||||
## 2023.02
|
||||
|
||||
### Added
|
||||
- Prometheus metrics exporting from `/api/v1/akkoma/metrics`
|
||||
- Ability to alter http pool size
|
||||
|
@ -37,6 +110,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Simplified HTTP signature processing
|
||||
- Rich media will now hard-exit after 5 seconds, to prevent timeline hangs
|
||||
- HTTP Content Security Policy is now far more strict to prevent any potential XSS/CSS leakages
|
||||
- Follow requests are now paginated, matches mastodon API spec, so use the Link header to paginate.
|
||||
|
||||
### Fixed
|
||||
- /api/v1/accounts/lookup will now respect restrict\_unauthenticated
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM hexpm/elixir:1.13.4-erlang-24.3.4.5-alpine-3.15.6
|
||||
FROM hexpm/elixir:1.14.3-erlang-25.2.2-alpine-3.18.0
|
||||
|
||||
ENV MIX_ENV=prod
|
||||
ENV ERL_EPMD_ADDRESS=127.0.0.1
|
||||
|
|
7
Makefile
7
Makefile
|
@ -1,7 +0,0 @@
|
|||
all: install
|
||||
pipenv run mkdocs build
|
||||
|
||||
install:
|
||||
pipenv install
|
||||
clean:
|
||||
rm -rf docs
|
|
@ -54,6 +54,9 @@ If your platform is not supported, or you just want to be able to edit the sourc
|
|||
### Docker
|
||||
Docker installation is supported via [this setup](https://docs.akkoma.dev/stable/installation/docker_en/)
|
||||
|
||||
### Packages
|
||||
Akkoma is packaged for [YunoHost](https://yunohost.org) and can be found and installed from the [YunoHost app catalogue](https://yunohost.org/#/apps).
|
||||
|
||||
### Compilation Troubleshooting
|
||||
If you ever encounter compilation issues during the updating of Akkoma, you can try these commands and see if they fix things:
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
link_name: false,
|
||||
proxy_remote: false,
|
||||
filename_display_max_length: 30,
|
||||
default_description: nil,
|
||||
base_url: nil
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
||||
|
@ -261,7 +260,8 @@
|
|||
privileged_staff: false,
|
||||
local_bubble: [],
|
||||
max_frontend_settings_json_chars: 100_000,
|
||||
export_prometheus_metrics: true
|
||||
export_prometheus_metrics: true,
|
||||
federated_timeline_available: true
|
||||
|
||||
config :pleroma, :welcome,
|
||||
direct_message: [
|
||||
|
@ -354,7 +354,7 @@
|
|||
|
||||
config :pleroma, :activitypub,
|
||||
unfollow_blocked: true,
|
||||
outgoing_blocks: true,
|
||||
outgoing_blocks: false,
|
||||
blockers_visible: true,
|
||||
follow_handshake_timeout: 500,
|
||||
note_replies_output_limit: 5,
|
||||
|
@ -418,6 +418,8 @@
|
|||
|
||||
config :pleroma, :mrf_follow_bot, follower_nickname: nil
|
||||
|
||||
config :pleroma, :mrf_reject_newly_created_account_notes, age: 86_400
|
||||
|
||||
config :pleroma, :rich_media,
|
||||
enabled: true,
|
||||
ignore_hosts: [],
|
||||
|
@ -441,7 +443,8 @@
|
|||
# Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1
|
||||
max_read_duration: 30_000
|
||||
],
|
||||
whitelist: []
|
||||
whitelist: [],
|
||||
blocklist: []
|
||||
|
||||
config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Http,
|
||||
method: :purge,
|
||||
|
@ -745,6 +748,9 @@
|
|||
primary: %{"name" => "pleroma-fe", "ref" => "stable"},
|
||||
admin: %{"name" => "admin-fe", "ref" => "stable"},
|
||||
mastodon: %{"name" => "mastodon-fe", "ref" => "akkoma"},
|
||||
pickable: [
|
||||
"pleroma-fe/stable"
|
||||
],
|
||||
swagger: %{
|
||||
"name" => "swagger-ui",
|
||||
"ref" => "stable",
|
||||
|
@ -810,7 +816,7 @@
|
|||
private_instance? = :if_instance_is_private
|
||||
|
||||
config :pleroma, :restrict_unauthenticated,
|
||||
timelines: %{local: private_instance?, federated: private_instance?},
|
||||
timelines: %{local: private_instance?, federated: private_instance?, bubble: true},
|
||||
profiles: %{local: private_instance?, remote: private_instance?},
|
||||
activities: %{local: private_instance?, remote: private_instance?}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
hehe, /emoji/hehe.png, Akkoma
|
||||
nothehe, /emoji/nothehe.png, Akkoma
|
|
@ -790,7 +790,7 @@
|
|||
%{
|
||||
key: :healthcheck,
|
||||
type: :boolean,
|
||||
description: "If enabled, system data will be shown on `/api/pleroma/healthcheck`"
|
||||
description: "If enabled, system data will be shown on `/api/v1/pleroma/healthcheck`"
|
||||
},
|
||||
%{
|
||||
key: :remote_post_retention_days,
|
||||
|
@ -969,6 +969,12 @@
|
|||
key: :export_prometheus_metrics,
|
||||
type: :boolean,
|
||||
description: "Enable prometheus metrics (at /api/v1/akkoma/metrics)"
|
||||
},
|
||||
%{
|
||||
key: :federated_timeline_available,
|
||||
type: :boolean,
|
||||
description:
|
||||
"Let people view the 'firehose' feed of all public statuses from all instances."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1552,7 +1558,21 @@
|
|||
%{
|
||||
key: :whitelist,
|
||||
type: {:list, :string},
|
||||
description: "List of hosts with scheme to bypass the MediaProxy",
|
||||
description: """
|
||||
List of hosts with scheme to bypass the MediaProxy.\n
|
||||
The media will be fetched by the client, directly from the remote server.\n
|
||||
To allow this, it will Content-Security-Policy exceptions for each instance listed.\n
|
||||
This is to be used for instances you trust and do not want to cache media for.
|
||||
""",
|
||||
suggestions: ["http://example.com"]
|
||||
},
|
||||
%{
|
||||
key: :blocklist,
|
||||
type: {:list, :string},
|
||||
description: """
|
||||
List of hosts with scheme which will not go through the MediaProxy, and will not be explicitly allowed by the Content-Security-Policy.
|
||||
This is to be used for instances where you do not want their media to go through your server or to be accessed by clients.
|
||||
""",
|
||||
suggestions: ["http://example.com"]
|
||||
}
|
||||
]
|
||||
|
@ -2993,6 +3013,11 @@
|
|||
key: :federated,
|
||||
type: :boolean,
|
||||
description: "Disallow viewing the whole known network timeline."
|
||||
},
|
||||
%{
|
||||
key: :bubble,
|
||||
type: :boolean,
|
||||
description: "Disallow viewing the bubble timeline."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3148,6 +3173,12 @@
|
|||
description:
|
||||
"A map containing available frontends and parameters for their installation.",
|
||||
children: frontend_options
|
||||
},
|
||||
%{
|
||||
key: :pickable,
|
||||
type: {:list, :string},
|
||||
description:
|
||||
"A list containing all frontends users can pick as their preference, format is :name/:ref, e.g pleroma-fe/stable."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
config :pleroma, Pleroma.Upload,
|
||||
filters: [],
|
||||
link_name: false,
|
||||
default_description: :filename
|
||||
link_name: false
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) akkoma
|
||||
docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) db
|
||||
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) akkoma
|
||||
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) db
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker-compose run --rm akkoma $@
|
||||
docker compose run --rm akkoma $@
|
||||
|
|
|
@ -2,33 +2,27 @@
|
|||
|
||||
You don't need to build and test the docs as long as you make sure the syntax is correct. But in case you do want to build the docs, feel free to do so.
|
||||
|
||||
You'll need to install mkdocs for which you can check the [mkdocs installation guide](https://www.mkdocs.org/#installation). Generally it's best to install it using `pip`. You'll also need to install the correct dependencies.
|
||||
```sh
|
||||
# Make sure you're in the same directory as this README
|
||||
# From the root of the Akkoma repo, you'll need to do
|
||||
cd docs
|
||||
|
||||
### Example using a Debian based distro
|
||||
# Optionally use a virtual environment
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
#### 1. Install pipenv and dependencies
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
```shell
|
||||
pip install pipenv
|
||||
pipenv sync
|
||||
# Run an http server who rebuilds when files change
|
||||
# Accessable on http://127.0.0.1:8000
|
||||
mkdocs serve
|
||||
|
||||
# Build the docs
|
||||
# The static html pages will have been created in the folder "site"
|
||||
# You can serve them from a server by pointing your server software (nginx, apache...) to this location
|
||||
mkdocs build
|
||||
|
||||
# To get out of the virtual environment, you do
|
||||
deactivate
|
||||
```
|
||||
|
||||
#### 2. (Optional) Activate the virtual environment
|
||||
|
||||
Since dependencies are installed in a virtual environment, you can't use them directly. To use them you should either prefix the command with `pipenv run`, or activate the virtual environment for current shell by executing `pipenv shell` once.
|
||||
|
||||
#### 3. Build the docs using the script
|
||||
|
||||
```shell
|
||||
[pipenv run] make all
|
||||
```
|
||||
|
||||
#### 4. Serve the files
|
||||
|
||||
A folder `site` containing the static html pages will have been created. You can serve them from a server by pointing your server software (nginx, apache...) to this location. During development, you can run locally with
|
||||
|
||||
```shell
|
||||
[pipenv run] mkdocs serve
|
||||
```
|
||||
|
||||
This handles setting up an http server and rebuilding when files change. You can then access the docs on <http://127.0.0.1:8000>
|
||||
|
|
|
@ -21,7 +21,6 @@ Replaces embedded objects with references to them in the `objects` table. Only n
|
|||
mix pleroma.database remove_embedded_objects [option ...]
|
||||
```
|
||||
|
||||
|
||||
### Options
|
||||
- `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
|
||||
|
||||
|
@ -29,8 +28,11 @@ Replaces embedded objects with references to them in the `objects` table. Only n
|
|||
|
||||
This will prune remote posts older than 90 days (configurable with [`config :pleroma, :instance, remote_post_retention_days`](../../configuration/cheatsheet.md#instance)) from the database. Pruned posts may be refetched in some cases.
|
||||
|
||||
!!! note
|
||||
The disk space will only be reclaimed after a proper vacuum. By default Postgresql does this for you on a regular basis, but if your instance has been running for a long time and there are many rows deleted, it may be advantageous to use `VACUUM FULL` (e.g. by using the `--vacuum` option).
|
||||
|
||||
!!! danger
|
||||
The disk space will only be reclaimed after `VACUUM FULL`. You may run out of disk space during the execution of the task or vacuuming if you don't have about 1/3rds of the database size free.
|
||||
You may run out of disk space during the execution of the task or vacuuming if you don't have about 1/3rds of the database size free. Vacuum causes a substantial increase in I/O traffic, and may lead to a degraded experience while it is running.
|
||||
|
||||
=== "OTP"
|
||||
|
||||
|
@ -46,9 +48,10 @@ This will prune remote posts older than 90 days (configurable with [`config :ple
|
|||
|
||||
### Options
|
||||
|
||||
- `--keep-threads` - don't prune posts when they are part of a thread where at least one post has seen local interaction (e.g. one of the posts is a local post, or is favourited by a local user, or has been repeated by a local user...)
|
||||
- `--keep-non-public` - keep non-public posts like DM's and followers-only, even if they are remote
|
||||
- `--vacuum` - run `VACUUM FULL` after the objects are pruned
|
||||
- `--keep-threads` - Don't prune posts when they are part of a thread where at least one post has seen local interaction (e.g. one of the posts is a local post, or is favourited by a local user, or has been repeated by a local user...). It also wont delete posts when at least one of the posts in that thread is kept (e.g. because one of the posts has seen recent activity).
|
||||
- `--keep-non-public` - Keep non-public posts like DM's and followers-only, even if they are remote.
|
||||
- `--prune-orphaned-activities` - Also prune orphaned activities afterwards. Activities are things like Like, Create, Announce, Flag (aka reports)... They can significantly help reduce the database size.
|
||||
- `--vacuum` - Run `VACUUM FULL` after the objects are pruned. This should not be used on a regular basis, but is useful if your instance has been running for a long time before pruning.
|
||||
|
||||
## Create a conversation for all existing DMs
|
||||
|
||||
|
@ -96,6 +99,9 @@ Can be safely re-run
|
|||
|
||||
## Vacuum the database
|
||||
|
||||
!!! note
|
||||
By default Postgresql has an autovacuum deamon running. While the tasks described here can help in some cases, they shouldn't be needed on a regular basis. See [the Postgresql docs on vacuuming](https://www.postgresql.org/docs/current/sql-vacuum.html) for more information on this.
|
||||
|
||||
### Analyze
|
||||
|
||||
Running an `analyze` vacuum job can improve performance by updating statistics used by the query planner. **It is safe to cancel this.**
|
||||
|
|
|
@ -42,7 +42,7 @@ For a frontend configured under the `available` key, it's enough to install it b
|
|||
|
||||
This will download the latest build for the pre-configured `ref` and install it. It can then be configured as the one of the served frontends in the config file (see `primary` or `admin`).
|
||||
|
||||
You can override any of the details. To install a Pleroma-FE build from a different URL, you could do this:
|
||||
You can override any of the details. To install an Akkoma-FE build from a different URL, you could do this:
|
||||
|
||||
=== "OTP"
|
||||
|
||||
|
|
|
@ -21,33 +21,15 @@
|
|||
6. Restore the database schema and akkoma role using either of the following options
|
||||
* You can use the original `setup_db.psql` if you have it[²]: `sudo -Hu postgres psql -f config/setup_db.psql`.
|
||||
* Or recreate the database and user yourself (replace the password with the one you find in the config file) `sudo -Hu postgres psql -c "CREATE USER akkoma WITH ENCRYPTED PASSWORD '<database-password-wich-you-can-find-in-your-config-file>'; CREATE DATABASE akkoma OWNER akkoma;"`.
|
||||
7. Now restore the Akkoma instance's data into the empty database schema[¹][³]: `sudo -Hu postgres pg_restore -d akkoma -v -1 </path/to/backup_location/akkoma.pgdump>`
|
||||
8. If you installed a newer Akkoma version, you should run `MIX_ENV=prod mix ecto.migrate`[⁴]. This task performs database migrations, if there were any.
|
||||
7. Now restore the Akkoma instance's data into the empty database schema[¹]: `sudo -Hu postgres pg_restore -d akkoma -v -1 </path/to/backup_location/akkoma.pgdump>`
|
||||
8. If you installed a newer Akkoma version, you should run `MIX_ENV=prod mix ecto.migrate`[³]. This task performs database migrations, if there were any.
|
||||
9. Restart the Akkoma service.
|
||||
10. Run `sudo -Hu postgres vacuumdb --all --analyze-in-stages`. This will quickly generate the statistics so that postgres can properly plan queries.
|
||||
11. If setting up on a new server configure Nginx by using the `installation/akkoma.nginx` config sample or reference the Akkoma installation guide for your OS which contains the Nginx configuration instructions.
|
||||
|
||||
[¹]: We assume the database name and user are both "akkoma". If not, you can find the correct name in your config files.
|
||||
[²]: You can recreate the `config/setup_db.psql` by running the `mix pleroma.instance gen` task again. You can ignore most of the questions, but make the database user, name, and password the same as found in your backed up config file. This will also create a new `config/generated_config.exs` file which you may delete as it is not needed.
|
||||
[³]: `pg_restore` will add data before adding indexes. The indexes are added in alphabetical order. There's one index, `activities_visibility_index` which may take a long time because it can't make use of an index that's only added later. You can significantly speed up restoration by skipping this index and add it afterwards. For that, you can do the following (we assume the akkoma.pgdump is in the directory you're running the commands):
|
||||
|
||||
```sh
|
||||
pg_restore -l akkoma.pgdump > db.list
|
||||
|
||||
# Comment out the step for creating activities_visibility_index by adding a semi colon at the start of the line
|
||||
sed -i -E 's/(.*activities_visibility_index.*)/;\1/' db.list
|
||||
|
||||
# We restore the database using the db.list list-file
|
||||
sudo -Hu postgres pg_restore -L db.list -d akkoma -v -1 akkoma.pgdump
|
||||
|
||||
# You can see the sql statement with which to create the index using
|
||||
grep -Eao 'CREATE INDEX activities_visibility_index.*' akkoma.pgdump
|
||||
|
||||
# Then create the index manually
|
||||
# Make sure that the command to create is correct! You never know it has changed since writing this guide
|
||||
sudo -Hu postgres psql -d pleroma_ynh -c "CREATE INDEX activities_visibility_index ON public.activities USING btree (public.activity_visibility(actor, recipients, data), id DESC NULLS LAST) WHERE ((data ->> 'type'::text) = 'Create'::text);"
|
||||
```
|
||||
[⁴]: Prefix with `MIX_ENV=prod` to run it using the production config file.
|
||||
[³]: Prefix with `MIX_ENV=prod` to run it using the production config file.
|
||||
|
||||
## Remove
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ su -s "$SHELL" akkoma
|
|||
# Run database migrations
|
||||
./bin/pleroma_ctl migrate
|
||||
|
||||
# Update frontend(s). See Frontend Configuration doc for more information.
|
||||
./bin/pleroma_ctl frontend install pleroma-fe --ref stable
|
||||
|
||||
# Start akkoma
|
||||
./bin/pleroma daemon # or using the system service manager (e.g. systemctl start akkoma)
|
||||
|
||||
# Update frontend(s). See Frontend Configuration doc for more information.
|
||||
./bin/pleroma_ctl frontend install pleroma-fe --ref stable
|
||||
```
|
||||
|
||||
If you selected an alternate flavour on installation,
|
||||
|
@ -59,9 +59,9 @@ sudo systemctl stop akkoma
|
|||
# Run database migrations
|
||||
mix ecto.migrate
|
||||
|
||||
# Update Pleroma-FE frontend to latest stable. For other Frontends see Frontend Configration doc for more information.
|
||||
mix pleroma.frontend install pleroma-fe --ref stable
|
||||
|
||||
# Start akkoma (replace with your system service manager's equivalent if different)
|
||||
sudo systemctl start akkoma
|
||||
|
||||
# Update Akkoma-FE frontend to latest stable. For other Frontends see Frontend Configuration doc for more information.
|
||||
mix pleroma.frontend install pleroma-fe --ref stable
|
||||
```
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
Note: Additional clients may work, but these are known to work with Akkoma.
|
||||
Apps listed here might not support all of Akkoma's features.
|
||||
|
||||
## Multiplatform
|
||||
### Kaiteki
|
||||
- Homepage: <https://kaiteki.app/>
|
||||
- Source Code: <https://github.com/Kaiteki-Fedi/Kaiteki>
|
||||
- Contact: [@kaiteki@fedi.software](https://fedi.software/@Kaiteki)
|
||||
- Platforms: Web, Windows, Linux, Android
|
||||
- Features: MastoAPI, Supports multiple backends
|
||||
|
||||
## Desktop
|
||||
### Whalebird
|
||||
- Homepage: <https://whalebird.social/>
|
||||
|
@ -25,7 +33,7 @@ Apps listed here might not support all of Akkoma's features.
|
|||
- Features: MastoAPI, Streaming Ready, Moderation, Text Formatting
|
||||
|
||||
### Husky
|
||||
- Source code: <https://git.sr.ht/~captainepoch/husky>
|
||||
- Source code: <https://codeberg.org/husky/husky>
|
||||
- Contact: [@captainepoch@stereophonic.space](https://stereophonic.space/captainepoch)
|
||||
- Platforms: Android
|
||||
- Features: MastoAPI, No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
||||
|
@ -45,10 +53,10 @@ Apps listed here might not support all of Akkoma's features.
|
|||
|
||||
## Alternative Web Interfaces
|
||||
### Pinafore
|
||||
- Note: Pinafore is unmaintained (See [the author's original article](https://nolanlawson.com/2023/01/09/retiring-pinafore/) for details)
|
||||
- Homepage: <https://pinafore.social/>
|
||||
- Source Code: <https://github.com/nolanlawson/pinafore>
|
||||
- Contact: [@pinafore@mastodon.technology](https://mastodon.technology/users/pinafore)
|
||||
- Note: Pleroma support is a secondary goal
|
||||
- Features: MastoAPI, No Streaming
|
||||
|
||||
### Sengi
|
||||
|
|
|
@ -246,11 +246,11 @@ Notes:
|
|||
|
||||
### :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](https://docs-fe.akkoma.dev/stable/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` and `masto_fe` are configured. You can find the documentation for `pleroma_fe` configuration into [Akkoma-FE configuration and customization for instance administrators](https://docs-fe.akkoma.dev/stable/CONFIGURATION/#options).
|
||||
|
||||
Frontends can access these settings at `/api/v1/pleroma/frontend_configurations`
|
||||
|
||||
To add your own configuration for Pleroma-FE, use it like this:
|
||||
To add your own configuration for Akkoma-FE, use it like this:
|
||||
|
||||
```elixir
|
||||
config :pleroma, :frontend_configurations,
|
||||
|
@ -562,7 +562,6 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
|
|||
* `proxy_remote`: If you're using a remote uploader, Akkoma will proxy media requests instead of redirecting to it.
|
||||
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
||||
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
||||
* `default_description`: Sets which default description an image has if none is set explicitly. Options: nil (default) - Don't set a default, :filename - use the filename of the file, a string (e.g. "attachment") - Use this string
|
||||
|
||||
!!! warning
|
||||
`strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
|
||||
|
@ -616,6 +615,12 @@ This filter only strips the GPS and location metadata with Exiftool leaving colo
|
|||
|
||||
No specific configuration.
|
||||
|
||||
#### Pleroma.Upload.Filter.OnlyMedia
|
||||
|
||||
This filter rejects uploads that are not identified with Content-Type matching audio/\*, image/\*, or video/\*
|
||||
|
||||
No specific configuration.
|
||||
|
||||
#### Pleroma.Upload.Filter.Mogrify
|
||||
|
||||
* `args`: List of actions for the `mogrify` command like `"strip"` or `["strip", "auto-orient", {"implode", "1"}]`.
|
||||
|
|
|
@ -6,7 +6,7 @@ To add a custom theme to your instance, you'll first need to get a custom theme,
|
|||
|
||||
### Create your own theme
|
||||
|
||||
* You can create your own theme using the Pleroma FE by going to settings (gear on the top right) and choose the Theme tab. Here you have the options to create a personal theme.
|
||||
* You can create your own theme using the Akkoma FE by going to settings (gear on the top right) and choose the Theme tab. Here you have the options to create a personal theme.
|
||||
* To download your theme, you can do Save preset
|
||||
* If you want to upload a theme to customise it further, you can upload it using Load preset
|
||||
|
||||
|
@ -70,4 +70,4 @@ config :pleroma, :frontend_configurations,
|
|||
}
|
||||
```
|
||||
|
||||
If you added it in the back-end configuration file, you'll need to restart your instance for the changes to take effect. If you don't see the changes, it's probably because the browser has cached the previous theme. In that case you'll want to clear browser caches. Alternatively you can use a private/incognito window just to see the changes.
|
||||
If you added it in the back-end configuration file, you'll need to restart your instance for the changes to take effect. If you don't see the changes, it's probably because the browser has cached the previous theme. In that case you'll want to clear browser caches. Alternatively you can use a private/incognito window just to see the changes.
|
||||
|
|
|
@ -6,6 +6,31 @@ Akkoma performance is largely dependent on performance of the underlying databas
|
|||
|
||||
[PgTune](https://pgtune.leopard.in.ua) can be used to get recommended settings. Be sure to set "Number of Connections" to 20, otherwise it might produce settings hurtful to database performance. It is also recommended to not use "Network Storage" option.
|
||||
|
||||
If your server runs other services, you may want to take that into account. E.g. if you have 4G ram, but 1G of it is already used for other services, it may be better to tell PGTune you only have 3G. In the end, PGTune only provides recomended settings, you can always try to finetune further.
|
||||
|
||||
### Example configurations
|
||||
|
||||
Here are some configuration suggestions for PostgreSQL 10+.
|
||||
|
||||
#### 1GB RAM, 1 CPU
|
||||
```
|
||||
shared_buffers = 256MB
|
||||
effective_cache_size = 768MB
|
||||
maintenance_work_mem = 64MB
|
||||
work_mem = 13107kB
|
||||
```
|
||||
|
||||
#### 2GB RAM, 2 CPU
|
||||
```
|
||||
shared_buffers = 512MB
|
||||
effective_cache_size = 1536MB
|
||||
maintenance_work_mem = 128MB
|
||||
work_mem = 26214kB
|
||||
max_worker_processes = 2
|
||||
max_parallel_workers_per_gather = 1
|
||||
max_parallel_workers = 2
|
||||
```
|
||||
|
||||
## Disable generic query plans
|
||||
|
||||
When PostgreSQL receives a query, it decides on a strategy for searching the requested data, this is called a query plan. The query planner has two modes: generic and custom. Generic makes a plan for all queries of the same shape, ignoring the parameters, which is then cached and reused. Custom, on the contrary, generates a unique query plan based on query parameters.
|
||||
|
@ -23,26 +48,3 @@ config :pleroma, Pleroma.Repo,
|
|||
```
|
||||
|
||||
A more detailed explaination of the issue can be found at <https://blog.soykaf.com/post/postgresql-elixir-troubles/>.
|
||||
|
||||
## Example configurations
|
||||
|
||||
Here are some configuration suggestions for PostgreSQL 10+.
|
||||
|
||||
### 1GB RAM, 1 CPU
|
||||
```
|
||||
shared_buffers = 256MB
|
||||
effective_cache_size = 768MB
|
||||
maintenance_work_mem = 64MB
|
||||
work_mem = 13107kB
|
||||
```
|
||||
|
||||
### 2GB RAM, 2 CPU
|
||||
```
|
||||
shared_buffers = 512MB
|
||||
effective_cache_size = 1536MB
|
||||
maintenance_work_mem = 128MB
|
||||
work_mem = 26214kB
|
||||
max_worker_processes = 2
|
||||
max_parallel_workers_per_gather = 1
|
||||
max_parallel_workers = 2
|
||||
```
|
||||
|
|
|
@ -6,33 +6,46 @@ as soon as the post is received by your instance.
|
|||
|
||||
## Nginx
|
||||
|
||||
```
|
||||
proxy_cache_path /long/term/storage/path/akkoma-media-cache levels=1:2
|
||||
keys_zone=akkoma_media_cache:10m inactive=1y use_temp_path=off;
|
||||
The following are excerpts from the [suggested nginx config](../../../installation/nginx/akkoma.nginx) that demonstrates the necessary config for the media proxy to work.
|
||||
|
||||
A `proxy_cache_path` must be defined, for example:
|
||||
|
||||
```
|
||||
proxy_cache_path /long/term/storage/path/akkoma-media-cache levels=1:2
|
||||
keys_zone=akkoma_media_cache:10m inactive=1y use_temp_path=off;
|
||||
```
|
||||
|
||||
The `proxy_cache_path` must then be configured for use with media proxy paths:
|
||||
|
||||
```
|
||||
location ~ ^/(media|proxy) {
|
||||
proxy_cache akkoma_media_cache;
|
||||
slice 1m;
|
||||
proxy_cache_key $host$uri$is_args$args$slice_range;
|
||||
proxy_set_header Range $slice_range;
|
||||
proxy_http_version 1.1;
|
||||
proxy_cache_valid 206 301 302 304 1h;
|
||||
proxy_cache_valid 200 1y;
|
||||
proxy_cache_use_stale error timeout invalid_header updating;
|
||||
proxy_cache_valid 200 206 301 304 1h;
|
||||
proxy_cache_lock on;
|
||||
proxy_ignore_client_abort on;
|
||||
proxy_buffering on;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_ignore_headers Cache-Control Expires;
|
||||
proxy_hide_header Cache-Control Expires;
|
||||
proxy_pass http://127.0.0.1:4000;
|
||||
proxy_pass http://phoenix;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Ensure that `proxy_http_version 1.1;` is set for the above `location` block. In the suggested config, this is already the case.
|
||||
|
||||
## Akkoma
|
||||
|
||||
Add to your `prod.secret.exs`:
|
||||
### File-based Configuration
|
||||
|
||||
If you're using static file configuration, add the `MediaProxyWarmingPolicy` to your MRF policies. For example:
|
||||
|
||||
```
|
||||
config :pleroma, :mrf,
|
||||
policies: [Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy]
|
||||
```
|
||||
|
||||
### Database Configuration
|
||||
|
||||
In the admin interface, add `MediaProxyWarmingPolicy` to the `Policies` option under `Settings` → `MRF`.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Authentication is required and the user must be an admin.
|
||||
|
||||
The `/api/v1/pleroma/admin/*` path is backwards compatible with `/api/pleroma/admin/*` (`/api/pleroma/admin/*` will be deprecated in the future).
|
||||
Backwards-compatibility for admin API endpoints without version prefixes (`/api/pleroma/admin/*`) has been removed as of Akkoma 3.6.0. Please use `/api/v1/pleroma/admin/*` instead.
|
||||
|
||||
## `GET /api/v1/pleroma/admin/users`
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Home, public, hashtag & list timelines accept these parameters:
|
|||
## Statuses
|
||||
|
||||
- `visibility`: has additional possible values `list` and `local` (for local-only statuses)
|
||||
- `emoji_reactions`: additional field since Akkoma 3.2.0; identical to `pleroma/emoji_reactions`
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
|
@ -36,7 +37,9 @@ Has these additional fields under the `pleroma` object:
|
|||
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain`
|
||||
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
|
||||
- `thread_muted`: true if the thread the post belongs to is muted
|
||||
- `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint.
|
||||
- `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 2, me: true, account_ids: ["UserID1", "UserID2"]}`.
|
||||
The `account_ids` property was added in Akkoma 3.2.0.
|
||||
Further info about all reacting users at once, can be found using the `/statuses/:id/reactions` endpoint.
|
||||
- `parent_visible`: If the parent of this post is visible to the user or not.
|
||||
- `pinned_at`: a datetime (iso8601) when status was pinned, `null` otherwise.
|
||||
|
||||
|
@ -214,6 +217,11 @@ Returns: array of Status.
|
|||
|
||||
The maximum number of statuses is limited to 100 per request.
|
||||
|
||||
## PUT `/api/v1/statuses/:id/emoji_reactions/:emoji`
|
||||
|
||||
This endpoint is an extension of the Fedibird Mastodon fork.
|
||||
It behaves identical to PUT `/api/v1/pleroma/statuses/:id/reactions/:emoji`.
|
||||
|
||||
## PATCH `/api/v1/accounts/update_credentials`
|
||||
|
||||
Additional parameters can be added to the JSON body/Form data:
|
||||
|
|
|
@ -5,27 +5,16 @@ Akkoma includes support for exporting metrics via the [prometheus_ex](https://gi
|
|||
Config example:
|
||||
|
||||
```
|
||||
config :prometheus, Pleroma.Web.Endpoint.MetricsExporter,
|
||||
enabled: true,
|
||||
auth: {:basic, "myusername", "mypassword"},
|
||||
ip_whitelist: ["127.0.0.1"],
|
||||
path: "/api/pleroma/app_metrics",
|
||||
format: :text
|
||||
config :pleroma, :instance,
|
||||
export_prometheus_metrics: true
|
||||
```
|
||||
|
||||
* `enabled` (Akkoma extension) enables the endpoint
|
||||
* `ip_whitelist` (Akkoma extension) could be used to restrict access only to specified IPs
|
||||
* `auth` sets the authentication (`false` for no auth; configurable to HTTP Basic Auth, see [prometheus-plugs](https://github.com/deadtrickster/prometheus-plugs#exporting) documentation)
|
||||
* `format` sets the output format (`:text` or `:protobuf`)
|
||||
* `path` sets the path to app metrics page
|
||||
|
||||
|
||||
## `/api/pleroma/app_metrics`
|
||||
## `/api/v1/akkoma/metrics`
|
||||
|
||||
### Exports Prometheus application metrics
|
||||
|
||||
* Method: `GET`
|
||||
* Authentication: not required by default (see configuration options above)
|
||||
* Authentication: required
|
||||
* Params: none
|
||||
* Response: text
|
||||
|
||||
|
@ -37,7 +26,7 @@ The following is a config example to use with [Grafana](https://grafana.com)
|
|||
|
||||
```
|
||||
- job_name: 'beam'
|
||||
metrics_path: /api/pleroma/app_metrics
|
||||
metrics_path: /api/v1/akkoma/metrics
|
||||
scheme: https
|
||||
static_configs:
|
||||
- targets: ['otp.akkoma.dev']
|
||||
|
|
|
@ -1 +1,48 @@
|
|||
This section contains notes and guidelines for developers.
|
||||
# Contributing to Akkoma
|
||||
|
||||
You wish to add a new feature in Akkoma, but don't know how to proceed? This guide takes you through the various steps of the development and contribution process.
|
||||
|
||||
If you're looking for stuff to implement or fix, check the [bug-tracker](https://akkoma.dev/AkkomaGang/akkoma/issues) or [forum](https://meta.akkoma.dev/c/requests/5).
|
||||
|
||||
Come say hi to us in the [#akkoma-dev chat room](./../#irc)!
|
||||
|
||||
## Akkoma Clients
|
||||
|
||||
Akkoma is the back-end. Clients have their own repositories and often separate projects. You can check what clients work with Akkoma [on the clients page](../clients/). If you maintain a working client not listed yet, feel free to make a PR [to these docs](./#docs)!
|
||||
|
||||
For resources on APIs and such, check the sidebar of this page.
|
||||
|
||||
## Docs
|
||||
|
||||
The docs are written in Markdown, including certain extensions, and can be found [in the docs folder of the Akkoma repo](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/docs/). The content itself is stored in the `docs` subdirectory.
|
||||
|
||||
## Technology
|
||||
|
||||
Akkoma is written in [Elixir](https://elixir-lang.org/) and uses [Postgresql](https://www.postgresql.org/) for database. We use [Git](https://git-scm.com/) for collaboration and tracking code changes. Furthermore it can typically run on [Unix and Unix-like OS'es](https://en.wikipedia.org/wiki/Unix-like). For development, you should use an OS which [can run Akkoma](../installation/debian_based_en/).
|
||||
|
||||
It's good to have at least some basic understanding of at least Git and Elixir. If this is completely new for you, there's some [videos explaining Git](https://git-scm.com/doc) and Codeberg has a nice article explaining the typical [pull requests Git flow](https://docs.codeberg.org/collaborating/pull-requests-and-git-flow/). For Elixir, you can follow Elixir's own [Getting Started guide](https://elixir-lang.org/getting-started/introduction.html).
|
||||
|
||||
## Setting up a development environment
|
||||
|
||||
The best way to start is getting the software to run from source so you can start poking on it. Check out the [guides for setting up an Akkoma instance for development](setting_up_akkoma_dev/#setting-up-a-akkoma-development-environment).
|
||||
|
||||
## General overview
|
||||
### Modules
|
||||
|
||||
Akkoma has several modules. There are modules for [uploading](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/lib/pleroma/uploaders), [upload filters](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/lib/pleroma/upload/filter), [translators](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/lib/pleroma/akkoma/translators)... The most famous ones are without a doubt the [MRF policies](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/lib/pleroma/web/activity_pub/mrf). Modules are often self contained and a good way to start with development because you don't have to think about much more than just the module itself. We even have an example on [writing your own MRF policy](/configuration/mrf/#writing-your-own-mrf-policy)!
|
||||
|
||||
Another easy entry point is the [mix tasks](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/lib/mix/tasks/pleroma). They too are often self contained and don't need you to go through much of the code.
|
||||
|
||||
### Activity Streams/Activity Pub
|
||||
|
||||
Akkoma uses Activity Streams for both federation, as well as internal representation. It may be interesting to at least go over the specifications of [Activity Pub](https://www.w3.org/TR/activitypub/), [Activity Streams 2.0](https://www.w3.org/TR/activitystreams-core/), and [Activity Streams Vocabulary](https://www.w3.org/TR/activitystreams-vocabulary/). Note that these are not enough to have a full grasp of how everything works, but should at least give you the basics to understand how messages are passed between and inside Akkoma instances.
|
||||
|
||||
## Don't forget
|
||||
|
||||
When you make changes, you're expected to create [a Pull Request](https://akkoma.dev/AkkomaGang/akkoma/pulls). You don't have to wait until you finish to create the PR, but please do prefix the title of the PR with "WIP: " for as long as you're still working on it. The sooner you create your PR, the sooner people know what you are working on and the sooner you can get feedback and, if needed, help. You can then simply keep working on it until you are finished.
|
||||
|
||||
When doing changes, don't forget to add it to the relevant parts of the [CHANGELOG.md](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/CHANGELOG.md).
|
||||
|
||||
You're expected to write [tests](https://elixirschool.com/en/lessons/testing/basics). While code is generally stored in the `lib` directory, tests are stored in the `test` directory using a similar folder structure. Feel free to peak at other tests to see how they are done. Obviously tests are expected to pass and properly test the functionality you added. If you feel really confident, you could even try to [write a test first and then write the code needed to make it pass](https://en.wikipedia.org/wiki/Test-driven_development)!
|
||||
|
||||
Code is formatted using the default formatter that comes with Elixir. You can format a file with e.g. `mix format /path/to/file.ex`. To check if everything is properly formatted, you can run `mix format --check-formatted`.
|
||||
|
|
|
@ -5,22 +5,37 @@ Akkoma requires some adjustments from the defaults for running the instance loca
|
|||
## Installing
|
||||
|
||||
1. Install Akkoma as explained in [the docs](../installation/debian_based_en.md), with some exceptions:
|
||||
* You can use your own fork of the repository and add akkoma as a remote `git remote add akkoma 'https://akkoma.dev/AkkomaGang/akkoma.git'`
|
||||
* You can skip systemd and nginx and all that stuff
|
||||
* No need to create a dedicated akkoma user, it's easier to just use your own user
|
||||
* For the DB you can still choose a dedicated user, the mix tasks set it up for you so it's no extra work for you
|
||||
* You can use your own fork of the repository and add akkoma as a remote `git remote add akkoma 'https://akkoma.dev/AkkomaGang/akkoma.git'`
|
||||
* For domain you can use `localhost`
|
||||
* For the DB you can still choose a dedicated user. The mix tasks sets it up, so it's no extra work for you
|
||||
* instead of creating a `prod.secret.exs`, create `dev.secret.exs`
|
||||
* No need to prefix with `MIX_ENV=prod`. We're using dev and that's the default MIX_ENV
|
||||
* You can skip nginx and systemd
|
||||
* For front-end, you'll probably want to install and use the develop branch instead of the stable branch. There's no guarantee that the stable branch of the FE will always work on the develop branch of the BE.
|
||||
2. Change the dev.secret.exs
|
||||
* Change the FE settings to use the installed branch (see also [Frontend Management](/configuration/frontend_management/))
|
||||
* Change the scheme in `config :pleroma, Pleroma.Web.Endpoint` to http (see examples below)
|
||||
* If you want to change other settings, you can do that too
|
||||
3. You can now start the server `mix phx.server`. Once it's build and started, you can access the instance on `http://<host>:<port>` (e.g.http://localhost:4000 ) and should be able to do everything locally you normaly can.
|
||||
3. You can now start the server with `mix phx.server`. Once it's build and started, you can access the instance on `http://<host>:<port>` (e.g.http://localhost:4000 ) and should be able to do everything locally you normally can.
|
||||
|
||||
Example on how to install pleroma-fe and admin-fe using it's develop branch
|
||||
```sh
|
||||
mix pleroma.frontend install pleroma-fe --ref develop
|
||||
mix pleroma.frontend install admin-fe --ref develop
|
||||
```
|
||||
|
||||
Example config to use the pleroma-fe and admin-fe installed from the develop branch
|
||||
```elixir
|
||||
config :pleroma, :frontends,
|
||||
primary: %{"name" => "pleroma-fe", "ref" => "develop"},
|
||||
admin: %{"name" => "admin-fe", "ref" => "develop"}
|
||||
```
|
||||
|
||||
Example config to change the scheme to http. Change the port if you want to run on another port.
|
||||
```elixir
|
||||
config :pleroma, Pleroma.Web.Endpoint,
|
||||
url: [host: "localhost", scheme: "http", port: 4000],
|
||||
config :pleroma, Pleroma.Web.Endpoint,
|
||||
url: [host: "localhost", scheme: "http", port: 4000],
|
||||
```
|
||||
|
||||
Example config to disable captcha. This makes it a bit easier to create test-users.
|
||||
|
@ -94,4 +109,4 @@ Update Akkoma as explained in [the docs](../administration/updating.md). Just ma
|
|||
|
||||
## Working on multiple branches
|
||||
|
||||
If you develop on a separate branch, it's possible you did migrations that aren't merged into another branch you're working on. If you have multiple things you're working on, it's probably best to set up multiple Akkoma instances each with their own database. If you finished with a branch and want to switch back to develop to start a new branch from there, you can drop the database and recreate the database (e.g. by using `config/setup_db.psql`). The commands to drop and recreate the database can be found in [the docs](../administration/backup.md).
|
||||
If you develop on a separate branch, it's possible you did migrations that aren't merged into another branch you're working on. In that case, it's probably best to set up multiple Akkoma instances each with their own database. If you finished with a branch and want to switch back to develop to start a new branch from there, you can drop the database and recreate the database (e.g. by using `config/setup_db.psql`). The commands to drop and recreate the database can be found in [the docs](../administration/backup.md).
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Introduction to Akkoma
|
||||
## What is Akkoma?
|
||||
Akkoma is a federated social networking platform, compatible with Mastodon and other ActivityPub implementations. It is free software licensed under the AGPLv3.
|
||||
It actually consists of two components: a backend, named simply Akkoma, and a user-facing frontend, named Pleroma-FE. It also includes the Mastodon frontend, if that's your thing.
|
||||
It actually consists of two components: a backend, named simply Akkoma, and a user-facing frontend, named Akkoma-FE. It also includes the Mastodon frontend, if that's your thing.
|
||||
It's part of what we call the fediverse, a federated network of instances which speak common protocols and can communicate with each other.
|
||||
One account on an instance is enough to talk to the entire fediverse!
|
||||
|
||||
|
@ -31,11 +31,11 @@ Installation instructions can be found in the installation section of these docs
|
|||
## I got an account, now what?
|
||||
Great! Now you can explore the fediverse! Open the login page for your Akkoma instance (e.g. <https://otp.akkoma.dev>) and login with your username and password. (If you don't have an account yet, click on Register)
|
||||
|
||||
### Pleroma-FE
|
||||
The default front-end used by Akkoma is Pleroma-FE. You can find more information on what it is and how to use it in the [Introduction to Pleroma-FE](https://docs-fe.akkoma.dev/stable/).
|
||||
### Akkoma-FE
|
||||
The default front-end used by Akkoma is Akkoma-FE. You can find more information on what it is and how to use it in the [Introduction to Akkoma-FE](https://docs-fe.akkoma.dev/stable/).
|
||||
|
||||
### Mastodon interface
|
||||
If the Pleroma-FE 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!
|
||||
If the Akkoma-FE 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://otp.akkoma.dev/web>) and you'll end on the Mastodon web interface, but with a Akkoma 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.
|
||||
|
||||
|
|
|
@ -23,23 +23,7 @@ sudo apt full-upgrade
|
|||
sudo apt install git build-essential postgresql postgresql-contrib cmake libmagic-dev
|
||||
```
|
||||
|
||||
### Install Elixir and Erlang
|
||||
|
||||
* Install Elixir and Erlang (you might need to use backports or [asdf](https://github.com/asdf-vm/asdf) on old systems):
|
||||
|
||||
```shell
|
||||
sudo apt update
|
||||
sudo apt install elixir erlang-dev erlang-nox
|
||||
```
|
||||
|
||||
|
||||
### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
|
||||
|
||||
```shell
|
||||
sudo apt install imagemagick ffmpeg libimage-exiftool-perl
|
||||
```
|
||||
|
||||
### Install AkkomaBE
|
||||
### Create the akkoma user
|
||||
|
||||
* Add a new system user for the Akkoma service:
|
||||
|
||||
|
@ -49,7 +33,67 @@ sudo useradd -r -s /bin/false -m -d /var/lib/akkoma -U akkoma
|
|||
|
||||
**Note**: To execute a single command as the Akkoma system user, use `sudo -Hu akkoma command`. You can also switch to a shell by using `sudo -Hu akkoma $SHELL`. If you don’t have and want `sudo` on your system, you can use `su` as root user (UID 0) for a single command by using `su -l akkoma -s $SHELL -c 'command'` and `su -l akkoma -s $SHELL` for starting a shell.
|
||||
|
||||
* Git clone the AkkomaBE repository from stable-branch and make the Akkoma user the owner of the directory:
|
||||
### Install Elixir and Erlang
|
||||
|
||||
If your distribution packages a recent enough version of Elixir, you can install it directly from the distro repositories and skip to the next section of the guide:
|
||||
|
||||
```shell
|
||||
sudo apt install elixir erlang-dev erlang-nox
|
||||
```
|
||||
|
||||
Otherwise use [asdf](https://github.com/asdf-vm/asdf) to install the latest versions of Elixir and Erlang.
|
||||
|
||||
First, install some dependencies needed to build Elixir and Erlang:
|
||||
```shell
|
||||
sudo apt install curl unzip build-essential autoconf m4 libncurses5-dev libssh-dev unixodbc-dev xsltproc libxml2-utils libncurses-dev
|
||||
```
|
||||
|
||||
Then login to the `akkoma` user and install asdf:
|
||||
```shell
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3
|
||||
```
|
||||
|
||||
Add the following lines to `~/.bashrc`:
|
||||
```shell
|
||||
. "$HOME/.asdf/asdf.sh"
|
||||
# asdf completions
|
||||
. "$HOME/.asdf/completions/asdf.bash"
|
||||
```
|
||||
|
||||
Restart the shell:
|
||||
```shell
|
||||
exec $SHELL
|
||||
```
|
||||
|
||||
Next install Erlang:
|
||||
```shell
|
||||
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
|
||||
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
|
||||
asdf install erlang 25.3.2.1
|
||||
asdf global erlang 25.3.2.1
|
||||
```
|
||||
|
||||
Now install Elixir:
|
||||
```shell
|
||||
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
|
||||
asdf install elixir 1.14.5-otp-25
|
||||
asdf global elixir 1.14.5-otp-25
|
||||
```
|
||||
|
||||
Confirm that Elixir is installed correctly by checking the version:
|
||||
```shell
|
||||
elixir --version
|
||||
```
|
||||
|
||||
### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
|
||||
|
||||
```shell
|
||||
sudo apt install imagemagick ffmpeg libimage-exiftool-perl
|
||||
```
|
||||
|
||||
### Install AkkomaBE
|
||||
|
||||
* Log into the `akkoma` user and clone the AkkomaBE repository from the stable branch and make the Akkoma user the owner of the directory:
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /opt/akkoma
|
||||
|
|
|
@ -10,7 +10,7 @@ If you want to migrate from or OTP to docker, check out [the migration guide](./
|
|||
|
||||
### Prepare the system
|
||||
|
||||
* Install docker and docker-compose
|
||||
* Install docker and docker compose
|
||||
* [Docker](https://docs.docker.com/engine/install/)
|
||||
* [Docker-compose](https://docs.docker.com/compose/install/)
|
||||
* This will usually just be a repository installation and a package manager invocation.
|
||||
|
@ -26,7 +26,7 @@ echo "DOCKER_USER=$(id -u):$(id -g)" >> .env
|
|||
```
|
||||
|
||||
This probably won't need to be changed, it's only there to set basic environment
|
||||
variables for the docker-compose file.
|
||||
variables for the docker compose file.
|
||||
|
||||
### Building the container
|
||||
|
||||
|
@ -65,9 +65,9 @@ cp config/generated_config.exs config/prod.secret.exs
|
|||
We need to run a few commands on the database container, this isn't too bad
|
||||
|
||||
```bash
|
||||
docker-compose run --rm --user akkoma -d db
|
||||
docker compose run --rm --user akkoma -d db
|
||||
# Note down the name it gives here, it will be something like akkoma_db_run
|
||||
docker-compose run --rm akkoma psql -h db -U akkoma -f config/setup_db.psql
|
||||
docker compose run --rm akkoma psql -h db -U akkoma -f config/setup_db.psql
|
||||
docker stop akkoma_db_run # Replace with the name you noted down
|
||||
```
|
||||
|
||||
|
@ -84,17 +84,17 @@ We're going to run it in the foreground on the first run, just to make sure
|
|||
everything start up.
|
||||
|
||||
```bash
|
||||
docker-compose up
|
||||
docker compose up
|
||||
```
|
||||
|
||||
If everything went well, you should be able to access your instance at http://localhost:4000
|
||||
|
||||
You can `ctrl-c` out of the docker-compose now to shutdown the server.
|
||||
You can `ctrl-c` out of the docker compose now to shutdown the server.
|
||||
|
||||
### Running in the background
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Create your first user
|
||||
|
@ -125,8 +125,8 @@ cp docker-resources/Caddyfile.example docker-resources/Caddyfile
|
|||
|
||||
Then edit the TLD in your caddyfile to the domain you're serving on.
|
||||
|
||||
Uncomment the `caddy` section in the docker-compose file,
|
||||
then run `docker-compose up -d` again.
|
||||
Uncomment the `caddy` section in the docker compose file,
|
||||
then run `docker compose up -d` again.
|
||||
|
||||
#### Running a reverse proxy on the host
|
||||
|
||||
|
@ -152,7 +152,7 @@ git pull
|
|||
./docker-resources/manage.sh mix deps.get
|
||||
./docker-resources/manage.sh mix compile
|
||||
./docker-resources/manage.sh mix ecto.migrate
|
||||
docker-compose restart akkoma db
|
||||
docker compose restart akkoma db
|
||||
```
|
||||
|
||||
#### Further reading
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
## Required dependencies
|
||||
|
||||
* PostgreSQL 9.6+
|
||||
* Elixir 1.12+ (1.13+ recommended)
|
||||
* Erlang OTP 22.2+
|
||||
* Elixir 1.14+
|
||||
* Erlang OTP 24+
|
||||
* git
|
||||
* file / libmagic
|
||||
* gcc (clang might also work)
|
||||
|
|
|
@ -117,4 +117,16 @@ To fix this, run:
|
|||
mix pleroma.config delete pleroma frontends
|
||||
```
|
||||
|
||||
which will remove the config from the database. Things should work now.
|
||||
which will remove the config from the database. Things should work now.
|
||||
|
||||
## Migrating back to Pleroma
|
||||
|
||||
Akkoma is a hard fork of Pleroma. As such, migrating back is not guaranteed to always work. But if you want to migrate back to Pleroma, you can always try. Just note that you may run into unexpected issues and you're basically on your own. The following are some tips that may help, but note that these are barely tested, so proceed at your own risk.
|
||||
|
||||
First you will need to roll back the database migrations. The latest migration both Akkoma and Pleroma still have in common should be 20210416051708, so roll back to that. If you run from source, that should be
|
||||
|
||||
```sh
|
||||
MIX_ENV=prod mix ecto.rollback --to 20210416051708
|
||||
```
|
||||
|
||||
Then switch back to Pleroma for updates (similar to how was done to migrate to Akkoma), and remove the front-ends. The front-ends are installed in the `frontends` folder in the [static directory](../configuration/static_dir.md). Once you are back to Pleroma, you will need to run the database migrations again. See the Pleroma documentation for this.
|
||||
|
|
|
@ -10,7 +10,7 @@ You probably should, in the first instance.
|
|||
|
||||
### Prepare the system
|
||||
|
||||
* Install docker and docker-compose
|
||||
* Install docker and docker compose
|
||||
* [Docker](https://docs.docker.com/engine/install/)
|
||||
* [Docker-compose](https://docs.docker.com/compose/install/)
|
||||
* This will usually just be a repository installation and a package manager invocation.
|
||||
|
@ -46,7 +46,7 @@ For *most* from-source installs it'll already be there.
|
|||
And the same with `uploads`, make sure your uploads (if you have them on disk) are
|
||||
located at `uploads/` in the akkoma source directory.
|
||||
|
||||
If you have them on a different disk, you will need to mount that disk into the docker-compose file,
|
||||
If you have them on a different disk, you will need to mount that disk into the docker compose file,
|
||||
with an entry that looks like this:
|
||||
|
||||
```yaml
|
||||
|
@ -66,7 +66,7 @@ echo "DOCKER_USER=$(id -u):$(id -g)" >> .env
|
|||
```
|
||||
|
||||
This probably won't need to be changed, it's only there to set basic environment
|
||||
variables for the docker-compose file.
|
||||
variables for the docker compose file.
|
||||
|
||||
=== "From source"
|
||||
|
||||
|
@ -126,21 +126,21 @@ mkdir pgdata
|
|||
Now we can import our database to the container.
|
||||
|
||||
```bash
|
||||
docker-compose run --rm --user akkoma -d db
|
||||
docker-compose run --rm akkoma pg_restore -v -U akkoma -j $(grep -c ^processor /proc/cpuinfo) -d akkoma -h db akkoma_backup.sql
|
||||
docker compose run --rm --user akkoma -d db
|
||||
docker compose run --rm akkoma pg_restore -v -U akkoma -j $(grep -c ^processor /proc/cpuinfo) -d akkoma -h db akkoma_backup.sql
|
||||
```
|
||||
|
||||
### Reverse proxies
|
||||
|
||||
If you're just reusing your old proxy, you may have to uncomment the line in
|
||||
the docker-compose file under `ports`. You'll find it.
|
||||
the docker compose file under `ports`. You'll find it.
|
||||
|
||||
Otherwise, you can use the same setup as the [docker installation guide](./docker_en.md#reverse-proxies).
|
||||
|
||||
### Let's go
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
You should now be at the same point as you were before, but with a docker install.
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
# Optional software packages needed for specific functionality
|
||||
|
||||
For specific Pleroma functionality (which is disabled by default) some or all of the below packages are required:
|
||||
* `ImageMagic`
|
||||
For specific Akkoma functionality (which is disabled by default) some or all of the below packages are required:
|
||||
* `ImageMagick`
|
||||
* `ffmpeg`
|
||||
* `exiftool`
|
||||
|
||||
Please refer to documentation in `docs/installation` on how to install them on specific OS.
|
||||
|
||||
Note: the packages are not required with the current default settings of Pleroma.
|
||||
Note: the packages are not required with the current default settings of Akkoma.
|
||||
|
||||
## `ImageMagick`
|
||||
|
||||
`ImageMagick` is a set of tools to create, edit, compose, or convert bitmap images.
|
||||
|
||||
It is required for the following Pleroma features:
|
||||
It is required for the following Akkoma features:
|
||||
* `Pleroma.Upload.Filters.Mogrify`, `Pleroma.Upload.Filters.Mogrifun` upload filters (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
||||
* Media preview proxy for still images (related config: `media_preview_proxy/enabled` in `config/config.exs`)
|
||||
|
||||
|
@ -21,12 +21,12 @@ It is required for the following Pleroma features:
|
|||
|
||||
`ffmpeg` is software to record, convert and stream audio and video.
|
||||
|
||||
It is required for the following Pleroma features:
|
||||
It is required for the following Akkoma features:
|
||||
* Media preview proxy for videos (related config: `media_preview_proxy/enabled` in `config/config.exs`)
|
||||
|
||||
## `exiftool`
|
||||
|
||||
`exiftool` is media files metadata reader/writer.
|
||||
|
||||
It is required for the following Pleroma features:
|
||||
It is required for the following Akkoma features:
|
||||
* `Pleroma.Upload.Filters.Exiftool` upload filter (related config: `Plaroma.Upload/filters` in `config/config.exs`)
|
||||
|
|
|
@ -19,12 +19,16 @@ This is a little more complex than it used to be (thanks ubuntu)
|
|||
|
||||
Use the following mapping to figure out your flavour:
|
||||
|
||||
| distribution | flavour | available branches |
|
||||
| ------------- | ------------------ | ------------------- |
|
||||
| debian stable | amd64 | develop, stable |
|
||||
| ubuntu focal | amd64 | develop, stable |
|
||||
| ubuntu jammy | amd64-ubuntu-jammy | develop, stable |
|
||||
| alpine | amd64-musl | stable |
|
||||
| distribution | architecture | flavour | available branches |
|
||||
| --------------- | ------------------ | ------------------- | ------------------- |
|
||||
| debian bullseye | amd64 | amd64 | develop, stable |
|
||||
| debian bullseye | arm64 | arm64 | stable |
|
||||
| ubuntu focal | amd64 | amd64 | develop, stable |
|
||||
| ubuntu focal | arm64 | arm64 | stable |
|
||||
| ubuntu jammy | amd64 | amd64-ubuntu-jammy | develop, stable |
|
||||
| ubuntu jammy | arm64 | arm64-ubuntu-jammy | develop, stable |
|
||||
| alpine | amd64 | amd64-musl | stable |
|
||||
| alpine | arm64 | arm64-musl | stable |
|
||||
|
||||
Other similar distributions will _probably_ work, but if it is not listed above, there is no official
|
||||
support.
|
||||
|
|
9
docs/docs/installation/yunohost_en.md
Normal file
9
docs/docs/installation/yunohost_en.md
Normal file
|
@ -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 Akkoma which allows you to install Akkoma 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/akkoma_ynh).
|
||||
|
||||
## Questions
|
||||
|
||||
Questions and problems related to the YunoHost parts can be done through the [YunoHost channels](https://yunohost.org/en/help).
|
||||
|
||||
For questions about Akkoma, check out the [Akkoma community channels](../../#community-channels).
|
8
docs/theme/partials/source.html
vendored
8
docs/theme/partials/source.html
vendored
|
@ -38,11 +38,11 @@
|
|||
{% endif %}
|
||||
|
||||
{% if page and page.url.startswith('backend') %}
|
||||
{% set repo_url = "https://git.pleroma.social/pleroma/pleroma" %}
|
||||
{% set repo_name = "pleroma/pleroma" %}
|
||||
{% set repo_url = "https://akkoma.dev/AkkomaGang/akkoma" %}
|
||||
{% set repo_name = "AkkomaGang/akkoma" %}
|
||||
{% elif page and page.url.startswith('frontend') %}
|
||||
{% set repo_url = "https://git.pleroma.social/pleroma/pleroma-fe" %}
|
||||
{% set repo_name = "pleroma/pleroma-fe" %}
|
||||
{% set repo_url = "https://akkoma.dev/AkkomaGang/akkoma-fe" %}
|
||||
{% set repo_name = "AkkomaGang/akkoma-fe" %}
|
||||
{% else %}
|
||||
{% set repo_url = config.repo_url %}
|
||||
{% set repo_name = config.repo_name %}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
elixir_version=1.9.4
|
||||
erlang_version=22.3.4.1
|
||||
elixir_version=1.14.3
|
||||
erlang_version=25.3
|
||||
|
|
|
@ -7,7 +7,9 @@ ExecReload=/bin/kill $MAINPID
|
|||
Restart=on-failure
|
||||
|
||||
; Uncomment this if you're on Arch Linux
|
||||
; Evironment="PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"
|
||||
; Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"
|
||||
; Uncomment if using asdf to manage Elixir and Erlang
|
||||
; Environment="PATH=/var/lib/akkoma/.asdf/shims:/var/lib/akkoma/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
; Name of the user that runs the Akkoma service.
|
||||
User=akkoma
|
||||
|
@ -24,6 +26,8 @@ Environment="HOME=/var/lib/akkoma"
|
|||
WorkingDirectory=/opt/akkoma
|
||||
; Path to the Mix binary.
|
||||
ExecStart=/usr/bin/mix phx.server
|
||||
; If using asdf comment the above line and uncomment the one below instead
|
||||
; ExecStart=/var/lib/akkoma/.asdf/shims/mix phx.server
|
||||
|
||||
; Some security directives.
|
||||
; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
|
||||
|
@ -34,6 +38,8 @@ ProtectHome=true
|
|||
ProtectSystem=full
|
||||
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
|
||||
PrivateDevices=false
|
||||
; Ensures that the service process and all its children can never gain new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
; Drops the sysadmin capability from the daemon.
|
||||
CapabilityBoundingSet=~CAP_SYS_ADMIN
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# 1. Replace 'example.tld' with your instance's domain wherever it appears.
|
||||
# 2. Copy this section into your Caddyfile and restart Caddy.
|
||||
|
||||
# If you are able to, it's highly recommended to have your media served via a separate subdomain for improved security.
|
||||
# Uncomment the relevant sectons here and modify the base_url setting for Pleroma.Upload and :media_proxy accordingly.
|
||||
|
||||
example.tld {
|
||||
log {
|
||||
output file /var/log/caddy/akkoma.log
|
||||
|
@ -14,4 +17,21 @@ example.tld {
|
|||
# this is explicitly IPv4 since Pleroma.Web.Endpoint binds on IPv4 only
|
||||
# and `localhost.` resolves to [::0] on some systems: see issue #930
|
||||
reverse_proxy 127.0.0.1:4000
|
||||
|
||||
# Uncomment if using a separate media subdomain
|
||||
#@mediaproxy path /media/* /proxy/*
|
||||
#handle @mediaproxy {
|
||||
# redir https://media.example.tld{uri} permanent
|
||||
#}
|
||||
}
|
||||
|
||||
# Uncomment if using a separate media subdomain
|
||||
#media.example.tld {
|
||||
# @mediaproxy path /media/* /proxy/*
|
||||
# reverse_proxy @mediaproxy 127.0.0.1:4000 {
|
||||
# transport http {
|
||||
# response_header_timeout 10s
|
||||
# read_timeout 15s
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
|
|
|
@ -8,6 +8,7 @@ pidfile="/var/run/akkoma.pid"
|
|||
directory=/opt/akkoma
|
||||
healthcheck_delay=60
|
||||
healthcheck_timer=30
|
||||
no_new_privs="yes"
|
||||
|
||||
: ${akkoma_port:-4000}
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ def run(["prune_objects" | args]) do
|
|||
strict: [
|
||||
vacuum: :boolean,
|
||||
keep_threads: :boolean,
|
||||
keep_non_public: :boolean
|
||||
keep_non_public: :boolean,
|
||||
prune_orphaned_activities: :boolean
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -94,6 +95,21 @@ def run(["prune_objects" | args]) do
|
|||
log_message
|
||||
end
|
||||
|
||||
log_message =
|
||||
if Keyword.get(options, :prune_orphaned_activities) do
|
||||
log_message <> ", pruning orphaned activities"
|
||||
else
|
||||
log_message
|
||||
end
|
||||
|
||||
log_message =
|
||||
if Keyword.get(options, :vacuum) do
|
||||
log_message <>
|
||||
", doing a full vacuum (you shouldn't do this as a recurring maintanance task)"
|
||||
else
|
||||
log_message
|
||||
end
|
||||
|
||||
Logger.info(log_message)
|
||||
|
||||
if Keyword.get(options, :keep_threads) do
|
||||
|
@ -155,14 +171,64 @@ def run(["prune_objects" | args]) do
|
|||
end
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
|
||||
prune_hashtags_query = """
|
||||
if !Keyword.get(options, :keep_threads) do
|
||||
# Without the --keep-threads option, it's possible that bookmarked
|
||||
# objects have been deleted. We remove the corresponding bookmarks.
|
||||
"""
|
||||
delete from public.bookmarks
|
||||
where id in (
|
||||
select b.id from public.bookmarks b
|
||||
left join public.activities a on b.activity_id = a.id
|
||||
left join public.objects o on a."data" ->> 'object' = o.data ->> 'id'
|
||||
where o.id is null
|
||||
)
|
||||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
end
|
||||
|
||||
if Keyword.get(options, :prune_orphaned_activities) do
|
||||
# Prune activities who link to a single object
|
||||
"""
|
||||
delete from public.activities
|
||||
where id in (
|
||||
select a.id from public.activities a
|
||||
left join public.objects o on a.data ->> 'object' = o.data ->> 'id'
|
||||
left join public.activities a2 on a.data ->> 'object' = a2.data ->> 'id'
|
||||
left join public.users u on a.data ->> 'object' = u.ap_id
|
||||
where not a.local
|
||||
and jsonb_typeof(a."data" -> 'object') = 'string'
|
||||
and o.id is null
|
||||
and a2.id is null
|
||||
and u.id is null
|
||||
)
|
||||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
|
||||
# Prune activities who link to an array of objects
|
||||
"""
|
||||
delete from public.activities
|
||||
where id in (
|
||||
select a.id from public.activities a
|
||||
join json_array_elements_text((a."data" -> 'object')::json) as j on jsonb_typeof(a."data" -> 'object') = 'array'
|
||||
left join public.objects o on j.value = o.data ->> 'id'
|
||||
left join public.activities a2 on j.value = a2.data ->> 'id'
|
||||
left join public.users u on j.value = u.ap_id
|
||||
group by a.id
|
||||
having max(o.data ->> 'id') is null
|
||||
and max(a2.data ->> 'id') is null
|
||||
and max(u.ap_id) is null
|
||||
)
|
||||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
end
|
||||
|
||||
"""
|
||||
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)
|
||||
|> Repo.query()
|
||||
|
||||
if Keyword.get(options, :vacuum) do
|
||||
Maintenance.vacuum("full")
|
||||
|
|
|
@ -82,4 +82,46 @@ def run(["user_timeline", nickname, reading_nickname]) do
|
|||
Ecto.Adapters.SQL.explain(Repo, :all, query, analyze: true, timeout: :infinity)
|
||||
|> IO.puts()
|
||||
end
|
||||
|
||||
def run(["notifications", nickname]) do
|
||||
start_pleroma()
|
||||
user = Repo.get_by!(User, nickname: nickname)
|
||||
account_ap_id = user.ap_id
|
||||
options = %{account_ap_id: user.ap_id}
|
||||
|
||||
query =
|
||||
user
|
||||
|> Pleroma.Notification.for_user_query(options)
|
||||
|> where([n, a], a.actor == ^account_ap_id)
|
||||
|> limit(20)
|
||||
|
||||
Ecto.Adapters.SQL.explain(Repo, :all, query, analyze: true, timeout: :infinity)
|
||||
|> IO.puts()
|
||||
end
|
||||
|
||||
def run(["known_network", nickname]) do
|
||||
start_pleroma()
|
||||
user = Repo.get_by!(User, nickname: nickname)
|
||||
|
||||
params =
|
||||
%{}
|
||||
|> Map.put(:type, ["Create"])
|
||||
|> Map.put(:local_only, false)
|
||||
|> Map.put(:blocking_user, user)
|
||||
|> Map.put(:muting_user, user)
|
||||
|> Map.put(:reply_filtering_user, user)
|
||||
# Restricts unfederated content to authenticated users
|
||||
|> Map.put(:includes_local_public, not is_nil(user))
|
||||
|> Map.put(:restrict_unlisted, true)
|
||||
|
||||
query =
|
||||
Pleroma.Web.ActivityPub.ActivityPub.fetch_activities_query(
|
||||
[Pleroma.Constants.as_public()],
|
||||
params
|
||||
)
|
||||
|> limit(20)
|
||||
|
||||
Ecto.Adapters.SQL.explain(Repo, :all, query, analyze: true, timeout: :infinity)
|
||||
|> IO.puts()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -277,6 +277,13 @@ def get_create_by_object_ap_id_with_object(ap_id) when is_binary(ap_id) do
|
|||
|
||||
def get_create_by_object_ap_id_with_object(_), do: nil
|
||||
|
||||
def get_local_create_by_object_ap_id(ap_id) when is_binary(ap_id) do
|
||||
ap_id
|
||||
|> create_by_object_ap_id()
|
||||
|> where(local: true)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
@spec create_by_id_with_object(String.t()) :: t() | nil
|
||||
def create_by_id_with_object(id) do
|
||||
get_by_id_with_opts(id, preload: [:object], filter: [type: "Create"])
|
||||
|
|
|
@ -21,7 +21,7 @@ defp generate_topics(object, activity) do
|
|||
["user", "list"] ++ visibility_tags(object, activity)
|
||||
end
|
||||
|
||||
defp visibility_tags(object, activity) do
|
||||
defp visibility_tags(object, %{data: %{"type" => type}} = activity) when type != "Announce" do
|
||||
case Visibility.get_visibility(activity) do
|
||||
"public" ->
|
||||
if activity.local do
|
||||
|
@ -31,6 +31,10 @@ defp visibility_tags(object, activity) do
|
|||
end
|
||||
|> item_creation_tags(object, activity)
|
||||
|
||||
"local" ->
|
||||
["public:local"]
|
||||
|> item_creation_tags(object, activity)
|
||||
|
||||
"direct" ->
|
||||
["direct"]
|
||||
|
||||
|
@ -39,6 +43,10 @@ defp visibility_tags(object, activity) do
|
|||
end
|
||||
end
|
||||
|
||||
defp visibility_tags(_object, _activity) do
|
||||
[]
|
||||
end
|
||||
|
||||
defp item_creation_tags(tags, object, %{data: %{"type" => "Create"}} = activity) do
|
||||
tags ++
|
||||
remote_topics(activity) ++ hashtags_to_topics(object) ++ attachment_topics(object, activity)
|
||||
|
@ -63,7 +71,18 @@ defp remote_topics(_), do: []
|
|||
|
||||
defp attachment_topics(%{data: %{"attachment" => []}}, _act), do: []
|
||||
|
||||
defp attachment_topics(_object, %{local: true}), do: ["public:media", "public:local:media"]
|
||||
defp attachment_topics(_object, %{local: true} = activity) do
|
||||
case Visibility.get_visibility(activity) do
|
||||
"public" ->
|
||||
["public:media", "public:local:media"]
|
||||
|
||||
"local" ->
|
||||
["public:local:media"]
|
||||
|
||||
_ ->
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
defp attachment_topics(_object, %{actor: actor}) when is_binary(actor),
|
||||
do: ["public:media", "public:remote:media:" <> URI.parse(actor).host]
|
||||
|
|
|
@ -40,7 +40,7 @@ def translate(string, from_language, to_language) do
|
|||
if Map.has_key?(body, "detectedLanguage") do
|
||||
get_in(body, ["detectedLanguage", "language"])
|
||||
else
|
||||
from_language
|
||||
from_language || ""
|
||||
end
|
||||
|
||||
{:ok, detected, translated}
|
||||
|
|
|
@ -262,11 +262,14 @@ defp http_children do
|
|||
proxy = Pleroma.HTTP.AdapterHelper.format_proxy(proxy_url)
|
||||
pool_size = Config.get([:http, :pool_size])
|
||||
|
||||
:public_key.cacerts_load()
|
||||
|
||||
config =
|
||||
[:http, :adapter]
|
||||
|> Config.get([])
|
||||
|> Pleroma.HTTP.AdapterHelper.add_pool_size(pool_size)
|
||||
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy_pool(proxy)
|
||||
|> Pleroma.HTTP.AdapterHelper.maybe_add_cacerts(:public_key.cacerts_get())
|
||||
|> Keyword.put(:name, MyFinch)
|
||||
|
||||
[{Finch, config}]
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Constants do
|
|||
|
||||
const(static_only_files,
|
||||
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 embed sw.js sw-pleroma.js favicon.png schemas doc)
|
||||
)
|
||||
|
||||
const(status_updatable_fields,
|
||||
|
@ -38,7 +38,8 @@ defmodule Pleroma.Constants do
|
|||
"summary",
|
||||
"sensitive",
|
||||
"attachment",
|
||||
"generator"
|
||||
"generator",
|
||||
"contentMap"
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ defmodule Pleroma.Emoji do
|
|||
:named_table,
|
||||
{:read_concurrency, true}
|
||||
]
|
||||
@emoji_regex ~r/:[A-Za-z0-9_-]+(@.+)?:/
|
||||
|
||||
defstruct [:code, :file, :tags, :safe_code, :safe_file]
|
||||
|
||||
|
@ -205,4 +206,7 @@ def fully_qualify_emoji(unquote(unqualified)), do: unquote(qualified)
|
|||
end
|
||||
|
||||
def fully_qualify_emoji(emoji), do: emoji
|
||||
|
||||
def matches_shortcode?(nil), do: false
|
||||
def matches_shortcode?(s), do: Regex.match?(@emoji_regex, s)
|
||||
end
|
||||
|
|
|
@ -155,14 +155,13 @@ def following_count(%User{} = user) do
|
|||
|> Repo.aggregate(:count, :id)
|
||||
end
|
||||
|
||||
def get_follow_requests(%User{id: id}) do
|
||||
def get_follow_requests_query(%User{id: id}) do
|
||||
__MODULE__
|
||||
|> join(:inner, [r], f in assoc(r, :follower))
|
||||
|> join(:inner, [r], f in assoc(r, :follower), as: :follower)
|
||||
|> where([r], r.state == ^:follow_pending)
|
||||
|> where([r], r.following_id == ^id)
|
||||
|> where([r, f], f.is_active == true)
|
||||
|> select([r, f], f)
|
||||
|> Repo.all()
|
||||
|> where([r, follower: f], f.is_active == true)
|
||||
|> select([r, follower: f], f)
|
||||
end
|
||||
|
||||
def following?(%User{id: follower_id}, %User{id: followed_id}) do
|
||||
|
|
|
@ -124,8 +124,8 @@ def mentions_escape(text, options \\ []) do
|
|||
end
|
||||
end
|
||||
|
||||
def markdown_to_html(text) do
|
||||
Earmark.as_html!(text, %Earmark.Options{compact_output: true})
|
||||
def markdown_to_html(text, opts \\ %{}) do
|
||||
Earmark.as_html!(text, %Earmark.Options{compact_output: true} |> Map.merge(opts))
|
||||
end
|
||||
|
||||
def html_escape({text, mentions, hashtags}, type) do
|
||||
|
|
|
@ -47,6 +47,17 @@ def maybe_add_proxy_pool(opts, proxy) do
|
|||
|> put_in([:pools, :default, :conn_opts, :proxy], proxy)
|
||||
end
|
||||
|
||||
def maybe_add_cacerts(opts, nil), do: opts
|
||||
|
||||
def maybe_add_cacerts(opts, cacerts) do
|
||||
opts
|
||||
|> maybe_add_pools()
|
||||
|> maybe_add_default_pool()
|
||||
|> maybe_add_conn_opts()
|
||||
|> maybe_add_transport_opts()
|
||||
|> put_in([:pools, :default, :conn_opts, :transport_opts, :cacerts], cacerts)
|
||||
end
|
||||
|
||||
def add_pool_size(opts, pool_size) do
|
||||
opts
|
||||
|> maybe_add_pools()
|
||||
|
@ -82,6 +93,16 @@ defp maybe_add_conn_opts(opts) do
|
|||
end
|
||||
end
|
||||
|
||||
defp maybe_add_transport_opts(opts) do
|
||||
transport_opts = get_in(opts, [:pools, :default, :conn_opts, :transport_opts])
|
||||
|
||||
unless is_nil(transport_opts) do
|
||||
opts
|
||||
else
|
||||
put_in(opts, [:pools, :default, :conn_opts, :transport_opts], [])
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Merge default connection & adapter options with received ones.
|
||||
"""
|
||||
|
|
|
@ -162,7 +162,7 @@ def local do
|
|||
%Instance{
|
||||
host: Pleroma.Web.Endpoint.host(),
|
||||
favicon: Pleroma.Web.Endpoint.url() <> "/favicon.png",
|
||||
nodeinfo: Pleroma.Web.Nodeinfo.NodeinfoController.raw_nodeinfo()
|
||||
nodeinfo: Pleroma.Web.Nodeinfo.Nodeinfo.get_nodeinfo("2.1")
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ defp exclude_filtered(query, user) do
|
|||
from([_n, a, o] in query,
|
||||
where:
|
||||
fragment("not(?->>'content' ~* ?)", o.data, ^regex) or
|
||||
fragment("?->>'content' is null", o.data) or
|
||||
fragment("?->>'actor' = ?", o.data, ^user.ap_id)
|
||||
)
|
||||
end
|
||||
|
@ -695,7 +696,7 @@ def skip?(
|
|||
cond do
|
||||
opts[:type] == "poll" -> false
|
||||
user.ap_id == actor -> false
|
||||
!User.following?(follower, user) -> true
|
||||
!User.following?(user, follower) -> true
|
||||
true -> false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -251,6 +251,7 @@ defp build_resp_headers(headers, opts) do
|
|||
|> Enum.filter(fn {k, _} -> k in @keep_resp_headers end)
|
||||
|> build_resp_cache_headers(opts)
|
||||
|> build_resp_content_disposition_header(opts)
|
||||
|> build_csp_headers()
|
||||
|> Keyword.merge(Keyword.get(opts, :resp_headers, []))
|
||||
end
|
||||
|
||||
|
@ -316,6 +317,10 @@ defp build_resp_content_disposition_header(headers, opts) do
|
|||
end
|
||||
end
|
||||
|
||||
defp build_csp_headers(headers) do
|
||||
List.keystore(headers, "content-security-policy", 0, {"content-security-policy", "sandbox"})
|
||||
end
|
||||
|
||||
defp header_length_constraint(headers, limit) when is_integer(limit) and limit > 0 do
|
||||
with {_, size} <- List.keyfind(headers, "content-length", 0),
|
||||
{size, _} <- Integer.parse(size),
|
||||
|
|
|
@ -17,6 +17,7 @@ def key_id_to_actor_id(key_id) do
|
|||
key_id
|
||||
|> URI.parse()
|
||||
|> Map.put(:fragment, nil)
|
||||
|> Map.put(:query, nil)
|
||||
|> remove_suffix(@known_suffixes)
|
||||
|
||||
maybe_ap_id = URI.to_string(uri)
|
||||
|
|
|
@ -65,15 +65,6 @@ defmodule Pleroma.Upload do
|
|||
}
|
||||
defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path]
|
||||
|
||||
defp get_description(opts, upload) do
|
||||
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||
{description, _} when is_binary(description) -> description
|
||||
{_, :filename} -> upload.name
|
||||
{_, str} when is_binary(str) -> str
|
||||
_ -> ""
|
||||
end
|
||||
end
|
||||
|
||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||
@doc "Store a file. If using a `Plug.Upload{}` as the source, be sure to use `Majic.Plug` to ensure its content_type and filename is correct."
|
||||
def store(upload, opts \\ []) do
|
||||
|
@ -82,7 +73,7 @@ def store(upload, opts \\ []) do
|
|||
with {:ok, upload} <- prepare_upload(upload, opts),
|
||||
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
||||
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
||||
description = get_description(opts, upload),
|
||||
description = Map.get(opts, :description) || "",
|
||||
{_, true} <-
|
||||
{:description_limit,
|
||||
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},
|
||||
|
|
|
@ -38,9 +38,9 @@ def filter([filter | rest], upload) do
|
|||
{:ok, :noop} ->
|
||||
filter(rest, upload)
|
||||
|
||||
error ->
|
||||
Logger.error("#{__MODULE__}: Filter #{filter} failed: #{inspect(error)}")
|
||||
error
|
||||
{:error, e} ->
|
||||
Logger.error("#{__MODULE__}: Filter #{filter} failed: #{inspect(e)}")
|
||||
{:error, e}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
20
lib/pleroma/upload/filter/only_media.ex
Normal file
20
lib/pleroma/upload/filter/only_media.ex
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Upload.Filter.OnlyMedia do
|
||||
@behaviour Pleroma.Upload.Filter
|
||||
alias Pleroma.Upload
|
||||
|
||||
def filter(%Upload{content_type: content_type}) do
|
||||
[type, _subtype] = String.split(content_type, "/")
|
||||
|
||||
if type in ["image", "video", "audio"] do
|
||||
{:ok, :noop}
|
||||
else
|
||||
{:error, "Disallowed content-type: #{content_type}"}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: {:ok, :noop}
|
||||
end
|
|
@ -159,6 +159,11 @@ defmodule Pleroma.User do
|
|||
field(:language, :string)
|
||||
field(:status_ttl_days, :integer, default: nil)
|
||||
|
||||
field(:accepts_direct_messages_from, Ecto.Enum,
|
||||
values: [:everybody, :people_i_follow, :nobody],
|
||||
default: :everybody
|
||||
)
|
||||
|
||||
embeds_one(
|
||||
:notification_settings,
|
||||
Pleroma.User.NotificationSetting,
|
||||
|
@ -273,7 +278,13 @@ def cached_muted_users_ap_ids(user) do
|
|||
defdelegate following(user), to: FollowingRelationship
|
||||
defdelegate following?(follower, followed), to: FollowingRelationship
|
||||
defdelegate following_ap_ids(user), to: FollowingRelationship
|
||||
defdelegate get_follow_requests(user), to: FollowingRelationship
|
||||
defdelegate get_follow_requests_query(user), to: FollowingRelationship
|
||||
|
||||
def get_follow_requests(user) do
|
||||
get_follow_requests_query(user)
|
||||
|> Repo.all()
|
||||
end
|
||||
|
||||
defdelegate search(query, opts \\ []), to: User.Search
|
||||
|
||||
@doc """
|
||||
|
@ -360,21 +371,21 @@ def invisible?(%User{invisible: true}), do: true
|
|||
def invisible?(_), do: false
|
||||
|
||||
def avatar_url(user, options \\ []) do
|
||||
case user.avatar do
|
||||
%{"url" => [%{"href" => href} | _]} ->
|
||||
href
|
||||
|
||||
_ ->
|
||||
unless options[:no_default] do
|
||||
Config.get([:assets, :default_user_avatar], "#{Endpoint.url()}/images/avi.png")
|
||||
end
|
||||
end
|
||||
default = Config.get([:assets, :default_user_avatar], "#{Endpoint.url()}/images/avi.png")
|
||||
do_optional_url(user.avatar, default, options)
|
||||
end
|
||||
|
||||
def banner_url(user, options \\ []) do
|
||||
case user.banner do
|
||||
%{"url" => [%{"href" => href} | _]} -> href
|
||||
_ -> !options[:no_default] && "#{Endpoint.url()}/images/banner.png"
|
||||
do_optional_url(user.banner, "#{Endpoint.url()}/images/banner.png", options)
|
||||
end
|
||||
|
||||
defp do_optional_url(field, default, options) do
|
||||
case field do
|
||||
%{"url" => [%{"href" => href} | _]} when is_binary(href) ->
|
||||
href
|
||||
|
||||
_ ->
|
||||
unless options[:no_default], do: default
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -530,7 +541,8 @@ def update_changeset(struct, params \\ %{}) do
|
|||
:is_discoverable,
|
||||
:actor_type,
|
||||
:disclose_client,
|
||||
:status_ttl_days
|
||||
:status_ttl_days,
|
||||
:accepts_direct_messages_from
|
||||
]
|
||||
)
|
||||
|> unique_constraint(:nickname)
|
||||
|
@ -864,7 +876,7 @@ def post_register_action(%User{is_approved: true, is_confirmed: true} = user) do
|
|||
end
|
||||
end
|
||||
|
||||
defp send_user_approval_email(user) do
|
||||
defp send_user_approval_email(%User{email: email} = user) when is_binary(email) do
|
||||
user
|
||||
|> Pleroma.Emails.UserEmail.approval_pending_email()
|
||||
|> Pleroma.Emails.Mailer.deliver_async()
|
||||
|
@ -872,6 +884,10 @@ defp send_user_approval_email(user) do
|
|||
{:ok, :enqueued}
|
||||
end
|
||||
|
||||
defp send_user_approval_email(_user) do
|
||||
{:ok, :skipped}
|
||||
end
|
||||
|
||||
defp send_admin_approval_emails(user) do
|
||||
all_superusers()
|
||||
|> Enum.filter(fn user -> not is_nil(user.email) end)
|
||||
|
@ -2070,10 +2086,14 @@ def parse_bio(bio, user) when is_binary(bio) and bio != "" do
|
|||
# TODO: get profile URLs other than user.ap_id
|
||||
profile_urls = [user.ap_id]
|
||||
|
||||
bio
|
||||
|> CommonUtils.format_input("text/plain",
|
||||
CommonUtils.format_input(bio, "text/plain",
|
||||
mentions_format: :full,
|
||||
rel: &RelMe.maybe_put_rel_me(&1, profile_urls)
|
||||
rel: fn link ->
|
||||
case RelMe.maybe_put_rel_me(link, profile_urls) do
|
||||
"me" -> "me"
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|> elem(0)
|
||||
end
|
||||
|
@ -2711,4 +2731,16 @@ def unfollow_hashtag(%User{} = user, %Hashtag{} = hashtag) do
|
|||
def following_hashtag?(%User{} = user, %Hashtag{} = hashtag) do
|
||||
not is_nil(HashtagFollow.get(user, hashtag))
|
||||
end
|
||||
|
||||
def accepts_direct_messages?(
|
||||
%User{accepts_direct_messages_from: :people_i_follow} = receiver,
|
||||
%User{} = sender
|
||||
) do
|
||||
User.following?(receiver, sender)
|
||||
end
|
||||
|
||||
def accepts_direct_messages?(%User{accepts_direct_messages_from: :everybody}, _), do: true
|
||||
|
||||
def accepts_direct_messages?(%User{accepts_direct_messages_from: :nobody}, _),
|
||||
do: false
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ def show(%User{} = source, %User{} = target) do
|
|||
UserNote
|
||||
|> where(source_id: ^source.id, target_id: ^target.id)
|
||||
|> Repo.one() do
|
||||
note.comment
|
||||
note.comment || ""
|
||||
else
|
||||
_ -> ""
|
||||
end
|
||||
|
|
|
@ -1502,13 +1502,22 @@ def fetch_activities_bounded(
|
|||
|
||||
@spec upload(Upload.source(), keyword()) :: {:ok, Object.t()} | {:error, any()}
|
||||
def upload(file, opts \\ []) do
|
||||
with {:ok, data} <- Upload.store(file, opts) do
|
||||
with {:ok, data} <- Upload.store(sanitize_upload_file(file), opts) do
|
||||
obj_data = Maps.put_if_present(data, "actor", opts[:actor])
|
||||
|
||||
Repo.insert(%Object{data: obj_data})
|
||||
end
|
||||
end
|
||||
|
||||
defp sanitize_upload_file(%Plug.Upload{filename: filename} = upload) when is_binary(filename) do
|
||||
%Plug.Upload{
|
||||
upload
|
||||
| filename: Path.basename(filename)
|
||||
}
|
||||
end
|
||||
|
||||
defp sanitize_upload_file(upload), do: upload
|
||||
|
||||
@spec get_actor_url(any()) :: binary() | nil
|
||||
defp get_actor_url(url) when is_binary(url), do: url
|
||||
defp get_actor_url(%{"href" => href}) when is_binary(href), do: href
|
||||
|
|
|
@ -8,7 +8,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.Delivery
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Object.Fetcher
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||
|
@ -293,33 +292,12 @@ def inbox(%{assigns: %{valid_signature: false}} = conn, _params) do
|
|||
|> json("Invalid HTTP Signature")
|
||||
end
|
||||
|
||||
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
||||
def inbox(conn, %{"type" => "Create"} = params) do
|
||||
if FederatingPlug.federating?() do
|
||||
post_inbox_relayed_create(conn, params)
|
||||
else
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json("Not federating")
|
||||
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
|
||||
Logger.debug(
|
||||
"Signature missing or not from author, relayed Create message, fetching object from source"
|
||||
)
|
||||
|
||||
Fetcher.fetch_object_from_id(params["object"]["id"])
|
||||
|
||||
json(conn, "ok")
|
||||
end
|
||||
|
||||
defp represent_service_actor(%User{} = user, conn) do
|
||||
conn
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|
|
|
@ -147,7 +147,8 @@ def get_policies do
|
|||
|> Enum.concat([
|
||||
Pleroma.Web.ActivityPub.MRF.HashtagPolicy,
|
||||
Pleroma.Web.ActivityPub.MRF.InlineQuotePolicy,
|
||||
Pleroma.Web.ActivityPub.MRF.NormalizeMarkup
|
||||
Pleroma.Web.ActivityPub.MRF.NormalizeMarkup,
|
||||
Pleroma.Web.ActivityPub.MRF.DirectMessageDisabledPolicy
|
||||
])
|
||||
|> Enum.uniq()
|
||||
end
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
defmodule Pleroma.Web.ActivityPub.MRF.DirectMessageDisabledPolicy do
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
alias Pleroma.User
|
||||
require Pleroma.Constants
|
||||
|
||||
@moduledoc """
|
||||
Removes entries from the "To" field from direct messages if the user has requested to not
|
||||
allow direct messages
|
||||
"""
|
||||
|
||||
@impl true
|
||||
def filter(
|
||||
%{
|
||||
"type" => "Create",
|
||||
"actor" => actor,
|
||||
"object" => %{
|
||||
"type" => "Note"
|
||||
}
|
||||
} = activity
|
||||
) do
|
||||
with recipients <- Map.get(activity, "to", []),
|
||||
cc <- Map.get(activity, "cc", []),
|
||||
true <- is_direct?(recipients, cc),
|
||||
sender <- User.get_cached_by_ap_id(actor) do
|
||||
new_to =
|
||||
Enum.filter(recipients, fn recv ->
|
||||
should_include?(sender, recv)
|
||||
end)
|
||||
|
||||
{:ok,
|
||||
activity
|
||||
|> Map.put("to", new_to)
|
||||
|> maybe_replace_object_to(new_to)}
|
||||
else
|
||||
_ ->
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def filter(object), do: {:ok, object}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
|
||||
defp should_include?(sender, receiver_ap_id) do
|
||||
with %User{local: true} = receiver <- User.get_cached_by_ap_id(receiver_ap_id) do
|
||||
User.accepts_direct_messages?(receiver, sender)
|
||||
else
|
||||
_ -> true
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_replace_object_to(%{"object" => %{"to" => _}} = activity, to) do
|
||||
Kernel.put_in(activity, ["object", "to"], to)
|
||||
end
|
||||
|
||||
defp maybe_replace_object_to(other, _), do: other
|
||||
|
||||
defp is_direct?(to, cc) do
|
||||
!(Enum.member?(to, Pleroma.Constants.as_public()) ||
|
||||
Enum.member?(cc, Pleroma.Constants.as_public()))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
defmodule Pleroma.Web.ActivityPub.MRF.RejectNewlyCreatedAccountNotesPolicy do
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
alias Pleroma.User
|
||||
|
||||
@moduledoc """
|
||||
Rejects notes from accounts that were created below a certain threshold of time ago
|
||||
"""
|
||||
@impl true
|
||||
def filter(
|
||||
%{
|
||||
"type" => type,
|
||||
"actor" => actor
|
||||
} = activity
|
||||
)
|
||||
when type in ["Note", "Create"] do
|
||||
min_age = Pleroma.Config.get([:mrf_reject_newly_created_account_notes, :age])
|
||||
|
||||
with %User{local: false} = user <- Pleroma.User.get_cached_by_ap_id(actor),
|
||||
true <- Timex.diff(Timex.now(), user.inserted_at, :seconds) < min_age do
|
||||
{:reject, "[RejectNewlyCreatedAccountNotesPolicy] Account created too recently"}
|
||||
else
|
||||
_ -> {:ok, activity}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def filter(object), do: {:ok, object}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
|
||||
@impl true
|
||||
def config_description do
|
||||
%{
|
||||
key: :mrf_reject_newly_created_account_notes,
|
||||
related_policy: "Pleroma.Web.ActivityPub.MRF.RejectNewlyCreatedAccountNotesPolicy",
|
||||
label: "MRF Reject New Accounts",
|
||||
description: "Reject notes from accounts created too recently",
|
||||
children: [
|
||||
%{
|
||||
key: :age,
|
||||
type: :integer,
|
||||
description: "Time below which to reject (in seconds)",
|
||||
suggestions: [86_400]
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
|
@ -104,9 +104,9 @@ defp remote_mention_resolver(
|
|||
end
|
||||
end
|
||||
|
||||
# https://github.com/misskey-dev/misskey/pull/8787
|
||||
# Misskey has an awful tendency to drop all custom formatting when it sends remotely
|
||||
# So this basically reprocesses their MFM source
|
||||
# See https://akkoma.dev/FoundKeyGang/FoundKey/issues/343
|
||||
# Misskey/Foundkey drops some of the custom formatting when it sends remotely
|
||||
# So this basically reprocesses the MFM source
|
||||
defp fix_misskey_content(
|
||||
%{"source" => %{"mediaType" => "text/x.misskeymarkdown", "content" => content}} = object
|
||||
)
|
||||
|
@ -121,6 +121,8 @@ defp fix_misskey_content(
|
|||
Map.put(object, "content", linked)
|
||||
end
|
||||
|
||||
# See https://github.com/misskey-dev/misskey/pull/8787
|
||||
# This is for compatibility with older Misskey instances
|
||||
defp fix_misskey_content(%{"_misskey_content" => content} = object) when is_binary(content) do
|
||||
mention_handler = fn nick, buffer, opts, acc ->
|
||||
remote_mention_resolver(object, nick, buffer, opts, acc)
|
||||
|
|
|
@ -22,7 +22,10 @@ def cast_and_filter_recipients(message, field, follower_collection, field_fallba
|
|||
end
|
||||
|
||||
def fix_object_defaults(data) do
|
||||
context = Utils.maybe_create_context(data["context"] || data["conversation"])
|
||||
context =
|
||||
Utils.maybe_create_context(
|
||||
data["context"] || data["conversation"] || data["inReplyTo"] || data["id"]
|
||||
)
|
||||
|
||||
%User{follower_address: follower_collection} = User.get_cached_by_ap_id(data["attributedTo"])
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
|
|||
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||
|
||||
@primary_key false
|
||||
@emoji_regex ~r/:[A-Za-z0-9_-]+(@.+)?:/
|
||||
|
||||
embedded_schema do
|
||||
quote do
|
||||
|
@ -75,9 +74,6 @@ defp fix(data) do
|
|||
end
|
||||
end
|
||||
|
||||
defp matches_shortcode?(nil), do: false
|
||||
defp matches_shortcode?(s), do: Regex.match?(@emoji_regex, s)
|
||||
|
||||
defp fix_emoji_qualification(%{"content" => emoji} = data) do
|
||||
new_emoji = Pleroma.Emoji.fully_qualify_emoji(emoji)
|
||||
|
||||
|
@ -98,7 +94,7 @@ defp fix_emoji_qualification(data), do: data
|
|||
defp validate_emoji(cng) do
|
||||
content = get_field(cng, :content)
|
||||
|
||||
if Emoji.is_unicode_emoji?(content) || matches_shortcode?(content) do
|
||||
if Emoji.is_unicode_emoji?(content) || Emoji.matches_shortcode?(content) do
|
||||
cng
|
||||
else
|
||||
cng
|
||||
|
|
|
@ -108,15 +108,28 @@ defp blocked_instances do
|
|||
Config.get([:mrf_simple, :reject], [])
|
||||
end
|
||||
|
||||
defp allowed_instances do
|
||||
Config.get([:mrf_simple, :accept])
|
||||
end
|
||||
|
||||
def should_federate?(url) do
|
||||
%{host: host} = URI.parse(url)
|
||||
|
||||
quarantined_instances =
|
||||
blocked_instances()
|
||||
with allowed <- allowed_instances(),
|
||||
false <- Enum.empty?(allowed) do
|
||||
allowed
|
||||
|> Pleroma.Web.ActivityPub.MRF.instance_list_from_tuples()
|
||||
|> Pleroma.Web.ActivityPub.MRF.subdomains_regex()
|
||||
|> Pleroma.Web.ActivityPub.MRF.subdomain_match?(host)
|
||||
else
|
||||
_ ->
|
||||
quarantined_instances =
|
||||
blocked_instances()
|
||||
|> Pleroma.Web.ActivityPub.MRF.instance_list_from_tuples()
|
||||
|> Pleroma.Web.ActivityPub.MRF.subdomains_regex()
|
||||
|
||||
!Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
||||
not Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
||||
end
|
||||
end
|
||||
|
||||
@spec recipients(User.t(), Activity.t()) :: list(User.t()) | []
|
||||
|
|
|
@ -419,28 +419,19 @@ def handle_incoming(%{"id" => id}, _options) when is_binary(id) and byte_size(id
|
|||
def handle_incoming(
|
||||
%{
|
||||
"type" => "Like",
|
||||
"_misskey_reaction" => reaction,
|
||||
"tag" => _
|
||||
"content" => reaction
|
||||
} = data,
|
||||
options
|
||||
) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> Map.put("content", reaction)
|
||||
|> handle_incoming(options)
|
||||
end
|
||||
|
||||
def handle_incoming(
|
||||
%{
|
||||
"type" => "Like",
|
||||
"_misskey_reaction" => reaction
|
||||
} = data,
|
||||
options
|
||||
) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> Map.put("content", reaction)
|
||||
|> handle_incoming(options)
|
||||
if Pleroma.Emoji.is_unicode_emoji?(reaction) || Pleroma.Emoji.matches_shortcode?(reaction) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> handle_incoming(options)
|
||||
else
|
||||
data
|
||||
|> Map.delete("content")
|
||||
|> handle_incoming(options)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_incoming(
|
||||
|
@ -929,8 +920,13 @@ def add_attributed_to(object) do
|
|||
|
||||
def prepare_attachments(object) do
|
||||
attachments =
|
||||
object
|
||||
|> Map.get("attachment", [])
|
||||
case Map.get(object, "attachment", []) do
|
||||
[_ | _] = list -> list
|
||||
_ -> []
|
||||
end
|
||||
|
||||
attachments =
|
||||
attachments
|
||||
|> Enum.map(fn data ->
|
||||
[%{"mediaType" => media_type, "href" => href} = url | _] = data["url"]
|
||||
|
||||
|
|
|
@ -5,6 +5,16 @@ defmodule Pleroma.Web.AkkomaAPI.FrontendSettingsController do
|
|||
alias Pleroma.Akkoma.FrontendSettingsProfile
|
||||
|
||||
@unauthenticated_access %{fallback: :proceed_unauthenticated, scopes: []}
|
||||
|
||||
plug(
|
||||
OAuthScopesPlug,
|
||||
@unauthenticated_access
|
||||
when action in [
|
||||
:available_frontends,
|
||||
:update_preferred_frontend
|
||||
]
|
||||
)
|
||||
|
||||
plug(
|
||||
OAuthScopesPlug,
|
||||
%{@unauthenticated_access | scopes: ["read:accounts"]}
|
||||
|
@ -93,4 +103,22 @@ def update_profile(%{body_params: %{settings: settings, version: version}} = con
|
|||
|> json(profile.settings)
|
||||
end
|
||||
end
|
||||
|
||||
@doc "GET /api/v1/akkoma/preferred_frontend/available"
|
||||
def available_frontends(conn, _params) do
|
||||
available = Pleroma.Config.get([:frontends, :pickable])
|
||||
|
||||
conn
|
||||
|> json(available)
|
||||
end
|
||||
|
||||
@doc "PUT /api/v1/akkoma/preferred_frontend"
|
||||
def update_preferred_frontend(
|
||||
%{body_params: %{frontend_name: preferred_frontend}} = conn,
|
||||
_params
|
||||
) do
|
||||
conn
|
||||
|> put_resp_cookie("preferred_frontend", preferred_frontend)
|
||||
|> json(%{frontend_name: preferred_frontend})
|
||||
end
|
||||
end
|
||||
|
|
20
lib/pleroma/web/akkoma_api/controllers/frontend_switcher.ex
Normal file
20
lib/pleroma/web/akkoma_api/controllers/frontend_switcher.ex
Normal file
|
@ -0,0 +1,20 @@
|
|||
defmodule Pleroma.Web.AkkomaAPI.FrontendSwitcherController do
|
||||
use Pleroma.Web, :controller
|
||||
alias Pleroma.Config
|
||||
|
||||
@doc "GET /akkoma/frontend"
|
||||
def switch(conn, _params) do
|
||||
pickable = Config.get([:frontends, :pickable], [])
|
||||
|
||||
conn
|
||||
|> put_view(Pleroma.Web.AkkomaAPI.FrontendSwitcherView)
|
||||
|> render("switch.html", choices: pickable)
|
||||
end
|
||||
|
||||
@doc "POST /akkoma/frontend"
|
||||
def do_switch(conn, params) do
|
||||
conn
|
||||
|> put_resp_cookie("preferred_frontend", params["frontend"])
|
||||
|> html("<meta http-equiv=\"refresh\" content=\"0; url=/\">")
|
||||
end
|
||||
end
|
3
lib/pleroma/web/akkoma_api/views/frontend_switcher.ex
Normal file
3
lib/pleroma/web/akkoma_api/views/frontend_switcher.ex
Normal file
|
@ -0,0 +1,3 @@
|
|||
defmodule Pleroma.Web.AkkomaAPI.FrontendSwitcherView do
|
||||
use Pleroma.Web, :view
|
||||
end
|
|
@ -410,7 +410,7 @@ def blocks_operation do
|
|||
operationId: "AccountController.blocks",
|
||||
description: "View your blocks. See also accounts/:id/{block,unblock}",
|
||||
security: [%{"oAuth" => ["read:blocks"]}],
|
||||
parameters: pagination_params(),
|
||||
parameters: [with_relationships_param() | pagination_params()],
|
||||
responses: %{
|
||||
200 => Operation.response("Accounts", "application/json", array_of_accounts())
|
||||
}
|
||||
|
@ -708,6 +708,16 @@ defp update_credentials_request do
|
|||
nullable: true,
|
||||
description:
|
||||
"Number of days after which statuses will be deleted. Set to -1 to disable."
|
||||
},
|
||||
accepts_direct_messages_from: %Schema{
|
||||
type: :string,
|
||||
enum: [
|
||||
"everybody",
|
||||
"nobody",
|
||||
"people_i_follow"
|
||||
],
|
||||
nullable: true,
|
||||
description: "Who to accept DMs from"
|
||||
}
|
||||
},
|
||||
example: %{
|
||||
|
@ -729,7 +739,8 @@ defp update_credentials_request do
|
|||
also_known_as: ["https://foo.bar/users/foo"],
|
||||
discoverable: false,
|
||||
actor_type: "Person",
|
||||
status_ttl_days: 30
|
||||
status_ttl_days: 30,
|
||||
accepts_direct_messages_from: "everybody"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -756,7 +767,7 @@ defp array_of_relationships do
|
|||
"showing_reblogs" => true,
|
||||
"followed_by" => true,
|
||||
"blocking" => false,
|
||||
"blocked_by" => true,
|
||||
"blocked_by" => false,
|
||||
"muting" => false,
|
||||
"muting_notifications" => false,
|
||||
"note" => "",
|
||||
|
@ -772,7 +783,7 @@ defp array_of_relationships do
|
|||
"showing_reblogs" => true,
|
||||
"followed_by" => true,
|
||||
"blocking" => false,
|
||||
"blocked_by" => true,
|
||||
"blocked_by" => false,
|
||||
"muting" => true,
|
||||
"muting_notifications" => false,
|
||||
"note" => "",
|
||||
|
|
|
@ -143,7 +143,7 @@ def admin_account do
|
|||
}
|
||||
},
|
||||
tags: %Schema{type: :string},
|
||||
is_confirmed: %Schema{type: :string}
|
||||
is_confirmed: %Schema{type: :boolean}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -225,6 +225,12 @@ defp update_request do
|
|||
type: :integer,
|
||||
description:
|
||||
"Number of seconds from now the filter should expire. Otherwise, null for a filter that doesn't expire."
|
||||
},
|
||||
expires_at: %Schema{
|
||||
nullable: true,
|
||||
type: :string,
|
||||
description:
|
||||
"When the filter should no longer be applied. String (ISO 8601 Datetime), or null if the filter does not expire."
|
||||
}
|
||||
},
|
||||
required: [:phrase, :context],
|
||||
|
|
|
@ -19,6 +19,7 @@ def index_operation do
|
|||
summary: "Retrieve follow requests",
|
||||
security: [%{"oAuth" => ["read:follows", "follow"]}],
|
||||
operationId: "FollowRequestController.index",
|
||||
parameters: pagination_params(),
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Array of Account", "application/json", %Schema{
|
||||
|
@ -62,4 +63,22 @@ defp id_param do
|
|||
required: true
|
||||
)
|
||||
end
|
||||
|
||||
defp pagination_params do
|
||||
[
|
||||
Operation.parameter(:max_id, :query, :string, "Return items older than this ID"),
|
||||
Operation.parameter(
|
||||
:since_id,
|
||||
:query,
|
||||
:string,
|
||||
"Return the oldest items newer than this ID"
|
||||
),
|
||||
Operation.parameter(
|
||||
:limit,
|
||||
:query,
|
||||
%Schema{type: :integer, default: 20},
|
||||
"Maximum number of items to return. Will be ignored if it's more than 40"
|
||||
)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ def open_api_operation(action) do
|
|||
@spec list_profiles_operation() :: Operation.t()
|
||||
def list_profiles_operation() do
|
||||
%Operation{
|
||||
tags: ["Retrieve frontend setting profiles"],
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profiles",
|
||||
description: "List frontend setting profiles",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.list_profiles",
|
||||
|
@ -37,7 +37,7 @@ def list_profiles_operation() do
|
|||
@spec get_profile_operation() :: Operation.t()
|
||||
def get_profile_operation() do
|
||||
%Operation{
|
||||
tags: ["Retrieve frontend setting profile"],
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profile",
|
||||
description: "Get frontend setting profile",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.get_profile",
|
||||
|
@ -60,7 +60,7 @@ def get_profile_operation() do
|
|||
@spec delete_profile_operation() :: Operation.t()
|
||||
def delete_profile_operation() do
|
||||
%Operation{
|
||||
tags: ["Delete frontend setting profile"],
|
||||
tags: ["Frontends"],
|
||||
summary: "Delete frontend Settings Profile",
|
||||
description: "Delete frontend setting profile",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.delete_profile",
|
||||
|
@ -76,7 +76,7 @@ def delete_profile_operation() do
|
|||
@spec update_profile_operation() :: Operation.t()
|
||||
def update_profile_operation() do
|
||||
%Operation{
|
||||
tags: ["Update frontend setting profile"],
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profile",
|
||||
description: "Update frontend setting profile",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.update_profile_operation",
|
||||
|
@ -90,6 +90,57 @@ def update_profile_operation() do
|
|||
}
|
||||
end
|
||||
|
||||
def available_frontends_operation() do
|
||||
%Operation{
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profiles",
|
||||
description: "List frontend setting profiles",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.available_frontends",
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Frontends", "application/json", %Schema{
|
||||
type: :array,
|
||||
items: %Schema{
|
||||
type: :string
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def update_preferred_frontend_operation() do
|
||||
%Operation{
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profiles",
|
||||
description: "List frontend setting profiles",
|
||||
operationId: "AkkomaAPI.FrontendSettingsController.available_frontends",
|
||||
requestBody:
|
||||
request_body(
|
||||
"Frontend",
|
||||
%Schema{
|
||||
type: :object,
|
||||
required: [:frontend_name],
|
||||
properties: %{
|
||||
frontend_name: %Schema{
|
||||
type: :string,
|
||||
description: "Frontend name"
|
||||
}
|
||||
}
|
||||
},
|
||||
required: true
|
||||
),
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Frontends", "application/json", %Schema{
|
||||
type: :array,
|
||||
items: %Schema{
|
||||
type: :string
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def frontend_name_param do
|
||||
Operation.parameter(:frontend_name, :path, :string, "Frontend name",
|
||||
example: "pleroma-fe",
|
||||
|
|
|
@ -70,7 +70,8 @@ def public_operation do
|
|||
operationId: "TimelineController.public",
|
||||
responses: %{
|
||||
200 => Operation.response("Array of Status", "application/json", array_of_statuses()),
|
||||
401 => Operation.response("Error", "application/json", ApiError)
|
||||
401 => Operation.response("Error", "application/json", ApiError),
|
||||
404 => Operation.response("Error", "application/json", ApiError)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -13,7 +13,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountRelationship do
|
|||
description: "Relationship between current account and requested account",
|
||||
type: :object,
|
||||
properties: %{
|
||||
blocked_by: %Schema{type: :boolean},
|
||||
blocked_by: %Schema{
|
||||
type: :boolean,
|
||||
description: "Represents being blocked by this user. Always false."
|
||||
},
|
||||
blocking: %Schema{type: :boolean},
|
||||
domain_blocking: %Schema{type: :boolean},
|
||||
endorsed: %Schema{type: :boolean},
|
||||
|
|
|
@ -88,7 +88,7 @@ def reject_follow_request(follower, followed) do
|
|||
|
||||
def delete(activity_id, user) do
|
||||
with {_, %Activity{data: %{"object" => _, "type" => "Create"}} = activity} <-
|
||||
{:find_activity, Activity.get_by_id(activity_id)},
|
||||
{:find_activity, Activity.get_by_id(activity_id, filter: [])},
|
||||
{_, %Object{} = object, _} <-
|
||||
{:find_object, Object.normalize(activity, fetch: false), activity},
|
||||
true <- User.superuser?(user) || user.ap_id == object.data["actor"],
|
||||
|
|
|
@ -144,6 +144,8 @@ def make_poll_data(%{poll: %{options: options, expires_in: expires_in}} = data)
|
|||
when is_list(options) do
|
||||
limits = Config.get([:instance, :poll_limits])
|
||||
|
||||
options = options |> Enum.uniq()
|
||||
|
||||
with :ok <- validate_poll_expiration(expires_in, limits),
|
||||
:ok <- validate_poll_options_amount(options, limits),
|
||||
:ok <- validate_poll_options_length(options, limits) do
|
||||
|
@ -179,10 +181,15 @@ def make_poll_data(_data) do
|
|||
end
|
||||
|
||||
defp validate_poll_options_amount(options, %{max_options: max_options}) do
|
||||
if Enum.count(options) > max_options do
|
||||
{:error, "Poll can't contain more than #{max_options} options"}
|
||||
else
|
||||
:ok
|
||||
cond do
|
||||
Enum.count(options) < 2 ->
|
||||
{:error, "Poll must contain at least 2 options"}
|
||||
|
||||
Enum.count(options) > max_options ->
|
||||
{:error, "Poll can't contain more than #{max_options} options"}
|
||||
|
||||
true ->
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -289,7 +296,7 @@ def format_input(text, "text/html", options) do
|
|||
|
||||
def format_input(text, "text/x.misskeymarkdown", options) do
|
||||
text
|
||||
|> Formatter.markdown_to_html()
|
||||
|> Formatter.markdown_to_html(%{breaks: true})
|
||||
|> MfmParser.Parser.parse()
|
||||
|> MfmParser.Encoder.to_html()
|
||||
|> Formatter.linkify(options)
|
||||
|
|
|
@ -11,22 +11,31 @@ defmodule Pleroma.Web.EmbedController do
|
|||
|
||||
alias Pleroma.Web.ActivityPub.Visibility
|
||||
|
||||
plug(:put_layout, :embed)
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
with %Activity{local: true} = activity <-
|
||||
Activity.get_by_id_with_object(id),
|
||||
true <- Visibility.is_public?(activity.object) do
|
||||
with {:activity, %Activity{} = activity} <-
|
||||
{:activity, Activity.get_by_id_with_object(id)},
|
||||
{:local, true} <- {:local, activity.local},
|
||||
{:visible, true} <- {:visible, Visibility.visible_for_user?(activity, nil)} do
|
||||
{:ok, author} = User.get_or_fetch(activity.object.data["actor"])
|
||||
|
||||
conn
|
||||
|> delete_resp_header("x-frame-options")
|
||||
|> delete_resp_header("content-security-policy")
|
||||
|> put_view(Pleroma.Web.EmbedView)
|
||||
|> render("show.html",
|
||||
activity: activity,
|
||||
author: User.sanitize_html(author),
|
||||
counts: get_counts(activity)
|
||||
)
|
||||
else
|
||||
{:activity, _} ->
|
||||
render_error(conn, :not_found, "Post not found")
|
||||
|
||||
{:local, false} ->
|
||||
render_error(conn, :unauthorized, "Federated posts cannot be embedded")
|
||||
|
||||
{:visible, false} ->
|
||||
render_error(conn, :unauthorized, "Not authorized to view this post")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ def api_not_implemented(conn, _params) do
|
|||
def redirector(conn, _params, code \\ 200) do
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(code, index_file_path())
|
||||
|> send_file(code, index_file_path(conn))
|
||||
end
|
||||
|
||||
def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
|
||||
|
@ -33,7 +33,7 @@ def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id}
|
|||
end
|
||||
|
||||
def redirector_with_meta(conn, params) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
{:ok, index_content} = File.read(index_file_path(conn))
|
||||
|
||||
tags = build_tags(conn, params)
|
||||
preloads = preload_data(conn, params)
|
||||
|
@ -53,7 +53,7 @@ def redirector_with_preload(conn, %{"path" => ["pleroma", "admin"]}) do
|
|||
end
|
||||
|
||||
def redirector_with_preload(conn, params) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
{:ok, index_content} = File.read(index_file_path(conn))
|
||||
preloads = preload_data(conn, params)
|
||||
tags = Metadata.build_static_tags(params)
|
||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
||||
|
@ -77,8 +77,9 @@ def empty(conn, _params) do
|
|||
|> text("")
|
||||
end
|
||||
|
||||
defp index_file_path do
|
||||
Pleroma.Web.Plugs.InstanceStatic.file_path("index.html")
|
||||
defp index_file_path(conn) do
|
||||
frontend_type = Pleroma.Web.Plugs.FrontendStatic.preferred_or_fallback(conn, :primary)
|
||||
Pleroma.Web.Plugs.InstanceStatic.file_path("index.html", frontend_type)
|
||||
end
|
||||
|
||||
defp build_tags(conn, params) do
|
||||
|
|
|
@ -221,6 +221,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
|
|||
|> Maps.put_if_present(:is_discoverable, params[:discoverable])
|
||||
|> Maps.put_if_present(:language, Pleroma.Web.Gettext.normalize_locale(params[:language]))
|
||||
|> Maps.put_if_present(:status_ttl_days, params[:status_ttl_days], status_ttl_days_value)
|
||||
|> Maps.put_if_present(:accepts_direct_messages_from, params[:accepts_direct_messages_from])
|
||||
|
||||
# What happens here:
|
||||
#
|
||||
|
@ -517,7 +518,12 @@ def blocks(%{assigns: %{user: user}} = conn, params) do
|
|||
|
||||
conn
|
||||
|> add_link_headers(users)
|
||||
|> render("index.json", users: users, for: user, as: :user)
|
||||
|> render("index.json",
|
||||
users: users,
|
||||
for: user,
|
||||
as: :user,
|
||||
embed_relationships: embed_relationships?(params)
|
||||
)
|
||||
end
|
||||
|
||||
@doc "GET /api/v1/accounts/lookup"
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.FollowRequestController do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
import Pleroma.Web.ControllerHelper,
|
||||
only: [add_link_headers: 2]
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
alias Pleroma.Pagination
|
||||
|
||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||
plug(:assign_follower when action != :index)
|
||||
|
@ -24,10 +28,15 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestController do
|
|||
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.FollowRequestOperation
|
||||
|
||||
@doc "GET /api/v1/follow_requests"
|
||||
def index(%{assigns: %{user: followed}} = conn, _params) do
|
||||
follow_requests = User.get_follow_requests(followed)
|
||||
def index(%{assigns: %{user: followed}} = conn, params) do
|
||||
follow_requests =
|
||||
followed
|
||||
|> User.get_follow_requests_query()
|
||||
|> Pagination.fetch_paginated(params, :keyset, :follower)
|
||||
|
||||
render(conn, "index.json", for: followed, users: follow_requests, as: :user)
|
||||
conn
|
||||
|> add_link_headers(follow_requests)
|
||||
|> render("index.json", for: followed, users: follow_requests, as: :user)
|
||||
end
|
||||
|
||||
@doc "POST /api/v1/follow_requests/:id/authorize"
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
alias Pleroma.Web.Plugs.RateLimiter
|
||||
|
||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||
plug(:skip_public_check when action in [:public, :hashtag])
|
||||
plug(:skip_public_check when action in [:public, :hashtag, :bubble])
|
||||
|
||||
# TODO: Replace with a macro when there is a Phoenix release with the following commit in it:
|
||||
# https://github.com/phoenixframework/phoenix/commit/2e8c63c01fec4dde5467dbbbf9705ff9e780735e
|
||||
|
@ -28,19 +28,25 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
plug(RateLimiter, [name: :timeline, bucket_name: :list_timeline] when action == :list)
|
||||
plug(RateLimiter, [name: :timeline, bucket_name: :bubble_timeline] when action == :bubble)
|
||||
|
||||
plug(OAuthScopesPlug, %{scopes: ["read:statuses"]} when action in [:home, :direct, :bubble])
|
||||
plug(OAuthScopesPlug, %{scopes: ["read:statuses"]} when action in [:home, :direct])
|
||||
plug(OAuthScopesPlug, %{scopes: ["read:lists"]} when action == :list)
|
||||
|
||||
plug(
|
||||
OAuthScopesPlug,
|
||||
%{scopes: ["read:statuses"], fallback: :proceed_unauthenticated}
|
||||
when action in [:public, :hashtag]
|
||||
when action in [:public, :hashtag, :bubble]
|
||||
)
|
||||
|
||||
require Logger
|
||||
|
||||
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.TimelineOperation
|
||||
|
||||
# GET /api/v1/timelines/home
|
||||
def home(%{assigns: %{user: user}} = conn, params) do
|
||||
%{nickname: nickname} = user
|
||||
|
||||
Logger.debug("TimelineController.home: #{nickname}")
|
||||
|
||||
followed_hashtags =
|
||||
user
|
||||
|> User.followed_hashtags()
|
||||
|
@ -58,11 +64,15 @@ def home(%{assigns: %{user: user}} = conn, params) do
|
|||
|> Map.put(:followed_hashtags, followed_hashtags)
|
||||
|> Map.delete(:local)
|
||||
|
||||
Logger.debug("TimelineController.home: #{nickname} - fetching activities")
|
||||
|
||||
activities =
|
||||
[user.ap_id | User.following(user)]
|
||||
|> ActivityPub.fetch_activities(params)
|
||||
|> Enum.reverse()
|
||||
|
||||
Logger.debug("TimelineController.home: #{nickname} - rendering")
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities)
|
||||
|> render("index.json",
|
||||
|
@ -75,6 +85,8 @@ def home(%{assigns: %{user: user}} = conn, params) do
|
|||
|
||||
# GET /api/v1/timelines/direct
|
||||
def direct(%{assigns: %{user: user}} = conn, params) do
|
||||
Logger.debug("TimelineController.direct: #{user.nickname}")
|
||||
|
||||
params =
|
||||
params
|
||||
|> Map.put(:type, "Create")
|
||||
|
@ -82,11 +94,15 @@ def direct(%{assigns: %{user: user}} = conn, params) do
|
|||
|> Map.put(:user, user)
|
||||
|> Map.put(:visibility, "direct")
|
||||
|
||||
Logger.debug("TimelineController.direct: #{user.nickname} - fetching activities")
|
||||
|
||||
activities =
|
||||
[user.ap_id]
|
||||
|> ActivityPub.fetch_activities_query(params)
|
||||
|> Pagination.fetch_paginated(params)
|
||||
|
||||
Logger.debug("TimelineController.direct: #{user.nickname} - rendering")
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities)
|
||||
|> render("index.json",
|
||||
|
@ -96,21 +112,22 @@ def direct(%{assigns: %{user: user}} = conn, params) do
|
|||
)
|
||||
end
|
||||
|
||||
defp restrict_unauthenticated?(true = _local_only) do
|
||||
Config.restrict_unauthenticated_access?(:timelines, :local)
|
||||
end
|
||||
|
||||
defp restrict_unauthenticated?(_) do
|
||||
Config.restrict_unauthenticated_access?(:timelines, :federated)
|
||||
defp restrict_unauthenticated?(type) do
|
||||
Config.restrict_unauthenticated_access?(:timelines, type)
|
||||
end
|
||||
|
||||
# GET /api/v1/timelines/public
|
||||
def public(%{assigns: %{user: user}} = conn, params) do
|
||||
Logger.debug("TimelineController.public")
|
||||
local_only = params[:local]
|
||||
timeline_type = if local_only, do: :local, else: :federated
|
||||
|
||||
with {:enabled, true} <-
|
||||
{:enabled, local_only || Config.get([:instance, :federated_timeline_available], true)},
|
||||
{:authenticated, true} <-
|
||||
{:authenticated, !(is_nil(user) and restrict_unauthenticated?(timeline_type))} do
|
||||
Logger.debug("TimelineController.public: fetching activities")
|
||||
|
||||
if is_nil(user) and restrict_unauthenticated?(local_only) do
|
||||
fail_on_bad_auth(conn)
|
||||
else
|
||||
activities =
|
||||
params
|
||||
|> Map.put(:type, ["Create"])
|
||||
|
@ -123,6 +140,8 @@ def public(%{assigns: %{user: user}} = conn, params) do
|
|||
|> Map.put(:includes_local_public, not is_nil(user))
|
||||
|> ActivityPub.fetch_public_activities()
|
||||
|
||||
Logger.debug("TimelineController.public: rendering")
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities, %{"local" => local_only})
|
||||
|> render("index.json",
|
||||
|
@ -131,20 +150,32 @@ def public(%{assigns: %{user: user}} = conn, params) do
|
|||
as: :activity,
|
||||
with_muted: Map.get(params, :with_muted, false)
|
||||
)
|
||||
else
|
||||
{:enabled, false} ->
|
||||
conn
|
||||
|> put_status(404)
|
||||
|> json(%{error: "Federated timeline is disabled"})
|
||||
|
||||
{:authenticated, false} ->
|
||||
fail_on_bad_auth(conn)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /api/v1/timelines/bubble
|
||||
def bubble(%{assigns: %{user: user}} = conn, params) do
|
||||
bubble_instances =
|
||||
Enum.uniq(
|
||||
Config.get([:instance, :local_bubble], []) ++
|
||||
[Pleroma.Web.Endpoint.host()]
|
||||
)
|
||||
Logger.debug("TimelineController.bubble")
|
||||
|
||||
if is_nil(user) do
|
||||
if is_nil(user) and restrict_unauthenticated?(:bubble) do
|
||||
fail_on_bad_auth(conn)
|
||||
else
|
||||
bubble_instances =
|
||||
Enum.uniq(
|
||||
Config.get([:instance, :local_bubble], []) ++
|
||||
[Pleroma.Web.Endpoint.host()]
|
||||
)
|
||||
|
||||
Logger.debug("TimelineController.bubble: fetching activities")
|
||||
|
||||
activities =
|
||||
params
|
||||
|> Map.put(:type, ["Create"])
|
||||
|
@ -154,6 +185,8 @@ def bubble(%{assigns: %{user: user}} = conn, params) do
|
|||
|> Map.put(:instance, bubble_instances)
|
||||
|> ActivityPub.fetch_public_activities()
|
||||
|
||||
Logger.debug("TimelineController.bubble: rendering")
|
||||
|
||||
conn
|
||||
|> add_link_headers(activities)
|
||||
|> render("index.json",
|
||||
|
@ -195,7 +228,7 @@ defp hashtag_fetching(params, user, local_only) do
|
|||
def hashtag(%{assigns: %{user: user}} = conn, params) do
|
||||
local_only = params[:local]
|
||||
|
||||
if is_nil(user) and restrict_unauthenticated?(local_only) do
|
||||
if is_nil(user) and restrict_unauthenticated?(if local_only, do: :local, else: :federated) do
|
||||
fail_on_bad_auth(conn)
|
||||
else
|
||||
activities = hashtag_fetching(params, user, local_only)
|
||||
|
|
|
@ -124,14 +124,7 @@ def render(
|
|||
target,
|
||||
&User.blocks_user?(&1, &2)
|
||||
),
|
||||
blocked_by:
|
||||
UserRelationship.exists?(
|
||||
user_relationships,
|
||||
:block,
|
||||
target,
|
||||
reading_user,
|
||||
&User.blocks_user?(&1, &2)
|
||||
),
|
||||
blocked_by: false,
|
||||
muting:
|
||||
UserRelationship.exists?(
|
||||
user_relationships,
|
||||
|
@ -334,7 +327,8 @@ defp maybe_put_follow_requests_count(
|
|||
%User{id: user_id}
|
||||
) do
|
||||
count =
|
||||
User.get_follow_requests(user)
|
||||
user
|
||||
|> User.get_follow_requests()
|
||||
|> length()
|
||||
|
||||
data
|
||||
|
@ -353,6 +347,7 @@ defp maybe_put_settings(
|
|||
|> Kernel.put_in([:source, :privacy], user.default_scope)
|
||||
|> Kernel.put_in([:source, :pleroma, :show_role], user.show_role)
|
||||
|> Kernel.put_in([:source, :pleroma, :no_rich_text], user.no_rich_text)
|
||||
|> Kernel.put_in([:accepts_direct_messages_from], user.accepts_direct_messages_from)
|
||||
end
|
||||
|
||||
defp maybe_put_settings(data, _, _, _), do: data
|
||||
|
|
|
@ -65,7 +65,11 @@ def features do
|
|||
"shareable_emoji_packs",
|
||||
"multifetch",
|
||||
"pleroma:api/v1/notifications:include_types_filter",
|
||||
"quote_posting",
|
||||
"editing",
|
||||
if !Enum.empty?(Config.get([:instance, :local_bubble], [])) do
|
||||
"bubble_timeline"
|
||||
end,
|
||||
if Config.get([:media_proxy, :enabled]) do
|
||||
"media_proxy"
|
||||
end,
|
||||
|
|
|
@ -21,6 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
alias Pleroma.Web.MastodonAPI.StatusView
|
||||
alias Pleroma.Web.MediaProxy
|
||||
alias Pleroma.Web.PleromaAPI.EmojiReactionController
|
||||
require Logger
|
||||
|
||||
import Pleroma.Web.ActivityPub.Visibility, only: [get_visibility: 1, visible_for_user?: 2]
|
||||
|
||||
|
@ -87,6 +88,7 @@ defp reblogged?(activity, %User{ap_id: ap_id}) do
|
|||
defp reblogged?(_activity, _user), do: false
|
||||
|
||||
def render("index.json", opts) do
|
||||
Logger.debug("Rendering index")
|
||||
reading_user = opts[:for]
|
||||
# To do: check AdminAPIControllerTest on the reasons behind nil activities in the list
|
||||
activities = Enum.filter(opts.activities, & &1)
|
||||
|
@ -136,8 +138,10 @@ def render("index.json", opts) do
|
|||
|
||||
def render(
|
||||
"show.json",
|
||||
%{activity: %{data: %{"type" => "Announce", "object" => _object}} = activity} = opts
|
||||
%{activity: %{id: id, data: %{"type" => "Announce", "object" => _object}} = activity} =
|
||||
opts
|
||||
) do
|
||||
Logger.debug("Rendering reblog #{id}")
|
||||
user = CommonAPI.get_user(activity.data["actor"])
|
||||
created_at = Utils.to_masto_date(activity.data["published"])
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
@ -183,7 +187,7 @@ def render(
|
|||
in_reply_to_id: nil,
|
||||
in_reply_to_account_id: nil,
|
||||
reblog: reblogged,
|
||||
content: reblogged[:content] || "",
|
||||
content: "",
|
||||
created_at: created_at,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
|
@ -209,7 +213,9 @@ def render(
|
|||
}
|
||||
end
|
||||
|
||||
def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
|
||||
def render("show.json", %{activity: %{id: id, data: %{"object" => _object}} = activity} = opts) do
|
||||
Logger.debug("Rendering status #{id}")
|
||||
|
||||
with %Object{} = object <- Object.normalize(activity, fetch: false) do
|
||||
user = CommonAPI.get_user(activity.data["actor"])
|
||||
user_follower_address = user.follower_address
|
||||
|
@ -227,8 +233,10 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
|||
|> Enum.filter(fn tag -> is_map(tag) and tag["type"] == "Mention" end)
|
||||
|> Enum.map(fn tag -> tag["href"] end)
|
||||
|
||||
to_data = if is_nil(object.data["to"]), do: [], else: object.data["to"]
|
||||
|
||||
mentions =
|
||||
(object.data["to"] ++ tag_mentions)
|
||||
(to_data ++ tag_mentions)
|
||||
|> Enum.uniq()
|
||||
|> Enum.map(fn
|
||||
Pleroma.Constants.as_public() -> nil
|
||||
|
@ -426,6 +434,7 @@ def render("show.json", _) do
|
|||
end
|
||||
|
||||
def render("history.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
|
||||
Logger.debug("Rendering history for #{activity.id}")
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
hashtags = Object.hashtags(object)
|
||||
|
@ -612,6 +621,8 @@ def render("attachment_meta.json", %{
|
|||
def render("attachment_meta.json", _), do: nil
|
||||
|
||||
def render("context.json", %{activity: activity, activities: activities, user: user}) do
|
||||
Logger.debug("Rendering context for #{activity.id}")
|
||||
|
||||
%{ancestors: ancestors, descendants: descendants} =
|
||||
activities
|
||||
|> Enum.reverse()
|
||||
|
|
|
@ -52,7 +52,7 @@ def url(url) do
|
|||
|
||||
@spec url_proxiable?(String.t()) :: boolean()
|
||||
def url_proxiable?(url) do
|
||||
not local?(url) and not whitelisted?(url)
|
||||
not local?(url) and not whitelisted?(url) and not blocked?(url)
|
||||
end
|
||||
|
||||
def preview_url(url, preview_params \\ []) do
|
||||
|
@ -83,6 +83,16 @@ def whitelisted?(url) do
|
|||
domain in mediaproxy_whitelist_domains
|
||||
end
|
||||
|
||||
def blocked?(url) do
|
||||
%{scheme: scheme, host: domain} = URI.parse(url)
|
||||
# Block either the bare domain or the scheme-domain combo
|
||||
scheme_domain = "#{scheme}://#{domain}"
|
||||
blocklist = Config.get([:media_proxy, :blocklist])
|
||||
|
||||
Enum.member?(blocklist, domain) ||
|
||||
Enum.member?(blocklist, scheme_domain)
|
||||
end
|
||||
|
||||
defp maybe_get_domain_from_url("http" <> _ = url) do
|
||||
URI.parse(url).host
|
||||
end
|
||||
|
|
|
@ -8,12 +8,20 @@ defmodule Pleroma.Web.Metadata.Providers.RelMe do
|
|||
|
||||
@impl Provider
|
||||
def build_tags(%{user: user}) do
|
||||
bio_tree = Floki.parse_fragment!(user.bio)
|
||||
profile_tree =
|
||||
user.bio
|
||||
|> append_fields_tag(user.fields)
|
||||
|> Floki.parse_fragment!()
|
||||
|
||||
(Floki.attribute(bio_tree, "link[rel~=me]", "href") ++
|
||||
Floki.attribute(bio_tree, "a[rel~=me]", "href"))
|
||||
(Floki.attribute(profile_tree, "link[rel~=me]", "href") ++
|
||||
Floki.attribute(profile_tree, "a[rel~=me]", "href"))
|
||||
|> Enum.map(fn link ->
|
||||
{:link, [rel: "me", href: link], []}
|
||||
end)
|
||||
end
|
||||
|
||||
defp append_fields_tag(bio, fields) do
|
||||
fields
|
||||
|> Enum.reduce(bio, fn %{"value" => v}, res -> res <> v end)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,12 +20,12 @@ def build_tags(%{activity_id: id, object: object, user: user}) do
|
|||
|
||||
[
|
||||
title_tag(user),
|
||||
{:meta, [property: "twitter:description", content: scrubbed_content], []}
|
||||
{:meta, [name: "twitter:description", content: scrubbed_content], []}
|
||||
] ++
|
||||
if attachments == [] or Metadata.activity_nsfw?(object) do
|
||||
[
|
||||
image_tag(user),
|
||||
{:meta, [property: "twitter:card", content: "summary"], []}
|
||||
{:meta, [name: "twitter:card", content: "summary"], []}
|
||||
]
|
||||
else
|
||||
attachments
|
||||
|
@ -37,20 +37,19 @@ def build_tags(%{user: user}) do
|
|||
with truncated_bio = Utils.scrub_html_and_truncate(user.bio) do
|
||||
[
|
||||
title_tag(user),
|
||||
{:meta, [property: "twitter:description", content: truncated_bio], []},
|
||||
{:meta, [name: "twitter:description", content: truncated_bio], []},
|
||||
image_tag(user),
|
||||
{:meta, [property: "twitter:card", content: "summary"], []}
|
||||
{:meta, [name: "twitter:card", content: "summary"], []}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
defp title_tag(user) do
|
||||
{:meta, [property: "twitter:title", content: Utils.user_name_string(user)], []}
|
||||
{:meta, [name: "twitter:title", content: Utils.user_name_string(user)], []}
|
||||
end
|
||||
|
||||
def image_tag(user) do
|
||||
{:meta, [property: "twitter:image", content: MediaProxy.preview_url(User.avatar_url(user))],
|
||||
[]}
|
||||
{:meta, [name: "twitter:image", content: MediaProxy.preview_url(User.avatar_url(user))], []}
|
||||
end
|
||||
|
||||
defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
||||
|
@ -60,10 +59,10 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
|||
case Utils.fetch_media_type(@media_types, url["mediaType"]) do
|
||||
"audio" ->
|
||||
[
|
||||
{:meta, [property: "twitter:card", content: "player"], []},
|
||||
{:meta, [property: "twitter:player:width", content: "480"], []},
|
||||
{:meta, [property: "twitter:player:height", content: "80"], []},
|
||||
{:meta, [property: "twitter:player", content: player_url(id)], []}
|
||||
{:meta, [name: "twitter:card", content: "player"], []},
|
||||
{:meta, [name: "twitter:player:width", content: "480"], []},
|
||||
{:meta, [name: "twitter:player:height", content: "80"], []},
|
||||
{:meta, [name: "twitter:player", content: player_url(id)], []}
|
||||
| acc
|
||||
]
|
||||
|
||||
|
@ -74,10 +73,10 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
|||
# workaround.
|
||||
"image" ->
|
||||
[
|
||||
{:meta, [property: "twitter:card", content: "summary_large_image"], []},
|
||||
{:meta, [name: "twitter:card", content: "summary_large_image"], []},
|
||||
{:meta,
|
||||
[
|
||||
property: "twitter:player",
|
||||
name: "twitter:player",
|
||||
content: MediaProxy.url(url["href"])
|
||||
], []}
|
||||
| acc
|
||||
|
@ -90,14 +89,14 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
|||
width = url["width"] || 480
|
||||
|
||||
[
|
||||
{:meta, [property: "twitter:card", content: "player"], []},
|
||||
{:meta, [property: "twitter:player", content: player_url(id)], []},
|
||||
{:meta, [property: "twitter:player:width", content: "#{width}"], []},
|
||||
{:meta, [property: "twitter:player:height", content: "#{height}"], []},
|
||||
{:meta, [property: "twitter:player:stream", content: MediaProxy.url(url["href"])],
|
||||
{:meta, [name: "twitter:card", content: "player"], []},
|
||||
{:meta, [name: "twitter:player", content: player_url(id)], []},
|
||||
{:meta, [name: "twitter:player:width", content: "#{width}"], []},
|
||||
{:meta, [name: "twitter:player:height", content: "#{height}"], []},
|
||||
{:meta, [name: "twitter:player:stream", content: MediaProxy.url(url["href"])],
|
||||
[]},
|
||||
{:meta,
|
||||
[property: "twitter:player:stream:content_type", content: url["mediaType"]], []}
|
||||
{:meta, [name: "twitter:player:stream:content_type", content: url["mediaType"]],
|
||||
[]}
|
||||
| acc
|
||||
]
|
||||
|
||||
|
@ -123,8 +122,8 @@ defp maybe_add_dimensions(metadata, url) do
|
|||
!is_nil(url["height"]) && !is_nil(url["width"]) ->
|
||||
metadata ++
|
||||
[
|
||||
{:meta, [property: "twitter:player:width", content: "#{url["width"]}"], []},
|
||||
{:meta, [property: "twitter:player:height", content: "#{url["height"]}"], []}
|
||||
{:meta, [name: "twitter:player:width", content: "#{url["width"]}"], []},
|
||||
{:meta, [name: "twitter:player:height", content: "#{url["height"]}"], []}
|
||||
]
|
||||
|
||||
true ->
|
||||
|
|
|
@ -71,7 +71,15 @@ def get_nodeinfo("2.0") do
|
|||
restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
|
||||
skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
|
||||
privilegedStaff: Config.get([:instance, :privileged_staff]),
|
||||
localBubbleInstances: Config.get([:instance, :local_bubble], [])
|
||||
localBubbleInstances: Config.get([:instance, :local_bubble], []),
|
||||
publicTimelineVisibility: %{
|
||||
federated:
|
||||
!Config.restrict_unauthenticated_access?(:timelines, :federated) &&
|
||||
Config.get([:instance, :federated_timeline_available], true),
|
||||
local: !Config.restrict_unauthenticated_access?(:timelines, :local),
|
||||
bubble: !Config.restrict_unauthenticated_access?(:timelines, :bubble)
|
||||
},
|
||||
federatedTimelineAvailable: Config.get([:instance, :federated_timeline_available], true)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Stats
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.Federator.Publisher
|
||||
alias Pleroma.Web.MastodonAPI.InstanceView
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.Nodeinfo.Nodeinfo
|
||||
|
||||
def schemas(conn, _params) do
|
||||
response = %{
|
||||
|
@ -29,101 +25,15 @@ def schemas(conn, _params) do
|
|||
json(conn, response)
|
||||
end
|
||||
|
||||
# returns a nodeinfo 2.0 map, since 2.1 just adds a repository field
|
||||
# under software.
|
||||
def raw_nodeinfo do
|
||||
stats = Stats.get_stats()
|
||||
|
||||
staff_accounts =
|
||||
User.all_superusers()
|
||||
|> Enum.map(fn u -> u.ap_id end)
|
||||
|> Enum.filter(fn u -> not Enum.member?(Config.get([:instance, :staff_transparency]), u) end)
|
||||
|
||||
features = InstanceView.features()
|
||||
federation = InstanceView.federation()
|
||||
|
||||
%{
|
||||
version: "2.0",
|
||||
software: %{
|
||||
name: Pleroma.Application.name() |> String.downcase(),
|
||||
version: Pleroma.Application.version()
|
||||
},
|
||||
protocols: Publisher.gather_nodeinfo_protocol_names(),
|
||||
services: %{
|
||||
inbound: [],
|
||||
outbound: []
|
||||
},
|
||||
openRegistrations: Config.get([:instance, :registrations_open]),
|
||||
usage: %{
|
||||
users: %{
|
||||
total: Map.get(stats, :user_count, 0)
|
||||
},
|
||||
localPosts: Map.get(stats, :status_count, 0)
|
||||
},
|
||||
metadata: %{
|
||||
nodeName: Config.get([:instance, :name]),
|
||||
nodeDescription: Config.get([:instance, :description]),
|
||||
private: !Config.get([:instance, :public], true),
|
||||
suggestions: %{
|
||||
enabled: false
|
||||
},
|
||||
staffAccounts: staff_accounts,
|
||||
federation: federation,
|
||||
pollLimits: Config.get([:instance, :poll_limits]),
|
||||
postFormats: Config.get([:instance, :allowed_post_formats]),
|
||||
uploadLimits: %{
|
||||
general: Config.get([:instance, :upload_limit]),
|
||||
avatar: Config.get([:instance, :avatar_upload_limit]),
|
||||
banner: Config.get([:instance, :banner_upload_limit]),
|
||||
background: Config.get([:instance, :background_upload_limit])
|
||||
},
|
||||
fieldsLimits: %{
|
||||
maxFields: Config.get([:instance, :max_account_fields]),
|
||||
maxRemoteFields: Config.get([:instance, :max_remote_account_fields]),
|
||||
nameLength: Config.get([:instance, :account_field_name_length]),
|
||||
valueLength: Config.get([:instance, :account_field_value_length])
|
||||
},
|
||||
accountActivationRequired: Config.get([:instance, :account_activation_required], false),
|
||||
invitesEnabled: Config.get([:instance, :invites_enabled], false),
|
||||
mailerEnabled: Config.get([Pleroma.Emails.Mailer, :enabled], false),
|
||||
features: features,
|
||||
restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
|
||||
skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
|
||||
localBubbleInstances: Config.get([:instance, :local_bubble], [])
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
|
||||
# and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
|
||||
def nodeinfo(conn, %{"version" => "2.0"}) do
|
||||
def nodeinfo(conn, %{"version" => version}) when version in ["2.0", "2.1"] do
|
||||
conn
|
||||
|> put_resp_header(
|
||||
"content-type",
|
||||
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
|
||||
)
|
||||
|> json(raw_nodeinfo())
|
||||
end
|
||||
|
||||
def nodeinfo(conn, %{"version" => "2.1"}) do
|
||||
raw_response = raw_nodeinfo()
|
||||
|
||||
updated_software =
|
||||
raw_response
|
||||
|> Map.get(:software)
|
||||
|> Map.put(:repository, Pleroma.Application.repository())
|
||||
|
||||
response =
|
||||
raw_response
|
||||
|> Map.put(:software, updated_software)
|
||||
|> Map.put(:version, "2.1")
|
||||
|
||||
conn
|
||||
|> put_resp_header(
|
||||
"content-type",
|
||||
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8"
|
||||
)
|
||||
|> json(response)
|
||||
|> json(Nodeinfo.get_nodeinfo(version))
|
||||
end
|
||||
|
||||
def nodeinfo(conn, _) do
|
||||
|
|
|
@ -71,6 +71,8 @@ def validate(scopes, app_scopes, _user) do
|
|||
"""
|
||||
def filter_admin_scopes(scopes, %Pleroma.User{is_admin: true}), do: scopes
|
||||
|
||||
def filter_admin_scopes(scopes, %Pleroma.User{is_moderator: true}), do: scopes
|
||||
|
||||
def filter_admin_scopes(scopes, _user) do
|
||||
drop_scopes = OAuthScopesPlug.filter_descendants(scopes, ["admin"])
|
||||
Enum.reject(scopes, fn scope -> Enum.member?(drop_scopes, scope) end)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue