Merge branch 'develop' into phoenix1.7
Some checks failed
ci/woodpecker/push/build-amd64 Pipeline is pending
ci/woodpecker/push/build-arm64 Pipeline is pending
ci/woodpecker/push/docs Pipeline is pending
ci/woodpecker/push/lint Pipeline is pending
ci/woodpecker/push/test Pipeline is pending
ci/woodpecker/pr/lint Pipeline failed
ci/woodpecker/pr/build-arm64 unknown status
ci/woodpecker/pr/build-amd64 unknown status
ci/woodpecker/pr/test unknown status
ci/woodpecker/pr/docs unknown status

This commit is contained in:
FloatingGhost 2023-08-14 11:27:34 +01:00
commit 0454275e21
10 changed files with 71 additions and 8 deletions

View file

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Added ## Added
- Full compatibility with Erlang OTP26 - Full compatibility with Erlang OTP26
- handling of GET /api/v1/preferences
## Changed ## Changed
- OTP builds are now built on erlang OTP26 - OTP builds are now built on erlang OTP26

View file

@ -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. 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 ## Pre-requisites
* 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 * A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and an `x86_64` or `arm64` 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. * 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 * A (sub)domain pointed to the machine
@ -187,18 +187,18 @@ The location of nginx configs is dependent on the distro
=== "Alpine" === "Alpine"
``` ```
cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/conf.d/akkoma.conf cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/conf.d/akkoma.conf
``` ```
=== "Debian/Ubuntu" === "Debian/Ubuntu"
``` ```
cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/sites-available/akkoma.conf cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.conf
ln -s /etc/nginx/sites-available/akkoma.conf /etc/nginx/sites-enabled/akkoma.conf ln -s /etc/nginx/sites-available/akkoma.conf /etc/nginx/sites-enabled/akkoma.conf
``` ```
If your distro does not have either of those you can append `include /etc/nginx/akkoma.conf` to the end of the http section in /etc/nginx/nginx.conf and If your distro does not have either of those you can append `include /etc/nginx/akkoma.conf` to the end of the http section in /etc/nginx/nginx.conf and
```sh ```sh
cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/akkoma.conf cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/akkoma.conf
``` ```
#### Edit the nginx config #### Edit the nginx config

View file

@ -178,7 +178,7 @@ certbot certonly --standalone --preferred-challenges http -d yourinstance.tld
#### Copy Akkoma nginx configuration to the nginx folder #### Copy Akkoma nginx configuration to the nginx folder
```shell ```shell
cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/conf.d/akkoma.conf cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/conf.d/akkoma.conf
``` ```
#### Edit the nginx config #### Edit the nginx config

View file

@ -130,6 +130,7 @@ def run(["get-packs" | args]) do
} }
File.write!(Path.join(pack_path, "pack.json"), Jason.encode!(pack_json, pretty: true)) File.write!(Path.join(pack_path, "pack.json"), Jason.encode!(pack_json, pretty: true))
Pleroma.Emoji.reload()
else else
IO.puts(IO.ANSI.format([:bright, :red, "No pack named \"#{pack_name}\" found"])) IO.puts(IO.ANSI.format([:bright, :red, "No pack named \"#{pack_name}\" found"]))
end end
@ -235,6 +236,7 @@ def run(["gen-pack" | args]) do
IO.puts("#{pack_file} has been created with the #{name} pack") IO.puts("#{pack_file} has been created with the #{name} pack")
end end
Pleroma.Emoji.reload()
end end
def run(["reload"]) do def run(["reload"]) do

View file

@ -30,12 +30,12 @@ def run(["index"]) do
meili_put( meili_put(
"/indexes/objects/settings/ranking-rules", "/indexes/objects/settings/ranking-rules",
[ [
"published:desc",
"words", "words",
"exactness",
"proximity", "proximity",
"typo", "typo",
"exactness",
"attribute", "attribute",
"published:desc",
"sort" "sort"
] ]
) )

View file

