aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/dev.exs1
-rwxr-xr-xinstallation/netbsd/rc.d/pleroma57
-rw-r--r--installation/openbsd/httpd.conf36
-rwxr-xr-xinstallation/openbsd/rc.d/pleromad34
-rw-r--r--installation/openbsd/relayd.conf44
-rw-r--r--lib/mix/tasks/pleroma/instance.ex16
-rw-r--r--lib/mix/tasks/pleroma/sample_config.eex2
-rw-r--r--lib/pleroma/user/info.ex5
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex8
-rw-r--r--lib/pleroma/web/twitter_api/views/activity_view.ex6
-rw-r--r--mix.exs7
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs14
12 files changed, 213 insertions, 17 deletions
diff --git a/config/dev.exs b/config/dev.exs
index 080a2f8db..8f89aa03c 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -12,6 +12,7 @@ config :pleroma, Pleroma.Web.Endpoint,
protocol_options: [max_request_line_length: 8192, max_header_value_length: 8192]
],
protocol: "http",
+ secure_cookie_flag: false,
debug_errors: true,
code_reloader: true,
check_origin: false,
diff --git a/installation/netbsd/rc.d/pleroma b/installation/netbsd/rc.d/pleroma
new file mode 100755
index 000000000..1114668ee
--- /dev/null
+++ b/installation/netbsd/rc.d/pleroma
@@ -0,0 +1,57 @@
+#!/bin/sh
+# PROVIDE: pleroma
+# REQUIRE: DAEMON pgsql
+
+if [ -f /etc/rc.subr ]; then
+ . /etc/rc.subr
+fi
+
+name="pleroma"
+rcvar=${name}
+command="/usr/pkg/bin/elixir"
+command_args="--detached -S /usr/pkg/bin/mix phx.server"
+start_precmd="ulimit -n unlimited"
+pidfile="/dev/null"
+
+pleroma_chdir="${pleroma_home}/pleroma"
+pleroma_env="HOME=${pleroma_home} MIX_ENV=prod"
+
+check_pidfile()
+{
+ pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$)
+ echo -n "${pid}"
+}
+
+if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ # newer NetBSD
+ load_rc_config ${name}
+ run_rc_command "$1"
+else
+ # ancient NetBSD, Solaris and illumos, Linux, etc...
+ cmd=${1:-start}
+
+ case ${cmd} in
+ start)
+ echo "Starting ${name}."
+ ${start_cmd}
+ ;;
+
+ stop)
+ echo "Stopping ${name}."
+ check_pidfile
+ ! [ -n ${pid} ] && kill ${pid}
+ ;;
+
+ restart)
+ ( $0 stop )
+ sleep 5
+ $0 start
+ ;;
+
+ *)
+ echo 1>&2 "Usage: $0 [start|stop|restart]"
+ exit 1
+ ;;
+ esac
+ exit 0
+fi
diff --git a/installation/openbsd/httpd.conf b/installation/openbsd/httpd.conf
new file mode 100644
index 000000000..82f4803fd
--- /dev/null
+++ b/installation/openbsd/httpd.conf
@@ -0,0 +1,36 @@
+#
+# Default httpd.conf file for Pleroma on OpenBSD
+# Simple installation instructions
+# 1. Place file in /etc
+# 2. Replace <IPv4 address> with your public IP address
+# 3. If using IPv6, uncomment IPv6 lines and replace <IPv6 address> with your public IPv6 address
+# 4. Check file using 'doas httpd -n'
+# 5. Enable and start httpd:
+# # doas rcctl enable httpd
+# # doas rcctl start httpd
+#
+
+ext_inet="<IPv4 address>"
+#ext_inet6="<IPv6 address>"
+
+server "default" {
+ listen on $ext_inet port 80 # Comment to disable listening on IPv4
+# listen on $ext_inet6 port 80 # Comment to disable listening on IPv6
+ listen on 127.0.0.1 port 80 # Do NOT comment this line
+
+ log syslog
+ directory no index
+
+ location "/.well-known/acme-challenge/*" {
+ root "/acme"
+ request strip 2
+ }
+
+ location "/robots.txt" { root "/htdocs/local/" }
+ location "/*" { block return 302 "https://$HTTP_HOST$REQUEST_URI" }
+}
+
+types {
+ include "/usr/share/misc/mime.types"
+}
+
diff --git a/installation/openbsd/rc.d/pleromad b/installation/openbsd/rc.d/pleromad
new file mode 100755
index 000000000..19ac4bb51
--- /dev/null
+++ b/installation/openbsd/rc.d/pleromad
@@ -0,0 +1,34 @@
+#!/bin/ksh
+#
+# Default init file for Pleroma on OpenBSD
+#
+# Simple installation instructions:
+# 1. Install Pleroma per wiki instructions
+# 2. Place this pleromad file in /etc/rc.d
+# 3. Enable and start Pleroma
+# # doas rcctl enable pleromad
+# # doas rcctl start pleromad
+#
+
+daemon="/usr/local/bin/elixir"
+daemon_flags="--detached -S /usr/local/bin/mix phx.server"
+daemon_user="_pleroma"
+
+. /etc/rc.d/rc.subr
+
+rc_reload=NO
+pexp="phx.server"
+
+rc_check() {
+ pgrep -q -U _pleroma -f "phx.server"
+}
+
+rc_start() {
+ ${rcexec} "cd pleroma; ${daemon} ${daemon_flags}"
+}
+
+rc_stop() {
+ pkill -q -U _pleroma -f "phx.server"
+}
+
+rc_cmd $1
diff --git a/installation/openbsd/relayd.conf b/installation/openbsd/relayd.conf
new file mode 100644
index 000000000..31c2c1129
--- /dev/null
+++ b/installation/openbsd/relayd.conf
@@ -0,0 +1,44 @@
+#
+# Default relayd.conf file for Pleroma on OpenBSD
+# Simple installation instructions:
+# 1. Place in /etc
+# 2. Replace <ipaddr> with your public IPv4 address
+# 3. If using IPv6i, uncomment IPv6 lines and replace <ip6addr> with your public IPv6 address
+# 4. Check file using 'doas relayd -n'
+# 5. Reload/start relayd
+# # doas rcctl enable relayd
+# # doas rcctl start relayd
+#
+
+ext_inet="<ipaddr>"
+#ext_inet6="<ip6addr>"
+
+table <pleroma_server> { 127.0.0.1 }
+table <httpd_server> { 127.0.0.1 }
+
+http protocol plerup { # Protocol for upstream pleroma server
+ #tcp { nodelay, sack, socket buffer 65536, backlog 128 } # Uncomment and adjust as you see fit
+ tls ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA0-POLY1305"
+ tls ecdhe secp384r1
+
+ # Forward some paths to the local server (as pleroma won't respond to them as you might want)
+ pass request quick path "/robots.txt" forward to <httpd_server>
+
+ # Append a bunch of headers
+ match request header append "X-Forwarded-For" value "$REMOTE_ADDR" # This two header and the next one are not strictl required by pleroma but adding them won't hurt
+ match request header append "X-Forwarded-By" value "$SERVER_ADDR:$SERVER_PORT"
+
+ match request header append "Connection" value "upgrade"
+
+}
+
+relay wwwtls {
+ listen on $ext_inet port https tls # Comment to disable listening on IPv4
+# listen on $ext_inet6 port https tls # Comment to disable listening on IPv6
+
+ protocol plerup
+
+ forward to <pleroma_server> port 4000 check http "/" code 200
+ forward to <httpd_server> port 80 check http "/robots.txt" code 200
+}
+
diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex
index 3be856115..02e1ce27d 100644
--- a/lib/mix/tasks/pleroma/instance.ex
+++ b/lib/mix/tasks/pleroma/instance.ex
@@ -58,12 +58,15 @@ defmodule Mix.Tasks.Pleroma.Instance do
proceed? = Enum.empty?(will_overwrite) or Keyword.get(options, :force, false)
unless not proceed? do
- domain =
- Common.get_option(
- options,
- :domain,
- "What domain will your instance use? (e.g pleroma.soykaf.com)"
- )
+ [domain, port | _] =
+ String.split(
+ Common.get_option(
+ options,
+ :domain,
+ "What domain will your instance use? (e.g pleroma.soykaf.com)"
+ ),
+ ":"
+ ) ++ [443]
name =
Common.get_option(
@@ -104,6 +107,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
EEx.eval_file(
"sample_config.eex" |> Path.expand(__DIR__),
domain: domain,
+ port: port,
email: email,
name: name,
dbhost: dbhost,
diff --git a/lib/mix/tasks/pleroma/sample_config.eex b/lib/mix/tasks/pleroma/sample_config.eex
index 0cd572797..740b9f8d1 100644
--- a/lib/mix/tasks/pleroma/sample_config.eex
+++ b/lib/mix/tasks/pleroma/sample_config.eex
@@ -6,7 +6,7 @@
use Mix.Config
config :pleroma, Pleroma.Web.Endpoint,
- url: [host: "<%= domain %>", scheme: "https", port: 443],
+ url: [host: "<%= domain %>", scheme: "https", port: <%= port %>],
secret_key_base: "<%= secret %>"
config :pleroma, :instance,
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index d81b45b8d..a3785447c 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -149,9 +149,12 @@ defmodule Pleroma.User.Info do
])
end
- def mastodon_settings_update(info, params) do
+ def mastodon_settings_update(info, settings) do
+ params = %{settings: settings}
+
info
|> cast(params, [:settings])
+ |> validate_required([:settings])
end
def set_source_data(info, source_data) do
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 0414d73d8..726807f0a 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -929,7 +929,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
]
},
settings:
- Map.get(user.info, :settings) ||
+ user.info.settings ||
%{
onboarded: true,
home: %{
@@ -978,13 +978,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do
info_cng = User.Info.mastodon_settings_update(user.info, settings)
- with changeset <- User.update_changeset(user),
+ with changeset <- Ecto.Changeset.change(user),
changeset <- Ecto.Changeset.put_embed(changeset, :info, info_cng),
{:ok, _user} <- User.update_and_set_cache(changeset) do
json(conn, %{})
else
e ->
- json(conn, %{error: inspect(e)})
+ conn
+ |> put_resp_content_type("application/json")
+ |> send_resp(500, Jason.encode!(%{"error" => inspect(e)}))
end
end
diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex
index 433c3b141..0699bf1da 100644
--- a/lib/pleroma/web/twitter_api/views/activity_view.ex
+++ b/lib/pleroma/web/twitter_api/views/activity_view.ex
@@ -14,6 +14,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
alias Pleroma.HTML
import Ecto.Query
+ require Logger
defp query_context_ids([]), do: []
@@ -277,6 +278,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
}
end
+ def render("activity.json", %{activity: unhandled_activity}) do
+ Logger.warn("#{__MODULE__} unhandled activity: #{inspect(unhandled_activity)}")
+ nil
+ end
+
def render_content(%{"type" => "Note"} = object) do
summary = object["summary"]
diff --git a/mix.exs b/mix.exs
index a8a171eb9..5b56b9490 100644
--- a/mix.exs
+++ b/mix.exs
@@ -8,12 +8,7 @@ defmodule Pleroma.Mixfile do
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
- elixirc_options:
- if Mix.env() == :test do
- []
- else
- [warnings_as_errors: true]
- end,
+ elixirc_options: [warnings_as_errors: true],
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index e8275d4ab..aec0f851c 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -1415,4 +1415,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert result["stats"]["user_count"] == 2
assert result["stats"]["status_count"] == 1
end
+
+ test "put settings", %{conn: conn} do
+ user = insert(:user)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> put("/api/web/settings", %{"data" => %{"programming" => "socks"}})
+
+ assert result = json_response(conn, 200)
+
+ user = User.get_cached_by_ap_id(user.ap_id)
+ assert user.info.settings == %{"programming" => "socks"}
+ end
end