forked from AkkomaGang/akkoma
Compare commits
261 commits
credo-on-p
...
develop
Author | SHA1 | Date | |
---|---|---|---|
8c956bc671 | |||
5144d6f4ba | |||
3e4a279a1b | |||
fc87baf1cf | |||
|
767e1272b3 | ||
|
07b478dc49 | ||
67cae52b08 | |||
4db42f5ab5 | |||
145191ef26 | |||
6674b33d75 | |||
2dfce40117 | |||
5e3ca133f2 | |||
|
3a13f91fff | ||
5ce38591e5 | |||
2482d96782 | |||
f68b047bf7 | |||
48a0145736 | |||
d956dc2f09 | |||
fb8081e1a3 | |||
|
1b560d547a | ||
39b3d92cd8 | |||
|
70b0f93865 | ||
a388d2503e | |||
7fb9960ccd | |||
9d83a1e23f | |||
82ca7a6470 | |||
9e9cf58fdf | |||
2fc26609f6 | |||
8c208f751d | |||
037f881187 | |||
ab34680554 | |||
d310f99d6a | |||
4e969758e5 | |||
f72d773cc3 | |||
3437e11cf7 | |||
6225f24f5f | |||
|
f49e9e6d4c | ||
|
c7fb78cc32 | ||
ddf4d8026d | |||
3fef9d1b67 | |||
9c4203632d | |||
f1e66b39c7 | |||
145c73076d | |||
d8bed0ff63 | |||
b86b3a9e29 | |||
d6bed599c8 | |||
963d29ad8c | |||
f2b4e7f86b | |||
522221f7fb | |||
|
1fa3c0b485 | ||
|
d2b0d86471 | ||
f12d3cce39 | |||
8c86a06ed1 | |||
ba59fdcd54 | |||
4c9c959bb3 | |||
9e8e7cc13e | |||
a079ec3a3c | |||
1b2c24a19e | |||
62e22eeff2 | |||
ca1accc1cf | |||
|
d8d9edee98 | ||
2a8c1f4192 | |||
66d162bb9e | |||
d85d1e128a | |||
ef8f13a158 | |||
|
0151ca1d52 | ||
|
3f340cbc43 | ||
1d94f2a424 | |||
de64c6c54a | |||
4bbe9c8f5c | |||
281c4636fa | |||
f94e8a3713 | |||
dd44387f1a | |||
63870c2c17 | |||
3c30666d3f | |||
f22bba6359 | |||
4a5164be93 | |||
fe7045632b | |||
86a5cf3c82 | |||
2c9e02429a | |||
9464d50562 | |||
bd040fe96a | |||
ba635e97c8 | |||
377d1483b6 | |||
c5769bbf6d | |||
643b8c5f15 | |||
3d964a9970 | |||
c2ae3273d5 | |||
3f76de76da | |||
0c77be9308 | |||
|
6c396fcab4 | ||
e17d8f744e | |||
58f75ac062 | |||
70803d7966 | |||
800fe40407 | |||
5ca22c2459 | |||
19eb826424 | |||
9977588612 | |||
e124a109c1 | |||
592340a49d | |||
f1e836b183 | |||
08dfce98be | |||
b2112302ce | |||
964a855319 | |||
8a4437d2be | |||
87d5e5b06a | |||
c8add9d1dc | |||
d43c8080d0 | |||
df03d64dc5 | |||
b88e6560e0 | |||
1ab0b3a0e2 | |||
cb28b8f0fe | |||
531a550184 | |||
45a11aa20f | |||
f56e3098ef | |||
fd1dc87eb4 | |||
7bd80ccf07 | |||
f7211459ef | |||
fc842aa7c7 | |||
08d49fba7d | |||
|
328b4d93b7 | ||
|
c1c962e1a8 | ||
|
57eef6d764 | ||
|
a7ec6e039c | ||
|
3b634dcbe7 | ||
|
8b2adc4fb4 | ||
9f34294332 | |||
d3089ec399 | |||
f22c6e4108 | |||
3f03f1df9c | |||
9dc3f8fcdc | |||
3744789710 | |||
ea30d22dfe | |||
|
b4952a81fe | ||
292f0444d0 | |||
a18b5755b4 | |||
da4c87b226 | |||
439ec49137 | |||
ef279ac53f | |||
b4e37b03d8 | |||
f92484fd01 | |||
6e07ed6ea9 | |||
d2b57a7f9e | |||
439e915531 | |||
|
b71db2f82d | ||
aeb68a0ad1 | |||
|
7f8932304f | ||
56c37dc6b3 | |||
3405623d46 | |||
702979bca3 | |||
|
7e3ede02f7 | ||
d601ddeb91 | |||
676cc0d0d7 | |||
|
e74e1efe1c | ||
|
ce6f652a9a | ||
|
377527ea03 | ||
153539a246 | |||
d394ab0a8a | |||
90088cce11 | |||
63ce25f32c | |||
|
20cd8a0fc4 | ||
0fb2042f2c | |||
0c8da6466e | |||
975bc6d7e8 | |||
2fc5fb7f5a | |||
f3c118ca23 | |||
0d342a35e3 | |||
7ca9ce9d67 | |||
65e8e8fb6d | |||
ff5793198f | |||
78c44f31ca | |||
260c87006e | |||
ae54c06bb4 | |||
22068f0853 | |||
7eebaa7a18 | |||
cc63a89b5d | |||
f86bf16430 | |||
6965a2f163 | |||
7695010268 | |||
357f80a714 | |||
a8cd859ef9 | |||
0d56adc16b | |||
eb55472450 | |||
13d943667e | |||
f2b925f32c | |||
b98fe4476c | |||
336d06b2a8 | |||
eb1b9c4155 | |||
fcce355112 | |||
ef1c68a8e9 | |||
d427c23e56 | |||
769b5969a8 | |||
57e51fe62c | |||
6a333ade7f | |||
798d13d6e9 | |||
6e646c4cbc | |||
e03206a9a0 | |||
6be3383a09 | |||
c4b46ca460 | |||
745e15468e | |||
b8f280b4b5 | |||
c8f2c4b638 | |||
bf7ff6a337 | |||
|
1d884fd914 | ||
5d4c291d52 | |||
bca1c43dcb | |||
bdc676e433 | |||
063cc61fc1 | |||
084bb3b371 | |||
5624366056 | |||
9be6caf125 | |||
a5e98083f2 | |||
1121deb078 | |||
5a405bdadf | |||
d1bf8aa9ed | |||
e66bcb64a4 | |||
11ec4e1b8f | |||
e392662d76 | |||
5a6fa6717b | |||
03a00d005a | |||
6610a1d5fb | |||
1fd5c4b221 | |||
64ccdadad3 | |||
af7c3fab98 | |||
|
4a78c431cf | ||
|
e17c71a389 | ||
07ccfafd92 | |||
c092fc9fd6 | |||
233c4bb3ba | |||
28ab09d377 | |||
3d546409b2 | |||
52d8183787 | |||
dcac8adb3d | |||
126f1ca69c | |||
afab5585a0 | |||
7b76fdeed3 | |||
b91e671c0d | |||
e0a758e0b2 | |||
eb9ef59d50 | |||
584f99b69d | |||
372eea4e7c | |||
1f5bc4d68a | |||
18bf82d747 | |||
20e3cb2b25 | |||
426f4271c2 | |||
9a320ba814 | |||
ca70d42541 | |||
48d302a60f | |||
6d8e4d5e05 | |||
d1a0d93bf7 | |||
c2054f82ab | |||
b8be8192fb | |||
e2320f870e | |||
|
29584197bb | ||
|
63be819661 | ||
|
0995fa1410 | ||
|
8f58eb4a18 | ||
|
f8d3383179 | ||
|
a06bb694c1 | ||
|
1e9c2cd8ef | ||
|
33243c56e5 |
237 changed files with 6936 additions and 3122 deletions
9
.gitattributes
vendored
9
.gitattributes
vendored
|
@ -1,11 +1,4 @@
|
|||
*.ex diff=elixir
|
||||
*.exs diff=elixir
|
||||
|
||||
# Most of js/css files included in the repo are minified bundles,
|
||||
# and we don't want to search/diff those as text files.
|
||||
*.js binary
|
||||
*.js.map binary
|
||||
*.css binary
|
||||
|
||||
priv/static/instance/static.css diff=css
|
||||
priv/static/static-fe/static-fe.css diff=css
|
||||
*.css diff=css
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -73,6 +73,8 @@ pleroma.iml
|
|||
|
||||
# Generated documentation
|
||||
docs/site
|
||||
docs/venv
|
||||
|
||||
# docker stuff
|
||||
docker-db
|
||||
*.iml
|
||||
|
|
|
@ -41,7 +41,7 @@ variables:
|
|||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13
|
||||
image: postgres:15
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
@ -74,14 +74,6 @@ pipeline:
|
|||
- mix deps.get
|
||||
- mix compile
|
||||
|
||||
credo:
|
||||
<<: *on-pr-open
|
||||
image: akkoma/ci-base:1.14
|
||||
commands:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix credo || true # we don't want to error here
|
||||
|
||||
test:
|
||||
image: akkoma/ci-base:1.14
|
||||
<<: *on-pr-open
|
||||
|
@ -103,7 +95,7 @@ pipeline:
|
|||
|
||||
# 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
|
||||
|
@ -130,7 +122,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
|
||||
|
@ -159,8 +151,8 @@ pipeline:
|
|||
|
||||
# Canonical amd64-musl
|
||||
musl:
|
||||
image: hexpm/elixir:1.14.2-erlang-25.1.2-alpine-3.16.2
|
||||
<<: *on-stable
|
||||
image: hexpm/elixir:1.14.3-erlang-25.2.2-alpine-3.15.6
|
||||
<<: *on-release
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
commands:
|
||||
|
@ -175,7 +167,7 @@ pipeline:
|
|||
|
||||
release-musl:
|
||||
image: akkoma/releaser
|
||||
<<: *on-stable
|
||||
<<: *on-release
|
||||
secrets: *scw-secrets
|
||||
commands:
|
||||
- export SOURCE=akkoma-amd64-musl.zip
|
||||
|
|
86
CHANGELOG.md
86
CHANGELOG.md
|
@ -6,15 +6,101 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
## Unreleased
|
||||
|
||||
- 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
|
||||
|
||||
## 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
|
||||
- Translation of statuses via ArgosTranslate
|
||||
- Argon2 password hashing
|
||||
- Ability to "verify" links in profile fields via rel=me
|
||||
- Mix tasks to dump/load config to/from json for bulk editing
|
||||
- Followed hashtag list at /api/v1/followed\_tags, API parity with mastodon
|
||||
- Ability to set posting language in the post form, API parity with mastodon
|
||||
- Ability to match domains in MRF by a trailing wildcard
|
||||
- Currently supported formats:
|
||||
- `example.com` (implicitly matches `*.example.com`)
|
||||
- `*.example.com`
|
||||
- `example.*` (implicitly matches `*.example.*`)
|
||||
|
||||
### Removed
|
||||
- Non-finch HTTP adapters
|
||||
- Legacy redirect from /api/pleroma/admin to /api/v1/pleroma/admin
|
||||
- Legacy redirects from /api/pleroma to /api/v1/pleroma
|
||||
- :crypt dependency
|
||||
|
||||
### Changed
|
||||
- Return HTTP error 413 when uploading an avatar or banner that's above the configured upload limit instead of a 500.
|
||||
- Non-admin users now cannot register `admin` scope tokens (not security-critical, they didn't work before, but you _could_ create them)
|
||||
- Admin scopes will be dropped on create
|
||||
- Rich media will now backoff for 20 minutes after a failure
|
||||
- Quote posts are now considered as part of the same thread as the post they are quoting
|
||||
- Extend the mix task `prune_objects` with options to keep more relevant posts
|
||||
- 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.
|
||||
- `internal.fetch` and `relay` actors are now represented with the actor type `Application`
|
||||
|
||||
### Fixed
|
||||
- /api/v1/accounts/lookup will now respect restrict\_unauthenticated
|
||||
- Unknown atoms in the config DB will no longer crash akkoma on boot
|
||||
|
||||
### Upgrade notes
|
||||
- Ensure `config :tesla, :adapter` is either unset, or set to `{Tesla.Adapter.Finch, name: MyFinch}` in your .exs config
|
||||
- Pleroma-FE will need to be updated to handle the new /api/v1/pleroma endpoints for custom emoji
|
||||
|
||||
## 2022.12
|
||||
|
||||
|
|
|
@ -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.3-alpine-3.17.2
|
||||
|
||||
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"
|
||||
|
@ -179,6 +178,7 @@
|
|||
receive_timeout: :timer.seconds(15),
|
||||
proxy_url: nil,
|
||||
user_agent: :default,
|
||||
pool_size: 50,
|
||||
adapter: []
|
||||
|
||||
config :pleroma, :instance,
|
||||
|
@ -259,7 +259,9 @@
|
|||
profile_directory: true,
|
||||
privileged_staff: false,
|
||||
local_bubble: [],
|
||||
max_frontend_settings_json_chars: 100_000
|
||||
max_frontend_settings_json_chars: 100_000,
|
||||
export_prometheus_metrics: true,
|
||||
federated_timeline_available: true
|
||||
|
||||
config :pleroma, :welcome,
|
||||
direct_message: [
|
||||
|
@ -352,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,
|
||||
|
@ -416,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: [],
|
||||
|
@ -424,7 +428,7 @@
|
|||
Pleroma.Web.RichMedia.Parsers.TwitterCard,
|
||||
Pleroma.Web.RichMedia.Parsers.OEmbed
|
||||
],
|
||||
failure_backoff: 60_000,
|
||||
failure_backoff: :timer.minutes(20),
|
||||
ttl_setters: [Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl]
|
||||
|
||||
config :pleroma, :media_proxy,
|
||||
|
@ -439,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,
|
||||
|
@ -743,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",
|
||||
|
@ -781,14 +789,6 @@
|
|||
"https://akkoma-updates.s3-website.fr-par.scw.cloud/frontend/${ref}/admin-fe.zip",
|
||||
"ref" => "stable"
|
||||
},
|
||||
"soapbox-fe" => %{
|
||||
"name" => "soapbox-fe",
|
||||
"git" => "https://gitlab.com/soapbox-pub/soapbox",
|
||||
"build_url" =>
|
||||
"https://gitlab.com/soapbox-pub/soapbox/-/jobs/artifacts/${ref}/download?job=build-production",
|
||||
"ref" => "v2.0.0",
|
||||
"build_dir" => "static"
|
||||
},
|
||||
# For developers - enables a swagger frontend to view the openapi spec
|
||||
"swagger-ui" => %{
|
||||
"name" => "swagger-ui",
|
||||
|
@ -816,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?}
|
||||
|
||||
|
@ -888,6 +888,11 @@
|
|||
url: "http://127.0.0.1:5000",
|
||||
api_key: nil
|
||||
|
||||
config :pleroma, :argos_translate,
|
||||
command_argos_translate: "argos-translate",
|
||||
command_argospm: "argospm",
|
||||
strip_html: true
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{Mix.env()}.exs"
|
||||
|
|
|
@ -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,
|
||||
|
@ -964,6 +964,17 @@
|
|||
type: {:list, :string},
|
||||
description:
|
||||
"List of instances that make up your local bubble (closely-related instances). Used to populate the 'bubble' timeline (domain only)."
|
||||
},
|
||||
%{
|
||||
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."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1547,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"]
|
||||
}
|
||||
]
|
||||
|
@ -2656,6 +2681,12 @@
|
|||
"What user agent to use. Must be a string or an atom `:default`. Default value is `:default`.",
|
||||
suggestions: ["Pleroma", :default]
|
||||
},
|
||||
%{
|
||||
key: :pool_size,
|
||||
type: :integer,
|
||||
description: "Number of concurrent outbound HTTP requests to allow. Default 50.",
|
||||
suggestions: [50]
|
||||
},
|
||||
%{
|
||||
key: :adapter,
|
||||
type: :keyword,
|
||||
|
@ -2982,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."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3137,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."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3431,5 +3473,32 @@
|
|||
suggestion: [nil]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: :argos_translate,
|
||||
type: :group,
|
||||
description: "ArgosTranslate Settings.",
|
||||
children: [
|
||||
%{
|
||||
key: :command_argos_translate,
|
||||
type: :string,
|
||||
description:
|
||||
"command for `argos-translate`. Can be the command if it's in your PATH, or the full path to the file.",
|
||||
suggestion: ["argos-translate"]
|
||||
},
|
||||
%{
|
||||
key: :command_argospm,
|
||||
type: :string,
|
||||
description:
|
||||
"command for `argospm`. Can be the command if it's in your PATH, or the full path to the file.",
|
||||
suggestion: ["argospm"]
|
||||
},
|
||||
%{
|
||||
key: :strip_html,
|
||||
type: :boolean,
|
||||
description: "Strip html from the post before translating it."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -155,3 +155,51 @@ This forcibly removes all saved values in the database.
|
|||
```sh
|
||||
mix pleroma.config [--force] reset
|
||||
```
|
||||
|
||||
## Dumping specific configuration values to JSON
|
||||
|
||||
If you want to bulk-modify configuration values (for example, for MRF modifications),
|
||||
it may be easier to dump the values to JSON and then modify them in a text editor.
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl config dump_to_file group key path
|
||||
# For example, to dump the MRF simple configuration:
|
||||
./bin/pleroma_ctl config dump_to_file pleroma mrf_simple /tmp/mrf_simple.json
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.config dump_to_file group key path
|
||||
# For example, to dump the MRF simple configuration:
|
||||
mix pleroma.config dump_to_file pleroma mrf_simple /tmp/mrf_simple.json
|
||||
```
|
||||
|
||||
## Loading specific configuration values from JSON
|
||||
|
||||
**Note:** This will overwrite any existing value in the database, and can
|
||||
cause crashes if you do not have exactly the correct formatting.
|
||||
|
||||
Once you have modified the JSON file, you can load it back into the database.
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl config load_from_file path
|
||||
# For example, to load the MRF simple configuration:
|
||||
./bin/pleroma_ctl config load_from_file /tmp/mrf_simple.json
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.config load_from_file path
|
||||
# For example, to load the MRF simple configuration:
|
||||
mix pleroma.config load_from_file /tmp/mrf_simple.json
|
||||
```
|
||||
|
||||
**NOTE** an instance reboot is needed for many changes to take effect,
|
||||
you may want to visit `/api/v1/pleroma/admin/restart` on your instance
|
||||
to soft-restart the instance.
|
||||
|
|
|
@ -21,16 +21,18 @@ 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
|
||||
|
||||
## Prune old remote posts from the database
|
||||
|
||||
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, they will be refetched from source when accessed.
|
||||
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"
|
||||
|
||||
|
@ -45,7 +47,11 @@ This will prune remote posts older than 90 days (configurable with [`config :ple
|
|||
```
|
||||
|
||||
### Options
|
||||
- `--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
|
||||
|
||||
|
@ -93,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.**
|
||||
|
@ -178,4 +187,4 @@ to the current day.
|
|||
|
||||
```sh
|
||||
mix pleroma.database prune_task
|
||||
```
|
||||
```
|
||||
|
|
|
@ -21,24 +21,23 @@ Currently, known `<frontend>` values are:
|
|||
- [admin-fe](https://akkoma.dev/AkkomaGang/admin-fe)
|
||||
- [mastodon-fe](https://akkoma.dev/AkkomaGang/masto-fe)
|
||||
- [pleroma-fe](https://akkoma.dev/AkkomaGang/pleroma-fe)
|
||||
- [soapbox-fe](https://gitlab.com/soapbox-pub/soapbox-fe)
|
||||
|
||||
You can still install frontends that are not configured, see below.
|
||||
|
||||
## Example installations for a known frontend
|
||||
## Example installations for a known frontend (Stable-Version)
|
||||
|
||||
For a frontend configured under the `available` key, it's enough to install it by name.
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl frontend install pleroma-fe
|
||||
./bin/pleroma_ctl frontend install pleroma-fe --ref stable
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.frontend install pleroma-fe
|
||||
mix pleroma.frontend install pleroma-fe --ref stable
|
||||
```
|
||||
|
||||
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`).
|
||||
|
|
|
@ -11,11 +11,11 @@ If you want to generate a restrictive `robots.txt`, you can run the following mi
|
|||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl robots_txt disallow_all
|
||||
./bin/pleroma_ctl robotstxt disallow_all
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.robots_txt disallow_all
|
||||
mix pleroma.robotstxt disallow_all
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
33
docs/docs/administration/monitoring.md
Normal file
33
docs/docs/administration/monitoring.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Monitoring Akkoma
|
||||
|
||||
If you run akkoma, you may be inclined to collect metrics to ensure your instance is running smoothly,
|
||||
and that there's nothing quietly failing in the background.
|
||||
|
||||
To facilitate this, akkoma exposes prometheus metrics to be scraped.
|
||||
|
||||
## Prometheus
|
||||
|
||||
See: [export\_prometheus\_metrics](../../configuration/cheatsheet#instance)
|
||||
|
||||
To scrape prometheus metrics, we need an oauth2 token with the `admin:metrics` scope.
|
||||
|
||||
consider using [constanze](https://akkoma.dev/AkkomaGang/constanze) to make this easier -
|
||||
|
||||
```bash
|
||||
constanze token --client-app --scopes "admin:metrics" --client-name "Prometheus"
|
||||
```
|
||||
|
||||
or see `scripts/create_metrics_app.sh` in the source tree for the process to get this token.
|
||||
|
||||
Once you have your token of the form `Bearer $ACCESS_TOKEN`, you can use that in your prometheus config:
|
||||
|
||||
```yaml
|
||||
- job_name: akkoma
|
||||
scheme: https
|
||||
authorization:
|
||||
credentials: $ACCESS_TOKEN # this should have the bearer prefix removed
|
||||
metrics_path: /api/v1/akkoma/metrics
|
||||
static_configs:
|
||||
- targets:
|
||||
- example.com
|
||||
```
|
|
@ -1,6 +1,6 @@
|
|||
# Updating your instance
|
||||
|
||||
You should **always check the [release notes/changelog](https://akkoma.dev/AkkomaGang/akkoma/src/branch/develop/CHANGELOG.md)** in case there are config deprecations, special update steps, etc.
|
||||
You should **always check the [release notes/changelog](https://akkoma.dev/AkkomaGang/akkoma/src/branch/stable/CHANGELOG.md)** in case there are config deprecations, special update steps, etc.
|
||||
|
||||
Besides that, doing the following is generally enough:
|
||||
## Switch to the akkoma user
|
||||
|
@ -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,
|
||||
|
@ -41,8 +41,10 @@ you _may_ need to specify `--flavour`, in the same way as
|
|||
Run as the `akkoma` user:
|
||||
|
||||
```sh
|
||||
# Pull in new changes
|
||||
git pull
|
||||
# fetch changes
|
||||
git fetch
|
||||
# check out the latest tag
|
||||
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
|
||||
|
||||
# Run with production configuration
|
||||
export MIX_ENV=prod
|
||||
|
@ -57,9 +59,9 @@ sudo systemctl stop akkoma
|
|||
# Run database migrations
|
||||
mix ecto.migrate
|
||||
|
||||
# Update frontend(s). 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 Pleroma-FE frontend to latest stable. For other Frontends see Frontend Configuration doc for more information.
|
||||
mix pleroma.frontend install pleroma-fe --ref stable
|
||||
```
|
||||
|
|
|
@ -25,7 +25,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 +45,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
|
||||
|
|
|
@ -62,6 +62,7 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `password_reset_token_validity`: The time after which reset tokens aren't accepted anymore, in seconds (default: one day).
|
||||
* `local_bubble`: Array of domains representing instances closely related to yours. Used to populate the `bubble` timeline. e.g `["example.com"]`, (default: `[]`)
|
||||
* `languages`: List of Language Codes used by the instance. This is used to try and set a default language from the frontend. It will try and find the first match between the languages set here and the user's browser languages. It will default to the first language in this setting if there is no match.. (default `["en"]`)
|
||||
* `export_prometheus_metrics`: Enable prometheus metrics, served at `/api/v1/akkoma/metrics`, requiring the `admin:metrics` oauth scope.
|
||||
|
||||
## :database
|
||||
* `improved_hashtag_timeline`: Setting to force toggle / force disable improved hashtags timeline. `:enabled` forces hashtags to be fetched from `hashtags` table for hashtags timeline. `:disabled` forces object-embedded hashtags to be used (slower). Keep it `:auto` for automatic behaviour (it is auto-set to `:enabled` [unless overridden] when HashtagsTableMigrator completes).
|
||||
|
@ -561,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`.
|
||||
|
@ -615,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"}]`.
|
||||
|
@ -1118,7 +1124,7 @@ Each job has these settings:
|
|||
### Translation Settings
|
||||
|
||||
Settings to automatically translate statuses for end users. Currently supported
|
||||
translation services are DeepL and LibreTranslate.
|
||||
translation services are DeepL and LibreTranslate. The supported command line tool is [Argos Translate](https://github.com/argosopentech/argos-translate).
|
||||
|
||||
Translations are available at `/api/v1/statuses/:id/translations/:language`, where
|
||||
`language` is the target language code (e.g `en`)
|
||||
|
@ -1127,7 +1133,7 @@ Translations are available at `/api/v1/statuses/:id/translations/:language`, whe
|
|||
|
||||
- `:enabled` - enables translation
|
||||
- `:module` - Sets module to be used
|
||||
- Either `Pleroma.Akkoma.Translators.DeepL` or `Pleroma.Akkoma.Translators.LibreTranslate`
|
||||
- Either `Pleroma.Akkoma.Translators.DeepL`, `Pleroma.Akkoma.Translators.LibreTranslate`, or `Pleroma.Akkoma.Translators.ArgosTranslate`
|
||||
|
||||
### `:deepl`
|
||||
|
||||
|
@ -1139,3 +1145,9 @@ Translations are available at `/api/v1/statuses/:id/translations/:language`, whe
|
|||
|
||||
- `:url` - URL of LibreTranslate instance
|
||||
- `:api_key` - API key for LibreTranslate
|
||||
|
||||
### `:argos_translate`
|
||||
|
||||
- `:command_argos_translate` - command for `argos-translate`. Can be the command if it's in your PATH, or the full path to the file (default: `argos-translate`).
|
||||
- `:command_argospm` - command for `argospm`. Can be the command if it's in your PATH, or the full path to the file (default: `argospm`).
|
||||
- `:strip_html` - Strip html from the post before translating it (default: `true`).
|
||||
|
|
|
@ -67,3 +67,29 @@ Priority of tags assigns in emoji.txt and custom.txt:
|
|||
Priority for globs:
|
||||
|
||||
`special group setting in config.exs > default setting in config.exs`
|
||||
|
||||
## Stealing emoji
|
||||
|
||||
Managing your emoji can be hard work, and you just want to have the cool emoji your friends use? As usual, crime comes to the rescue!
|
||||
|
||||
You can use the `Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy` [Message Rewrite Facility](../configuration/cheatsheet.md#mrf) to automatically add to your instance emoji that messages from specific servers contain. Note that this happens on message processing, so the emoji will be added only after your instance receives some interaction containing emoji _after_ configuring this.
|
||||
|
||||
To activate this you have to [configure](../configuration/cheatsheet.md#mrf_steal_emoji) it in your configuration file. For example if you wanted to steal any emoji that is not related to cinnamon and not larger than about 10K from `coolemoji.space` and `spiceenthusiasts.biz`, you would add the following:
|
||||
```elixir
|
||||
config :pleroma, :mrf,
|
||||
policies: [
|
||||
Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy
|
||||
]
|
||||
|
||||
config :pleroma, :mrf_steal_emoji,
|
||||
hosts: [
|
||||
"coolemoji.space",
|
||||
"spiceenthusiasts.biz"
|
||||
],
|
||||
rejected_shortcodes: [
|
||||
".*cinnamon.*"
|
||||
],
|
||||
size_limit: 10000
|
||||
```
|
||||
|
||||
Note that this may not obey emoji licensing restrictions. It's extremely unlikely that anyone will care, but keep this in mind for when Nintendo starts their own instance.
|
||||
|
|
|
@ -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`
|
||||
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -84,12 +84,12 @@ doas adduser -S -s /bin/false -h /opt/akkoma -H -G akkoma akkoma
|
|||
|
||||
**Note**: To execute a single command as the Akkoma system user, use `doas -u akkoma command`. You can also switch to a shell by using `doas -su akkoma`. If you don’t have and want `doas` 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 and make the Akkoma user the owner of the directory:
|
||||
* Git clone the AkkomaBE repository from stable-branch and make the Akkoma user the owner of the directory:
|
||||
|
||||
```shell
|
||||
doas mkdir -p /opt/akkoma
|
||||
doas chown -R akkoma:akkoma /opt/akkoma
|
||||
doas -u akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git /opt/akkoma
|
||||
doas -u akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma
|
||||
```
|
||||
|
||||
* Change to the new directory:
|
||||
|
@ -109,7 +109,7 @@ doas -u akkoma mix deps.get
|
|||
* This may take some time, because parts of akkoma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instance, `dev.secret.exs` for development instances):
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instances):
|
||||
|
||||
```shell
|
||||
doas -u akkoma mv config/{generated_config.exs,prod.secret.exs}
|
||||
|
|
|
@ -75,12 +75,12 @@ 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 and make the Akkoma user the owner of the directory:
|
||||
* Git clone the AkkomaBE repository from stable-branch and make the Akkoma user the owner of the directory:
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /opt/akkoma
|
||||
sudo chown -R akkoma:akkoma /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma
|
||||
```
|
||||
|
||||
* Change to the new directory:
|
||||
|
@ -100,7 +100,7 @@ sudo -Hu akkoma mix deps.get
|
|||
* This may take some time, because parts of akkoma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instance, `dev.secret.exs` for development instances):
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instances):
|
||||
|
||||
```shell
|
||||
sudo -Hu akkoma mv config/{generated_config.exs,prod.secret.exs}
|
||||
|
|
|
@ -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,12 +33,72 @@ 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 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
|
||||
sudo chown -R akkoma:akkoma /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma
|
||||
```
|
||||
|
||||
* Change to the new directory:
|
||||
|
@ -74,7 +118,7 @@ sudo -Hu akkoma mix deps.get
|
|||
* This may take some time, because parts of akkoma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instance, `dev.secret.exs` for development instances):
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instances):
|
||||
|
||||
```shell
|
||||
sudo -Hu akkoma mv config/{generated_config.exs,prod.secret.exs}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -30,11 +30,10 @@ sudo dnf install git gcc g++ make cmake file-devel postgresql-server postgresql-
|
|||
|
||||
* Enable and initialize Postgres:
|
||||
```shell
|
||||
sudo systemctl enable postgresql.service
|
||||
sudo postgresql-setup --initdb --unit postgresql
|
||||
# Allow password auth for postgres
|
||||
sudo sed -E -i 's|(host +all +all +127.0.0.1/32 +)ident|\1md5|' /var/lib/pgsql/data/pg_hba.conf
|
||||
sudo systemctl start postgresql.service
|
||||
sudo systemctl enable --now postgresql.service
|
||||
```
|
||||
|
||||
### Install Elixir and Erlang
|
||||
|
@ -59,7 +58,7 @@ sudo dnf install ffmpeg
|
|||
* Install ImageMagick and ExifTool for image manipulation:
|
||||
|
||||
```shell
|
||||
sudo dnf install Imagemagick perl-Image-ExifTool
|
||||
sudo dnf install ImageMagick perl-Image-ExifTool
|
||||
```
|
||||
|
||||
|
||||
|
@ -74,12 +73,12 @@ 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 and make the Akkoma user the owner of the directory:
|
||||
* Git clone the AkkomaBE repository from stable-branch and make the Akkoma user the owner of the directory:
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /opt/akkoma
|
||||
sudo chown -R akkoma:akkoma /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git /opt/akkoma
|
||||
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma
|
||||
```
|
||||
|
||||
* Change to the new directory:
|
||||
|
@ -99,7 +98,7 @@ sudo -Hu akkoma mix deps.get
|
|||
* This may take some time, because parts of akkoma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instance, `dev.secret.exs` for development instances):
|
||||
* Check the configuration and if all looks right, rename it, so Akkoma will load it (`prod.secret.exs` for productive instances):
|
||||
|
||||
```shell
|
||||
sudo -Hu akkoma mv config/{generated_config.exs,prod.secret.exs}
|
||||
|
|
|
@ -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,6 +1,6 @@
|
|||
# Installing on OpenBSD
|
||||
|
||||
This guide describes the installation and configuration of akkoma (and the required software to run it) on a single OpenBSD 6.6 server.
|
||||
This guide describes the installation and configuration of akkoma (and the required software to run it) on a single OpenBSD 7.2 server.
|
||||
|
||||
For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
|
||||
|
||||
|
@ -12,11 +12,10 @@ For any additional information regarding commands and configuration files mentio
|
|||
To install them, run the following command (with doas or as root):
|
||||
|
||||
```
|
||||
pkg_add elixir gmake git postgresql-server postgresql-contrib cmake ffmpeg ImageMagick erlang-wx-25
|
||||
pkg_add elixir gmake git postgresql-server postgresql-contrib cmake ffmpeg erlang-wx libmagic
|
||||
pkg_add erlang-wx # Choose the latest version as package version when promted
|
||||
```
|
||||
|
||||
(Note that the erlang version may change, it was 25 at the time of writing)
|
||||
|
||||
Akkoma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
|
||||
|
||||
#### Optional software
|
||||
|
@ -29,32 +28,35 @@ Per [`docs/installation/optional/media_graphics_packages.md`](../installation/op
|
|||
To install the above:
|
||||
|
||||
```
|
||||
pkg_add ImageMagick ffmpeg p5-Image-ExifTool
|
||||
pkg_add ffmpeg p5-Image-ExifTool
|
||||
```
|
||||
|
||||
#### Creating the akkoma user
|
||||
Akkoma will be run by a dedicated user, \_akkoma. Before creating it, insert the following lines in login.conf:
|
||||
Akkoma will be run by a dedicated user, `_akkoma`. Before creating it, insert the following lines in `/etc/login.conf`:
|
||||
```
|
||||
akkoma:\
|
||||
:datasize-max=1536M:\
|
||||
:datasize-cur=1536M:\
|
||||
:openfiles-max=4096
|
||||
```
|
||||
This creates a "akkoma" login class and sets higher values than default for datasize and openfiles (see [login.conf(5)](https://man.openbsd.org/login.conf)), this is required to avoid having akkoma crash some time after starting.
|
||||
This creates a `akkoma` login class and sets higher values than default for datasize and openfiles (see [login.conf(5)](https://man.openbsd.org/login.conf)), this is required to avoid having akkoma crash some time after starting.
|
||||
|
||||
Create the \_akkoma user, assign it the akkoma login class and create its home directory (/home/\_akkoma/): `useradd -m -L akkoma _akkoma`
|
||||
Create the `_akkoma` user, assign it the akkoma login class and create its home directory (`/home/_akkoma/`): `useradd -m -L akkoma _akkoma`
|
||||
|
||||
#### Clone akkoma's directory
|
||||
Enter a shell as the \_akkoma user. As root, run `su _akkoma -;cd`. Then clone the repository with `git clone https://akkoma.dev/AkkomaGang/akkoma.git`. Akkoma is now installed in /home/\_akkoma/akkoma/, it will be configured and started at the end of this guide.
|
||||
Enter a shell as the `_akkoma` user. As root, run `su _akkoma -;cd`. Then clone the repository with `git clone https://akkoma.dev/AkkomaGang/akkoma.git`. Akkoma is now installed in `/home/_akkoma/akkoma/`, it will be configured and started at the end of this guide.
|
||||
|
||||
#### PostgreSQL
|
||||
Start a shell as the \_postgresql user (as root run `su _postgresql -` then run the `initdb` command to initialize postgresql:
|
||||
You will need to specify pgdata directory to the default (/var/postgresql/data) with the `-D <path>` and set the user to postgres with the `-U <username>` flag. This can be done as follows:
|
||||
Create `_postgresql`'s user directory (it hasn't been created yet): `mdir var/postgresql/data`. To set it as home
|
||||
directory for user `_postgresql` run `usermod -d /var/postgresql/data _postgresql`.
|
||||
|
||||
Start a shell as the `_postgresql` user (as root run `su _postgresql -` then run the `initdb` command to initialize postgresql.
|
||||
You will need to specify pgdata directory to the default (`/var/postgresql/data`) with the `-D <path>` and set the user to postgres with the `-U <username>` flag. This can be done as follows:
|
||||
|
||||
```
|
||||
initdb -D /var/postgresql/data -U postgres
|
||||
```
|
||||
If you are not using the default directory, you will have to update the `datadir` variable in the /etc/rc.d/postgresql script.
|
||||
If you are not using the default directory, you will have to update the `datadir` variable in the `/etc/rc.d/postgresql` script.
|
||||
|
||||
When this is done, enable postgresql so that it starts on boot and start it. As root, run:
|
||||
```
|
||||
|
@ -70,7 +72,7 @@ httpd will have three fuctions:
|
|||
* serve a robots.txt file
|
||||
* get Let's Encrypt certificates, with acme-client
|
||||
|
||||
Insert the following config in httpd.conf:
|
||||
Insert the following config in `/etc/httpd.conf`:
|
||||
```
|
||||
# $OpenBSD: httpd.conf,v 1.17 2017/04/16 08:50:49 ajacoutot Exp $
|
||||
|
||||
|
@ -93,13 +95,10 @@ server "default" {
|
|||
location "/robots.txt" { root "/htdocs/local/" }
|
||||
location "/*" { block return 302 "https://$HTTP_HOST$REQUEST_URI" }
|
||||
}
|
||||
|
||||
types {
|
||||
}
|
||||
```
|
||||
Do not forget to change *<IPv4/6 address\>* to your server's address(es). If httpd should only listen on one protocol family, comment one of the two first *listen* options.
|
||||
|
||||
Create the /var/www/htdocs/local/ folder and write the content of your robots.txt in /var/www/htdocs/local/robots.txt.
|
||||
Create the `/var/www/htdocs/local/` folder and write the content of your robots.txt in `/var/www/htdocs/local/robots.txt`.
|
||||
Check the configuration with `httpd -n`, if it is OK enable and start httpd (as root):
|
||||
```
|
||||
rcctl enable httpd
|
||||
|
@ -108,7 +107,7 @@ rcctl start httpd
|
|||
|
||||
#### acme-client
|
||||
acme-client is used to get SSL/TLS certificates from Let's Encrypt.
|
||||
Insert the following configuration in /etc/acme-client.conf:
|
||||
Insert the following configuration in `/etc/acme-client.conf`:
|
||||
```
|
||||
#
|
||||
# $OpenBSD: acme-client.conf,v 1.4 2017/03/22 11:14:14 benno Exp $
|
||||
|
@ -129,7 +128,7 @@ domain <domain name> {
|
|||
}
|
||||
```
|
||||
Replace *<domain name\>* by the domain name you'll use for your instance. As root, run `acme-client -n` to check the config, then `acme-client -ADv <domain name>` to create account and domain keys, and request a certificate for the first time.
|
||||
Make acme-client run everyday by adding it in /etc/daily.local. As root, run the following command: `echo "acme-client <domain name>" >> /etc/daily.local`.
|
||||
Make acme-client run everyday by adding it in `/etc/daily.local`. As root, run the following command: `echo "acme-client <domain name>" >> /etc/daily.local`.
|
||||
|
||||
Relayd will look for certificates and keys based on the address it listens on (see next part), the easiest way to make them available to relayd is to create a link, as root run:
|
||||
```
|
||||
|
@ -140,7 +139,7 @@ This will have to be done for each IPv4 and IPv6 address relayd listens on.
|
|||
|
||||
#### relayd
|
||||
relayd will be used as the reverse proxy sitting in front of akkoma.
|
||||
Insert the following configuration in /etc/relayd.conf:
|
||||
Insert the following configuration in `/etc/relayd.conf`:
|
||||
```
|
||||
# $OpenBSD: relayd.conf,v 1.4 2018/03/23 09:55:06 claudio Exp $
|
||||
|
||||
|
@ -198,7 +197,7 @@ rcctl start relayd
|
|||
|
||||
#### pf
|
||||
Enabling and configuring pf is highly recommended.
|
||||
In /etc/pf.conf, insert the following configuration:
|
||||
In `/etc/pf.conf`, insert the following configuration:
|
||||
```
|
||||
# Macros
|
||||
if="<network interface>"
|
||||
|
@ -222,31 +221,30 @@ pass in quick on $if inet6 proto icmp6 to ($if) icmp6-type { echoreq unreach par
|
|||
pass in quick on $if proto tcp to ($if) port { http https } # relayd/httpd
|
||||
pass in quick on $if proto tcp from $authorized_ssh_clients to ($if) port ssh
|
||||
```
|
||||
Replace *<network interface\>* by your server's network interface name (which you can get with ifconfig). Consider replacing the content of the authorized\_ssh\_clients macro by, for exemple, your home IP address, to avoid SSH connection attempts from bots.
|
||||
Replace *<network interface\>* by your server's network interface name (which you can get with ifconfig). Consider replacing the content of the `authorized_ssh_clients` macro by, for example, your home IP address, to avoid SSH connection attempts from bots.
|
||||
|
||||
Check pf's configuration by running `pfctl -nf /etc/pf.conf`, load it with `pfctl -f /etc/pf.conf` and enable pf at boot with `rcctl enable pf`.
|
||||
|
||||
#### Configure and start akkoma
|
||||
Enter a shell as \_akkoma (as root `su _akkoma -`) and enter akkoma's installation directory (`cd ~/akkoma/`).
|
||||
Enter a shell as `_akkoma` (as root `su _akkoma -`) and enter akkoma's installation directory (`cd ~/akkoma/`).
|
||||
|
||||
Then follow the main installation guide:
|
||||
|
||||
* run `mix deps.get`
|
||||
* run `MIX_ENV=prod mix pleroma.instance gen` and enter your instance's information when asked
|
||||
* copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK.
|
||||
* copy `config/generated_config.exs` to `config/prod.secret.exs`. The default values should be sufficient but you should edit it and check that everything seems OK.
|
||||
* exit your current shell back to a root one and run `psql -U postgres -f /home/_akkoma/akkoma/config/setup_db.psql` to setup the database.
|
||||
* return to a \_akkoma shell into akkoma's installation directory (`su _akkoma -;cd ~/akkoma`) and run `MIX_ENV=prod mix ecto.migrate`
|
||||
* return to a `_akkoma` shell into akkoma's installation directory (`su _akkoma -;cd ~/akkoma`) and run `MIX_ENV=prod mix ecto.migrate`
|
||||
|
||||
As \_akkoma in /home/\_akkoma/akkoma, you can now run `LC_ALL=en_US.UTF-8 MIX_ENV=prod mix phx.server` to start your instance.
|
||||
As `_akkoma` in `/home/_akkoma/akkoma`, you can now run `LC_ALL=en_US.UTF-8 MIX_ENV=prod mix phx.server` to start your instance.
|
||||
In another SSH session/tmux window, check that it is working properly by running `ftp -MVo - http://127.0.0.1:4000/api/v1/instance`, you should get json output. Double-check that *uri*'s value is your instance's domain name.
|
||||
|
||||
##### Starting akkoma at boot
|
||||
An rc script to automatically start akkoma at boot hasn't been written yet, it can be run in a tmux session (tmux is in base).
|
||||
|
||||
|
||||
#### Create administrative user
|
||||
|
||||
If your instance is up and running, you can create your first user with administrative rights with the following command as the \_akkoma user.
|
||||
If your instance is up and running, you can create your first user with administrative rights with the following command as the `_akkoma` user.
|
||||
```
|
||||
LC_ALL=en_US.UTF-8 MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
|
||||
```
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
This guide covers a installation using an OTP release. To install Akkoma from source, please check out the corresponding guide for your distro.
|
||||
|
||||
## Pre-requisites
|
||||
* A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and `x86_64`, `aarch64` or `armv7l` CPU, you have root access to. If you are not sure if it's compatible see [Detecting flavour section](#detecting-flavour) below
|
||||
* A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and an `x86_64` CPU you have root access to. If you are not sure if it's compatible see [Detecting flavour section](#detecting-flavour) below
|
||||
* For installing OTP releases on RedHat-based distros like Fedora and Centos Stream, please follow [this guide](./otp_redhat_en.md) instead.
|
||||
* A (sub)domain pointed to the machine
|
||||
|
||||
|
@ -118,8 +118,8 @@ Restart PostgreSQL to apply configuration changes:
|
|||
adduser --system --shell /bin/false --home /opt/akkoma akkoma
|
||||
|
||||
# Set the flavour environment variable to the string you got in Detecting flavour section.
|
||||
# For example if the flavour is `amd64-musl` the command will be
|
||||
export FLAVOUR="amd64-musl"
|
||||
# For example if the flavour is `amd64` the command will be
|
||||
export FLAVOUR="amd64"
|
||||
|
||||
# Clone the release build into a temporary directory and unpack it
|
||||
su akkoma -s $SHELL -lc "
|
||||
|
|
|
@ -37,7 +37,7 @@ sudo dnf install git gcc g++ erlang elixir erlang-os_mon erlang-eldap erlang-xme
|
|||
|
||||
```shell
|
||||
cd ~
|
||||
git clone https://akkoma.dev/AkkomaGang/akkoma.git
|
||||
git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable
|
||||
```
|
||||
|
||||
* Change to the new directory:
|
||||
|
|
|
@ -12,7 +12,7 @@ Release URLs will always be of the form
|
|||
https://akkoma-updates.s3-website.fr-par.scw.cloud/{branch}/akkoma-{flavour}.zip
|
||||
```
|
||||
|
||||
Where branch is usually `stable` or `develop`, and `flavour` is
|
||||
Where branch is usually `stable` and `flavour` is
|
||||
the one [that you detect on install](../otp_en/#detecting-flavour).
|
||||
|
||||
So, for an AMD64 stable install, your update URL will be
|
||||
|
|
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).
|
|
@ -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.
|
||||
|
|
|
@ -54,8 +54,6 @@ server {
|
|||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
|
||||
ssl_prefer_server_ciphers off;
|
||||
# In case of an old server with an OpenSSL version of 1.0.2 or below,
|
||||
# leave only prime256v1 or comment out the following line.
|
||||
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
|
|
@ -79,6 +79,45 @@ def run(["dump", group]) do
|
|||
end)
|
||||
end
|
||||
|
||||
def run(["dump_to_file", group, key, fname]) do
|
||||
check_configdb(fn ->
|
||||
start_pleroma()
|
||||
|
||||
group = maybe_atomize(group)
|
||||
key = maybe_atomize(key)
|
||||
|
||||
config = ConfigDB.get_by_group_and_key(group, key)
|
||||
|
||||
json =
|
||||
%{
|
||||
group: ConfigDB.to_json_types(config.group),
|
||||
key: ConfigDB.to_json_types(config.key),
|
||||
value: ConfigDB.to_json_types(config.value)
|
||||
}
|
||||
|> Jason.encode!()
|
||||
|> Jason.Formatter.pretty_print()
|
||||
|
||||
File.write(fname, json)
|
||||
shell_info("Wrote #{group}_#{key}.json")
|
||||
end)
|
||||
end
|
||||
|
||||
def run(["load_from_file", fname]) do
|
||||
check_configdb(fn ->
|
||||
start_pleroma()
|
||||
|
||||
json = File.read!(fname)
|
||||
config = Jason.decode!(json)
|
||||
group = ConfigDB.to_elixir_types(config["group"])
|
||||
key = ConfigDB.to_elixir_types(config["key"])
|
||||
value = ConfigDB.to_elixir_types(config["value"])
|
||||
params = %{group: group, key: key, value: value}
|
||||
|
||||
ConfigDB.update_or_create(params)
|
||||
shell_info("Loaded #{config["group"]}, #{config["key"]}")
|
||||
end)
|
||||
end
|
||||
|
||||
def run(["groups"]) do
|
||||
check_configdb(fn ->
|
||||
start_pleroma()
|
||||
|
|
|
@ -67,43 +67,168 @@ def run(["prune_objects" | args]) do
|
|||
OptionParser.parse(
|
||||
args,
|
||||
strict: [
|
||||
vacuum: :boolean
|
||||
vacuum: :boolean,
|
||||
keep_threads: :boolean,
|
||||
keep_non_public: :boolean,
|
||||
prune_orphaned_activities: :boolean
|
||||
]
|
||||
)
|
||||
|
||||
start_pleroma()
|
||||
|
||||
deadline = Pleroma.Config.get([:instance, :remote_post_retention_days])
|
||||
time_deadline = NaiveDateTime.utc_now() |> NaiveDateTime.add(-(deadline * 86_400))
|
||||
|
||||
Logger.info("Pruning objects older than #{deadline} days")
|
||||
log_message = "Pruning objects older than #{deadline} days"
|
||||
|
||||
time_deadline =
|
||||
NaiveDateTime.utc_now()
|
||||
|> NaiveDateTime.add(-(deadline * 86_400))
|
||||
log_message =
|
||||
if Keyword.get(options, :keep_non_public) do
|
||||
log_message <> ", keeping non public posts"
|
||||
else
|
||||
log_message
|
||||
end
|
||||
|
||||
from(o in Object,
|
||||
where:
|
||||
fragment(
|
||||
"?->'to' \\? ? OR ?->'cc' \\? ?",
|
||||
o.data,
|
||||
^Pleroma.Constants.as_public(),
|
||||
o.data,
|
||||
^Pleroma.Constants.as_public()
|
||||
),
|
||||
where: o.inserted_at < ^time_deadline,
|
||||
where:
|
||||
log_message =
|
||||
if Keyword.get(options, :keep_threads) do
|
||||
log_message <> ", keeping threads intact"
|
||||
else
|
||||
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
|
||||
# We want to delete objects from threads where
|
||||
# 1. the newest post is still old
|
||||
# 2. none of the activities is local
|
||||
# 3. none of the activities is bookmarked
|
||||
# 4. optionally none of the posts is non-public
|
||||
deletable_context =
|
||||
if Keyword.get(options, :keep_non_public) do
|
||||
Pleroma.Activity
|
||||
|> join(:left, [a], b in Pleroma.Bookmark, on: a.id == b.activity_id)
|
||||
|> group_by([a], fragment("? ->> 'context'::text", a.data))
|
||||
|> having(
|
||||
[a],
|
||||
not fragment(
|
||||
# Posts (checked on Create Activity) is non-public
|
||||
"bool_or((not(?->'to' \\? ? OR ?->'cc' \\? ?)) and ? ->> 'type' = 'Create')",
|
||||
a.data,
|
||||
^Pleroma.Constants.as_public(),
|
||||
a.data,
|
||||
^Pleroma.Constants.as_public(),
|
||||
a.data
|
||||
)
|
||||
)
|
||||
else
|
||||
Pleroma.Activity
|
||||
|> join(:left, [a], b in Pleroma.Bookmark, on: a.id == b.activity_id)
|
||||
|> group_by([a], fragment("? ->> 'context'::text", a.data))
|
||||
end
|
||||
|> having([a], max(a.updated_at) < ^time_deadline)
|
||||
|> having([a], not fragment("bool_or(?)", a.local))
|
||||
|> having([_, b], fragment("max(?::text) is null", b.id))
|
||||
|> select([a], fragment("? ->> 'context'::text", a.data))
|
||||
|
||||
Pleroma.Object
|
||||
|> where([o], fragment("? ->> 'context'::text", o.data) in subquery(deletable_context))
|
||||
else
|
||||
if Keyword.get(options, :keep_non_public) do
|
||||
Pleroma.Object
|
||||
|> where(
|
||||
[o],
|
||||
fragment(
|
||||
"?->'to' \\? ? OR ?->'cc' \\? ?",
|
||||
o.data,
|
||||
^Pleroma.Constants.as_public(),
|
||||
o.data,
|
||||
^Pleroma.Constants.as_public()
|
||||
)
|
||||
)
|
||||
else
|
||||
Pleroma.Object
|
||||
end
|
||||
|> where([o], o.updated_at < ^time_deadline)
|
||||
|> where(
|
||||
[o],
|
||||
fragment("split_part(?->>'actor', '/', 3) != ?", o.data, ^Pleroma.Web.Endpoint.host())
|
||||
)
|
||||
)
|
||||
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"])
|
||||
|
|
109
lib/pleroma/akkoma/translators/argos_translate.ex
Normal file
109
lib/pleroma/akkoma/translators/argos_translate.ex
Normal file
|
@ -0,0 +1,109 @@
|
|||
defmodule Pleroma.Akkoma.Translators.ArgosTranslate do
|
||||
@behaviour Pleroma.Akkoma.Translator
|
||||
|
||||
alias Pleroma.Config
|
||||
|
||||
defp argos_translate do
|
||||
Config.get([:argos_translate, :command_argos_translate])
|
||||
end
|
||||
|
||||
defp argospm do
|
||||
Config.get([:argos_translate, :command_argospm])
|
||||
end
|
||||
|
||||
defp strip_html? do
|
||||
Config.get([:argos_translate, :strip_html])
|
||||
end
|
||||
|
||||
defp safe_languages() do
|
||||
try do
|
||||
System.cmd(argospm(), ["list"], stderr_to_stdout: true, parallelism: true)
|
||||
rescue
|
||||
_ -> {"Command #{argospm()} not found", 1}
|
||||
end
|
||||
end
|
||||
|
||||
@impl Pleroma.Akkoma.Translator
|
||||
def languages do
|
||||
with {response, 0} <- safe_languages() do
|
||||
langs =
|
||||
response
|
||||
|> String.split("\n", trim: true)
|
||||
|> Enum.map(fn
|
||||
"translate-" <> l -> String.split(l, "_")
|
||||
end)
|
||||
|
||||
source_langs =
|
||||
langs
|
||||
|> Enum.map(fn [l, _] -> %{code: l, name: l} end)
|
||||
|> Enum.uniq()
|
||||
|
||||
dest_langs =
|
||||
langs
|
||||
|> Enum.map(fn [_, l] -> %{code: l, name: l} end)
|
||||
|> Enum.uniq()
|
||||
|
||||
{:ok, source_langs, dest_langs}
|
||||
else
|
||||
{response, _} -> {:error, "ArgosTranslate failed to fetch languages (#{response})"}
|
||||
end
|
||||
end
|
||||
|
||||
defp safe_translate(string, from_language, to_language) do
|
||||
try do
|
||||
System.cmd(
|
||||
argos_translate(),
|
||||
["--from-lang", from_language, "--to-lang", to_language, string],
|
||||
stderr_to_stdout: true,
|
||||
parallelism: true
|
||||
)
|
||||
rescue
|
||||
_ -> {"Command #{argos_translate()} not found", 1}
|
||||
end
|
||||
end
|
||||
|
||||
defp clean_string(string, true) do
|
||||
string
|
||||
|> String.replace("<p>", "\n")
|
||||
|> String.replace("</p>", "\n")
|
||||
|> String.replace("<br>", "\n")
|
||||
|> String.replace("<br/>", "\n")
|
||||
|> String.replace("<li>", "\n")
|
||||
|> Pleroma.HTML.strip_tags()
|
||||
|> HtmlEntities.decode()
|
||||
end
|
||||
|
||||
defp clean_string(string, _), do: string
|
||||
|
||||
defp htmlify_response(string, true) do
|
||||
string
|
||||
|> HtmlEntities.encode()
|
||||
|> String.replace("\n", "<br/>")
|
||||
end
|
||||
|
||||
defp htmlify_response(string, _), do: string
|
||||
|
||||
@impl Pleroma.Akkoma.Translator
|
||||
def translate(string, nil, to_language) do
|
||||
# Akkoma's Pleroma-fe expects us to detect the source language automatically.
|
||||
# Argos-translate doesn't have that option (yet?)
|
||||
# see <https://github.com/argosopentech/argos-translate/issues/9>
|
||||
# For now we return the text unchanged, supposedly translated from the target language.
|
||||
# Afterwards people get the option to overwrite the source language from a dropdown.
|
||||
{:ok, to_language, string}
|
||||
end
|
||||
|
||||
def translate(string, from_language, to_language) do
|
||||
# Argos Translate doesn't properly translate HTML (yet?)
|
||||
# For now we give admins the option to strip the html before translating
|
||||
# Note that we have to add some html back to the response afterwards
|
||||
string = clean_string(string, strip_html?())
|
||||
|
||||
with {translated, 0} <-
|
||||
safe_translate(string, from_language, to_language) do
|
||||
{:ok, from_language, translated |> htmlify_response(strip_html?())}
|
||||
else
|
||||
{response, _} -> {:error, "ArgosTranslate failed to translate (#{response})"}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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}
|
||||
|
|
|
@ -73,7 +73,8 @@ def start(_type, _args) do
|
|||
Pleroma.JobQueueMonitor,
|
||||
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
|
||||
{Oban, Config.get(Oban)},
|
||||
Pleroma.Web.Endpoint
|
||||
Pleroma.Web.Endpoint,
|
||||
Pleroma.Web.Telemetry
|
||||
] ++
|
||||
elasticsearch_children() ++
|
||||
task_children(@mix_env) ++
|
||||
|
@ -158,7 +159,8 @@ defp cachex_children do
|
|||
build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000),
|
||||
build_cachex("translations", default_ttl: :timer.hours(24 * 30), limit: 2500),
|
||||
build_cachex("instances", default_ttl: :timer.hours(24), ttl_interval: 1000, limit: 2500),
|
||||
build_cachex("request_signatures", default_ttl: :timer.hours(24 * 30), limit: 3000)
|
||||
build_cachex("request_signatures", default_ttl: :timer.hours(24 * 30), limit: 3000),
|
||||
build_cachex("rel_me", default_ttl: :timer.hours(24 * 30), limit: 300)
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -258,11 +260,16 @@ def limiters_setup do
|
|||
defp http_children do
|
||||
proxy_url = Config.get([:http, :proxy_url])
|
||||
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,9 @@ defp reboot_time_subkeys,
|
|||
do: [
|
||||
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
||||
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
||||
{:pleroma, :instance, [:upload_limit]}
|
||||
{:pleroma, :instance, [:upload_limit]},
|
||||
{:pleroma, :http, [:pool_size]},
|
||||
{:pleroma, :http, [:proxy_url]}
|
||||
]
|
||||
|
||||
def start_link(restart_pleroma? \\ true) do
|
||||
|
@ -40,6 +42,7 @@ def load_and_update_env(deleted_settings \\ [], restart_pleroma? \\ true) do
|
|||
# We need to restart applications for loaded settings take effect
|
||||
{logger, other} =
|
||||
(Repo.all(ConfigDB) ++ deleted_settings)
|
||||
|> Enum.reject(&invalid_key_or_group/1)
|
||||
|> Enum.map(&merge_with_default/1)
|
||||
|> Enum.split_with(fn {group, _, _, _} -> group == :logger end)
|
||||
|
||||
|
@ -83,6 +86,10 @@ defp maybe_set_pleroma_last(apps) do
|
|||
end
|
||||
end
|
||||
|
||||
defp invalid_key_or_group(%ConfigDB{key: :invalid_atom}), do: true
|
||||
defp invalid_key_or_group(%ConfigDB{group: :invalid_atom}), do: true
|
||||
defp invalid_key_or_group(_), do: false
|
||||
|
||||
defp merge_with_default(%{group: group, key: key, value: value} = setting) do
|
||||
default =
|
||||
if group == :pleroma do
|
||||
|
|
|
@ -342,7 +342,11 @@ def string_to_elixir_types(":" <> atom), do: String.to_atom(atom)
|
|||
|
||||
def string_to_elixir_types(value) do
|
||||
if module_name?(value) do
|
||||
String.to_existing_atom("Elixir." <> value)
|
||||
try do
|
||||
String.to_existing_atom("Elixir." <> value)
|
||||
rescue
|
||||
ArgumentError -> :invalid_atom
|
||||
end
|
||||
else
|
||||
value
|
||||
end
|
||||
|
|
|
@ -38,7 +38,8 @@ defmodule Pleroma.Constants do
|
|||
"summary",
|
||||
"sensitive",
|
||||
"attachment",
|
||||
"generator"
|
||||
"generator",
|
||||
"contentMap"
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ def user_invitation_email(
|
|||
"user invitation email body",
|
||||
"""
|
||||
<h3>You are invited to %{instance_name}</h3>
|
||||
<p>%{inviter_name} invites you to join %{instance_name}, an instance of Pleroma federated social networking platform.</p>
|
||||
<p>%{inviter_name} invites you to join %{instance_name}, an instance of Akkoma federated social networking platform.</p>
|
||||
<p>Click the following link to register: <a href="%{registration_url}">accept invitation</a>.</p>
|
||||
""",
|
||||
instance_name: instance_name(),
|
||||
|
@ -357,7 +357,7 @@ def backup_is_ready_email(backup, admin_user_id \\ nil) do
|
|||
"static_pages",
|
||||
"account archive email body - self-requested",
|
||||
"""
|
||||
<p>You requested a full backup of your Pleroma account. It's ready for download:</p>
|
||||
<p>You requested a full backup of your Akkoma account. It's ready for download:</p>
|
||||
<p><a href="%{download_url}">%{download_url}</a></p>
|
||||
""",
|
||||
download_url: download_url
|
||||
|
@ -369,7 +369,7 @@ def backup_is_ready_email(backup, admin_user_id \\ nil) do
|
|||
"static_pages",
|
||||
"account archive email body - admin requested",
|
||||
"""
|
||||
<p>Admin @%{admin_nickname} requested a full backup of your Pleroma account. It's ready for download:</p>
|
||||
<p>Admin @%{admin_nickname} requested a full backup of your Akkoma account. It's ready for download:</p>
|
||||
<p><a href="%{download_url}">%{download_url}</a></p>
|
||||
""",
|
||||
admin_nickname: admin.nickname,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -252,7 +252,7 @@ def download(name, url, as) do
|
|||
|
||||
with :ok <- validate_shareable_packs_available(uri),
|
||||
{:ok, remote_pack} <-
|
||||
uri |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{name}") |> http_get(),
|
||||
uri |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{URI.encode(name)}") |> http_get(),
|
||||
{:ok, %{sha: sha, url: url} = pack_info} <- fetch_pack_info(remote_pack, uri, name),
|
||||
{:ok, archive} <- download_archive(url, sha),
|
||||
pack <- copy_as(remote_pack, as || name),
|
||||
|
@ -593,7 +593,9 @@ defp fetch_pack_info(remote_pack, uri, name) do
|
|||
{:ok,
|
||||
%{
|
||||
sha: sha,
|
||||
url: URI.merge(uri, "/api/v1/pleroma/emoji/packs/archive?name=#{name}") |> to_string()
|
||||
url:
|
||||
URI.merge(uri, "/api/v1/pleroma/emoji/packs/archive?name=#{URI.encode(name)}")
|
||||
|> to_string()
|
||||
}}
|
||||
|
||||
%{"fallback-src" => src, "fallback-src-sha256" => sha} when is_binary(src) ->
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,7 +65,7 @@ def request(method, url, body, headers, options) when is_binary(url) do
|
|||
options = put_in(options[:adapter], adapter_opts)
|
||||
params = options[:params] || []
|
||||
request = build_request(method, headers, options, url, body, params)
|
||||
client = Tesla.client([Tesla.Middleware.FollowRedirects])
|
||||
client = Tesla.client([Tesla.Middleware.FollowRedirects, Tesla.Middleware.Telemetry])
|
||||
|
||||
request(client, request)
|
||||
end
|
||||
|
|
|
@ -47,6 +47,24 @@ 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()
|
||||
|> maybe_add_default_pool()
|
||||
|> put_in([:pools, :default, :size], pool_size)
|
||||
end
|
||||
|
||||
defp maybe_add_pools(opts) do
|
||||
if Keyword.has_key?(opts, :pools) do
|
||||
opts
|
||||
|
@ -75,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
|
||||
|
||||
|
|
11
lib/pleroma/iso639.ex
Normal file
11
lib/pleroma/iso639.ex
Normal file
|
@ -0,0 +1,11 @@
|
|||
defmodule Pleroma.ISO639 do
|
||||
@file "priv/language-codes.json"
|
||||
@data File.read!(@file)
|
||||
|> Jason.decode!()
|
||||
|
||||
for %{"alpha2" => alpha2} <- @data do
|
||||
def valid_alpha2?(unquote(alpha2)), do: true
|
||||
end
|
||||
|
||||
def valid_alpha2?(_alpha2), do: false
|
||||
end
|
|
@ -88,9 +88,9 @@ def paginate(query, options, :offset, table_binding) do
|
|||
|
||||
defp cast_params(params) do
|
||||
param_types = %{
|
||||
min_id: :string,
|
||||
since_id: :string,
|
||||
max_id: :string,
|
||||
min_id: params[:id_type] || :string,
|
||||
since_id: params[:id_type] || :string,
|
||||
max_id: params[:id_type] || :string,
|
||||
offset: :integer,
|
||||
limit: :integer,
|
||||
skip_extra_order: :boolean,
|
||||
|
|
55
lib/pleroma/password.ex
Normal file
55
lib/pleroma/password.ex
Normal file
|
@ -0,0 +1,55 @@
|
|||
defmodule Pleroma.Password do
|
||||
@moduledoc """
|
||||
This module handles password hashing and verification.
|
||||
It will delegate to the appropriate module based on the password hash.
|
||||
It also handles upgrading of password hashes.
|
||||
"""
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Password.Pbkdf2
|
||||
require Logger
|
||||
|
||||
@hashing_module Argon2
|
||||
|
||||
@spec hash_pwd_salt(String.t()) :: String.t()
|
||||
defdelegate hash_pwd_salt(pass), to: @hashing_module
|
||||
|
||||
@spec checkpw(String.t(), String.t()) :: boolean()
|
||||
def checkpw(password, "$2" <> _ = password_hash) do
|
||||
# Handle bcrypt passwords for Mastodon migration
|
||||
Bcrypt.verify_pass(password, password_hash)
|
||||
end
|
||||
|
||||
def checkpw(password, "$pbkdf2" <> _ = password_hash) do
|
||||
Pbkdf2.verify_pass(password, password_hash)
|
||||
end
|
||||
|
||||
def checkpw(password, "$argon2" <> _ = password_hash) do
|
||||
Argon2.verify_pass(password, password_hash)
|
||||
end
|
||||
|
||||
def checkpw(_password, _password_hash) do
|
||||
Logger.error("Password hash not recognized")
|
||||
false
|
||||
end
|
||||
|
||||
@spec maybe_update_password(User.t(), String.t()) ::
|
||||
{:ok, User.t()} | {:error, Ecto.Changeset.t()}
|
||||
def maybe_update_password(%User{password_hash: "$2" <> _} = user, password) do
|
||||
do_update_password(user, password)
|
||||
end
|
||||
|
||||
def maybe_update_password(%User{password_hash: "$6" <> _} = user, password) do
|
||||
do_update_password(user, password)
|
||||
end
|
||||
|
||||
def maybe_update_password(%User{password_hash: "$pbkdf2" <> _} = user, password) do
|
||||
do_update_password(user, password)
|
||||
end
|
||||
|
||||
def maybe_update_password(user, _), do: {:ok, user}
|
||||
|
||||
defp do_update_password(user, password) do
|
||||
User.reset_password(user, %{password: password, password_confirmation: password})
|
||||
end
|
||||
end
|
49
lib/pleroma/prometheus_exporter.ex
Normal file
49
lib/pleroma/prometheus_exporter.ex
Normal file
|
@ -0,0 +1,49 @@
|
|||
defmodule Pleroma.PrometheusExporter do
|
||||
@moduledoc """
|
||||
Exports metrics in Prometheus format.
|
||||
Mostly exists because of https://github.com/beam-telemetry/telemetry_metrics_prometheus_core/issues/52
|
||||
Basically we need to fetch metrics every so often, or the lib will let them pile up and eventually crash the VM.
|
||||
It also sorta acts as a cache so there is that too.
|
||||
"""
|
||||
|
||||
use GenServer
|
||||
require Logger
|
||||
|
||||
def start_link(_opts) do
|
||||
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
|
||||
end
|
||||
|
||||
def init(_opts) do
|
||||
schedule_next()
|
||||
{:ok, ""}
|
||||
end
|
||||
|
||||
defp schedule_next do
|
||||
Process.send_after(self(), :gather, 60_000)
|
||||
end
|
||||
|
||||
# Scheduled function, gather metrics and schedule next run
|
||||
def handle_info(:gather, _state) do
|
||||
schedule_next()
|
||||
state = TelemetryMetricsPrometheus.Core.scrape()
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
# Trigger the call dynamically, mostly for testing
|
||||
def handle_call(:gather, _from, _state) do
|
||||
state = TelemetryMetricsPrometheus.Core.scrape()
|
||||
{:reply, state, state}
|
||||
end
|
||||
|
||||
def handle_call(:show, _from, state) do
|
||||
{:reply, state, state}
|
||||
end
|
||||
|
||||
def show do
|
||||
GenServer.call(__MODULE__, :show)
|
||||
end
|
||||
|
||||
def gather do
|
||||
GenServer.call(__MODULE__, :gather)
|
||||
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)
|
||||
|
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Stats do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
@interval :timer.seconds(60)
|
||||
@interval :timer.seconds(300)
|
||||
|
||||
def start_link(_) do
|
||||
GenServer.start_link(
|
||||
|
@ -85,14 +85,24 @@ def calculate_stat_data do
|
|||
where: not u.invisible
|
||||
)
|
||||
|
||||
remote_users_query =
|
||||
from(u in User,
|
||||
where: u.is_active == true,
|
||||
where: u.local == false,
|
||||
where: not is_nil(u.nickname),
|
||||
where: not u.invisible
|
||||
)
|
||||
|
||||
user_count = Repo.aggregate(users_query, :count, :id)
|
||||
remote_user_count = Repo.aggregate(remote_users_query, :count, :id)
|
||||
|
||||
%{
|
||||
peers: peers,
|
||||
stats: %{
|
||||
domain_count: domain_count,
|
||||
status_count: status_count || 0,
|
||||
user_count: user_count
|
||||
user_count: user_count,
|
||||
remote_user_count: remote_user_count
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,6 +14,8 @@ defmodule Pleroma.Upload.Filter.Exiftool do
|
|||
# Formats not compatible with exiftool at this time
|
||||
def filter(%Pleroma.Upload{content_type: "image/heic"}), do: {:ok, :noop}
|
||||
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
|
||||
def filter(%Pleroma.Upload{content_type: "image/svg+xml"}), do: {:ok, :noop}
|
||||
def filter(%Pleroma.Upload{content_type: "image/jxl"}), do: {:ok, :noop}
|
||||
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||
try do
|
||||
|
|
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
|
||||
|
||||
|
@ -479,7 +490,7 @@ def remote_user_changeset(struct \\ %User{local: false}, params) do
|
|||
|> validate_format(:nickname, @email_regex)
|
||||
|> validate_length(:bio, max: bio_limit)
|
||||
|> validate_length(:name, max: name_limit)
|
||||
|> validate_fields(true)
|
||||
|> validate_fields(true, struct)
|
||||
|> validate_non_local()
|
||||
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)
|
||||
|
@ -549,7 +561,7 @@ def update_changeset(struct, params \\ %{}) do
|
|||
:pleroma_settings_store,
|
||||
&{:ok, Map.merge(struct.pleroma_settings_store, &1)}
|
||||
)
|
||||
|> validate_fields(false)
|
||||
|> validate_fields(false, struct)
|
||||
end
|
||||
|
||||
defp put_fields(changeset) do
|
||||
|
@ -1994,6 +2006,7 @@ defp create_service_actor(uri, nickname) do
|
|||
%User{
|
||||
invisible: true,
|
||||
local: true,
|
||||
actor_type: "Application",
|
||||
ap_id: uri,
|
||||
nickname: nickname,
|
||||
follower_address: uri <> "/followers"
|
||||
|
@ -2070,10 +2083,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
|
||||
|
@ -2277,7 +2294,7 @@ def get_ap_ids_by_nicknames(nicknames) do
|
|||
defp put_password_hash(
|
||||
%Ecto.Changeset{valid?: true, changes: %{password: password}} = changeset
|
||||
) do
|
||||
change(changeset, password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt(password))
|
||||
change(changeset, password_hash: Pleroma.Password.hash_pwd_salt(password))
|
||||
end
|
||||
|
||||
defp put_password_hash(changeset), do: changeset
|
||||
|
@ -2359,7 +2376,8 @@ def update_background(user, background) do
|
|||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
def validate_fields(changeset, remote? \\ false) do
|
||||
@spec validate_fields(Ecto.Changeset.t(), Boolean.t(), User.t()) :: Ecto.Changeset.t()
|
||||
def validate_fields(changeset, remote? \\ false, struct) do
|
||||
limit_name = if remote?, do: :max_remote_account_fields, else: :max_account_fields
|
||||
limit = Config.get([:instance, limit_name], 0)
|
||||
|
||||
|
@ -2372,6 +2390,7 @@ def validate_fields(changeset, remote? \\ false) do
|
|||
[fields: "invalid"]
|
||||
end
|
||||
end)
|
||||
|> maybe_validate_rel_me_field(struct)
|
||||
end
|
||||
|
||||
defp valid_field?(%{"name" => name, "value" => value}) do
|
||||
|
@ -2384,6 +2403,75 @@ defp valid_field?(%{"name" => name, "value" => value}) do
|
|||
|
||||
defp valid_field?(_), do: false
|
||||
|
||||
defp is_url(nil), do: nil
|
||||
|
||||
defp is_url(uri) do
|
||||
case URI.parse(uri) do
|
||||
%URI{host: nil} -> false
|
||||
%URI{scheme: nil} -> false
|
||||
_ -> true
|
||||
end
|
||||
end
|
||||
|
||||
@spec maybe_validate_rel_me_field(Changeset.t(), User.t()) :: Changeset.t()
|
||||
defp maybe_validate_rel_me_field(changeset, %User{ap_id: _ap_id} = struct) do
|
||||
fields = get_change(changeset, :fields)
|
||||
raw_fields = get_change(changeset, :raw_fields)
|
||||
|
||||
if is_nil(fields) do
|
||||
changeset
|
||||
else
|
||||
validate_rel_me_field(changeset, fields, raw_fields, struct)
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_validate_rel_me_field(changeset, _), do: changeset
|
||||
|
||||
@spec validate_rel_me_field(Changeset.t(), [Map.t()], [Map.t()], User.t()) :: Changeset.t()
|
||||
defp validate_rel_me_field(changeset, fields, raw_fields, %User{
|
||||
nickname: nickname,
|
||||
ap_id: ap_id
|
||||
}) do
|
||||
fields =
|
||||
fields
|
||||
|> Enum.with_index()
|
||||
|> Enum.map(fn {%{"name" => name, "value" => value}, index} ->
|
||||
raw_value =
|
||||
if is_nil(raw_fields) do
|
||||
nil
|
||||
else
|
||||
Enum.at(raw_fields, index)["value"]
|
||||
end
|
||||
|
||||
if is_url(raw_value) do
|
||||
frontend_url =
|
||||
Pleroma.Web.Router.Helpers.redirect_url(
|
||||
Pleroma.Web.Endpoint,
|
||||
:redirector_with_meta,
|
||||
nickname
|
||||
)
|
||||
|
||||
possible_urls = [ap_id, frontend_url]
|
||||
|
||||
with "me" <- RelMe.maybe_put_rel_me(raw_value, possible_urls) do
|
||||
%{
|
||||
"name" => name,
|
||||
"value" => value,
|
||||
"verified_at" => DateTime.to_iso8601(DateTime.utc_now())
|
||||
}
|
||||
else
|
||||
e ->
|
||||
Logger.error("Could not check for rel=me, #{inspect(e)}")
|
||||
%{"name" => name, "value" => value}
|
||||
end
|
||||
else
|
||||
%{"name" => name, "value" => value}
|
||||
end
|
||||
end)
|
||||
|
||||
put_change(changeset, :fields, fields)
|
||||
end
|
||||
|
||||
defp truncate_field(%{"name" => name, "value" => value}) do
|
||||
{name, _chopped} =
|
||||
String.split_at(name, Config.get([:instance, :account_field_name_length], 255))
|
||||
|
@ -2551,11 +2639,8 @@ def sanitize_html(%User{} = user) do
|
|||
# - display name
|
||||
def sanitize_html(%User{} = user, filter) do
|
||||
fields =
|
||||
Enum.map(user.fields, fn %{"name" => name, "value" => value} ->
|
||||
%{
|
||||
"name" => name,
|
||||
"value" => HTML.filter_tags(value, Pleroma.HTML.Scrubber.LinksOnly)
|
||||
}
|
||||
Enum.map(user.fields, fn %{"value" => value} = field ->
|
||||
Map.put(field, "value", HTML.filter_tags(value, Pleroma.HTML.Scrubber.LinksOnly))
|
||||
end)
|
||||
|
||||
user
|
||||
|
@ -2643,4 +2728,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
|
||||
|
|
|
@ -43,7 +43,13 @@ def get(%User{} = user, %Hashtag{} = hashtag) do
|
|||
end
|
||||
|
||||
def get_by_user(%User{} = user) do
|
||||
Ecto.assoc(user, :followed_hashtags)
|
||||
user
|
||||
|> followed_hashtags_query()
|
||||
|> Repo.all()
|
||||
end
|
||||
|
||||
def followed_hashtags_query(%User{} = user) do
|
||||
Ecto.assoc(user, :followed_hashtags)
|
||||
|> Ecto.Query.order_by([h], desc: h.id)
|
||||
end
|
||||
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
|
||||
|
|
|
@ -132,66 +132,6 @@ defp maybe_halt_on_missing_oauth_scopes_check(conn) do
|
|||
end
|
||||
end
|
||||
|
||||
def view do
|
||||
quote do
|
||||
use Phoenix.View,
|
||||
root: "lib/pleroma/web/templates",
|
||||
namespace: Pleroma.Web
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
|
||||
|
||||
import Pleroma.Web.ErrorHelpers
|
||||
import Pleroma.Web.Gettext
|
||||
|
||||
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||
|
||||
require Logger
|
||||
|
||||
@doc "Same as `render/3` but wrapped in a rescue block"
|
||||
def safe_render(view, template, assigns \\ %{}) do
|
||||
Phoenix.View.render(view, template, assigns)
|
||||
rescue
|
||||
error ->
|
||||
Logger.error(
|
||||
"#{__MODULE__} failed to render #{inspect({view, template})}\n" <>
|
||||
Exception.format(:error, error, __STACKTRACE__)
|
||||
)
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
@doc """
|
||||
Same as `render_many/4` but wrapped in rescue block.
|
||||
"""
|
||||
def safe_render_many(collection, view, template, assigns \\ %{}) do
|
||||
Enum.map(collection, fn resource ->
|
||||
as = Map.get(assigns, :as) || view.__resource__
|
||||
assigns = Map.put(assigns, as, resource)
|
||||
safe_render(view, template, assigns)
|
||||
end)
|
||||
|> Enum.filter(& &1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def router do
|
||||
quote do
|
||||
use Phoenix.Router
|
||||
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
end
|
||||
end
|
||||
|
||||
def channel do
|
||||
quote do
|
||||
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||
import Phoenix.Channel
|
||||
import Pleroma.Web.Gettext
|
||||
end
|
||||
end
|
||||
|
||||
def plug do
|
||||
quote do
|
||||
@behaviour Pleroma.Web.Plug
|
||||
|
@ -236,6 +176,80 @@ def call(%Plug.Conn{} = conn, options) do
|
|||
end
|
||||
end
|
||||
|
||||
def view do
|
||||
quote do
|
||||
use Phoenix.View,
|
||||
root: "lib/pleroma/web/templates",
|
||||
namespace: Pleroma.Web
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller,
|
||||
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
|
||||
|
||||
# Include shared imports and aliases for views
|
||||
unquote(view_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def live_view do
|
||||
quote do
|
||||
use Phoenix.LiveView,
|
||||
layout: {Pleroma.Web.LayoutView, "live.html"}
|
||||
|
||||
unquote(view_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def live_component do
|
||||
quote do
|
||||
use Phoenix.LiveComponent
|
||||
|
||||
unquote(view_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def component do
|
||||
quote do
|
||||
use Phoenix.Component
|
||||
|
||||
unquote(view_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def router do
|
||||
quote do
|
||||
use Phoenix.Router
|
||||
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Phoenix.LiveView.Router
|
||||
end
|
||||
end
|
||||
|
||||
def channel do
|
||||
quote do
|
||||
use Phoenix.Channel
|
||||
import Pleroma.Web.Gettext
|
||||
end
|
||||
end
|
||||
|
||||
defp view_helpers do
|
||||
quote do
|
||||
# Use all HTML functionality (forms, tags, etc)
|
||||
use Phoenix.HTML
|
||||
|
||||
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
|
||||
import Phoenix.LiveView.Helpers
|
||||
|
||||
# Import basic rendering functionality (render, render_layout, etc)
|
||||
import Phoenix.View
|
||||
|
||||
import Pleroma.Web.ErrorHelpers
|
||||
import Pleroma.Web.Gettext
|
||||
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
When used, dispatch to the appropriate controller/view/etc.
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
@ -161,10 +162,17 @@ defp get_policies(_), do: []
|
|||
# - https://extra.baddomain.net/
|
||||
# Does NOT match the following:
|
||||
# - https://maybebaddomain.net/
|
||||
|
||||
# *.baddomain.net
|
||||
def subdomain_regex("*." <> domain), do: subdomain_regex(domain)
|
||||
|
||||
# baddomain.net
|
||||
def subdomain_regex(domain) do
|
||||
~r/^(.+\.)?#{Regex.escape(domain)}$/i
|
||||
if String.ends_with?(domain, ".*") do
|
||||
~r/^(.+\.)?#{Regex.escape(String.replace_suffix(domain, ".*", ""))}\.(.+)$/i
|
||||
else
|
||||
~r/^(.+\.)?#{Regex.escape(domain)}$/i
|
||||
end
|
||||
end
|
||||
|
||||
@spec subdomains_regex([String.t()]) :: [Regex.t()]
|
||||
|
|
|
@ -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
|
|
@ -30,6 +30,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
|
|||
|
||||
field(:replies, {:array, ObjectValidators.ObjectID}, default: [])
|
||||
field(:source, :map)
|
||||
field(:contentMap, :map)
|
||||
end
|
||||
|
||||
def cast_and_apply(data) do
|
||||
|
@ -103,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
|
||||
)
|
||||
|
@ -120,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)
|
||||
|
@ -146,6 +149,21 @@ defp fix_source(%{"source" => source} = object) when is_binary(source) do
|
|||
|
||||
defp fix_source(object), do: object
|
||||
|
||||
defp fix_content_map_languages(%{"contentMap" => content_map} = object)
|
||||
when is_map(content_map) do
|
||||
# Only allow valid languages
|
||||
content_map =
|
||||
content_map
|
||||
|> Enum.reject(fn {lang, _content} ->
|
||||
!Pleroma.ISO639.valid_alpha2?(lang)
|
||||
end)
|
||||
|> Enum.into(%{})
|
||||
|
||||
Map.put(object, "contentMap", content_map)
|
||||
end
|
||||
|
||||
defp fix_content_map_languages(object), do: object
|
||||
|
||||
defp fix(data) do
|
||||
data
|
||||
|> CommonFixes.fix_actor()
|
||||
|
@ -158,6 +176,7 @@ defp fix(data) do
|
|||
|> Transmogrifier.fix_attachments()
|
||||
|> Transmogrifier.fix_emoji()
|
||||
|> Transmogrifier.fix_content_map()
|
||||
|> fix_content_map_languages()
|
||||
end
|
||||
|
||||
def changeset(struct, data) do
|
||||
|
|
|
@ -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()) | []
|
||||
|
|
|
@ -346,11 +346,16 @@ def fix_tag(%{"tag" => %{} = tag} = object) do
|
|||
def fix_tag(object), do: object
|
||||
|
||||
# content map usually only has one language so this will do for now.
|
||||
def fix_content_map(%{"contentMap" => content_map} = object) do
|
||||
def fix_content_map(%{"contentMap" => content_map} = object) when is_map(content_map) do
|
||||
content_groups = Map.to_list(content_map)
|
||||
{_, content} = Enum.at(content_groups, 0)
|
||||
|
||||
Map.put(object, "content", content)
|
||||
if Enum.empty?(content_groups) do
|
||||
object
|
||||
else
|
||||
{_, content} = Enum.at(content_groups, 0)
|
||||
|
||||
Map.put(object, "content", content)
|
||||
end
|
||||
end
|
||||
|
||||
def fix_content_map(object), do: object
|
||||
|
@ -414,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(
|
||||
|
|
|
@ -14,11 +14,11 @@ defmodule Pleroma.Web.AdminAPI.StatusView do
|
|||
defdelegate merge_account_views(user), to: AdminAPI.AccountView
|
||||
|
||||
def render("index.json", %{total: total} = opts) do
|
||||
%{total: total, activities: safe_render_many(opts.activities, __MODULE__, "show.json", opts)}
|
||||
%{total: total, activities: render_many(opts.activities, __MODULE__, "show.json", opts)}
|
||||
end
|
||||
|
||||
def render("index.json", opts) do
|
||||
safe_render_many(opts.activities, __MODULE__, "show.json", opts)
|
||||
render_many(opts.activities, __MODULE__, "show.json", opts)
|
||||
end
|
||||
|
||||
def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
|
||||
|
|
|
@ -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
|
24
lib/pleroma/web/akkoma_api/controllers/metrics_controller.ex
Normal file
24
lib/pleroma/web/akkoma_api/controllers/metrics_controller.ex
Normal file
|
@ -0,0 +1,24 @@
|
|||
defmodule Pleroma.Web.AkkomaAPI.MetricsController do
|
||||
use Pleroma.Web, :controller
|
||||
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
alias Pleroma.Config
|
||||
|
||||
plug(
|
||||
OAuthScopesPlug,
|
||||
%{scopes: ["admin:metrics"]}
|
||||
when action in [
|
||||
:show
|
||||
]
|
||||
)
|
||||
|
||||
def show(conn, _params) do
|
||||
if Config.get([:instance, :export_prometheus_metrics], true) do
|
||||
conn
|
||||
|> text(Pleroma.PrometheusExporter.show())
|
||||
else
|
||||
conn
|
||||
|> send_resp(404, "Not Found")
|
||||
end
|
||||
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
|
|
@ -23,19 +23,19 @@ def spec(opts \\ []) do
|
|||
[]
|
||||
end,
|
||||
info: %OpenApiSpex.Info{
|
||||
title: "Pleroma API",
|
||||
title: "Akkoma API",
|
||||
description: """
|
||||
This is documentation for client Pleroma API. Most of the endpoints and entities come
|
||||
This is documentation for the Akkoma API. Most of the endpoints and entities come
|
||||
from Mastodon API and have custom extensions on top.
|
||||
|
||||
While this document aims to be a complete guide to the client API Pleroma exposes,
|
||||
the details are still being worked out. Some endpoints may have incomplete or poorly worded documentation.
|
||||
While this document aims to be a complete guide to the client API Akkoma exposes,
|
||||
it may not be complete. Some endpoints may have incomplete or poorly worded documentation.
|
||||
You might want to check the following resources if something is not clear:
|
||||
- [Legacy Pleroma-specific endpoint documentation](https://docs-develop.pleroma.social/backend/development/API/pleroma_api/)
|
||||
- [Mastodon API documentation](https://docs.joinmastodon.org/client/intro/)
|
||||
- [Differences in Mastodon API responses from vanilla Mastodon](https://docs-develop.pleroma.social/backend/development/API/differences_in_mastoapi_responses/)
|
||||
- [Differences in Mastodon API responses from vanilla Mastodon](https://docs.akkoma.dev/stable/development/API/differences_in_mastoapi_responses/)
|
||||
|
||||
Please report such occurences on our [issue tracker](https://git.pleroma.social/pleroma/pleroma/-/issues). Feel free to submit API questions or proposals there too!
|
||||
Please report such occurrences on our [issue tracker](https://akkoma.dev/AkkomaGang/akkoma). Feel free to submit API questions or proposals there too!
|
||||
""",
|
||||
# Strip environment from the version
|
||||
version: Application.spec(:pleroma, :vsn) |> to_string() |> String.replace(~r/\+.*$/, ""),
|
||||
|
|
|
@ -432,6 +432,7 @@ def lookup_operation do
|
|||
],
|
||||
responses: %{
|
||||
200 => Operation.response("Account", "application/json", Account),
|
||||
401 => Operation.response("Error", "application/json", ApiError),
|
||||
404 => Operation.response("Error", "application/json", ApiError)
|
||||
}
|
||||
}
|
||||
|
@ -707,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: %{
|
||||
|
@ -728,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
|
||||
|
@ -755,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" => "",
|
||||
|
@ -771,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" => "",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -44,7 +44,7 @@ def unfollow_operation do
|
|||
tags: ["Tags"],
|
||||
summary: "Unfollow a hashtag",
|
||||
description: "Unfollow a hashtag",
|
||||
security: [%{"oAuth" => ["write:follow"]}],
|
||||
security: [%{"oAuth" => ["write:follows"]}],
|
||||
parameters: [id_param()],
|
||||
operationId: "TagController.unfollow",
|
||||
responses: %{
|
||||
|
@ -54,6 +54,26 @@ def unfollow_operation do
|
|||
}
|
||||
end
|
||||
|
||||
def show_followed_operation do
|
||||
%Operation{
|
||||
tags: ["Tags"],
|
||||
summary: "Followed hashtags",
|
||||
description: "View a list of hashtags the currently authenticated user is following",
|
||||
parameters: pagination_params(),
|
||||
security: [%{"oAuth" => ["read:follows"]}],
|
||||
operationId: "TagController.show_followed",
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Hashtags", "application/json", %Schema{
|
||||
type: :array,
|
||||
items: Tag
|
||||
}),
|
||||
403 => Operation.response("Forbidden", "application/json", ApiError),
|
||||
404 => Operation.response("Not Found", "application/json", ApiError)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
defp id_param do
|
||||
Operation.parameter(
|
||||
:id,
|
||||
|
@ -62,4 +82,22 @@ defp id_param do
|
|||
"Name of the hashtag"
|
||||
)
|
||||
end
|
||||
|
||||
def pagination_params do
|
||||
[
|
||||
Operation.parameter(:max_id, :query, :integer, "Return items older than this ID"),
|
||||
Operation.parameter(
|
||||
:min_id,
|
||||
:query,
|
||||
:integer,
|
||||
"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
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue