Merge branch 'develop' into feature/polls-2-electric-boogalo
This commit is contained in:
commit
026b245dbc
|
@ -0,0 +1 @@
|
||||||
|
https://github.com/hashnuke/heroku-buildpack-elixir
|
|
@ -95,3 +95,50 @@ docs-deploy:
|
||||||
- eval $(ssh-agent -s)
|
- eval $(ssh-agent -s)
|
||||||
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||||
- rsync -hrvz --delete -e "ssh -p ${SSH_PORT}" priv/static/doc/ "${SSH_USER_HOST_LOCATION}/${CI_COMMIT_REF_NAME}"
|
- rsync -hrvz --delete -e "ssh -p ${SSH_PORT}" priv/static/doc/ "${SSH_USER_HOST_LOCATION}/${CI_COMMIT_REF_NAME}"
|
||||||
|
|
||||||
|
review_app:
|
||||||
|
image: alpine:3.9
|
||||||
|
stage: deploy
|
||||||
|
before_script:
|
||||||
|
- apk update && apk add openssh-client git
|
||||||
|
when: manual
|
||||||
|
environment:
|
||||||
|
name: review/$CI_COMMIT_REF_NAME
|
||||||
|
url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
|
||||||
|
on_stop: stop_review_app
|
||||||
|
only:
|
||||||
|
- branches
|
||||||
|
except:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
script:
|
||||||
|
- echo "$CI_ENVIRONMENT_SLUG"
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||||
|
- ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
|
||||||
|
- (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
|
||||||
|
- ssh -t dokku@pleroma.online -- config:set "$CI_ENVIRONMENT_SLUG" APP_NAME="$CI_ENVIRONMENT_SLUG" APP_HOST="$CI_ENVIRONMENT_SLUG.pleroma.online" MIX_ENV=dokku
|
||||||
|
- (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
|
||||||
|
- (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
|
||||||
|
- (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
|
||||||
|
- (git remote add dokku dokku@pleroma.online:$CI_ENVIRONMENT_SLUG) || true
|
||||||
|
- git push -f dokku $CI_COMMIT_SHA:refs/heads/master
|
||||||
|
|
||||||
|
stop_review_app:
|
||||||
|
image: alpine:3.9
|
||||||
|
stage: deploy
|
||||||
|
before_script:
|
||||||
|
- apk update && apk add openssh-client git
|
||||||
|
when: manual
|
||||||
|
environment:
|
||||||
|
name: review/$CI_COMMIT_REF_NAME
|
||||||
|
action: stop
|
||||||
|
script:
|
||||||
|
- echo "$CI_ENVIRONMENT_SLUG"
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||||
|
- ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
|
||||||
|
- ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
|
||||||
|
- ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
use Mix.Config
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
|
http: [
|
||||||
|
port: String.to_integer(System.get_env("PORT") || "4000"),
|
||||||
|
protocol_options: [max_request_line_length: 8192, max_header_value_length: 8192]
|
||||||
|
],
|
||||||
|
protocol: "http",
|
||||||
|
secure_cookie_flag: false,
|
||||||
|
url: [host: System.get_env("APP_HOST"), scheme: "https", port: 443],
|
||||||
|
secret_key_base: "+S+ULgf7+N37c/lc9K66SMphnjQIRGklTu0BRr2vLm2ZzvK0Z6OH/PE77wlUNtvP"
|
||||||
|
|
||||||
|
database_url =
|
||||||
|
System.get_env("DATABASE_URL") ||
|
||||||
|
raise """
|
||||||
|
environment variable DATABASE_URL is missing.
|
||||||
|
For example: ecto://USER:PASS@HOST/DATABASE
|
||||||
|
"""
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Repo,
|
||||||
|
# ssl: true,
|
||||||
|
url: database_url,
|
||||||
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||||
|
|
||||||
|
config :pleroma, :instance, name: "#{System.get_env("APP_NAME")} CI Instance"
|
|
@ -126,20 +126,6 @@ Request parameters can be passed via [query strings](https://en.wikipedia.org/wi
|
||||||
## `/api/pleroma/admin/`…
|
## `/api/pleroma/admin/`…
|
||||||
See [Admin-API](Admin-API.md)
|
See [Admin-API](Admin-API.md)
|
||||||
|
|
||||||
## `/api/v1/pleroma/flavour/:flavour`
|
|
||||||
* Method `POST`
|
|
||||||
* Authentication: required
|
|
||||||
* Response: JSON string. Returns the user flavour or the default one on success, otherwise returns `{"error": "error_msg"}`
|
|
||||||
* Example response: "glitch"
|
|
||||||
* Note: This is intended to be used only by mastofe
|
|
||||||
|
|
||||||
## `/api/v1/pleroma/flavour`
|
|
||||||
* Method `GET`
|
|
||||||
* Authentication: required
|
|
||||||
* Response: JSON string. Returns the user flavour or the default one.
|
|
||||||
* Example response: "glitch"
|
|
||||||
* Note: This is intended to be used only by mastofe
|
|
||||||
|
|
||||||
## `/api/pleroma/notifications/read`
|
## `/api/pleroma/notifications/read`
|
||||||
### Mark a single notification as read
|
### Mark a single notification as read
|
||||||
* Method `POST`
|
* Method `POST`
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
elixir_version=1.8.2
|
||||||
|
erlang_version=21.3.7
|
|
@ -171,7 +171,16 @@ def get_notified_from_activity(
|
||||||
def get_notified_from_activity(_, _local_only), do: []
|
def get_notified_from_activity(_, _local_only), do: []
|
||||||
|
|
||||||
def skip?(activity, user) do
|
def skip?(activity, user) do
|
||||||
[:self, :blocked, :local, :muted, :followers, :follows, :recently_followed]
|
[
|
||||||
|
:self,
|
||||||
|
:blocked,
|
||||||
|
:muted,
|
||||||
|
:followers,
|
||||||
|
:follows,
|
||||||
|
:non_followers,
|
||||||
|
:non_follows,
|
||||||
|
:recently_followed
|
||||||
|
]
|
||||||
|> Enum.any?(&skip?(&1, activity, user))
|
|> Enum.any?(&skip?(&1, activity, user))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -184,12 +193,6 @@ def skip?(:blocked, activity, user) do
|
||||||
User.blocks?(user, %{ap_id: actor})
|
User.blocks?(user, %{ap_id: actor})
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(:local, %{local: true}, %{info: %{notification_settings: %{"local" => false}}}),
|
|
||||||
do: true
|
|
||||||
|
|
||||||
def skip?(:local, %{local: false}, %{info: %{notification_settings: %{"remote" => false}}}),
|
|
||||||
do: true
|
|
||||||
|
|
||||||
def skip?(:muted, activity, user) do
|
def skip?(:muted, activity, user) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
|
|
||||||
|
@ -206,12 +209,32 @@ def skip?(
|
||||||
User.following?(follower, user)
|
User.following?(follower, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def skip?(
|
||||||
|
:non_followers,
|
||||||
|
activity,
|
||||||
|
%{info: %{notification_settings: %{"non_followers" => false}}} = user
|
||||||
|
) do
|
||||||
|
actor = activity.data["actor"]
|
||||||
|
follower = User.get_cached_by_ap_id(actor)
|
||||||
|
!User.following?(follower, user)
|
||||||
|
end
|
||||||
|
|
||||||
def skip?(:follows, activity, %{info: %{notification_settings: %{"follows" => false}}} = user) do
|
def skip?(:follows, activity, %{info: %{notification_settings: %{"follows" => false}}} = user) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
followed = User.get_cached_by_ap_id(actor)
|
followed = User.get_cached_by_ap_id(actor)
|
||||||
User.following?(user, followed)
|
User.following?(user, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def skip?(
|
||||||
|
:non_follows,
|
||||||
|
activity,
|
||||||
|
%{info: %{notification_settings: %{"non_follows" => false}}} = user
|
||||||
|
) do
|
||||||
|
actor = activity.data["actor"]
|
||||||
|
followed = User.get_cached_by_ap_id(actor)
|
||||||
|
!User.following?(user, followed)
|
||||||
|
end
|
||||||
|
|
||||||
def skip?(:recently_followed, %{data: %{"type" => "Follow"}} = activity, user) do
|
def skip?(:recently_followed, %{data: %{"type" => "Follow"}} = activity, user) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ defmodule Pleroma.ReverseProxy do
|
||||||
* `http`: options for [hackney](https://github.com/benoitc/hackney).
|
* `http`: options for [hackney](https://github.com/benoitc/hackney).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@hackney Pleroma.Config.get(:hackney, :hackney)
|
|
||||||
|
|
||||||
@default_hackney_options []
|
@default_hackney_options []
|
||||||
|
|
||||||
@inline_content_types [
|
@inline_content_types [
|
||||||
|
@ -148,7 +146,7 @@ defp request(method, url, headers, hackney_opts) do
|
||||||
Logger.debug("#{__MODULE__} #{method} #{url} #{inspect(headers)}")
|
Logger.debug("#{__MODULE__} #{method} #{url} #{inspect(headers)}")
|
||||||
method = method |> String.downcase() |> String.to_existing_atom()
|
method = method |> String.downcase() |> String.to_existing_atom()
|
||||||
|
|
||||||
case @hackney.request(method, url, headers, "", hackney_opts) do
|
case :hackney.request(method, url, headers, "", hackney_opts) do
|
||||||
{:ok, code, headers, client} when code in @valid_resp_codes ->
|
{:ok, code, headers, client} when code in @valid_resp_codes ->
|
||||||
{:ok, code, downcase_headers(headers), client}
|
{:ok, code, downcase_headers(headers), client}
|
||||||
|
|
||||||
|
@ -198,7 +196,7 @@ defp chunk_reply(conn, client, opts, sent_so_far, duration) do
|
||||||
duration,
|
duration,
|
||||||
Keyword.get(opts, :max_read_duration, @max_read_duration)
|
Keyword.get(opts, :max_read_duration, @max_read_duration)
|
||||||
),
|
),
|
||||||
{:ok, data} <- @hackney.stream_body(client),
|
{:ok, data} <- :hackney.stream_body(client),
|
||||||
{:ok, duration} <- increase_read_duration(duration),
|
{:ok, duration} <- increase_read_duration(duration),
|
||||||
sent_so_far = sent_so_far + byte_size(data),
|
sent_so_far = sent_so_far + byte_size(data),
|
||||||
:ok <- body_size_constraint(sent_so_far, Keyword.get(opts, :max_body_size)),
|
:ok <- body_size_constraint(sent_so_far, Keyword.get(opts, :max_body_size)),
|
||||||
|
|
|
@ -42,12 +42,16 @@ defmodule Pleroma.User.Info do
|
||||||
field(:hide_follows, :boolean, default: false)
|
field(:hide_follows, :boolean, default: false)
|
||||||
field(:hide_favorites, :boolean, default: true)
|
field(:hide_favorites, :boolean, default: true)
|
||||||
field(:pinned_activities, {:array, :string}, default: [])
|
field(:pinned_activities, {:array, :string}, default: [])
|
||||||
field(:flavour, :string, default: nil)
|
|
||||||
field(:mascot, :map, default: nil)
|
field(:mascot, :map, default: nil)
|
||||||
field(:emoji, {:array, :map}, default: [])
|
field(:emoji, {:array, :map}, default: [])
|
||||||
|
|
||||||
field(:notification_settings, :map,
|
field(:notification_settings, :map,
|
||||||
default: %{"remote" => true, "local" => true, "followers" => true, "follows" => true}
|
default: %{
|
||||||
|
"followers" => true,
|
||||||
|
"follows" => true,
|
||||||
|
"non_follows" => true,
|
||||||
|
"non_followers" => true
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Found in the wild
|
# Found in the wild
|
||||||
|
@ -68,10 +72,15 @@ def set_activation_status(info, deactivated) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_notification_settings(info, settings) do
|
def update_notification_settings(info, settings) do
|
||||||
|
settings =
|
||||||
|
settings
|
||||||
|
|> Enum.map(fn {k, v} -> {k, v in [true, "true", "True", "1"]} end)
|
||||||
|
|> Map.new()
|
||||||
|
|
||||||
notification_settings =
|
notification_settings =
|
||||||
info.notification_settings
|
info.notification_settings
|
||||||
|> Map.merge(settings)
|
|> Map.merge(settings)
|
||||||
|> Map.take(["remote", "local", "followers", "follows"])
|
|> Map.take(["followers", "follows", "non_follows", "non_followers"])
|
||||||
|
|
||||||
params = %{notification_settings: notification_settings}
|
params = %{notification_settings: notification_settings}
|
||||||
|
|
||||||
|
@ -241,14 +250,6 @@ def mastodon_settings_update(info, settings) do
|
||||||
|> validate_required([:settings])
|
|> validate_required([:settings])
|
||||||
end
|
end
|
||||||
|
|
||||||
def mastodon_flavour_update(info, flavour) do
|
|
||||||
params = %{flavour: flavour}
|
|
||||||
|
|
||||||
info
|
|
||||||
|> cast(params, [:flavour])
|
|
||||||
|> validate_required([:flavour])
|
|
||||||
end
|
|
||||||
|
|
||||||
def mascot_update(info, url) do
|
def mascot_update(info, url) do
|
||||||
params = %{mascot: url}
|
params = %{mascot: url}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,11 @@ def fix_addressing_list(map, field) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mentions) do
|
def fix_explicit_addressing(
|
||||||
|
%{"to" => to, "cc" => cc} = object,
|
||||||
|
explicit_mentions,
|
||||||
|
follower_collection
|
||||||
|
) do
|
||||||
explicit_to =
|
explicit_to =
|
||||||
to
|
to
|
||||||
|> Enum.filter(fn x -> x in explicit_mentions end)
|
|> Enum.filter(fn x -> x in explicit_mentions end)
|
||||||
|
@ -77,6 +81,7 @@ def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mention
|
||||||
|
|
||||||
final_cc =
|
final_cc =
|
||||||
(cc ++ explicit_cc)
|
(cc ++ explicit_cc)
|
||||||
|
|> Enum.reject(fn x -> String.ends_with?(x, "/followers") and x != follower_collection end)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|
|
||||||
object
|
object
|
||||||
|
@ -84,7 +89,7 @@ def fix_explicit_addressing(%{"to" => to, "cc" => cc} = object, explicit_mention
|
||||||
|> Map.put("cc", final_cc)
|
|> Map.put("cc", final_cc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_explicit_addressing(object, _explicit_mentions), do: object
|
def fix_explicit_addressing(object, _explicit_mentions, _followers_collection), do: object
|
||||||
|
|
||||||
# if directMessage flag is set to true, leave the addressing alone
|
# if directMessage flag is set to true, leave the addressing alone
|
||||||
def fix_explicit_addressing(%{"directMessage" => true} = object), do: object
|
def fix_explicit_addressing(%{"directMessage" => true} = object), do: object
|
||||||
|
@ -99,8 +104,7 @@ def fix_explicit_addressing(object) do
|
||||||
explicit_mentions =
|
explicit_mentions =
|
||||||
explicit_mentions ++ ["https://www.w3.org/ns/activitystreams#Public", follower_collection]
|
explicit_mentions ++ ["https://www.w3.org/ns/activitystreams#Public", follower_collection]
|
||||||
|
|
||||||
object
|
fix_explicit_addressing(object, explicit_mentions, follower_collection)
|
||||||
|> fix_explicit_addressing(explicit_mentions)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# if as:Public is addressed, then make sure the followers collection is also addressed
|
# if as:Public is addressed, then make sure the followers collection is also addressed
|
||||||
|
@ -137,7 +141,7 @@ def fix_addressing(object) do
|
||||||
|> fix_addressing_list("cc")
|
|> fix_addressing_list("cc")
|
||||||
|> fix_addressing_list("bto")
|
|> fix_addressing_list("bto")
|
||||||
|> fix_addressing_list("bcc")
|
|> fix_addressing_list("bcc")
|
||||||
|> fix_explicit_addressing
|
|> fix_explicit_addressing()
|
||||||
|> fix_implicit_addressing(followers_collection)
|
|> fix_implicit_addressing(followers_collection)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@ def get_visibility(object) do
|
||||||
Enum.any?(to, &String.contains?(&1, "/followers")) ->
|
Enum.any?(to, &String.contains?(&1, "/followers")) ->
|
||||||
"private"
|
"private"
|
||||||
|
|
||||||
|
object.data["directMessage"] == true ->
|
||||||
|
"direct"
|
||||||
|
|
||||||
length(cc) > 0 ->
|
length(cc) > 0 ->
|
||||||
"private"
|
"private"
|
||||||
|
|
||||||
|
|
|
@ -1411,8 +1411,6 @@ def index(%{assigns: %{user: user}} = conn, _params) do
|
||||||
accounts =
|
accounts =
|
||||||
Map.put(%{}, user.id, AccountView.render("account.json", %{user: user, for: user}))
|
Map.put(%{}, user.id, AccountView.render("account.json", %{user: user, for: user}))
|
||||||
|
|
||||||
flavour = get_user_flavour(user)
|
|
||||||
|
|
||||||
initial_state =
|
initial_state =
|
||||||
%{
|
%{
|
||||||
meta: %{
|
meta: %{
|
||||||
|
@ -1499,7 +1497,7 @@ def index(%{assigns: %{user: user}} = conn, _params) do
|
||||||
conn
|
conn
|
||||||
|> put_layout(false)
|
|> put_layout(false)
|
||||||
|> put_view(MastodonView)
|
|> put_view(MastodonView)
|
||||||
|> render("index.html", %{initial_state: initial_state, flavour: flavour})
|
|> render("index.html", %{initial_state: initial_state})
|
||||||
else
|
else
|
||||||
conn
|
conn
|
||||||
|> put_session(:return_to, conn.request_path)
|
|> put_session(:return_to, conn.request_path)
|
||||||
|
@ -1522,43 +1520,6 @@ def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _para
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@supported_flavours ["glitch", "vanilla"]
|
|
||||||
|
|
||||||
def set_flavour(%{assigns: %{user: user}} = conn, %{"flavour" => flavour} = _params)
|
|
||||||
when flavour in @supported_flavours do
|
|
||||||
flavour_cng = User.Info.mastodon_flavour_update(user.info, flavour)
|
|
||||||
|
|
||||||
with changeset <- Ecto.Changeset.change(user),
|
|
||||||
changeset <- Ecto.Changeset.put_embed(changeset, :info, flavour_cng),
|
|
||||||
{:ok, user} <- User.update_and_set_cache(changeset),
|
|
||||||
flavour <- user.info.flavour do
|
|
||||||
json(conn, flavour)
|
|
||||||
else
|
|
||||||
e ->
|
|
||||||
conn
|
|
||||||
|> put_resp_content_type("application/json")
|
|
||||||
|> send_resp(500, Jason.encode!(%{"error" => inspect(e)}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_flavour(conn, _params) do
|
|
||||||
conn
|
|
||||||
|> put_status(400)
|
|
||||||
|> json(%{error: "Unsupported flavour"})
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_flavour(%{assigns: %{user: user}} = conn, _params) do
|
|
||||||
json(conn, get_user_flavour(user))
|
|
||||||
end
|
|
||||||
|
|
||||||
defp get_user_flavour(%User{info: %{flavour: flavour}}) when flavour in @supported_flavours do
|
|
||||||
flavour
|
|
||||||
end
|
|
||||||
|
|
||||||
defp get_user_flavour(_) do
|
|
||||||
"glitch"
|
|
||||||
end
|
|
||||||
|
|
||||||
def login(%{assigns: %{user: %User{}}} = conn, _params) do
|
def login(%{assigns: %{user: %User{}}} = conn, _params) do
|
||||||
redirect(conn, to: local_mastodon_root_path(conn))
|
redirect(conn, to: local_mastodon_root_path(conn))
|
||||||
end
|
end
|
||||||
|
|
|
@ -309,8 +309,6 @@ defmodule Pleroma.Web.Router do
|
||||||
post("/conversations/:id/read", MastodonAPIController, :conversation_read)
|
post("/conversations/:id/read", MastodonAPIController, :conversation_read)
|
||||||
|
|
||||||
get("/endorsements", MastodonAPIController, :empty_array)
|
get("/endorsements", MastodonAPIController, :empty_array)
|
||||||
|
|
||||||
get("/pleroma/flavour", MastodonAPIController, :get_flavour)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scope [] do
|
scope [] do
|
||||||
|
@ -352,8 +350,6 @@ defmodule Pleroma.Web.Router do
|
||||||
put("/filters/:id", MastodonAPIController, :update_filter)
|
put("/filters/:id", MastodonAPIController, :update_filter)
|
||||||
delete("/filters/:id", MastodonAPIController, :delete_filter)
|
delete("/filters/:id", MastodonAPIController, :delete_filter)
|
||||||
|
|
||||||
post("/pleroma/flavour/:flavour", MastodonAPIController, :set_flavour)
|
|
||||||
|
|
||||||
get("/pleroma/mascot", MastodonAPIController, :get_mascot)
|
get("/pleroma/mascot", MastodonAPIController, :get_mascot)
|
||||||
put("/pleroma/mascot", MastodonAPIController, :set_mascot)
|
put("/pleroma/mascot", MastodonAPIController, :set_mascot)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</title>
|
</title>
|
||||||
<link rel="icon" type="image/png" href="/favicon.png"/>
|
<link rel="icon" type="image/png" href="/favicon.png"/>
|
||||||
<script crossorigin='anonymous' src="/packs/locales.js"></script>
|
<script crossorigin='anonymous' src="/packs/locales.js"></script>
|
||||||
<script crossorigin='anonymous' src="/packs/locales/<%= @flavour %>/en.js"></script>
|
<script crossorigin='anonymous' src="/packs/locales/glitch/en.js"></script>
|
||||||
|
|
||||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/features/getting_started.js'>
|
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/features/getting_started.js'>
|
||||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/features/compose.js'>
|
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/features/compose.js'>
|
||||||
|
@ -19,10 +19,10 @@
|
||||||
<script src="/packs/core/common.js"></script>
|
<script src="/packs/core/common.js"></script>
|
||||||
<link rel="stylesheet" media="all" href="/packs/core/common.css" />
|
<link rel="stylesheet" media="all" href="/packs/core/common.css" />
|
||||||
|
|
||||||
<script src="/packs/flavours/<%= @flavour %>/common.js"></script>
|
<script src="/packs/flavours/glitch/common.js"></script>
|
||||||
<link rel="stylesheet" media="all" href="/packs/flavours/<%= @flavour %>/common.css" />
|
<link rel="stylesheet" media="all" href="/packs/flavours/glitch/common.css" />
|
||||||
|
|
||||||
<script src="/packs/flavours/<%= @flavour %>/home.js"></script>
|
<script src="/packs/flavours/glitch/home.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class='app-body no-reduce-motion system-font'>
|
<body class='app-body no-reduce-motion system-font'>
|
||||||
<div class='app-holder' data-props='{"locale":"en"}' id='mastodon'>
|
<div class='app-holder' data-props='{"locale":"en"}' id='mastodon'>
|
||||||
|
|
|
@ -121,6 +121,7 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
||||||
"tags" => user.tags
|
"tags" => user.tags
|
||||||
}
|
}
|
||||||
|> maybe_with_activation_status(user, for_user)
|
|> maybe_with_activation_status(user, for_user)
|
||||||
|
|> with_notification_settings(user, for_user)
|
||||||
}
|
}
|
||||||
|> maybe_with_user_settings(user, for_user)
|
|> maybe_with_user_settings(user, for_user)
|
||||||
|> maybe_with_role(user, for_user)
|
|> maybe_with_role(user, for_user)
|
||||||
|
@ -132,6 +133,12 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp with_notification_settings(data, %User{id: user_id} = user, %User{id: user_id}) do
|
||||||
|
Map.put(data, "notification_settings", user.info.notification_settings)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp with_notification_settings(data, _, _), do: data
|
||||||
|
|
||||||
defp maybe_with_activation_status(data, user, %User{info: %{is_admin: true}}) do
|
defp maybe_with_activation_status(data, user, %User{info: %{is_admin: true}}) do
|
||||||
Map.put(data, "deactivated", user.info.deactivated)
|
Map.put(data, "deactivated", user.info.deactivated)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddNonFollowsAndNonFollowersFieldsToNotificationSettings do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
execute("""
|
||||||
|
update users set info = jsonb_set(info, '{notification_settings}', '{"local": true, "remote": true, "follows": true, "followers": true, "non_follows": true, "non_followers": true}')
|
||||||
|
where local=true
|
||||||
|
""")
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","toot":"http://joinmastodon.org/ns#","featured":{"@id":"toot:featured","@type":"@id"},"alsoKnownAs":{"@id":"as:alsoKnownAs","@type":"@id"},"movedTo":{"@id":"as:movedTo","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value","Hashtag":"as:Hashtag","Emoji":"toot:Emoji","IdentityProof":"toot:IdentityProof","focalPoint":{"@container":"@list","@id":"toot:focalPoint"}}],"id":"https://mastodon.social/users/emelie","type":"Person","following":"https://mastodon.social/users/emelie/following","followers":"https://mastodon.social/users/emelie/followers","inbox":"https://mastodon.social/users/emelie/inbox","outbox":"https://mastodon.social/users/emelie/outbox","featured":"https://mastodon.social/users/emelie/collections/featured","preferredUsername":"emelie","name":"emelie 🎨","summary":"\u003cp\u003e23 / \u003ca href=\"https://mastodon.social/tags/sweden\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eSweden\u003c/span\u003e\u003c/a\u003e / \u003ca href=\"https://mastodon.social/tags/artist\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eArtist\u003c/span\u003e\u003c/a\u003e / \u003ca href=\"https://mastodon.social/tags/equestrian\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eEquestrian\u003c/span\u003e\u003c/a\u003e / \u003ca href=\"https://mastodon.social/tags/gamedev\" class=\"mention hashtag\" rel=\"tag\"\u003e#\u003cspan\u003eGameDev\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e\u003cp\u003eIf I ain\u0026apos;t spending time with my pets, I\u0026apos;m probably drawing. 🐴 🐱 🐰\u003c/p\u003e","url":"https://mastodon.social/@emelie","manuallyApprovesFollowers":false,"publicKey":{"id":"https://mastodon.social/users/emelie#main-key","owner":"https://mastodon.social/users/emelie","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3CWs1oAJPE3ZJ9sj6Ut\n/Mu+mTE7MOijsQc8/6c73XVVuhIEomiozJIH7l8a7S1n5SYL4UuiwcubSOi7u1bb\nGpYnp5TYhN+Cxvq/P80V4/ncNIPSQzS49it7nSLeG5pA21lGPDA44huquES1un6p\n9gSmbTwngVX9oe4MYuUeh0Z7vijjU13Llz1cRq/ZgPQPgfz+2NJf+VeXnvyDZDYx\nZPVBBlrMl3VoGbu0M5L8SjY35559KCZ3woIvqRolcoHXfgvJMdPcJgSZVYxlCw3d\nA95q9jQcn6s87CPSUs7bmYEQCrDVn5m5NER5TzwBmP4cgJl9AaDVWQtRd4jFZNTx\nlQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[{"type":"Hashtag","href":"https://mastodon.social/explore/sweden","name":"#sweden"},{"type":"Hashtag","href":"https://mastodon.social/explore/gamedev","name":"#gamedev"},{"type":"Hashtag","href":"https://mastodon.social/explore/artist","name":"#artist"},{"type":"Hashtag","href":"https://mastodon.social/explore/equestrian","name":"#equestrian"}],"attachment":[{"type":"PropertyValue","name":"Ko-fi","value":"\u003ca href=\"https://ko-fi.com/emeliepng\" rel=\"me nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003eko-fi.com/emeliepng\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"},{"type":"PropertyValue","name":"Instagram","value":"\u003ca href=\"https://www.instagram.com/emelie_png/\" rel=\"me nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttps://www.\u003c/span\u003e\u003cspan class=\"\"\u003einstagram.com/emelie_png/\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"},{"type":"PropertyValue","name":"Carrd","value":"\u003ca href=\"https://emelie.carrd.co/\" rel=\"me nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003eemelie.carrd.co/\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"},{"type":"PropertyValue","name":"Artstation","value":"\u003ca href=\"https://emiri.artstation.com\" rel=\"me nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003eemiri.artstation.com\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"}],"endpoints":{"sharedInbox":"https://mastodon.social/inbox"},"icon":{"type":"Image","mediaType":"image/png","url":"https://files.mastodon.social/accounts/avatars/000/015/657/original/e7163f98280da1a4.png"},"image":{"type":"Image","mediaType":"image/png","url":"https://files.mastodon.social/accounts/headers/000/015/657/original/847f331f3dd9e38b.png"}}
|
|
@ -78,33 +78,6 @@ test "it doesn't create a notification for an activity from a muted thread" do
|
||||||
assert nil == Notification.create_notification(activity, muter)
|
assert nil == Notification.create_notification(activity, muter)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it disables notifications from people on remote instances" do
|
|
||||||
user = insert(:user, info: %{notification_settings: %{"remote" => false}})
|
|
||||||
other_user = insert(:user)
|
|
||||||
|
|
||||||
create_activity = %{
|
|
||||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
|
||||||
"type" => "Create",
|
|
||||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
|
||||||
"actor" => other_user.ap_id,
|
|
||||||
"object" => %{
|
|
||||||
"type" => "Note",
|
|
||||||
"content" => "Hi @#{user.nickname}",
|
|
||||||
"attributedTo" => other_user.ap_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, %{local: false} = activity} = Transmogrifier.handle_incoming(create_activity)
|
|
||||||
assert nil == Notification.create_notification(activity, user)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it disables notifications from people on the local instance" do
|
|
||||||
user = insert(:user, info: %{notification_settings: %{"local" => false}})
|
|
||||||
other_user = insert(:user)
|
|
||||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
|
|
||||||
assert nil == Notification.create_notification(activity, user)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it disables notifications from followers" do
|
test "it disables notifications from followers" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, info: %{notification_settings: %{"followers" => false}})
|
followed = insert(:user, info: %{notification_settings: %{"followers" => false}})
|
||||||
|
@ -113,6 +86,13 @@ test "it disables notifications from followers" do
|
||||||
assert nil == Notification.create_notification(activity, followed)
|
assert nil == Notification.create_notification(activity, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it disables notifications from non-followers" do
|
||||||
|
follower = insert(:user)
|
||||||
|
followed = insert(:user, info: %{notification_settings: %{"non_followers" => false}})
|
||||||
|
{:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
|
||||||
|
assert nil == Notification.create_notification(activity, followed)
|
||||||
|
end
|
||||||
|
|
||||||
test "it disables notifications from people the user follows" do
|
test "it disables notifications from people the user follows" do
|
||||||
follower = insert(:user, info: %{notification_settings: %{"follows" => false}})
|
follower = insert(:user, info: %{notification_settings: %{"follows" => false}})
|
||||||
followed = insert(:user)
|
followed = insert(:user)
|
||||||
|
@ -122,6 +102,13 @@ test "it disables notifications from people the user follows" do
|
||||||
assert nil == Notification.create_notification(activity, follower)
|
assert nil == Notification.create_notification(activity, follower)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it disables notifications from people the user does not follow" do
|
||||||
|
follower = insert(:user, info: %{notification_settings: %{"non_follows" => false}})
|
||||||
|
followed = insert(:user)
|
||||||
|
{:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
|
||||||
|
assert nil == Notification.create_notification(activity, follower)
|
||||||
|
end
|
||||||
|
|
||||||
test "it doesn't create a notification for user if he is the activity author" do
|
test "it doesn't create a notification for user if he is the activity author" do
|
||||||
activity = insert(:note_activity)
|
activity = insert(:note_activity)
|
||||||
author = User.get_cached_by_ap_id(activity.data["actor"])
|
author = User.get_cached_by_ap_id(activity.data["actor"])
|
||||||
|
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ObjectView
|
alias Pleroma.Web.ActivityPub.ObjectView
|
||||||
alias Pleroma.Web.ActivityPub.UserView
|
alias Pleroma.Web.ActivityPub.UserView
|
||||||
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
@ -234,13 +235,17 @@ test "it clears `unreachable` federation status of the sender", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "/users/:nickname/inbox" do
|
describe "/users/:nickname/inbox" do
|
||||||
test "it inserts an incoming activity into the database", %{conn: conn} do
|
setup do
|
||||||
user = insert(:user)
|
|
||||||
|
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||||
|> Poison.decode!()
|
|> Poison.decode!()
|
||||||
|> Map.put("bcc", [user.ap_id])
|
|
||||||
|
[data: data]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it inserts an incoming activity into the database", %{conn: conn, data: data} do
|
||||||
|
user = insert(:user)
|
||||||
|
data = Map.put(data, "bcc", [user.ap_id])
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|
@ -253,16 +258,15 @@ test "it inserts an incoming activity into the database", %{conn: conn} do
|
||||||
assert Activity.get_by_ap_id(data["id"])
|
assert Activity.get_by_ap_id(data["id"])
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it accepts messages from actors that are followed by the user", %{conn: conn} do
|
test "it accepts messages from actors that are followed by the user", %{
|
||||||
|
conn: conn,
|
||||||
|
data: data
|
||||||
|
} do
|
||||||
recipient = insert(:user)
|
recipient = insert(:user)
|
||||||
actor = insert(:user, %{ap_id: "http://mastodon.example.org/users/actor"})
|
actor = insert(:user, %{ap_id: "http://mastodon.example.org/users/actor"})
|
||||||
|
|
||||||
{:ok, recipient} = User.follow(recipient, actor)
|
{:ok, recipient} = User.follow(recipient, actor)
|
||||||
|
|
||||||
data =
|
|
||||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
|
||||||
|> Poison.decode!()
|
|
||||||
|
|
||||||
object =
|
object =
|
||||||
data["object"]
|
data["object"]
|
||||||
|> Map.put("attributedTo", actor.ap_id)
|
|> Map.put("attributedTo", actor.ap_id)
|
||||||
|
@ -309,13 +313,9 @@ test "it returns a note activity in a collection", %{conn: conn} do
|
||||||
assert response(conn, 200) =~ note_activity.data["object"]["content"]
|
assert response(conn, 200) =~ note_activity.data["object"]["content"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it clears `unreachable` federation status of the sender", %{conn: conn} do
|
test "it clears `unreachable` federation status of the sender", %{conn: conn, data: data} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
data = Map.put(data, "bcc", [user.ap_id])
|
||||||
data =
|
|
||||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
|
||||||
|> Poison.decode!()
|
|
||||||
|> Map.put("bcc", [user.ap_id])
|
|
||||||
|
|
||||||
sender_host = URI.parse(data["actor"]).host
|
sender_host = URI.parse(data["actor"]).host
|
||||||
Instances.set_consistently_unreachable(sender_host)
|
Instances.set_consistently_unreachable(sender_host)
|
||||||
|
@ -330,6 +330,47 @@ test "it clears `unreachable` federation status of the sender", %{conn: conn} do
|
||||||
assert "ok" == json_response(conn, 200)
|
assert "ok" == json_response(conn, 200)
|
||||||
assert Instances.reachable?(sender_host)
|
assert Instances.reachable?(sender_host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it removes all follower collections but actor's", %{conn: conn} do
|
||||||
|
[actor, recipient] = insert_pair(:user)
|
||||||
|
|
||||||
|
data =
|
||||||
|
File.read!("test/fixtures/activitypub-client-post-activity.json")
|
||||||
|
|> Poison.decode!()
|
||||||
|
|
||||||
|
object = Map.put(data["object"], "attributedTo", actor.ap_id)
|
||||||
|
|
||||||
|
data =
|
||||||
|
data
|
||||||
|
|> Map.put("id", Utils.generate_object_id())
|
||||||
|
|> Map.put("actor", actor.ap_id)
|
||||||
|
|> Map.put("object", object)
|
||||||
|
|> Map.put("cc", [
|
||||||
|
recipient.follower_address,
|
||||||
|
actor.follower_address
|
||||||
|
])
|
||||||
|
|> Map.put("to", [
|
||||||
|
recipient.ap_id,
|
||||||
|
recipient.follower_address,
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
])
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> assign(:valid_signature, true)
|
||||||
|
|> put_req_header("content-type", "application/activity+json")
|
||||||
|
|> post("/users/#{recipient.nickname}/inbox", data)
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
activity = Activity.get_by_ap_id(data["id"])
|
||||||
|
|
||||||
|
assert activity.id
|
||||||
|
assert actor.follower_address in activity.recipients
|
||||||
|
assert actor.follower_address in activity.data["cc"]
|
||||||
|
|
||||||
|
refute recipient.follower_address in activity.recipients
|
||||||
|
refute recipient.follower_address in activity.data["cc"]
|
||||||
|
refute recipient.follower_address in activity.data["to"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "/users/:nickname/outbox" do
|
describe "/users/:nickname/outbox" do
|
||||||
|
|
|
@ -1284,9 +1284,12 @@ test "Rewrites Answers to Notes" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "fix_explicit_addressing" do
|
describe "fix_explicit_addressing" do
|
||||||
test "moves non-explicitly mentioned actors to cc" do
|
setup do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
[user: user]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "moves non-explicitly mentioned actors to cc", %{user: user} do
|
||||||
explicitly_mentioned_actors = [
|
explicitly_mentioned_actors = [
|
||||||
"https://pleroma.gold/users/user1",
|
"https://pleroma.gold/users/user1",
|
||||||
"https://pleroma.gold/user2"
|
"https://pleroma.gold/user2"
|
||||||
|
@ -1308,9 +1311,7 @@ test "moves non-explicitly mentioned actors to cc" do
|
||||||
assert "https://social.beepboop.ga/users/dirb" in fixed_object["cc"]
|
assert "https://social.beepboop.ga/users/dirb" in fixed_object["cc"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not move actor's follower collection to cc" do
|
test "does not move actor's follower collection to cc", %{user: user} do
|
||||||
user = insert(:user)
|
|
||||||
|
|
||||||
object = %{
|
object = %{
|
||||||
"actor" => user.ap_id,
|
"actor" => user.ap_id,
|
||||||
"to" => [user.follower_address],
|
"to" => [user.follower_address],
|
||||||
|
@ -1321,5 +1322,21 @@ test "does not move actor's follower collection to cc" do
|
||||||
assert user.follower_address in fixed_object["to"]
|
assert user.follower_address in fixed_object["to"]
|
||||||
refute user.follower_address in fixed_object["cc"]
|
refute user.follower_address in fixed_object["cc"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "removes recipient's follower collection from cc", %{user: user} do
|
||||||
|
recipient = insert(:user)
|
||||||
|
|
||||||
|
object = %{
|
||||||
|
"actor" => user.ap_id,
|
||||||
|
"to" => [recipient.ap_id, "https://www.w3.org/ns/activitystreams#Public"],
|
||||||
|
"cc" => [user.follower_address, recipient.follower_address]
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_object = Transmogrifier.fix_explicit_addressing(object)
|
||||||
|
|
||||||
|
assert user.follower_address in fixed_object["cc"]
|
||||||
|
refute recipient.follower_address in fixed_object["cc"]
|
||||||
|
refute recipient.follower_address in fixed_object["to"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,4 +117,8 @@ test "get_visibility", %{
|
||||||
assert Visibility.get_visibility(direct) == "direct"
|
assert Visibility.get_visibility(direct) == "direct"
|
||||||
assert Visibility.get_visibility(unlisted) == "unlisted"
|
assert Visibility.get_visibility(unlisted) == "unlisted"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "get_visibility with directMessage flag" do
|
||||||
|
assert Visibility.get_visibility(%{data: %{"directMessage" => true}}) == "direct"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,10 +78,10 @@ test "Represent the user account for the account owner" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
notification_settings = %{
|
notification_settings = %{
|
||||||
"remote" => true,
|
|
||||||
"local" => true,
|
|
||||||
"followers" => true,
|
"followers" => true,
|
||||||
"follows" => true
|
"follows" => true,
|
||||||
|
"non_follows" => true,
|
||||||
|
"non_followers" => true
|
||||||
}
|
}
|
||||||
|
|
||||||
privacy = user.info.default_scope
|
privacy = user.info.default_scope
|
||||||
|
|
|
@ -2950,31 +2950,6 @@ test "unmute conversation", %{conn: conn, user: user, activity: activity} do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "flavours switching (Pleroma Extension)", %{conn: conn} do
|
|
||||||
user = insert(:user)
|
|
||||||
|
|
||||||
get_old_flavour =
|
|
||||||
conn
|
|
||||||
|> assign(:user, user)
|
|
||||||
|> get("/api/v1/pleroma/flavour")
|
|
||||||
|
|
||||||
assert "glitch" == json_response(get_old_flavour, 200)
|
|
||||||
|
|
||||||
set_flavour =
|
|
||||||
conn
|
|
||||||
|> assign(:user, user)
|
|
||||||
|> post("/api/v1/pleroma/flavour/vanilla")
|
|
||||||
|
|
||||||
assert "vanilla" == json_response(set_flavour, 200)
|
|
||||||
|
|
||||||
get_new_flavour =
|
|
||||||
conn
|
|
||||||
|> assign(:user, user)
|
|
||||||
|> post("/api/v1/pleroma/flavour/vanilla")
|
|
||||||
|
|
||||||
assert json_response(set_flavour, 200) == json_response(get_new_flavour, 200)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "reports" do
|
describe "reports" do
|
||||||
setup do
|
setup do
|
||||||
reporter = insert(:user)
|
reporter = insert(:user)
|
||||||
|
|
|
@ -102,7 +102,6 @@ test "it updates notification settings", %{conn: conn} do
|
||||||
conn
|
conn
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|> put("/api/pleroma/notification_settings", %{
|
|> put("/api/pleroma/notification_settings", %{
|
||||||
"remote" => false,
|
|
||||||
"followers" => false,
|
"followers" => false,
|
||||||
"bar" => 1
|
"bar" => 1
|
||||||
})
|
})
|
||||||
|
@ -110,8 +109,12 @@ test "it updates notification settings", %{conn: conn} do
|
||||||
|
|
||||||
user = Repo.get(User, user.id)
|
user = Repo.get(User, user.id)
|
||||||
|
|
||||||
assert %{"remote" => false, "local" => true, "followers" => false, "follows" => true} ==
|
assert %{
|
||||||
user.info.notification_settings
|
"followers" => false,
|
||||||
|
"follows" => true,
|
||||||
|
"non_follows" => true,
|
||||||
|
"non_followers" => true
|
||||||
|
} == user.info.notification_settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -112,9 +112,11 @@ test "User exposes settings for themselves and only for themselves", %{user: use
|
||||||
as_user = UserView.render("show.json", %{user: user, for: user})
|
as_user = UserView.render("show.json", %{user: user, for: user})
|
||||||
assert as_user["default_scope"] == user.info.default_scope
|
assert as_user["default_scope"] == user.info.default_scope
|
||||||
assert as_user["no_rich_text"] == user.info.no_rich_text
|
assert as_user["no_rich_text"] == user.info.no_rich_text
|
||||||
|
assert as_user["pleroma"]["notification_settings"] == user.info.notification_settings
|
||||||
as_stranger = UserView.render("show.json", %{user: user})
|
as_stranger = UserView.render("show.json", %{user: user})
|
||||||
refute as_stranger["default_scope"]
|
refute as_stranger["default_scope"]
|
||||||
refute as_stranger["no_rich_text"]
|
refute as_stranger["no_rich_text"]
|
||||||
|
refute as_stranger["pleroma"]["notification_settings"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "A user for a given other follower", %{user: user} do
|
test "A user for a given other follower", %{user: user} do
|
||||||
|
|
Loading…
Reference in New Issue