Backend settings sync #226

Merged
floatingghost merged 9 commits from backend-sync-profiles into develop 2022-10-06 16:22:16 +00:00
19 changed files with 110 additions and 51 deletions
Showing only changes of commit bd7f7eadde - Show all commits

View file

@ -14,6 +14,14 @@ variables:
- stable - stable
- refs/tags/v* - refs/tags/v*
- refs/tags/stable-* - refs/tags/stable-*
- &on-stable
when:
event:
- push
- tag
branch:
- stable
- refs/tags/stable-*
- &on-point-release - &on-point-release
when: when:
event: event:
@ -87,7 +95,7 @@ pipeline:
# Canonical amd64 # Canonical amd64
ubuntu22: ubuntu22:
image: hexpm/elixir:1.13.4-erlang-25.0.2-ubuntu-jammy-20220428 image: hexpm/elixir:1.13.4-erlang-24.3.4.5-ubuntu-jammy-20220428
<<: *on-release <<: *on-release
environment: environment:
MIX_ENV: prod MIX_ENV: prod
@ -110,9 +118,11 @@ pipeline:
- export SOURCE=akkoma-ubuntu-jammy.zip - export SOURCE=akkoma-ubuntu-jammy.zip
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-ubuntu-jammy.zip - export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-ubuntu-jammy.zip
- /bin/sh /entrypoint.sh - /bin/sh /entrypoint.sh
- export DEST=scaleway:akkoma-updates/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/akkoma-amd64-ubuntu-jammy.zip
- /bin/sh /entrypoint.sh
debian-bullseye: debian-bullseye:
image: elixir:1.13.4 image: hexpm/elixir:1.13.4-erlang-24.3.4.5-debian-bullseye-20220801
<<: *on-release <<: *on-release
environment: environment:
MIX_ENV: prod MIX_ENV: prod
@ -141,8 +151,8 @@ pipeline:
# Canonical amd64-musl # Canonical amd64-musl
musl: musl:
image: elixir:1.13.4-alpine image: hexpm/elixir:1.13.4-erlang-24.3.4.5-alpine-3.15.6
<<: *on-release <<: *on-stable
environment: environment:
MIX_ENV: prod MIX_ENV: prod
commands: commands:
@ -157,7 +167,7 @@ pipeline:
release-musl: release-musl:
image: akkoma/releaser image: akkoma/releaser
<<: *on-release <<: *on-stable
secrets: *scw-secrets secrets: *scw-secrets
commands: commands:
- export SOURCE=akkoma-amd64-musl.zip - export SOURCE=akkoma-amd64-musl.zip

View file

@ -10,12 +10,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Ability to sync frontend profiles between clients, with a name attached - Ability to sync frontend profiles between clients, with a name attached
- Status card generation will now use the media summary if it is available - Status card generation will now use the media summary if it is available
### Updated ### Changed
- Emoji updated to latest 15.0 draft - Emoji updated to latest 15.0 draft
- **Breaking**: `/api/v1/pleroma/backups` endpoints now requires `read:backups` scope instead of `read:accounts`
### Fixed ### Fixed
- OAuthPlug no longer joins with the database every call and uses the user cache - OAuthPlug no longer joins with the database every call and uses the user cache
- Undo activities no longer try to look up by ID, and render correctly - Undo activities no longer try to look up by ID, and render correctly
- prevent false-errors from meilisearch
## 2022.09 ## 2022.09
@ -31,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed ### Changed
- MFM parsing is now done on the backend by a modified version of ilja's parser -> https://akkoma.dev/AkkomaGang/mfm-parser - MFM parsing is now done on the backend by a modified version of ilja's parser -> https://akkoma.dev/AkkomaGang/mfm-parser
- InlineQuotePolicy is now on by default - InlineQuotePolicy is now on by default
- Enable remote users to interact with posts
### Fixed ### Fixed
- Compatibility with latest meilisearch - Compatibility with latest meilisearch
@ -57,7 +60,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- amd64 is built for debian stable. Compatible with ubuntu 20. - amd64 is built for debian stable. Compatible with ubuntu 20.
- ubuntu-jammy is built for... well, ubuntu 22 (LTS) - ubuntu-jammy is built for... well, ubuntu 22 (LTS)
- amd64-musl is built for alpine 3.16 - amd64-musl is built for alpine 3.16
- Enable remote users to interact with posts
### Fixed ### Fixed
- Updated mastoFE path, for the newer version - Updated mastoFE path, for the newer version

