config :pleroma, :instance,
name: "Pleroma",
email: "example@example.com",
+ notify_email: "noreply@example.com",
description: "A Pleroma instance, an alternative fediverse server",
limit: 5_000,
remote_limit: 100_000,
config :pleroma, Pleroma.Mailer, adapter: Swoosh.Adapters.Test
+config :pleroma, :instance,
+ email: "admin@example.com",
+ notify_email: "noreply@example.com"
+
# Configure your database
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,
## :instance
* `name`: The instance’s name
* `email`: Email used to reach an Administrator/Moderator of the instance
+* `notify_email`: Email used for notifications.
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``
* `limit`: Posts character limit (CW/Subject included in the counter)
* `remote_limit`: Hard character limit beyond which remote posts will be dropped.
Authentication / authorization settings.
-* `auth_template`: authentication form template. By default it's `show.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/show.html.eex`.
+* `auth_template`: authentication form template. By default it's `show.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/show.html.eex`.
* `oauth_consumer_template`: OAuth consumer mode authentication form template. By default it's `consumer.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex`.
* `oauth_consumer_strategies`: the list of enabled OAuth consumer strategies; by default it's set by OAUTH_CONSUMER_STRATEGIES environment variable.
e.g. `OAUTH_CONSUMER_STRATEGIES="twitter facebook google microsoft" mix deps.get`.
The server should also be started with `OAUTH_CONSUMER_STRATEGIES="..." mix phx.server` in case you enable any strategies.
-Note: each strategy requires separate setup (on external provider side and Pleroma side). Below are the guidelines on setting up most popular strategies.
+Note: each strategy requires separate setup (on external provider side and Pleroma side). Below are the guidelines on setting up most popular strategies.
* For Twitter, [register an app](https://developer.twitter.com/en/apps), configure callback URL to https://<your_host>/oauth/twitter/callback
config :ueberauth, Ueberauth.Strategy.Microsoft.OAuth,
client_id: System.get_env("MICROSOFT_CLIENT_ID"),
client_secret: System.get_env("MICROSOFT_CLIENT_SECRET")
-
+
config :ueberauth, Ueberauth,
providers: [
microsoft: {Ueberauth.Strategy.Microsoft, [callback_params: []]}
- `--domain DOMAIN` - the domain of your instance
- `--instance-name INSTANCE_NAME` - the name of your instance
- `--admin-email ADMIN_EMAIL` - the email address of the instance admin
+ - `--notify-email NOTIFY_EMAIL` - email address for notifications
- `--dbhost HOSTNAME` - the hostname of the PostgreSQL database to use
- `--dbname DBNAME` - the name of the database to use
- `--dbuser DBUSER` - the user (aka role) to use for the database connection
- `--dbpass DBPASS` - the password to use for the database connection
+ - `--indexable Y/N` - Allow/disallow indexing site by search engines
"""
def run(["gen" | rest]) do
domain: :string,
instance_name: :string,
admin_email: :string,
+ notify_email: :string,
dbhost: :string,
dbname: :string,
dbuser: :string,
- dbpass: :string
+ dbpass: :string,
+ indexable: :string
],
aliases: [
o: :output,
will_overwrite = Enum.filter(paths, &File.exists?/1)
proceed? = Enum.empty?(will_overwrite) or Keyword.get(options, :force, false)
- unless not proceed? do
+ if proceed? do
[domain, port | _] =
String.split(
Common.get_option(
email = Common.get_option(options, :admin_email, "What is your admin email address?")
+ notify_email =
+ Common.get_option(
+ options,
+ :notify_email,
+ "What email address do you want to use for sending email notifications?",
+ email
+ )
+
indexable =
Common.get_option(
options,
domain: domain,
port: port,
email: email,
+ notify_email: notify_email,
name: name,
dbhost: dbhost,
dbname: dbname,
config :pleroma, :instance,
name: "<%= name %>",
email: "<%= email %>",
+ notify_email: "<%= notify_email %>",
limit: 5000,
registrations_open: true,
dedupe_media: false
# storage_url: "https://swift-endpoint.prodider.com/v1/AUTH_<tenant>/<container>",
# object_url: "https://cdn-endpoint.provider.com/<container>"
#
-
defp instance_config, do: Pleroma.Config.get(:instance)
defp instance_name, do: instance_config()[:name]
- defp instance_email, do: instance_config()[:email]
+ defp instance_notify_email, do: instance_config()[:notify_email]
defp user_url(user) do
Helpers.o_status_url(Pleroma.Web.Endpoint, :feed_redirect, user.nickname)
new()
|> to({to.name, to.email})
- |> from({instance_name(), instance_email()})
+ |> from({instance_name(), instance_notify_email()})
|> reply_to({reporter.name, reporter.email})
|> subject("#{instance_name()} Report")
|> html_body(html_body)
defp instance_name, do: instance_config()[:name]
defp sender do
- {instance_name(), instance_config()[:email]}
+ {instance_name(), instance_config()[:notify_email]}
end
defp recipient(email, nil), do: email
--- /dev/null
+defmodule Pleroma.InstanceTest do
+ use ExUnit.Case, async: true
+
+ setup do
+ File.mkdir_p!(tmp_path())
+ on_exit(fn -> File.rm_rf(tmp_path()) end)
+ :ok
+ end
+
+ defp tmp_path do
+ "/tmp/generated_files/"
+ end
+
+ test "running gen" do
+ mix_task = fn ->
+ Mix.Tasks.Pleroma.Instance.run([
+ "gen",
+ "--output",
+ tmp_path() <> "generated_config.exs",
+ "--output-psql",
+ tmp_path() <> "setup.psql",
+ "--domain",
+ "test.pleroma.social",
+ "--instance-name",
+ "Pleroma",
+ "--admin-email",
+ "admin@example.com",
+ "--notify-email",
+ "notify@example.com",
+ "--dbhost",
+ "dbhost",
+ "--dbname",
+ "dbname",
+ "--dbuser",
+ "dbuser",
+ "--dbpass",
+ "dbpass",
+ "--indexable",
+ "y"
+ ])
+ end
+
+ ExUnit.CaptureIO.capture_io(fn ->
+ mix_task.()
+ end)
+
+ generated_config = File.read!(tmp_path() <> "generated_config.exs")
+ assert generated_config =~ "host: \"test.pleroma.social\""
+ assert generated_config =~ "name: \"Pleroma\""
+ assert generated_config =~ "email: \"admin@example.com\""
+ assert generated_config =~ "notify_email: \"notify@example.com\""
+ assert generated_config =~ "hostname: \"dbhost\""
+ assert generated_config =~ "database: \"dbname\""
+ assert generated_config =~ "username: \"dbuser\""
+ assert generated_config =~ "password: \"dbpass\""
+ assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
+ end
+
+ defp generated_setup_psql do
+ ~s(CREATE USER dbuser WITH ENCRYPTED PASSWORD 'dbpass';\nCREATE DATABASE dbname OWNER dbuser;\n\\c dbname;\n--Extensions made by ecto.migrate that need superuser access\nCREATE EXTENSION IF NOT EXISTS citext;\nCREATE EXTENSION IF NOT EXISTS pg_trgm;\nCREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";\n)
+ end
+end
assert token_record
refute token_record.used
- Swoosh.TestAssertions.assert_email_sent(
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ email =
Pleroma.UserEmail.user_invitation_email(
user,
token_record,
recipient_email,
recipient_name
)
+
+ Swoosh.TestAssertions.assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {recipient_name, recipient_email},
+ html_body: email.html_body
)
end
conn = get(conn, "/api/v1/instance")
assert result = json_response(conn, 200)
+ email = Pleroma.Config.get([:instance, :email])
# Note: not checking for "max_toot_chars" since it's optional
assert %{
"uri" => _,
"title" => _,
"description" => _,
"version" => _,
- "email" => _,
+ "email" => from_config_email,
"urls" => %{
"streaming_api" => _
},
"languages" => _,
"registrations" => _
} = result
+
+ assert email == from_config_email
end
test "get instance stats", %{conn: conn} do
alias Pleroma.Web.TwitterAPI.TwitterAPI
alias Pleroma.Web.TwitterAPI.UserView
- import Pleroma.Factory
import Mock
+ import Pleroma.Factory
+ import Swoosh.TestAssertions
@banner "data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"
test "it sends an email to user", %{user: user} do
token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id)
- Swoosh.TestAssertions.assert_email_sent(
- Pleroma.UserEmail.password_reset_email(user, token_record.token)
+ email = Pleroma.UserEmail.password_reset_email(user, token_record.token)
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: email.html_body
)
end
end
|> assign(:user, user)
|> post("/api/account/resend_confirmation_email?email=#{user.email}")
- Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
+ email = Pleroma.UserEmail.account_confirmation_email(user)
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: email.html_body
+ )
end
end
assert user.info.confirmation_pending
- Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
+ email = Pleroma.UserEmail.account_confirmation_email(user)
+
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ Swoosh.TestAssertions.assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: email.html_body
+ )
end
test "it registers a new user and parses mentions in the bio" do