aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex6
-rw-r--r--lib/pleroma/web/federator/federator.ex12
-rw-r--r--lib/pleroma/web/router.ex36
3 files changed, 33 insertions, 21 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index c3fce17de..a503a5b3f 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -99,7 +99,7 @@ defmodule Pleroma.User do
|> cast(params, [:bio, :name])
|> unique_constraint(:nickname)
|> validate_format(:nickname, ~r/^[a-zA-Z\d]+$/)
- |> validate_length(:bio, min: 1, max: 5000)
+ |> validate_length(:bio, max: 1000)
|> validate_length(:name, min: 1, max: 100)
end
@@ -134,13 +134,13 @@ defmodule Pleroma.User do
def register_changeset(struct, params \\ %{}) do
changeset = struct
|> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation])
- |> validate_required([:bio, :email, :name, :nickname, :password, :password_confirmation])
+ |> validate_required([:email, :name, :nickname, :password, :password_confirmation])
|> validate_confirmation(:password)
|> unique_constraint(:email)
|> unique_constraint(:nickname)
|> validate_format(:nickname, ~r/^[a-zA-Z\d]+$/)
|> validate_format(:email, @email_regex)
- |> validate_length(:bio, min: 1, max: 1000)
+ |> validate_length(:bio, max: 1000)
|> validate_length(:name, min: 1, max: 100)
if changeset.valid? do
diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex
index 0b9808b8f..daf836a40 100644
--- a/lib/pleroma/web/federator/federator.ex
+++ b/lib/pleroma/web/federator/federator.ex
@@ -10,6 +10,8 @@ defmodule Pleroma.Web.Federator do
@websub Application.get_env(:pleroma, :websub)
@ostatus Application.get_env(:pleroma, :ostatus)
@httpoison Application.get_env(:pleroma, :httpoison)
+ @instance Application.get_env(:pleroma, :instance)
+ @federating Keyword.get(@instance, :federating)
@max_jobs 10
def start_link do
@@ -107,10 +109,12 @@ defmodule Pleroma.Web.Federator do
end
def enqueue(type, payload, priority \\ 1) do
- if Mix.env == :test do
- handle(type, payload)
- else
- GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})
+ if @federating do
+ if Mix.env == :test do
+ handle(type, payload)
+ else
+ GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})
+ end
end
end
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 8d93e1ea6..520ac4a8c 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -3,6 +3,9 @@ defmodule Pleroma.Web.Router do
alias Pleroma.{Repo, User, Web.Router}
+ @instance Application.get_env(:pleroma, :instance)
+ @federating Keyword.get(@instance, :federating)
+
def user_fetcher(username) do
{:ok, Repo.get_by(User, %{nickname: username})}
end
@@ -228,13 +231,16 @@ defmodule Pleroma.Web.Router do
get "/objects/:uuid", OStatus.OStatusController, :object
get "/activities/:uuid", OStatus.OStatusController, :activity
get "/notice/:id", OStatus.OStatusController, :notice
-
get "/users/:nickname/feed", OStatus.OStatusController, :feed
get "/users/:nickname", OStatus.OStatusController, :feed_redirect
- post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
- post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
- get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
- post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
+
+ if @federating do
+ post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
+ post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
+ get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
+ post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
+ end
+
end
pipeline :activitypub do
@@ -242,17 +248,19 @@ defmodule Pleroma.Web.Router do
plug Pleroma.Web.Plugs.HTTPSignaturePlug
end
- scope "/", Pleroma.Web.ActivityPub do
- pipe_through :activitypub
- post "/users/:nickname/inbox", ActivityPubController, :inbox
- post "/inbox", ActivityPubController, :inbox
- end
+ if @federating do
+ scope "/", Pleroma.Web.ActivityPub do
+ pipe_through :activitypub
+ post "/users/:nickname/inbox", ActivityPubController, :inbox
+ post "/inbox", ActivityPubController, :inbox
+ end
- scope "/.well-known", Pleroma.Web do
- pipe_through :well_known
+ scope "/.well-known", Pleroma.Web do
+ pipe_through :well_known
- get "/host-meta", WebFinger.WebFingerController, :host_meta
- get "/webfinger", WebFinger.WebFingerController, :webfinger
+ get "/host-meta", WebFinger.WebFingerController, :host_meta
+ get "/webfinger", WebFinger.WebFingerController, :webfinger
+ end
end
scope "/", Pleroma.Web.MastodonAPI do