@ -451,6 +451,20 @@ def endorsements_operation do
} }
end end
def preferences_operation do
%Operation{
tags: ["Account Preferences"],
description: "Preferences defined by the user in their account settings.",
summary: "Preferred common behaviors to be shared across clients.",
operationId: "AccountController.preferences",
security: [%{"oAuth" => ["read:accounts"]}],
responses: %{
200 => Operation.response("Preferences", "application/json", Account),
401 => Operation.response("Error", "application/json", ApiError)
}
}
end
def identity_proofs_operation do def identity_proofs_operation do
%Operation{ %Operation{
tags: ["Retrieve account information"], tags: ["Retrieve account information"],

View file

@ -51,7 +51,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
plug( plug(
OAuthScopesPlug, OAuthScopesPlug,
%{scopes: ["read:accounts"]} %{scopes: ["read:accounts"]}
when action in [:verify_credentials, :endorsements, :identity_proofs] when action in [:verify_credentials, :endorsements, :identity_proofs, :preferences]
) )
plug( plug(
@ -544,4 +544,9 @@ def endorsements(conn, params), do: MastodonAPIController.empty_array(conn, para
@doc "GET /api/v1/identity_proofs" @doc "GET /api/v1/identity_proofs"
def identity_proofs(conn, params), do: MastodonAPIController.empty_array(conn, params) def identity_proofs(conn, params), do: MastodonAPIController.empty_array(conn, params)
@doc "GET /api/v1/preferences"
def preferences(%{assigns: %{user: user}} = conn, _params) do
render(conn, "preferences.json", user: user)
end
end end

View file

@ -190,6 +190,17 @@ def render("instance.json", %{instance: %Pleroma.Instances.Instance{} = instance
def render("instance.json", _), do: nil def render("instance.json", _), do: nil
def render("preferences.json", %{user: user} = _opts) do
# TODO: Do we expose more settings that make sense to plug in here?
%{
"posting:default:visibility": user.default_scope,
"posting:default:sensitive": false,
"posting:default:language": nil,
"reading:expand:media": "default",
"reading:expand:spoilers": false
}
end
defp do_render("show.json", %{user: user} = opts) do defp do_render("show.json", %{user: user} = opts) do
user = User.sanitize_html(user, User.html_filter_policy(opts[:for])) user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
display_name = user.name || user.nickname display_name = user.name || user.nickname

View file

@ -629,6 +629,8 @@ defmodule Pleroma.Web.Router do
post("/tags/:id/follow", TagController, :follow) post("/tags/:id/follow", TagController, :follow)
post("/tags/:id/unfollow", TagController, :unfollow) post("/tags/:id/unfollow", TagController, :unfollow)
get("/followed_tags", TagController, :show_followed) get("/followed_tags", TagController, :show_followed)
get("/preferences", AccountController, :preferences)
end end
scope "/api/web", Pleroma.Web do scope "/api/web", Pleroma.Web do

View file

@ -2060,4 +2060,32 @@ test "removing user from followers errors", %{user: user, conn: conn} do
assert %{"error" => "Record not found"} = json_response_and_validate_schema(conn_res, 404) assert %{"error" => "Record not found"} = json_response_and_validate_schema(conn_res, 404)
end end
end end
describe "preferences" do
test "get account preferences" do
user = insert(:user, default_scope: "public")
%{conn: conn} = oauth_access(["read:accounts"], user: user)
conn = get(conn, "/api/v1/preferences")
response = json_response_and_validate_schema(conn, 200)
assert %{
"posting:default:language" => nil,
"posting:default:sensitive" => false,
"posting:default:visibility" => "public",
"reading:expand:media" => "default",
"reading:expand:spoilers" => false
} = response
end
test "test changing account preferences" do
user = insert(:user, default_scope: "unlisted")
%{conn: conn} = oauth_access(["read:accounts"], user: user)
conn = get(conn, "/api/v1/preferences")
response = json_response_and_validate_schema(conn, 200)
assert response["posting:default:visibility"] == "unlisted"
end
end
end end