View file

@ -48,6 +48,7 @@ config :pleroma, ecto_repos: [Pleroma.Repo]
config :pleroma, Pleroma.Repo, config :pleroma, Pleroma.Repo,
telemetry_event: [Pleroma.Repo.Instrumenter], telemetry_event: [Pleroma.Repo.Instrumenter],
queue_target: 20_000,
migration_lock: nil migration_lock: nil
config :pleroma, Pleroma.Captcha, config :pleroma, Pleroma.Captcha,
@ -753,9 +754,9 @@ config :pleroma, :frontends,
}, },
"soapbox-fe" => %{ "soapbox-fe" => %{
"name" => "soapbox-fe", "name" => "soapbox-fe",
"git" => "https://gitlab.com/soapbox-pub/soapbox-fe", "git" => "https://gitlab.com/soapbox-pub/soapbox",
"build_url" => "build_url" =>
"https://gitlab.com/soapbox-pub/soapbox-fe/-/jobs/artifacts/${ref}/download?job=build-production", "https://gitlab.com/soapbox-pub/soapbox/-/jobs/artifacts/${ref}/download?job=build-production",
"ref" => "v2.0.0", "ref" => "v2.0.0",
"build_dir" => "static" "build_dir" => "static"
}, },

View file

@ -14,6 +14,10 @@ su akkoma -s $SHELL -lc "./bin/pleroma_ctl update"
su akkoma -s $SHELL -lc "./bin/pleroma_ctl migrate" su akkoma -s $SHELL -lc "./bin/pleroma_ctl migrate"
``` ```
If you selected an alternate flavour on installation,
you _may_ need to specify `--flavour`, in the same way as
[when installing](../../installation/otp_en#detecting-flavour).
## For from source installations (using git) ## For from source installations (using git)
1. Go to the working directory of Akkoma (default is `/opt/akkoma`) 1. Go to the working directory of Akkoma (default is `/opt/akkoma`)

View file

@ -21,7 +21,7 @@ This will only save the theme for you personally. To make it available to the wh
### Upload the theme to the server ### Upload the theme to the server
Themes can be found in the [static directory](static_dir.md). Create `STATIC-DIR/static/themes/` if needed and copy your theme there. Next you need to add an entry for your theme to `STATIC-DIR/static/styles.json`. If you use a from source installation, you'll first need to copy the file from `priv/static/static/styles.json`. Themes can be found in the [static directory](static_dir.md). Create `STATIC-DIR/static/themes/` if needed and copy your theme there. Next you need to add an entry for your theme to `STATIC-DIR/static/styles.json`. If you use a from source installation, you'll first need to copy the file from `STATIC-DIR/frontends/pleroma-fe/REF/static/styles.json` (where `REF` is `stable` or `develop` depending on which ref you decided to install).
Example of `styles.json` where we add our own `my-awesome-theme.json` Example of `styles.json` where we add our own `my-awesome-theme.json`
```json ```json

View file

@ -14,11 +14,12 @@ apt -yq install tor
**WARNING:** Onion instances not using a Tor version supporting V3 addresses will not be able to federate with you. **WARNING:** Onion instances not using a Tor version supporting V3 addresses will not be able to federate with you.
Create the hidden service for your Akkoma instance in `/etc/tor/torrc`: Create the hidden service for your Akkoma instance in `/etc/tor/torrc`, with an HTTP tunnel:
``` ```
HiddenServiceDir /var/lib/tor/akkoma_hidden_service/ HiddenServiceDir /var/lib/tor/akkoma_hidden_service/
HiddenServicePort 80 127.0.0.1:8099 HiddenServicePort 80 127.0.0.1:8099
HiddenServiceVersion 3 # Remove if Tor version is below 0.3 ( tor --version ) HiddenServiceVersion 3 # Remove if Tor version is below 0.3 ( tor --version )
HTTPTunnelPort 9080
``` ```
Restart Tor to generate an adress: Restart Tor to generate an adress:
``` ```
@ -35,7 +36,7 @@ Next, edit your Akkoma config.
If running in prod, navigate to your Akkoma directory, edit `config/prod.secret.exs` If running in prod, navigate to your Akkoma directory, edit `config/prod.secret.exs`
and append this line: and append this line:
``` ```
config :pleroma, :http, proxy_url: {:socks5, :localhost, 9050} config :pleroma, :http, proxy_url: "http://localhost:9080"
``` ```
In your Akkoma directory, assuming you're running prod, In your Akkoma directory, assuming you're running prod,
run the following: run the following:

View file

@ -141,8 +141,7 @@ You then need to set the URL and authentication credentials if relevant.
### Initial indexing ### Initial indexing
After setting up the configuration, you'll want to index all of your already existsing posts. Only public posts are indexed. You'll only After setting up the configuration, you'll want to index all of your already existsing posts. You'll only have to do it one time, but it might take a while, depending on the amount of posts your instance has seen.
have to do it one time, but it might take a while, depending on the amount of posts your instance has seen.
The sequence of actions is as follows: The sequence of actions is as follows:

View file

@ -7,6 +7,20 @@ It actually consists of two components: a backend, named simply Akkoma, and a us
It's part of what we call the fediverse, a federated network of instances which speak common protocols and can communicate with each other. It's part of what we call the fediverse, a federated network of instances which speak common protocols and can communicate with each other.
One account on an instance is enough to talk to the entire fediverse! One account on an instance is enough to talk to the entire fediverse!
## Community Channels
### IRC
For support or general questions, pop over to #akkoma and #akkoma-dev at [irc.akkoma.dev](https://irc.akkoma.dev) (port 6697, SSL)
### Discourse
For more general meta-discussion, for example discussion of potential future features, head on over to [meta.akkoma.dev](https://meta.akkoma.dev)
### Dev diaries and release notifications
will be posted via [@akkoma@ihba](https://ihatebeinga.live/users/akkoma)
## How can I use it? ## How can I use it?
Akkoma instances are already widely deployed, a list can be found at <https://the-federation.info/pleroma> and <https://fediverse.network/pleroma>. Akkoma instances are already widely deployed, a list can be found at <https://the-federation.info/pleroma> and <https://fediverse.network/pleroma>.
@ -26,3 +40,4 @@ Just add a "/web" after your instance url (e.g. <https://pleroma.soykaf.com/web>
The Mastodon interface is from the Glitch-soc fork. For more information on the Mastodon interface you can check the [Mastodon](https://docs.joinmastodon.org/) and [Glitch-soc](https://glitch-soc.github.io/docs/) documentation. The Mastodon interface is from the Glitch-soc fork. For more information on the Mastodon interface you can check the [Mastodon](https://docs.joinmastodon.org/) and [Glitch-soc](https://glitch-soc.github.io/docs/) documentation.
Remember, what you see is only the frontend part of Mastodon, the backend is still Akkoma. Remember, what you see is only the frontend part of Mastodon, the backend is still Akkoma.

View file

@ -19,12 +19,12 @@ This is a little more complex than it used to be (thanks ubuntu)
Use the following mapping to figure out your flavour: Use the following mapping to figure out your flavour:
| distribution | flavour | | distribution | flavour | available branches |
| ------------- | ------------ | | ------------- | ------------------ | ------------------- |
| debian stable | amd64 | | debian stable | amd64 | develop, stable |
| ubuntu focal | amd64 | | ubuntu focal | amd64 | develop, stable |
| ubuntu jammy | ubuntu-jammy | | ubuntu jammy | amd64-ubuntu-jammy | develop, stable |
| alpine | amd64-musl | | alpine | amd64-musl | stable |
Other similar distributions will _probably_ work, but if it is not listed above, there is no official Other similar distributions will _probably_ work, but if it is not listed above, there is no official
support. support.

View file

@ -153,7 +153,7 @@ defmodule Pleroma.Search.Meilisearch do
) )
with {:ok, res} <- result, with {:ok, res} <- result,
true <- Map.has_key?(res, "uid") do true <- Map.has_key?(res, "taskUid") do
# Do nothing # Do nothing
else else
_ -> _ ->

View file

@ -94,6 +94,7 @@ defmodule Pleroma.User.Search do
|> subquery() |> subquery()
|> order_by(desc: :search_rank) |> order_by(desc: :search_rank)
|> maybe_restrict_local(for_user) |> maybe_restrict_local(for_user)
|> filter_deactivated_users()
end end
defp select_top_users(query, top_user_ids) do defp select_top_users(query, top_user_ids) do
@ -166,6 +167,10 @@ defmodule Pleroma.User.Search do
from(q in query, where: q.actor_type != "Application") from(q in query, where: q.actor_type != "Application")
end end
defp filter_deactivated_users(query) do
from(q in query, where: q.is_active == true)
end
defp filter_blocked_user(query, %User{} = blocker) do defp filter_blocked_user(query, %User{} = blocker) do
query query
|> join(:left, [u], b in Pleroma.UserRelationship, |> join(:left, [u], b in Pleroma.UserRelationship,

View file

@ -16,7 +16,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaBackupOperation do
%Operation{ %Operation{
tags: ["Backups"], tags: ["Backups"],
summary: "List backups", summary: "List backups",
security: [%{"oAuth" => ["read:account"]}], security: [%{"oAuth" => ["read:backups"]}],
operationId: "PleromaAPI.BackupController.index", operationId: "PleromaAPI.BackupController.index",
responses: %{ responses: %{
200 => 200 =>
@ -37,7 +37,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaBackupOperation do
%Operation{ %Operation{
tags: ["Backups"], tags: ["Backups"],
summary: "Create a backup", summary: "Create a backup",
security: [%{"oAuth" => ["read:account"]}], security: [%{"oAuth" => ["read:backups"]}],
operationId: "PleromaAPI.BackupController.create", operationId: "PleromaAPI.BackupController.create",
responses: %{ responses: %{
200 => 200 =>

View file

@ -9,7 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupController do
alias Pleroma.Web.Plugs.OAuthScopesPlug alias Pleroma.Web.Plugs.OAuthScopesPlug
action_fallback(Pleroma.Web.MastodonAPI.FallbackController) action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action in [:index, :create]) plug(OAuthScopesPlug, %{scopes: ["read:backups"]} when action in [:index, :create])
plug(Pleroma.Web.ApiSpec.CastAndValidate) plug(Pleroma.Web.ApiSpec.CastAndValidate)
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaBackupOperation defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaBackupOperation

View file

@ -1,7 +1,10 @@
defmodule Pleroma.Repo.Migrations.UpgradeObanToV11 do defmodule Pleroma.Repo.Migrations.UpgradeObanToV11 do
use Ecto.Migration use Ecto.Migration
def up, do: Oban.Migrations.up(version: 11) def up do
execute("UPDATE oban_jobs SET priority = 0 WHERE priority IS NULL;")
Oban.Migrations.up(version: 11)
end
def down, do: Oban.Migrations.down(version: 11) def down, do: Oban.Migrations.down(version: 11)
end end

View file

@ -0,0 +1,15 @@
defmodule Pleroma.Repo.Migrations.EnsureMastofeSettings do
use Ecto.Migration
def up do
alter table(:users) do
add_if_not_exists(:mastofe_settings, :map)
end
end
def down do
alter table(:users) do
remove_if_exists(:mastofe_settings, :map)
end
end
end

View file

@ -2,28 +2,24 @@
# XXX: This should be removed when elixir's releases get custom command support # XXX: This should be removed when elixir's releases get custom command support
detect_flavour() { detect_flavour() {
arch="$(uname -m)" arch="amd64"
if [ "$arch" = "x86_64" ]; then # Special cases
arch="amd64" if grep -qe "VERSION_CODENAME=jammy" /etc/os-release; then
elif [ "$arch" = "aarch64" ]; then echo "$arch-ubuntu-jammy"
arch="arm64" else
else if getconf GNU_LIBC_VERSION >/dev/null; then
echo "Unsupported arch: $arch" >&2 libc_postfix=""
exit 1 elif [ "$(ldd 2>&1 | head -c 9)" = "musl libc" ]; then
fi libc_postfix="-musl"
elif [ "$(find /lib/libc.musl* | wc -l)" ]; then
libc_postfix="-musl"
else
echo "Unsupported libc" >&2
exit 1
fi
if getconf GNU_LIBC_VERSION >/dev/null; then echo "$arch$libc_postfix"
libc_postfix="" fi
elif [ "$(ldd 2>&1 | head -c 9)" = "musl libc" ]; then
libc_postfix="-musl"
elif [ "$(find /lib/libc.musl* | wc -l)" ]; then
libc_postfix="-musl"
else
echo "Unsupported libc" >&2
exit 1
fi
echo "$arch$libc_postfix"
} }
detect_branch() { detect_branch() {

View file

@ -47,7 +47,7 @@ defmodule Pleroma.Search.MeilisearchTest do
Jason.decode!(body) Jason.decode!(body)
) )
json(%{updateId: 1}) json(%{taskUid: 1})
end) end)
{:ok, activity} = {:ok, activity} =
@ -100,11 +100,11 @@ defmodule Pleroma.Search.MeilisearchTest do
Jason.decode!(body) Jason.decode!(body)
) )
json(%{updateId: 1}) json(%{taskUid: 1})
%{method: :delete, url: "http://127.0.0.1:7700/indexes/objects/documents/" <> id} -> %{method: :delete, url: "http://127.0.0.1:7700/indexes/objects/documents/" <> id} ->
assert String.length(id) > 1 assert String.length(id) > 1
json(%{updateId: 2}) json(%{taskUid: 2})
end) end)
{:ok, activity} = {:ok, activity} =

View file

@ -65,6 +65,14 @@ defmodule Pleroma.UserSearchTest do
assert found_user.id == user.id assert found_user.id == user.id
end end
test "excludes deactivated users from results" do
user = insert(:user, %{nickname: "john t1000"})
insert(:user, %{is_active: false, nickname: "john t800"})
[found_user] = User.search("john")
assert found_user.id == user.id
end
# Note: as in Mastodon, `is_discoverable` doesn't anyhow relate to user searchability # Note: as in Mastodon, `is_discoverable` doesn't anyhow relate to user searchability
test "includes non-discoverable users in results" do test "includes non-discoverable users in results" do
insert(:user, %{nickname: "john 3000", is_discoverable: false}) insert(:user, %{nickname: "john 3000", is_discoverable: false})

View file

@ -11,7 +11,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
setup do setup do
clear_config([Pleroma.Upload, :uploader]) clear_config([Pleroma.Upload, :uploader])
clear_config([Backup, :limit_days]) clear_config([Backup, :limit_days])
oauth_access(["read:accounts"]) oauth_access(["read:backups"])
end end
test "GET /api/v1/pleroma/backups", %{user: user, conn: conn} do test "GET /api/v1/pleroma/backups", %{user: user, conn: conn} do
@ -85,7 +85,7 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
test "Backup without email address" do test "Backup without email address" do
user = Pleroma.Factory.insert(:user, email: nil) user = Pleroma.Factory.insert(:user, email: nil)
%{conn: conn} = oauth_access(["read:accounts"], user: user) %{conn: conn} = oauth_access(["read:backups"], user: user)
assert is_nil(user.email) assert is_nil(user.email)