From a05cb10a95901ff0daacfc17a7709f3a277f1cd4 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Fri, 14 Dec 2018 16:38:56 +0300 Subject: [#114] Email confirmation route, action, node setting, User.Info fields. --- lib/pleroma/user.ex | 4 ++++ lib/pleroma/user/info.ex | 6 ++++++ lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 1 + lib/pleroma/web/router.ex | 1 + lib/pleroma/web/twitter_api/twitter_api_controller.ex | 13 +++++++++++++ 5 files changed, 25 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 3ad1ab87a..ee0a0dfb9 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -364,6 +364,10 @@ defmodule Pleroma.User do end end + def get_by_confirmation_token(token) do + Repo.one(from(u in User, where: fragment("? ->> 'confirmation_token' = ?", u.info, ^token))) + end + def get_followers_query(%User{id: id, follower_address: follower_address}) do from( u in User, diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index a3785447c..f75984038 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -9,6 +9,8 @@ defmodule Pleroma.User.Info do field(:note_count, :integer, default: 0) field(:follower_count, :integer, default: 0) field(:locked, :boolean, default: false) + field(:confirmation_pending, :boolean, default: false) + field(:confirmation_token, :string, default: nil) field(:default_scope, :string, default: "public") field(:blocks, {:array, :string}, default: []) field(:domain_blocks, {:array, :string}, default: []) @@ -141,6 +143,10 @@ defmodule Pleroma.User.Info do ]) end + def confirmation_update(info, params) do + cast(info, params, [:confirmation_pending, :confirmation_token]) + end + def mastodon_profile_update(info, params) do info |> cast(params, [ diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 44c11f40a..70921605d 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -132,6 +132,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do banner: Keyword.get(instance, :banner_upload_limit), background: Keyword.get(instance, :background_upload_limit) }, + accountActivationRequired: Keyword.get(instance, :account_activation_required, false), invitesEnabled: Keyword.get(instance, :invites_enabled, false), features: features } diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index dd1985d6e..b2fbc088d 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -281,6 +281,7 @@ defmodule Pleroma.Web.Router do post("/account/register", TwitterAPI.Controller, :register) post("/account/password_reset", TwitterAPI.Controller, :password_reset) + get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email) get("/search", TwitterAPI.Controller, :search) get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 327620302..2680be25f 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -372,6 +372,19 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end end + def confirm_email(conn, %{"token" => token}) do + with %User{} = user <- User.get_by_confirmation_token(token), + true <- user.local, + new_info_fields <- %{confirmation_pending: false, confirmation_token: nil}, + info_change <- User.Info.confirmation_update(user.info, new_info_fields), + changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), + {:ok, _} <- User.update_and_set_cache(changeset) do + conn + |> put_flash(:info, "Email confirmed. Please sign in.") + |> redirect(to: "/") + end + end + def update_avatar(%{assigns: %{user: user}} = conn, params) do {:ok, object} = ActivityPub.upload(params, type: :avatar) change = Changeset.change(user, %{avatar: object.data}) -- cgit v1.2.3 From 1de0aa2f1025d4a860a11e658ce5fed26fe1c4ad Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Mon, 17 Dec 2018 17:28:58 +0300 Subject: [#114] Account confirmation email, registration as unconfirmed (config-based), auth prevention for unconfirmed. --- lib/pleroma/emails/user_email.ex | 24 +++++++++++++++++++++- lib/pleroma/user.ex | 2 ++ lib/pleroma/user/info.ex | 14 +++++++++++++ lib/pleroma/web/oauth/oauth_controller.ex | 2 ++ lib/pleroma/web/router.ex | 3 ++- .../web/twitter_api/controllers/util_controller.ex | 2 ++ lib/pleroma/web/twitter_api/twitter_api.ex | 22 ++++++++++++++++++-- .../web/twitter_api/twitter_api_controller.ex | 4 ++-- 8 files changed, 67 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 7e3e9b020..856816386 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -15,6 +15,7 @@ defmodule Pleroma.UserEmail do defp recipient(email, nil), do: email defp recipient(email, name), do: {name, email} + defp recipient(%Pleroma.User{} = user), do: recipient(user.email, user.name) def password_reset_email(user, password_reset_token) when is_binary(password_reset_token) do password_reset_url = @@ -32,7 +33,7 @@ defmodule Pleroma.UserEmail do """ new() - |> to(recipient(user.email, user.name)) + |> to(recipient(user)) |> from(sender()) |> subject("Password reset") |> html_body(html_body) @@ -63,4 +64,25 @@ defmodule Pleroma.UserEmail do |> subject("Invitation to #{instance_name()}") |> html_body(html_body) end + + def account_confirmation_email(user) do + confirmation_url = + Router.Helpers.confirm_email_url( + Endpoint, + :confirm_email, + to_string(user.info.confirmation_token) + ) + + html_body = """ +

Welcome to #{instance_name()}!

+

Email confirmation is required to activate the account.

+

Click the following link to proceed: activate your account.

+ """ + + new() + |> to(recipient(user)) + |> from(sender()) + |> subject("#{instance_name()} account confirmation") + |> html_body(html_body) + end end diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index ee0a0dfb9..a38ead81a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -38,6 +38,8 @@ defmodule Pleroma.User do timestamps() end + def auth_active?(user), do: user.info && !user.info.confirmation_pending + def avatar_url(user) do case user.avatar do %{"url" => [%{"href" => href} | _]} -> href diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index f75984038..9ce9129cd 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -143,6 +143,20 @@ defmodule Pleroma.User.Info do ]) end + def confirmation_update(info, :confirmed) do + confirmation_update(info, %{ + confirmation_pending: false, + confirmation_token: nil + }) + end + + def confirmation_update(info, :unconfirmed) do + confirmation_update(info, %{ + confirmation_pending: true, + confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64() + }) + end + def confirmation_update(info, params) do cast(info, params, [:confirmation_pending, :confirmation_token]) end diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 20c2e799b..10158f07e 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -31,6 +31,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do }) do with %User{} = user <- User.get_by_nickname_or_email(name), true <- Pbkdf2.checkpw(password, user.password_hash), + true <- User.auth_active?(user), %App{} = app <- Repo.get_by(App, client_id: client_id), {:ok, auth} <- Authorization.create_authorization(app, user) do # Special case: Local MastodonFE. @@ -101,6 +102,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do with %App{} = app <- get_app_from_request(conn, params), %User{} = user <- User.get_by_nickname_or_email(name), true <- Pbkdf2.checkpw(password, user.password_hash), + true <- User.auth_active?(user), {:ok, auth} <- Authorization.create_authorization(app, user), {:ok, token} <- Token.exchange_token(app, auth) do response = %{ diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index b2fbc088d..0e4589116 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -281,7 +281,8 @@ defmodule Pleroma.Web.Router do post("/account/register", TwitterAPI.Controller, :register) post("/account/password_reset", TwitterAPI.Controller, :password_reset) - get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email) + + get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email, as: :confirm_email) get("/search", TwitterAPI.Controller, :search) get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline) diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 38653f0b8..3baeba619 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -174,6 +174,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do closed: if(Keyword.get(instance, :registrations_open), do: "0", else: "1"), private: if(Keyword.get(instance, :public, true), do: "0", else: "1"), vapidPublicKey: vapid_public_key, + accountActivationRequired: + if(Keyword.get(instance, :account_activation_required, false), do: "1", else: "0"), invitesEnabled: if(Keyword.get(instance, :invites_enabled, false), do: "1", else: "0") } diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 90b8345c5..b77761aa4 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -1,8 +1,10 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do alias Pleroma.{UserInviteToken, User, Activity, Repo, Object} + alias Pleroma.{UserEmail, Mailer} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.TwitterAPI.UserView alias Pleroma.Web.CommonAPI + import Ecto.Query def create_status(%User{} = user, %{"status" => _} = data) do @@ -165,6 +167,22 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do with {:ok, user} <- Repo.insert(changeset) do !registrations_open && UserInviteToken.mark_as_used(token.token) + + if Pleroma.Config.get([:instance, :account_activation_required]) do + info_change = User.Info.confirmation_update(user.info, :unconfirmed) + + {:ok, unconfirmed_user} = + user + |> Ecto.Changeset.change() + |> Ecto.Changeset.put_embed(:info, info_change) + |> Repo.update() + + {:ok, _} = + unconfirmed_user + |> UserEmail.account_confirmation_email() + |> Mailer.deliver() + end + {:ok, user} else {:error, changeset} -> @@ -189,8 +207,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do %User{local: true} = user <- User.get_by_nickname_or_email(nickname_or_email), {:ok, token_record} <- Pleroma.PasswordResetToken.create_token(user) do user - |> Pleroma.UserEmail.password_reset_email(token_record.token) - |> Pleroma.Mailer.deliver() + |> UserEmail.password_reset_email(token_record.token) + |> Mailer.deliver() else false -> {:error, "bad user identifier"} diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 2680be25f..e8a3150e9 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -13,6 +13,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do require Logger plug(:only_if_public_instance when action in [:public_timeline, :public_and_external_timeline]) + plug(:fetch_flash when action in [:confirm_email]) action_fallback(:errors) def verify_credentials(%{assigns: %{user: user}} = conn, _params) do @@ -375,8 +376,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do def confirm_email(conn, %{"token" => token}) do with %User{} = user <- User.get_by_confirmation_token(token), true <- user.local, - new_info_fields <- %{confirmation_pending: false, confirmation_token: nil}, - info_change <- User.Info.confirmation_update(user.info, new_info_fields), + info_change <- User.Info.confirmation_update(user.info, :confirmed), changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), {:ok, _} <- User.update_and_set_cache(changeset) do conn -- cgit v1.2.3 From b86057cc7f45c79767ff5b83730c2c15ad6bb3bd Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Tue, 18 Dec 2018 13:13:57 +0300 Subject: [#114] Refactored User.register_changeset to init confirmation data. Introduced User.register/1 to encapsulate User record creation and post-registration actions. --- lib/pleroma/user.ex | 25 ++++++++++++-- lib/pleroma/web/admin_api/admin_api_controller.ex | 10 +++--- lib/pleroma/web/twitter_api/twitter_api.ex | 41 +++++++---------------- 3 files changed, 41 insertions(+), 35 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index a38ead81a..234617574 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -170,7 +170,14 @@ defmodule Pleroma.User do update_and_set_cache(password_update_changeset(user, data)) end - def register_changeset(struct, params \\ %{}) do + def register_changeset(struct, params \\ %{}, opts \\ []) do + confirmation_status = + if opts[:confirmed] || !Pleroma.Config.get([:instance, :account_activation_required]) do + :confirmed + else + :unconfirmed + end + changeset = struct |> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation]) @@ -182,7 +189,7 @@ defmodule Pleroma.User do |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) |> validate_length(:name, min: 1, max: 100) - |> put_change(:info, %Pleroma.User.Info{}) + |> put_change(:info, User.Info.confirmation_update(%User.Info{}, confirmation_status)) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) @@ -199,6 +206,20 @@ defmodule Pleroma.User do end end + @doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)" + def register(%Ecto.Changeset{} = changeset) do + with {:ok, user} <- Repo.insert(changeset) do + if user.info.confirmation_pending do + {:ok, _} = + user + |> Pleroma.UserEmail.account_confirmation_email() + |> Pleroma.Mailer.deliver() + end + + {:ok, user} + end + end + def needs_update?(%User{local: true}), do: false def needs_update?(%User{local: false, last_refreshed_at: nil}), do: true diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 4d73cf219..683310168 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -1,6 +1,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do use Pleroma.Web, :controller - alias Pleroma.{User, Repo} + alias Pleroma.User alias Pleroma.Web.ActivityPub.Relay import Pleroma.Web.ControllerHelper, only: [json_response: 3] @@ -26,7 +26,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do conn, %{"nickname" => nickname, "email" => email, "password" => password} ) do - new_user = %{ + user_data = %{ nickname: nickname, name: nickname, email: email, @@ -35,11 +35,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do bio: "." } - User.register_changeset(%User{}, new_user) - |> Repo.insert!() + changeset = User.register_changeset(%User{}, user_data, confirmed: true) + {:ok, user} = User.register(changeset) conn - |> json(new_user.nickname) + |> json(user.nickname) end def tag_users(conn, %{"nicknames" => nicknames, "tags" => tags}) do diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index b77761aa4..d8dd7dfa8 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -161,34 +161,19 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do Repo.get_by(UserInviteToken, %{token: tokenString}) end - cond do - registrations_open || (!is_nil(token) && !token.used) -> - changeset = User.register_changeset(%User{info: %{}}, params) - - with {:ok, user} <- Repo.insert(changeset) do - !registrations_open && UserInviteToken.mark_as_used(token.token) - - if Pleroma.Config.get([:instance, :account_activation_required]) do - info_change = User.Info.confirmation_update(user.info, :unconfirmed) - - {:ok, unconfirmed_user} = - user - |> Ecto.Changeset.change() - |> Ecto.Changeset.put_embed(:info, info_change) - |> Repo.update() - - {:ok, _} = - unconfirmed_user - |> UserEmail.account_confirmation_email() - |> Mailer.deliver() - end - - {:ok, user} - else - {:error, changeset} -> - errors = - Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end) - |> Jason.encode!() + cond do + registrations_open || (!is_nil(token) && !token.used) -> + changeset = User.register_changeset(%User{}, params) + + with {:ok, user} <- User.register(changeset) do + !registrations_open && UserInviteToken.mark_as_used(token.token) + + {:ok, user} + else + {:error, changeset} -> + errors = + Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end) + |> Jason.encode!() {:error, %{error: errors}} end -- cgit v1.2.3 From aed0f902871524ecc1db0d8c088ce5939e7c685a Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Tue, 18 Dec 2018 14:07:05 +0300 Subject: [#114] Added `pleroma.confirmation_pending` to user views, adjusted view tests. --- lib/pleroma/web/mastodon_api/views/account_view.ex | 1 + lib/pleroma/web/twitter_api/views/user_view.ex | 1 + 2 files changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index ebcf9230b..50df88aca 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -62,6 +62,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do # Pleroma extension pleroma: %{ + confirmation_pending: user_info.confirmation_pending, tags: user.tags } } diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 8a88d72b1..45b893eda 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -81,6 +81,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do # Pleroma extension "pleroma" => %{ + "confirmation_pending" => user_info.confirmation_pending, "tags" => user.tags } } -- cgit v1.2.3 From b096e30cffc79a4adf12be88da412a290cd0d190 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Tue, 18 Dec 2018 17:13:52 +0300 Subject: [#114] Added email confirmation resend action. Added tests for registration, authentication, email confirmation, confirmation resending. Made admin methods create confirmed users. --- lib/mix/tasks/pleroma/user.ex | 4 ++-- lib/pleroma/user.ex | 28 +++++++++++++--------- lib/pleroma/web/oauth/oauth_controller.ex | 18 ++++++++++++-- lib/pleroma/web/router.ex | 2 ++ .../web/twitter_api/twitter_api_controller.ex | 13 +++++++++- 5 files changed, 49 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 3d30e3a81..51086a443 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -103,8 +103,8 @@ defmodule Mix.Tasks.Pleroma.User do bio: bio } - user = User.register_changeset(%User{}, params) - Repo.insert!(user) + changeset = User.register_changeset(%User{}, params, confirmed: true) + {:ok, _user} = User.register(changeset) Mix.shell().info("User #{nickname} created") diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 234617574..0cd7bc463 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -74,13 +74,15 @@ defmodule Pleroma.User do def user_info(%User{} = user) do oneself = if user.local, do: 1, else: 0 + user_info = user.info %{ following_count: length(user.following) - oneself, - note_count: user.info.note_count, - follower_count: user.info.follower_count, - locked: user.info.locked, - default_scope: user.info.default_scope + note_count: user_info.note_count, + follower_count: user_info.follower_count, + locked: user_info.locked, + confirmation_pending: user_info.confirmation_pending, + default_scope: user_info.default_scope } end @@ -209,17 +211,21 @@ defmodule Pleroma.User do @doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)" def register(%Ecto.Changeset{} = changeset) do with {:ok, user} <- Repo.insert(changeset) do - if user.info.confirmation_pending do - {:ok, _} = - user - |> Pleroma.UserEmail.account_confirmation_email() - |> Pleroma.Mailer.deliver() - end - + {:ok, _} = try_send_confirmation_email(user) {:ok, user} end end + def try_send_confirmation_email(%User{} = user) do + if user.info.confirmation_pending do + user + |> Pleroma.UserEmail.account_confirmation_email() + |> Pleroma.Mailer.deliver() + else + {:ok, :noop} + end + end + def needs_update?(%User{local: true}), do: false def needs_update?(%User{local: false, last_refreshed_at: nil}), do: true diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 10158f07e..9a972ee47 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -31,7 +31,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do }) do with %User{} = user <- User.get_by_nickname_or_email(name), true <- Pbkdf2.checkpw(password, user.password_hash), - true <- User.auth_active?(user), + {:auth_active, true} <- {:auth_active, User.auth_active?(user)}, %App{} = app <- Repo.get_by(App, client_id: client_id), {:ok, auth} <- Authorization.create_authorization(app, user) do # Special case: Local MastodonFE. @@ -64,6 +64,15 @@ defmodule Pleroma.Web.OAuth.OAuthController do redirect(conn, external: url) end + else + {:auth_active, false} -> + conn + |> put_flash(:error, "Account confirmation pending") + |> put_status(:forbidden) + |> authorize(params) + + error -> + error end end @@ -102,7 +111,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do with %App{} = app <- get_app_from_request(conn, params), %User{} = user <- User.get_by_nickname_or_email(name), true <- Pbkdf2.checkpw(password, user.password_hash), - true <- User.auth_active?(user), + {:auth_active, true} <- {:auth_active, User.auth_active?(user)}, {:ok, auth} <- Authorization.create_authorization(app, user), {:ok, token} <- Token.exchange_token(app, auth) do response = %{ @@ -115,6 +124,11 @@ defmodule Pleroma.Web.OAuth.OAuthController do json(conn, response) else + {:auth_active, false} -> + conn + |> put_status(:forbidden) + |> json(%{error: "Account confirmation pending"}) + _error -> put_status(conn, 400) |> json(%{error: "Invalid credentials"}) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 0e4589116..ca069ab99 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -284,6 +284,8 @@ defmodule Pleroma.Web.Router do get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email, as: :confirm_email) + post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email) + get("/search", TwitterAPI.Controller, :search) get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline) end diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index e8a3150e9..7286c153b 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -13,7 +13,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do require Logger plug(:only_if_public_instance when action in [:public_timeline, :public_and_external_timeline]) - plug(:fetch_flash when action in [:confirm_email]) + plug(:fetch_flash when action in [:confirm_email, :resend_confirmation_email]) action_fallback(:errors) def verify_credentials(%{assigns: %{user: user}} = conn, _params) do @@ -385,6 +385,17 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end end + def resend_confirmation_email(conn, params) do + nickname_or_email = params["email"] || params["nickname"] + + with %User{} = user <- User.get_by_nickname_or_email(nickname_or_email), + {:ok, _} <- User.try_send_confirmation_email(user) do + conn + |> put_flash(:info, "Email confirmation has been sent.") + |> json_response(:no_content, "") + end + end + def update_avatar(%{assigns: %{user: user}} = conn, params) do {:ok, object} = ActivityPub.upload(params, type: :avatar) change = Changeset.change(user, %{avatar: object.data}) -- cgit v1.2.3 From 3371a45884b5d80ff4e8178ea921fe6f6c8d174d Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Tue, 18 Dec 2018 17:30:30 +0300 Subject: [#114] Formatting fix. --- lib/pleroma/web/twitter_api/twitter_api.ex | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index d8dd7dfa8..d816dc3bc 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -161,19 +161,19 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do Repo.get_by(UserInviteToken, %{token: tokenString}) end - cond do - registrations_open || (!is_nil(token) && !token.used) -> - changeset = User.register_changeset(%User{}, params) - - with {:ok, user} <- User.register(changeset) do - !registrations_open && UserInviteToken.mark_as_used(token.token) - - {:ok, user} - else - {:error, changeset} -> - errors = - Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end) - |> Jason.encode!() + cond do + registrations_open || (!is_nil(token) && !token.used) -> + changeset = User.register_changeset(%User{}, params) + + with {:ok, user} <- User.register(changeset) do + !registrations_open && UserInviteToken.mark_as_used(token.token) + + {:ok, user} + else + {:error, changeset} -> + errors = + Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end) + |> Jason.encode!() {:error, %{error: errors}} end -- cgit v1.2.3 From f58f20abbb761f652dbc6b44d213ebe90e305899 Mon Sep 17 00:00:00 2001 From: href Date: Tue, 18 Dec 2018 15:32:41 +0100 Subject: Twitter ActivityView: fix crash when activity content is nil --- lib/pleroma/web/twitter_api/views/activity_view.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 91d086740..bc90a1cd4 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -245,9 +245,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do |> Formatter.emojify(object["emoji"]) text = - content - |> String.replace(~r//, "\n") - |> HTML.strip_tags() + if content do + content + |> String.replace(~r//, "\n") + |> HTML.strip_tags() + end reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From a6dfe1fc6b65ec406159a2e068ab598de2cc13e0 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 18 Dec 2018 17:05:36 +0100 Subject: Documentation: Move generated files to priv/static/doc, add it to endpoint.ex --- lib/pleroma/web/endpoint.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index d79f61b2e..564fc2c1d 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -21,7 +21,7 @@ defmodule Pleroma.Web.Endpoint do at: "/", from: :pleroma, only: - ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png schemas) + ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png schemas doc) ) # Code reloading can be explicitly enabled under the -- cgit v1.2.3 From 59fc5d15dfde0120fb10ec14631ad1115a6087a9 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 19 Dec 2018 16:27:16 +0300 Subject: [#114] User.Info: renamed `confirmation_update` to `confirmation_change`. --- lib/pleroma/user.ex | 2 +- lib/pleroma/user/info.ex | 10 +++++----- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 0cd7bc463..41d01cbf5 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -191,7 +191,7 @@ defmodule Pleroma.User do |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) |> validate_length(:name, min: 1, max: 100) - |> put_change(:info, User.Info.confirmation_update(%User.Info{}, confirmation_status)) + |> put_change(:info, User.Info.confirmation_change(%User.Info{}, confirmation_status)) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 9ce9129cd..2800e9cff 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -143,21 +143,21 @@ defmodule Pleroma.User.Info do ]) end - def confirmation_update(info, :confirmed) do - confirmation_update(info, %{ + def confirmation_change(info, :confirmed) do + confirmation_change(info, %{ confirmation_pending: false, confirmation_token: nil }) end - def confirmation_update(info, :unconfirmed) do - confirmation_update(info, %{ + def confirmation_change(info, :unconfirmed) do + confirmation_change(info, %{ confirmation_pending: true, confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64() }) end - def confirmation_update(info, params) do + def confirmation_change(info, params) do cast(info, params, [:confirmation_pending, :confirmation_token]) end diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 7286c153b..4bd729b77 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -376,7 +376,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do def confirm_email(conn, %{"token" => token}) do with %User{} = user <- User.get_by_confirmation_token(token), true <- user.local, - info_change <- User.Info.confirmation_update(user.info, :confirmed), + info_change <- User.Info.confirmation_change(user.info, :confirmed), changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), {:ok, _} <- User.update_and_set_cache(changeset) do conn -- cgit v1.2.3 From 968d7490b689ba501a64f350841dc8f9b33b5244 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 19 Dec 2018 16:27:16 +0300 Subject: [#114] User.Info: renamed `confirmation_update` to `confirmation_changeset`. --- lib/pleroma/user.ex | 2 +- lib/pleroma/user/info.ex | 10 +++++----- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 41d01cbf5..4e227b08d 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -191,7 +191,7 @@ defmodule Pleroma.User do |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) |> validate_length(:name, min: 1, max: 100) - |> put_change(:info, User.Info.confirmation_change(%User.Info{}, confirmation_status)) + |> put_change(:info, User.Info.confirmation_changeset(%User.Info{}, confirmation_status)) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 2800e9cff..ad9fe1bbe 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -143,21 +143,21 @@ defmodule Pleroma.User.Info do ]) end - def confirmation_change(info, :confirmed) do - confirmation_change(info, %{ + def confirmation_changeset(info, :confirmed) do + confirmation_changeset(info, %{ confirmation_pending: false, confirmation_token: nil }) end - def confirmation_change(info, :unconfirmed) do - confirmation_change(info, %{ + def confirmation_changeset(info, :unconfirmed) do + confirmation_changeset(info, %{ confirmation_pending: true, confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64() }) end - def confirmation_change(info, params) do + def confirmation_changeset(info, params) do cast(info, params, [:confirmation_pending, :confirmation_token]) end diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 4bd729b77..b362f3946 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -376,7 +376,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do def confirm_email(conn, %{"token" => token}) do with %User{} = user <- User.get_by_confirmation_token(token), true <- user.local, - info_change <- User.Info.confirmation_change(user.info, :confirmed), + info_change <- User.Info.confirmation_changeset(user.info, :confirmed), changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), {:ok, _} <- User.update_and_set_cache(changeset) do conn -- cgit v1.2.3 From a532ad5d720cbbe3ef58e09f8ad209bfe15b43c9 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 19 Dec 2018 17:24:55 +0300 Subject: [#114] User.register/1 tweak. --- lib/pleroma/user.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 4e227b08d..4b8caf65c 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -210,8 +210,8 @@ defmodule Pleroma.User do @doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)" def register(%Ecto.Changeset{} = changeset) do - with {:ok, user} <- Repo.insert(changeset) do - {:ok, _} = try_send_confirmation_email(user) + with {:ok, user} <- Repo.insert(changeset), + {:ok, _} = try_send_confirmation_email(user) do {:ok, user} end end -- cgit v1.2.3 From 279096228c8b0113a8ea63a73e011934a3226df7 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 19 Dec 2018 18:56:52 +0300 Subject: [#114] Made MastodonAPI and TwitterAPI user show actions return 404 for auth-inactive users unless requested by admin or moderator. --- lib/pleroma/user.ex | 4 +++- lib/pleroma/user/info.ex | 2 ++ lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 3 ++- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 14 +++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 4b8caf65c..7e792cb0c 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -38,7 +38,9 @@ defmodule Pleroma.User do timestamps() end - def auth_active?(user), do: user.info && !user.info.confirmation_pending + def auth_active?(%User{} = user), do: user.info && !user.info.confirmation_pending + + def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info) def avatar_url(user) do case user.avatar do diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index ad9fe1bbe..3de4af56c 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -37,6 +37,8 @@ defmodule Pleroma.User.Info do # subject _> Where is this used? end + def superuser?(info), do: info.is_admin || info.is_moderator + def set_activation_status(info, deactivated) do params = %{deactivated: deactivated} diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 665b75437..c6db89442 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -110,7 +110,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end def user(%{assigns: %{user: for_user}} = conn, %{"id" => id}) do - with %User{} = user <- Repo.get(User, id) do + with %User{} = user <- Repo.get(User, id), + true <- User.auth_active?(user) || user.id == for_user.id || User.superuser?(for_user) do account = AccountView.render("account.json", %{user: user, for: for_user}) json(conn, account) else diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index b362f3946..e047ed0ad 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -97,10 +97,13 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def show_user(conn, params) do - with {:ok, shown} <- TwitterAPI.get_user(params) do + for_user = conn.assigns.user + + with {:ok, shown} <- TwitterAPI.get_user(params), + true <- User.auth_active?(shown) || for_user && (for_user.id == shown.id || User.superuser?(for_user)) do params = - if user = conn.assigns.user do - %{user: shown, for: user} + if for_user do + %{user: shown, for: for_user} else %{user: shown} end @@ -111,6 +114,11 @@ defmodule Pleroma.Web.TwitterAPI.Controller do else {:error, msg} -> bad_request_reply(conn, msg) + + false -> + conn + |> put_status(404) + |> json(%{error: "Unconfirmed user"}) end end -- cgit v1.2.3 From b520d44b58db3bac7a883c2220d83d05b07784d0 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 19 Dec 2018 19:03:39 +0300 Subject: [#114] `mix format` --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index e047ed0ad..2b0f7135a 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -100,7 +100,9 @@ defmodule Pleroma.Web.TwitterAPI.Controller do for_user = conn.assigns.user with {:ok, shown} <- TwitterAPI.get_user(params), - true <- User.auth_active?(shown) || for_user && (for_user.id == shown.id || User.superuser?(for_user)) do + true <- + User.auth_active?(shown) || + (for_user && (for_user.id == shown.id || User.superuser?(for_user))) do params = if for_user do %{user: shown, for: for_user} -- cgit v1.2.3 From f1b93b5be761826af9b833411689e9e0c086b815 Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 20 Dec 2018 09:35:01 +0000 Subject: [#413] fix parse mentions --- lib/pleroma/formatter.ex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 9401689cb..72fe9640b 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -7,6 +7,9 @@ defmodule Pleroma.Formatter do @tag_regex ~r/((?<=[^&])|\A)(\#)(\w+)/u @markdown_characters_regex ~r/(`|\*|_|{|}|[|]|\(|\)|#|\+|-|\.|!)/ + # Modified from https://www.w3.org/TR/html5/forms.html#valid-e-mail-address + @mentions_regex ~r/@[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]*@?[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/u + def parse_tags(text, data \\ %{}) do Regex.scan(@tag_regex, text) |> Enum.map(fn ["#" <> tag = full_tag | _] -> {full_tag, String.downcase(tag)} end) @@ -17,16 +20,15 @@ defmodule Pleroma.Formatter do end).() end + @doc "Parses mentions text and returns list {nickname, user}." + @spec parse_mentions(binary()) :: list({binary(), User.t()}) def parse_mentions(text) do - # Modified from https://www.w3.org/TR/html5/forms.html#valid-e-mail-address - regex = - ~r/@[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]*@?[a-zA-Z0-9_-](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/u - - Regex.scan(regex, text) + Regex.scan(@mentions_regex, text) |> List.flatten() |> Enum.uniq() - |> Enum.map(fn "@" <> match = full_match -> - {full_match, User.get_cached_by_nickname(match)} + |> Enum.map(fn nickname -> + with nickname <- String.trim_leading(nickname, "@"), + do: {"@" <> nickname, User.get_cached_by_nickname(nickname)} end) |> Enum.filter(fn {_match, user} -> user end) end -- cgit v1.2.3 From 501ce34d7fbb74f91e8afcaa491625c5a0152597 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 20 Dec 2018 12:55:12 +0300 Subject: [#114] Stylistic adjustments. --- lib/pleroma/user.ex | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 7e792cb0c..7e3a342f1 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -76,15 +76,14 @@ defmodule Pleroma.User do def user_info(%User{} = user) do oneself = if user.local, do: 1, else: 0 - user_info = user.info %{ following_count: length(user.following) - oneself, - note_count: user_info.note_count, - follower_count: user_info.follower_count, - locked: user_info.locked, - confirmation_pending: user_info.confirmation_pending, - default_scope: user_info.default_scope + note_count: user.info.note_count, + follower_count: user.info.follower_count, + locked: user.info.locked, + confirmation_pending: user.info.confirmation_pending, + default_scope: user.info.default_scope } end @@ -182,6 +181,8 @@ defmodule Pleroma.User do :unconfirmed end + info_change = User.Info.confirmation_changeset(%User.Info{}, confirmation_status) + changeset = struct |> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation]) @@ -193,7 +194,7 @@ defmodule Pleroma.User do |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) |> validate_length(:name, min: 1, max: 100) - |> put_change(:info, User.Info.confirmation_changeset(%User.Info{}, confirmation_status)) + |> put_change(:info, info_change) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) -- cgit v1.2.3 From 8adcd1e80f78cdacd245e9b6aacea4b05cb1a880 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 20 Dec 2018 13:05:42 +0300 Subject: [#114] Removed flash messages rendering on redirects. --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 2b0f7135a..46dc9b12c 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -13,7 +13,6 @@ defmodule Pleroma.Web.TwitterAPI.Controller do require Logger plug(:only_if_public_instance when action in [:public_timeline, :public_and_external_timeline]) - plug(:fetch_flash when action in [:confirm_email, :resend_confirmation_email]) action_fallback(:errors) def verify_credentials(%{assigns: %{user: user}} = conn, _params) do @@ -390,7 +389,6 @@ defmodule Pleroma.Web.TwitterAPI.Controller do changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), {:ok, _} <- User.update_and_set_cache(changeset) do conn - |> put_flash(:info, "Email confirmed. Please sign in.") |> redirect(to: "/") end end @@ -401,7 +399,6 @@ defmodule Pleroma.Web.TwitterAPI.Controller do with %User{} = user <- User.get_by_nickname_or_email(nickname_or_email), {:ok, _} <- User.try_send_confirmation_email(user) do conn - |> put_flash(:info, "Email confirmation has been sent.") |> json_response(:no_content, "") end end -- cgit v1.2.3 From f69cbf4755b974de0303731327180bb51ed244fc Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 20 Dec 2018 13:41:30 +0300 Subject: [#114] Added :user_id component to email confirmation path to improve the security. Added tests for `confirm_email` action. --- lib/pleroma/emails/user_email.ex | 1 + lib/pleroma/user.ex | 4 ---- lib/pleroma/web/router.ex | 7 ++++++- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 856816386..8f916f470 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -70,6 +70,7 @@ defmodule Pleroma.UserEmail do Router.Helpers.confirm_email_url( Endpoint, :confirm_email, + user.id, to_string(user.info.confirmation_token) ) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 7e3a342f1..ad50cf558 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -396,10 +396,6 @@ defmodule Pleroma.User do end end - def get_by_confirmation_token(token) do - Repo.one(from(u in User, where: fragment("? ->> 'confirmation_token' = ?", u.info, ^token))) - end - def get_followers_query(%User{id: id, follower_address: follower_address}) do from( u in User, diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index ca069ab99..d1c3b34f6 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -282,7 +282,12 @@ defmodule Pleroma.Web.Router do post("/account/register", TwitterAPI.Controller, :register) post("/account/password_reset", TwitterAPI.Controller, :password_reset) - get("/account/confirm_email/:token", TwitterAPI.Controller, :confirm_email, as: :confirm_email) + get( + "/account/confirm_email/:user_id/:token", + TwitterAPI.Controller, + :confirm_email, + as: :confirm_email + ) post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 46dc9b12c..c644681b0 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -382,9 +382,11 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end end - def confirm_email(conn, %{"token" => token}) do - with %User{} = user <- User.get_by_confirmation_token(token), + def confirm_email(conn, %{"user_id" => uid, "token" => token}) do + with %User{} = user <- Repo.get(User, uid), true <- user.local, + true <- user.info.confirmation_pending, + true <- user.info.confirmation_token == token, info_change <- User.Info.confirmation_changeset(user.info, :confirmed), changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change), {:ok, _} <- User.update_and_set_cache(changeset) do -- cgit v1.2.3 From 7cab7de9ff0432a582cfca0852a4b66fdd124c41 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 20 Dec 2018 14:48:48 +0300 Subject: [#114] Allowed unconfirmed users to authenticate if :account_activation_required is disabled prior to confirmation. Ensured that no confirmation emails are sent if :account_activation_required is not true. Adjusted tests. --- lib/pleroma/user.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index ad50cf558..f8827abec 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -38,7 +38,10 @@ defmodule Pleroma.User do timestamps() end - def auth_active?(%User{} = user), do: user.info && !user.info.confirmation_pending + def auth_active?(%User{} = user) do + (user.info && !user.info.confirmation_pending) || + !Pleroma.Config.get([:instance, :account_activation_required]) + end def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info) @@ -220,7 +223,8 @@ defmodule Pleroma.User do end def try_send_confirmation_email(%User{} = user) do - if user.info.confirmation_pending do + if user.info.confirmation_pending && + Pleroma.Config.get([:instance, :account_activation_required]) do user |> Pleroma.UserEmail.account_confirmation_email() |> Pleroma.Mailer.deliver() -- cgit v1.2.3 From 336e37d98f1b86c0332c9f260e27455a14714fa6 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Fri, 21 Dec 2018 00:32:37 +0300 Subject: Make captcha (kocaptcha) stateless Also rename seconds_retained to seconds_valid since that's how it is now. Put it down from 180 to 20 seconds. The answer data is now stored in an encrypted text transfered to the client and back, so no ETS is needed --- lib/pleroma/captcha/captcha.ex | 29 ++--------- lib/pleroma/captcha/captcha_service.ex | 12 ++--- lib/pleroma/captcha/kocaptcha.ex | 82 ++++++++++++++++-------------- lib/pleroma/web/twitter_api/twitter_api.ex | 16 ++++-- 4 files changed, 65 insertions(+), 74 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index 5630f6b57..61a0f907f 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -1,8 +1,6 @@ defmodule Pleroma.Captcha do use GenServer - @ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}] - @doc false def start_link() do GenServer.start_link(__MODULE__, [], name: __MODULE__) @@ -10,14 +8,6 @@ defmodule Pleroma.Captcha do @doc false def init(_) do - # Create a ETS table to store captchas - ets_name = Module.concat(method(), Ets) - ^ets_name = :ets.new(Module.concat(method(), Ets), @ets_options) - - # Clean up old captchas every few minutes - seconds_retained = Pleroma.Config.get!([__MODULE__, :seconds_retained]) - Process.send_after(self(), :cleanup, 1000 * seconds_retained) - {:ok, nil} end @@ -31,8 +21,8 @@ defmodule Pleroma.Captcha do @doc """ Ask the configured captcha service to validate the captcha """ - def validate(token, captcha) do - GenServer.call(__MODULE__, {:validate, token, captcha}) + def validate(token, captcha, answer_data) do + GenServer.call(__MODULE__, {:validate, token, captcha, answer_data}) end @doc false @@ -47,19 +37,8 @@ defmodule Pleroma.Captcha do end @doc false - def handle_call({:validate, token, captcha}, _from, state) do - {:reply, method().validate(token, captcha), state} - end - - @doc false - def handle_info(:cleanup, state) do - :ok = method().cleanup() - - seconds_retained = Pleroma.Config.get!([__MODULE__, :seconds_retained]) - # Schedule the next clenup - Process.send_after(self(), :cleanup, 1000 * seconds_retained) - - {:noreply, state} + def handle_call({:validate, token, captcha, answer_data}, _from, state) do + {:reply, method().validate(token, captcha, answer_data), state} end defp method, do: Pleroma.Config.get!([__MODULE__, :method]) diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex index 8d0b76f86..6f36d29b0 100644 --- a/lib/pleroma/captcha/captcha_service.ex +++ b/lib/pleroma/captcha/captcha_service.ex @@ -14,15 +14,15 @@ defmodule Pleroma.Captcha.Service do Arguments: * `token` the captcha is associated with * `captcha` solution of the captcha to validate + * `answer_data` is the data needed to validate the answer (presumably encrypted) Returns: `true` if captcha is valid, `false` if not """ - @callback validate(token :: String.t(), captcha :: String.t()) :: boolean - - @doc """ - This function is called periodically to clean up old captchas - """ - @callback cleanup() :: :ok + @callback validate( + token :: String.t(), + captcha :: String.t(), + answer_data :: String.t() + ) :: :ok | {:error, String.t()} end diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index 51900d123..f881c7b65 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -1,11 +1,11 @@ defmodule Pleroma.Captcha.Kocaptcha do + alias Plug.Crypto.KeyGenerator + alias Plug.Crypto.MessageEncryptor alias Calendar.DateTime alias Pleroma.Captcha.Service @behaviour Service - @ets __MODULE__.Ets - @impl Service def new() do endpoint = Pleroma.Config.get!([__MODULE__, :endpoint]) @@ -18,50 +18,56 @@ defmodule Pleroma.Captcha.Kocaptcha do json_resp = Poison.decode!(res.body) token = json_resp["token"] + answer_md5 = json_resp["md5"] - true = - :ets.insert( - @ets, - {token, json_resp["md5"], DateTime.now_utc() |> DateTime.Format.unix()} - ) + secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) - %{type: :kocaptcha, token: token, url: endpoint <> json_resp["url"]} - end - end - - @impl Service - def validate(token, captcha) do - with false <- is_nil(captcha), - [{^token, saved_md5, _}] <- :ets.lookup(@ets, token), - true <- :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(saved_md5) do - # Clear the saved value - :ets.delete(@ets, token) + # This make salt a little different for two keys + secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") + sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") + # Basicallty copy what Phoenix.Token does here, add the time to + # the actual data and make it a binary to then encrypt it + encrypted_captcha_answer = + %{ + at: DateTime.now_utc(), + answer_md5: answer_md5 + } + |> :erlang.term_to_binary() + |> MessageEncryptor.encrypt(secret, sign_secret) - true - else - _ -> false + %{ + type: :kocaptcha, + token: token, + url: endpoint <> json_resp["url"], + answer_data: encrypted_captcha_answer + } end end @impl Service - def cleanup() do - seconds_retained = Pleroma.Config.get!([Pleroma.Captcha, :seconds_retained]) - # If the time in ETS is less than current_time - seconds_retained, then the time has - # already passed - delete_after = - DateTime.subtract!(DateTime.now_utc(), seconds_retained) |> DateTime.Format.unix() + def validate(token, captcha, answer_data) do + secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) + secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") + sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") - :ets.select_delete( - @ets, - [ - { - {:_, :_, :"$1"}, - [{:<, :"$1", {:const, delete_after}}], - [true] - } - ] - ) + # If the time found is less than (current_time - seconds_valid), then the time has already passed. + # Later we check that the time found is more than the presumed invalidatation time, that means + # that the data is still valid and the captcha can be checked + seconds_valid = Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]) + valid_if_after = DateTime.subtract!(DateTime.now_utc(), seconds_valid) - :ok + with {:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret), + %{at: at, answer_md5: answer_md5} <- :erlang.binary_to_term(data) do + if DateTime.after?(at, valid_if_after) do + if not is_nil(captcha) and + :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_md5), + do: :ok, + else: {:error, "Invalid CAPTCHA"} + else + {:error, "CAPTCHA expired"} + end + else + _ -> {:error, "Invalid answer data"} + end end end diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index d816dc3bc..9e15f2c33 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -136,22 +136,28 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do password: params["password"], password_confirmation: params["confirm"], captcha_solution: params["captcha_solution"], - captcha_token: params["captcha_token"] + captcha_token: params["captcha_token"], + captcha_answer_data: params["captcha_answer_data"] } captcha_enabled = Pleroma.Config.get([Pleroma.Captcha, :enabled]) # true if captcha is disabled or enabled and valid, false otherwise captcha_ok = if !captcha_enabled do - true + :ok else - Pleroma.Captcha.validate(params[:captcha_token], params[:captcha_solution]) + Pleroma.Captcha.validate( + params[:captcha_token], + params[:captcha_solution], + params[:captcha_answer_data] + ) end # Captcha invalid - if not captcha_ok do + if captcha_ok != :ok do + {:error, error} = captcha_ok # I have no idea how this error handling works - {:error, %{error: Jason.encode!(%{captcha: ["Invalid CAPTCHA"]})}} + {:error, %{error: Jason.encode!(%{captcha: [error]})}} else registrations_open = Pleroma.Config.get([:instance, :registrations_open]) -- cgit v1.2.3 From b386e560ba22ca93b56ba74ffc134fe7e6de8b2d Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Sat, 22 Dec 2018 22:39:08 +0300 Subject: Move the encryption out of kocaptcha into general captcha module That way there won't be a need to reimplement it for other captcha services --- lib/pleroma/captcha/captcha.ex | 53 ++++++++++++++++++++++++++++++-- lib/pleroma/captcha/captcha_service.ex | 11 +++++-- lib/pleroma/captcha/kocaptcha.ex | 56 +++++----------------------------- 3 files changed, 67 insertions(+), 53 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index 61a0f907f..04769d4b2 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -1,4 +1,8 @@ defmodule Pleroma.Captcha do + alias Plug.Crypto.KeyGenerator + alias Plug.Crypto.MessageEncryptor + alias Calendar.DateTime + use GenServer @doc false @@ -32,13 +36,58 @@ defmodule Pleroma.Captcha do if !enabled do {:reply, %{type: :none}, state} else - {:reply, method().new(), state} + new_captcha = method().new() + + secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) + + # This make salt a little different for two keys + token = new_captcha[:token] + secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") + sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") + # Basicallty copy what Phoenix.Token does here, add the time to + # the actual data and make it a binary to then encrypt it + encrypted_captcha_answer = + %{ + at: DateTime.now_utc(), + answer_data: new_captcha[:answer_data] + } + |> :erlang.term_to_binary() + |> MessageEncryptor.encrypt(secret, sign_secret) + + IO.inspect(%{new_captcha | answer_data: encrypted_captcha_answer}) + + { + :reply, + # Repalce the answer with the encrypted answer + %{new_captcha | answer_data: encrypted_captcha_answer}, + state + } end end @doc false def handle_call({:validate, token, captcha, answer_data}, _from, state) do - {:reply, method().validate(token, captcha, answer_data), state} + secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) + secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") + sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") + + # If the time found is less than (current_time - seconds_valid), then the time has already passed. + # Later we check that the time found is more than the presumed invalidatation time, that means + # that the data is still valid and the captcha can be checked + seconds_valid = Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]) + valid_if_after = DateTime.subtract!(DateTime.now_utc(), seconds_valid) + + result = + with {:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret), + %{at: at, answer_data: answer_md5} <- :erlang.binary_to_term(data) do + if DateTime.after?(at, valid_if_after), + do: method().validate(token, captcha, answer_md5), + else: {:error, "CAPTCHA expired"} + else + _ -> {:error, "Invalid answer data"} + end + + {:reply, result, state} end defp method, do: Pleroma.Config.get!([__MODULE__, :method]) diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex index 6f36d29b0..6c5ab6c36 100644 --- a/lib/pleroma/captcha/captcha_service.ex +++ b/lib/pleroma/captcha/captcha_service.ex @@ -4,9 +4,14 @@ defmodule Pleroma.Captcha.Service do Returns: - Service-specific data for using the newly created captcha + Type/Name of the service, the token to identify the captcha, + the data of the answer and service-specific data to use the newly created captcha """ - @callback new() :: map + @callback new() :: %{ + type: atom(), + token: String.t(), + answer_data: any() + } @doc """ Validated the provided captcha solution. @@ -23,6 +28,6 @@ defmodule Pleroma.Captcha.Service do @callback validate( token :: String.t(), captcha :: String.t(), - answer_data :: String.t() + answer_data :: any() ) :: :ok | {:error, String.t()} end diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index f881c7b65..cd0eb6f21 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -1,8 +1,4 @@ defmodule Pleroma.Captcha.Kocaptcha do - alias Plug.Crypto.KeyGenerator - alias Plug.Crypto.MessageEncryptor - alias Calendar.DateTime - alias Pleroma.Captcha.Service @behaviour Service @@ -17,57 +13,21 @@ defmodule Pleroma.Captcha.Kocaptcha do {:ok, res} -> json_resp = Poison.decode!(res.body) - token = json_resp["token"] - answer_md5 = json_resp["md5"] - - secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) - - # This make salt a little different for two keys - secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") - sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") - # Basicallty copy what Phoenix.Token does here, add the time to - # the actual data and make it a binary to then encrypt it - encrypted_captcha_answer = - %{ - at: DateTime.now_utc(), - answer_md5: answer_md5 - } - |> :erlang.term_to_binary() - |> MessageEncryptor.encrypt(secret, sign_secret) - %{ type: :kocaptcha, - token: token, + token: json_resp["token"], url: endpoint <> json_resp["url"], - answer_data: encrypted_captcha_answer + answer_data: json_resp["md5"] } end end @impl Service - def validate(token, captcha, answer_data) do - secret_key_base = Pleroma.Config.get!([Pleroma.Web.Endpoint, :secret_key_base]) - secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt") - sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign") - - # If the time found is less than (current_time - seconds_valid), then the time has already passed. - # Later we check that the time found is more than the presumed invalidatation time, that means - # that the data is still valid and the captcha can be checked - seconds_valid = Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]) - valid_if_after = DateTime.subtract!(DateTime.now_utc(), seconds_valid) - - with {:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret), - %{at: at, answer_md5: answer_md5} <- :erlang.binary_to_term(data) do - if DateTime.after?(at, valid_if_after) do - if not is_nil(captcha) and - :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_md5), - do: :ok, - else: {:error, "Invalid CAPTCHA"} - else - {:error, "CAPTCHA expired"} - end - else - _ -> {:error, "Invalid answer data"} - end + def validate(_token, captcha, answer_data) do + # Here the token is unsed, because the unencrypted captcha answer is just passed to method + if not is_nil(captcha) and + :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data), + do: :ok, + else: {:error, "Invalid CAPTCHA"} end end -- cgit v1.2.3 From 92362e1e22a3debfaf3275822519417ee8755a7a Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Sat, 22 Dec 2018 23:18:31 +0100 Subject: Implement large thread filter --- lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex new file mode 100644 index 000000000..0e0918126 --- /dev/null +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -0,0 +1,15 @@ +defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do + @behaviour Pleroma.Web.ActivityPub.MRF + + @impl true + def filter(object) do + + policy = Pleroma.Config.get(:mrf_hellthreadmitigation) + + if (length(object["to"]) + length(object["cc"])) > Keyword.get(policy, :threshold) do + {:reject, nil} + else + {:ok, object} + end + end +end \ No newline at end of file -- cgit v1.2.3 From 409ff60bf87d40919ec8cfcbe054cb66b87ca972 Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Sat, 22 Dec 2018 23:32:38 +0100 Subject: Fix formatting --- lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index 0e0918126..edcbc5219 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -3,13 +3,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do @impl true def filter(object) do - policy = Pleroma.Config.get(:mrf_hellthreadmitigation) - if (length(object["to"]) + length(object["cc"])) > Keyword.get(policy, :threshold) do + if length(object["to"]) + length(object["cc"]) > Keyword.get(policy, :threshold) do {:reject, nil} else {:ok, object} end end -end \ No newline at end of file +end -- cgit v1.2.3 From c76179419d5d4bb2423496856ad931974b56d6d5 Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Sun, 23 Dec 2018 11:14:29 +0100 Subject: Renamed the things --- lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index edcbc5219..d5aa2b988 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -3,7 +3,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do @impl true def filter(object) do - policy = Pleroma.Config.get(:mrf_hellthreadmitigation) + policy = Pleroma.Config.get(:mrf_hellthread) if length(object["to"]) + length(object["cc"]) > Keyword.get(policy, :threshold) do {:reject, nil} -- cgit v1.2.3 From a7f07bb6e56ad5173b9c2063d7f920cd102b4f2d Mon Sep 17 00:00:00 2001 From: Karen Konou Date: Sun, 23 Dec 2018 12:24:53 +0100 Subject: Implement kaniini's tweaks --- lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index d5aa2b988..55d6ff3f0 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -2,13 +2,17 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do @behaviour Pleroma.Web.ActivityPub.MRF @impl true - def filter(object) do - policy = Pleroma.Config.get(:mrf_hellthread) + def filter(%{"type" => "Create"} = object) do + threshold = Pleroma.Config.get([:mrf_hellthread, :threshold]) + recipients = (object["to"] || []) ++ (object["cc"] || []) - if length(object["to"]) + length(object["cc"]) > Keyword.get(policy, :threshold) do + if length(recipients) > threshold do {:reject, nil} else {:ok, object} end end + + @impl true + def filter(object), do: {:ok, object} end -- cgit v1.2.3 From 3aff8067e4b65962fe65812807cbb52bd971ddd8 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 17 Nov 2018 18:34:45 +0100 Subject: =?UTF-8?q?transmogrifier:=20When=20it=E2=80=99s=20a=20Video=20mov?= =?UTF-8?q?e=20"url"=20to=20"attachment"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pleroma/web/activity_pub/transmogrifier.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index e6af4b211..d5cc82918 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -69,8 +69,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def fix_object(object) do object |> fix_actor - |> fix_attachments |> fix_url + |> fix_attachments |> fix_context |> fix_in_reply_to |> fix_emoji @@ -200,8 +200,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do true -> "" end - object - |> Map.put("url", url_string) + if Map.get(object, "type") == "Video" do + object + |> Map.delete("url") + |> Map.put("attachment", url_string) + else + object + |> Map.put("url", url_string) + end end def fix_url(object), do: object -- cgit v1.2.3 From 71f6d9f418087a16ff266ef380b3290088e0d301 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 13:28:17 +0000 Subject: transmogrifier: significantly rework handling of peertube videos, add test --- lib/pleroma/web/activity_pub/transmogrifier.ex | 37 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index d5cc82918..4bc96b00d 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -170,8 +170,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do attachments = attachment |> Enum.map(fn data -> - url = [%{"type" => "Link", "mediaType" => data["mediaType"], "href" => data["url"]}] - Map.put(data, "url", url) + media_type = data["mediaType"] || data["mimeType"] + href = data["url"] || data["href"] + + url = [%{"type" => "Link", "mediaType" => media_type, "href" => href}] + + data + |> Map.put("mediaType", media_type) + |> Map.put("url", url) end) object @@ -190,7 +196,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> Map.put("url", url["href"]) end - def fix_url(%{"url" => url} = object) when is_list(url) do + def fix_url(%{"type" => "Video", "url" => url} = object) when is_list(url) do + first_element = Enum.at(url, 0) + + link_element = + url + |> Enum.filter(fn x -> is_map(x) end) + |> Enum.filter(fn x -> x["mimeType"] == "text/html" end) + |> Enum.at(0) + + object + |> Map.put("attachment", [first_element]) + |> Map.put("url", link_element["href"]) + end + + def fix_url(%{"type" => object_type, "url" => url} = object) + when object_type != "Video" and is_list(url) do first_element = Enum.at(url, 0) url_string = @@ -200,14 +221,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do true -> "" end - if Map.get(object, "type") == "Video" do - object - |> Map.delete("url") - |> Map.put("attachment", url_string) - else - object - |> Map.put("url", url_string) - end + object + |> Map.put("url", url_string) end def fix_url(object), do: object -- cgit v1.2.3 From 32dfc1d12a29004ef3d90c8405d25e49e74c80ab Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 13:40:33 +0000 Subject: mastodon api: status view: remove obsolete peertube hack --- lib/pleroma/web/mastodon_api/views/status_view.ex | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 46c559e3a..d06da812c 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -106,7 +106,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || []) attachment_data = object["attachment"] || [] - attachment_data = attachment_data ++ if object["type"] == "Video", do: [object], else: [] attachments = render_many(attachment_data, StatusView, "attachment.json", as: :attachment) created_at = Utils.to_masto_date(object["published"]) -- cgit v1.2.3 From 79b51a97fe9479948d429f095c5b07bc78ab5edf Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 13:53:25 +0000 Subject: twitter api: activity representer: remove peertube hack --- lib/pleroma/web/twitter_api/representers/activity_representer.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 2808192b0..d9dd352be 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -171,14 +171,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do HTML.filter_tags(content, User.html_filter_policy(opts[:for])) |> Formatter.emojify(object["emoji"]) - video = - if object["type"] == "Video" do - [object] - else - [] - end - - attachments = (object["attachment"] || []) ++ video + attachments = object["attachment"] || [] reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From 34a4ed22c4904270b1c5c2acab09e995d9a8d6dd Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 13:58:45 +0000 Subject: twitter api: add "Video" to supported activity types list --- lib/pleroma/web/twitter_api/views/activity_view.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 91d086740..c37d5486a 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -301,7 +301,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do {summary, content} end - def render_content(%{"type" => object_type} = object) when object_type in ["Article", "Page"] do + def render_content(%{"type" => object_type} = object) + when object_type in ["Article", "Page", "Video"] do summary = object["name"] || object["summary"] content = -- cgit v1.2.3 From 2791ce9a1ff2365ac7256f5e1dc2324dee2f82c9 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 20:04:54 +0000 Subject: add license boilerplate to pleroma core --- lib/pleroma/PasswordResetToken.ex | 4 ++++ lib/pleroma/activity.ex | 4 ++++ lib/pleroma/application.ex | 4 ++++ lib/pleroma/captcha/captcha.ex | 4 ++++ lib/pleroma/captcha/captcha_service.ex | 4 ++++ lib/pleroma/captcha/kocaptcha.ex | 4 ++++ lib/pleroma/config.ex | 4 ++++ lib/pleroma/emails/mailer.ex | 4 ++++ lib/pleroma/emails/user_email.ex | 4 ++++ lib/pleroma/emoji.ex | 4 ++++ lib/pleroma/filter.ex | 4 ++++ lib/pleroma/formatter.ex | 4 ++++ lib/pleroma/gopher/server.ex | 4 ++++ lib/pleroma/html.ex | 4 ++++ lib/pleroma/http/connection.ex | 4 ++++ lib/pleroma/http/http.ex | 4 ++++ lib/pleroma/http/request_builder.ex | 4 ++++ lib/pleroma/list.ex | 4 ++++ lib/pleroma/mime.ex | 4 ++++ lib/pleroma/notification.ex | 4 ++++ lib/pleroma/object.ex | 4 ++++ lib/pleroma/plugs/admin_secret_authentication_plug.ex | 4 ++++ lib/pleroma/plugs/authentication_plug.ex | 4 ++++ lib/pleroma/plugs/basic_auth_decoder_plug.ex | 4 ++++ lib/pleroma/plugs/digest.ex | 4 ++++ lib/pleroma/plugs/ensure_authenticated_plug.ex | 4 ++++ lib/pleroma/plugs/ensure_user_key_plug.ex | 4 ++++ lib/pleroma/plugs/federating_plug.ex | 4 ++++ lib/pleroma/plugs/http_security_plug.ex | 4 ++++ lib/pleroma/plugs/http_signature.ex | 4 ++++ lib/pleroma/plugs/instance_static.ex | 4 ++++ lib/pleroma/plugs/legacy_authentication_plug.ex | 4 ++++ lib/pleroma/plugs/oauth_plug.ex | 4 ++++ lib/pleroma/plugs/session_authentication_plug.ex | 4 ++++ lib/pleroma/plugs/set_user_session_id_plug.ex | 4 ++++ lib/pleroma/plugs/uploaded_media.ex | 4 ++++ lib/pleroma/plugs/user_enabled_plug.ex | 4 ++++ lib/pleroma/plugs/user_fetcher_plug.ex | 4 ++++ lib/pleroma/plugs/user_is_admin_plug.ex | 4 ++++ lib/pleroma/repo.ex | 4 ++++ lib/pleroma/reverse_proxy.ex | 4 ++++ lib/pleroma/stats.ex | 4 ++++ lib/pleroma/upload.ex | 4 ++++ lib/pleroma/upload/filter.ex | 4 ++++ lib/pleroma/upload/filter/anonymize_filename.ex | 4 ++++ lib/pleroma/upload/filter/dedupe.ex | 4 ++++ lib/pleroma/upload/filter/mogrifun.ex | 4 ++++ lib/pleroma/upload/filter/mogrify.ex | 4 ++++ lib/pleroma/uploaders/local.ex | 4 ++++ lib/pleroma/uploaders/mdii.ex | 4 ++++ lib/pleroma/uploaders/s3.ex | 4 ++++ lib/pleroma/uploaders/swift/keystone.ex | 4 ++++ lib/pleroma/uploaders/swift/swift.ex | 4 ++++ lib/pleroma/uploaders/swift/uploader.ex | 4 ++++ lib/pleroma/uploaders/uploader.ex | 4 ++++ lib/pleroma/user.ex | 4 ++++ lib/pleroma/user/info.ex | 4 ++++ lib/pleroma/user_invite_token.ex | 4 ++++ lib/pleroma/web/activity_pub/activity_pub.ex | 4 ++++ lib/pleroma/web/activity_pub/activity_pub_controller.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/drop_policy.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/noop_policy.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/normalize_markup.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/reject_non_public.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/simple_policy.ex | 4 ++++ lib/pleroma/web/activity_pub/mrf/user_allowlist.ex | 4 ++++ lib/pleroma/web/activity_pub/relay.ex | 4 ++++ lib/pleroma/web/activity_pub/transmogrifier.ex | 4 ++++ lib/pleroma/web/activity_pub/utils.ex | 4 ++++ lib/pleroma/web/activity_pub/views/object_view.ex | 4 ++++ lib/pleroma/web/activity_pub/views/user_view.ex | 4 ++++ lib/pleroma/web/admin_api/admin_api_controller.ex | 4 ++++ lib/pleroma/web/channels/user_socket.ex | 4 ++++ lib/pleroma/web/chat_channel.ex | 4 ++++ lib/pleroma/web/common_api/common_api.ex | 4 ++++ lib/pleroma/web/common_api/utils.ex | 4 ++++ lib/pleroma/web/controller_helper.ex | 4 ++++ lib/pleroma/web/endpoint.ex | 4 ++++ lib/pleroma/web/federator/federator.ex | 4 ++++ lib/pleroma/web/federator/retry_queue.ex | 4 ++++ lib/pleroma/web/gettext.ex | 4 ++++ lib/pleroma/web/http_signatures/http_signatures.ex | 4 ++++ lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/account_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/filter_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/list_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/mastodon_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/push_subscription_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/status_view.ex | 4 ++++ lib/pleroma/web/mastodon_api/websocket_handler.ex | 4 ++++ lib/pleroma/web/media_proxy/controller.ex | 4 ++++ lib/pleroma/web/media_proxy/media_proxy.ex | 4 ++++ lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 4 ++++ lib/pleroma/web/oauth/app.ex | 4 ++++ lib/pleroma/web/oauth/authorization.ex | 4 ++++ lib/pleroma/web/oauth/fallback_controller.ex | 4 ++++ lib/pleroma/web/oauth/oauth_controller.ex | 4 ++++ lib/pleroma/web/oauth/oauth_view.ex | 4 ++++ lib/pleroma/web/oauth/token.ex | 4 ++++ lib/pleroma/web/ostatus/activity_representer.ex | 4 ++++ lib/pleroma/web/ostatus/feed_representer.ex | 4 ++++ lib/pleroma/web/ostatus/handlers/delete_handler.ex | 4 ++++ lib/pleroma/web/ostatus/handlers/follow_handler.ex | 4 ++++ lib/pleroma/web/ostatus/handlers/note_handler.ex | 4 ++++ lib/pleroma/web/ostatus/handlers/unfollow_handler.ex | 4 ++++ lib/pleroma/web/ostatus/ostatus.ex | 4 ++++ lib/pleroma/web/ostatus/ostatus_controller.ex | 4 ++++ lib/pleroma/web/ostatus/user_representer.ex | 4 ++++ lib/pleroma/web/push/push.ex | 4 ++++ lib/pleroma/web/push/subscription.ex | 4 ++++ lib/pleroma/web/router.ex | 4 ++++ lib/pleroma/web/salmon/salmon.ex | 4 ++++ lib/pleroma/web/streamer.ex | 4 ++++ lib/pleroma/web/twitter_api/controllers/util_controller.ex | 4 ++++ lib/pleroma/web/twitter_api/representers/activity_representer.ex | 4 ++++ lib/pleroma/web/twitter_api/representers/base_representer.ex | 4 ++++ lib/pleroma/web/twitter_api/representers/object_representer.ex | 4 ++++ lib/pleroma/web/twitter_api/twitter_api.ex | 4 ++++ lib/pleroma/web/twitter_api/twitter_api_controller.ex | 4 ++++ lib/pleroma/web/twitter_api/views/activity_view.ex | 4 ++++ lib/pleroma/web/twitter_api/views/notification_view.ex | 4 ++++ lib/pleroma/web/twitter_api/views/user_view.ex | 4 ++++ lib/pleroma/web/twitter_api/views/util_view.ex | 4 ++++ lib/pleroma/web/views/error_helpers.ex | 4 ++++ lib/pleroma/web/views/error_view.ex | 4 ++++ lib/pleroma/web/views/layout_view.ex | 4 ++++ lib/pleroma/web/web.ex | 4 ++++ lib/pleroma/web/web_finger/web_finger.ex | 4 ++++ lib/pleroma/web/web_finger/web_finger_controller.ex | 4 ++++ lib/pleroma/web/websub/websub.ex | 4 ++++ lib/pleroma/web/websub/websub_client_subscription.ex | 4 ++++ lib/pleroma/web/websub/websub_controller.ex | 4 ++++ lib/pleroma/web/websub/websub_server_subscription.ex | 4 ++++ lib/pleroma/web/xml/xml.ex | 4 ++++ 137 files changed, 548 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/PasswordResetToken.ex b/lib/pleroma/PasswordResetToken.ex index 15750565b..57e3b7ef0 100644 --- a/lib/pleroma/PasswordResetToken.ex +++ b/lib/pleroma/PasswordResetToken.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.PasswordResetToken do use Ecto.Schema diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 200addd6e..34b665765 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Activity do use Ecto.Schema alias Pleroma.{Repo, Activity, Notification} diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index e15991957..36a3694f2 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Application do use Application import Supervisor.Spec diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index 5630f6b57..f80946c8b 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Captcha do use GenServer diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex index 8d0b76f86..6037b7087 100644 --- a/lib/pleroma/captcha/captcha_service.ex +++ b/lib/pleroma/captcha/captcha_service.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Captcha.Service do @doc """ Request new captcha from a captcha service. diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index 51900d123..54f4c8bcd 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Captcha.Kocaptcha do alias Calendar.DateTime diff --git a/lib/pleroma/config.ex b/lib/pleroma/config.ex index 3876ddf1f..6b1598d66 100644 --- a/lib/pleroma/config.ex +++ b/lib/pleroma/config.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Config do defmodule Error do defexception [:message] diff --git a/lib/pleroma/emails/mailer.ex b/lib/pleroma/emails/mailer.ex index 14ed32ea8..a8bd70b6e 100644 --- a/lib/pleroma/emails/mailer.ex +++ b/lib/pleroma/emails/mailer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Mailer do use Swoosh.Mailer, otp_app: :pleroma end diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 8f916f470..688b0cd1c 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.UserEmail do @moduledoc "User emails" diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index bedad99d6..b5e0a83d8 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Emoji do @moduledoc """ The emojis are loaded from: diff --git a/lib/pleroma/filter.ex b/lib/pleroma/filter.ex index c57bd3bf8..9ddc5fd6c 100644 --- a/lib/pleroma/filter.ex +++ b/lib/pleroma/filter.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Filter do use Ecto.Schema import Ecto.{Changeset, Query} diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 72fe9640b..49a9913dc 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Formatter do alias Pleroma.User alias Pleroma.Web.MediaProxy diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex index 4d582ef25..fee7156d3 100644 --- a/lib/pleroma/gopher/server.ex +++ b/lib/pleroma/gopher/server.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Gopher.Server do use GenServer require Logger diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 583f05aeb..a0473676b 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTML do alias HtmlSanitizeEx.Scrubber diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex index 7b11060b2..35c1490da 100644 --- a/lib/pleroma/http/connection.ex +++ b/lib/pleroma/http/connection.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP.Connection do @moduledoc """ Connection for http-requests. diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 3c0256575..e572dfedf 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP do @moduledoc """ diff --git a/lib/pleroma/http/request_builder.ex b/lib/pleroma/http/request_builder.ex index 5aee2b8ae..54569c6f7 100644 --- a/lib/pleroma/http/request_builder.ex +++ b/lib/pleroma/http/request_builder.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.HTTP.RequestBuilder do @moduledoc """ Helper functions for building Tesla requests diff --git a/lib/pleroma/list.ex b/lib/pleroma/list.ex index c5bf3e083..2c799bc33 100644 --- a/lib/pleroma/list.ex +++ b/lib/pleroma/list.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.List do use Ecto.Schema import Ecto.{Changeset, Query} diff --git a/lib/pleroma/mime.ex b/lib/pleroma/mime.ex index 2cb3d8bd1..e3a389749 100644 --- a/lib/pleroma/mime.ex +++ b/lib/pleroma/mime.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.MIME do @moduledoc """ Returns the mime-type of a binary and optionally a normalized file-name. diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 47f6b6ee7..301cfd134 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Notification do use Ecto.Schema alias Pleroma.{User, Activity, Notification, Repo, Object} diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 31c8dd5bd..cc4a2181a 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Object do use Ecto.Schema alias Pleroma.{Repo, Object, User, Activity} diff --git a/lib/pleroma/plugs/admin_secret_authentication_plug.ex b/lib/pleroma/plugs/admin_secret_authentication_plug.ex index f61a6ee24..2c9348715 100644 --- a/lib/pleroma/plugs/admin_secret_authentication_plug.ex +++ b/lib/pleroma/plugs/admin_secret_authentication_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.AdminSecretAuthenticationPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex index b240ff29f..6b8d51300 100644 --- a/lib/pleroma/plugs/authentication_plug.ex +++ b/lib/pleroma/plugs/authentication_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.AuthenticationPlug do alias Comeonin.Pbkdf2 import Plug.Conn diff --git a/lib/pleroma/plugs/basic_auth_decoder_plug.ex b/lib/pleroma/plugs/basic_auth_decoder_plug.ex index f7ebf7db2..0690f4bea 100644 --- a/lib/pleroma/plugs/basic_auth_decoder_plug.ex +++ b/lib/pleroma/plugs/basic_auth_decoder_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.BasicAuthDecoderPlug do import Plug.Conn diff --git a/lib/pleroma/plugs/digest.ex b/lib/pleroma/plugs/digest.ex index 9d6bbb085..27b206965 100644 --- a/lib/pleroma/plugs/digest.ex +++ b/lib/pleroma/plugs/digest.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Plugs.DigestPlug do alias Plug.Conn require Logger diff --git a/lib/pleroma/plugs/ensure_authenticated_plug.ex b/lib/pleroma/plugs/ensure_authenticated_plug.ex index bca44eb2c..f18653f41 100644 --- a/lib/pleroma/plugs/ensure_authenticated_plug.ex +++ b/lib/pleroma/plugs/ensure_authenticated_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.EnsureAuthenticatedPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/plugs/ensure_user_key_plug.ex b/lib/pleroma/plugs/ensure_user_key_plug.ex index 05a567757..db3da228d 100644 --- a/lib/pleroma/plugs/ensure_user_key_plug.ex +++ b/lib/pleroma/plugs/ensure_user_key_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.EnsureUserKeyPlug do import Plug.Conn diff --git a/lib/pleroma/plugs/federating_plug.ex b/lib/pleroma/plugs/federating_plug.ex index b5326d97b..e7dfda295 100644 --- a/lib/pleroma/plugs/federating_plug.ex +++ b/lib/pleroma/plugs/federating_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.FederatingPlug do import Plug.Conn diff --git a/lib/pleroma/plugs/http_security_plug.ex b/lib/pleroma/plugs/http_security_plug.ex index f34f2364b..11bceafd4 100644 --- a/lib/pleroma/plugs/http_security_plug.ex +++ b/lib/pleroma/plugs/http_security_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.HTTPSecurityPlug do alias Pleroma.Config import Plug.Conn diff --git a/lib/pleroma/plugs/http_signature.ex b/lib/pleroma/plugs/http_signature.ex index 9e53371b7..33fbba840 100644 --- a/lib/pleroma/plugs/http_signature.ex +++ b/lib/pleroma/plugs/http_signature.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do alias Pleroma.Web.HTTPSignatures alias Pleroma.Web.ActivityPub.Utils diff --git a/lib/pleroma/plugs/instance_static.ex b/lib/pleroma/plugs/instance_static.ex index 46ee77e11..02ee99e0f 100644 --- a/lib/pleroma/plugs/instance_static.ex +++ b/lib/pleroma/plugs/instance_static.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.InstanceStatic do @moduledoc """ This is a shim to call `Plug.Static` but with runtime `from` configuration. diff --git a/lib/pleroma/plugs/legacy_authentication_plug.ex b/lib/pleroma/plugs/legacy_authentication_plug.ex index d22c1a647..3cb3fdf4b 100644 --- a/lib/pleroma/plugs/legacy_authentication_plug.ex +++ b/lib/pleroma/plugs/legacy_authentication_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.LegacyAuthenticationPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/plugs/oauth_plug.ex b/lib/pleroma/plugs/oauth_plug.ex index 13c914c1b..7c3541197 100644 --- a/lib/pleroma/plugs/oauth_plug.ex +++ b/lib/pleroma/plugs/oauth_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.OAuthPlug do import Plug.Conn import Ecto.Query diff --git a/lib/pleroma/plugs/session_authentication_plug.ex b/lib/pleroma/plugs/session_authentication_plug.ex index aed619432..413bdcf2c 100644 --- a/lib/pleroma/plugs/session_authentication_plug.ex +++ b/lib/pleroma/plugs/session_authentication_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.SessionAuthenticationPlug do import Plug.Conn diff --git a/lib/pleroma/plugs/set_user_session_id_plug.ex b/lib/pleroma/plugs/set_user_session_id_plug.ex index adc0a42b5..9fad6dfee 100644 --- a/lib/pleroma/plugs/set_user_session_id_plug.ex +++ b/lib/pleroma/plugs/set_user_session_id_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.SetUserSessionIdPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/plugs/uploaded_media.ex b/lib/pleroma/plugs/uploaded_media.ex index 7e1e84126..f998293e8 100644 --- a/lib/pleroma/plugs/uploaded_media.ex +++ b/lib/pleroma/plugs/uploaded_media.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.UploadedMedia do @moduledoc """ """ diff --git a/lib/pleroma/plugs/user_enabled_plug.ex b/lib/pleroma/plugs/user_enabled_plug.ex index 01482f47d..79d6a9b99 100644 --- a/lib/pleroma/plugs/user_enabled_plug.ex +++ b/lib/pleroma/plugs/user_enabled_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.UserEnabledPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/plugs/user_fetcher_plug.ex b/lib/pleroma/plugs/user_fetcher_plug.ex index e24785ad1..04957148b 100644 --- a/lib/pleroma/plugs/user_fetcher_plug.ex +++ b/lib/pleroma/plugs/user_fetcher_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.UserFetcherPlug do import Plug.Conn alias Pleroma.Repo diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex index cf22ce5d0..a98c2c853 100644 --- a/lib/pleroma/plugs/user_is_admin_plug.ex +++ b/lib/pleroma/plugs/user_is_admin_plug.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.UserIsAdminPlug do import Plug.Conn alias Pleroma.User diff --git a/lib/pleroma/repo.ex b/lib/pleroma/repo.ex index 7cecd7b38..0b49f7712 100644 --- a/lib/pleroma/repo.ex +++ b/lib/pleroma/repo.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Repo do use Ecto.Repo, otp_app: :pleroma diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex index 7f328d00d..c9d6f0d2c 100644 --- a/lib/pleroma/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.ReverseProxy do @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since if-none-match if-range range) @resp_cache_headers ~w(etag date last-modified cache-control) diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index 8478fe4ce..c48184ed3 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Stats do import Ecto.Query alias Pleroma.{User, Repo} diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 07031ac58..744abec56 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload do @moduledoc """ # Upload diff --git a/lib/pleroma/upload/filter.ex b/lib/pleroma/upload/filter.ex index d1384ddad..f7257be65 100644 --- a/lib/pleroma/upload/filter.ex +++ b/lib/pleroma/upload/filter.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload.Filter do @moduledoc """ Upload Filter behaviour diff --git a/lib/pleroma/upload/filter/anonymize_filename.ex b/lib/pleroma/upload/filter/anonymize_filename.ex index 39eed7af3..c26e4f32c 100644 --- a/lib/pleroma/upload/filter/anonymize_filename.ex +++ b/lib/pleroma/upload/filter/anonymize_filename.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload.Filter.AnonymizeFilename do @moduledoc """ Replaces the original filename with a pre-defined text or randomly generated string. diff --git a/lib/pleroma/upload/filter/dedupe.ex b/lib/pleroma/upload/filter/dedupe.ex index 0657b2c8d..2d1ddab7f 100644 --- a/lib/pleroma/upload/filter/dedupe.ex +++ b/lib/pleroma/upload/filter/dedupe.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload.Filter.Dedupe do @behaviour Pleroma.Upload.Filter alias Pleroma.Upload diff --git a/lib/pleroma/upload/filter/mogrifun.ex b/lib/pleroma/upload/filter/mogrifun.ex index 4d4f0b401..f8920d31b 100644 --- a/lib/pleroma/upload/filter/mogrifun.ex +++ b/lib/pleroma/upload/filter/mogrifun.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload.Filter.Mogrifun do @behaviour Pleroma.Upload.Filter diff --git a/lib/pleroma/upload/filter/mogrify.ex b/lib/pleroma/upload/filter/mogrify.ex index f106bd4b1..7331c2bd9 100644 --- a/lib/pleroma/upload/filter/mogrify.ex +++ b/lib/pleroma/upload/filter/mogrify.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Upload.Filter.Mogrify do @behaviour Pleroma.Upload.Filter diff --git a/lib/pleroma/uploaders/local.ex b/lib/pleroma/uploaders/local.ex index 2994bcd51..de50a13c1 100644 --- a/lib/pleroma/uploaders/local.ex +++ b/lib/pleroma/uploaders/local.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.Local do @behaviour Pleroma.Uploaders.Uploader diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex index f06755056..b16782fbb 100644 --- a/lib/pleroma/uploaders/mdii.ex +++ b/lib/pleroma/uploaders/mdii.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.MDII do alias Pleroma.Config diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 19832a7ec..db5e8b75e 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.S3 do @behaviour Pleroma.Uploaders.Uploader require Logger diff --git a/lib/pleroma/uploaders/swift/keystone.ex b/lib/pleroma/uploaders/swift/keystone.ex index 4aed977b1..f10361b19 100644 --- a/lib/pleroma/uploaders/swift/keystone.ex +++ b/lib/pleroma/uploaders/swift/keystone.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.Swift.Keystone do use HTTPoison.Base diff --git a/lib/pleroma/uploaders/swift/swift.ex b/lib/pleroma/uploaders/swift/swift.ex index d4e758bbb..fef426b42 100644 --- a/lib/pleroma/uploaders/swift/swift.ex +++ b/lib/pleroma/uploaders/swift/swift.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.Swift.Client do use HTTPoison.Base diff --git a/lib/pleroma/uploaders/swift/uploader.ex b/lib/pleroma/uploaders/swift/uploader.ex index b35b9807b..d359ff8f8 100644 --- a/lib/pleroma/uploaders/swift/uploader.ex +++ b/lib/pleroma/uploaders/swift/uploader.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.Swift do @behaviour Pleroma.Uploaders.Uploader diff --git a/lib/pleroma/uploaders/uploader.ex b/lib/pleroma/uploaders/uploader.ex index afda5609e..49da6e9a9 100644 --- a/lib/pleroma/uploaders/uploader.ex +++ b/lib/pleroma/uploaders/uploader.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Uploaders.Uploader do @moduledoc """ Defines the contract to put and get an uploaded file to any backend. diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index f8827abec..1f930479d 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.User do use Ecto.Schema diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 3de4af56c..71848d91e 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.User.Info do use Ecto.Schema import Ecto.Changeset diff --git a/lib/pleroma/user_invite_token.ex b/lib/pleroma/user_invite_token.ex index ce804f78e..65ffe149c 100644 --- a/lib/pleroma/user_invite_token.ex +++ b/lib/pleroma/user_invite_token.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.UserInviteToken do use Ecto.Schema diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 31455343c..188060780 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.ActivityPub do alias Pleroma.{Activity, Repo, Object, Upload, User, Notification} alias Pleroma.Web.ActivityPub.{Transmogrifier, MRF} diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 0317f3c8c..7fd6a45f5 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.ActivityPubController do use Pleroma.Web, :controller alias Pleroma.{User, Object} diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex index 0a4e2bf80..00919a5f6 100644 --- a/lib/pleroma/web/activity_pub/mrf.ex +++ b/lib/pleroma/web/activity_pub/mrf.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF do @callback filter(Map.t()) :: {:ok | :reject, Map.t()} diff --git a/lib/pleroma/web/activity_pub/mrf/drop_policy.ex b/lib/pleroma/web/activity_pub/mrf/drop_policy.ex index 811947943..6ac7b0ec1 100644 --- a/lib/pleroma/web/activity_pub/mrf/drop_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/drop_policy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do require Logger @behaviour Pleroma.Web.ActivityPub.MRF diff --git a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex index 6fa48454a..ca3ee8a0d 100644 --- a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex +++ b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do alias Pleroma.Object diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index 55d6ff3f0..e4fb0b5b0 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do @behaviour Pleroma.Web.ActivityPub.MRF diff --git a/lib/pleroma/web/activity_pub/mrf/noop_policy.ex b/lib/pleroma/web/activity_pub/mrf/noop_policy.ex index e26f60d26..8eacc62bc 100644 --- a/lib/pleroma/web/activity_pub/mrf/noop_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/noop_policy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do @behaviour Pleroma.Web.ActivityPub.MRF diff --git a/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex b/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex index c53cb1ad2..6cfd43974 100644 --- a/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex +++ b/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do alias Pleroma.HTML diff --git a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex index 627284083..07d739437 100644 --- a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex +++ b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do alias Pleroma.User @behaviour Pleroma.Web.ActivityPub.MRF diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex index 12fc3b181..9ced1e620 100644 --- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do alias Pleroma.User @behaviour Pleroma.Web.ActivityPub.MRF diff --git a/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex b/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex index 3503d8692..7a78c50bf 100644 --- a/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex +++ b/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do alias Pleroma.Config diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index fcdc6b1c0..d0a866589 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.Relay do alias Pleroma.{User, Object, Activity} alias Pleroma.Web.ActivityPub.ActivityPub diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 4bc96b00d..315571e1a 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.Transmogrifier do @moduledoc """ A module to handle coding from internal to wire ActivityPub and back. diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 074622f2b..59cf6abfc 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.Utils do alias Pleroma.{Repo, Web, Object, Activity, User, Notification} alias Pleroma.Web.Router.Helpers diff --git a/lib/pleroma/web/activity_pub/views/object_view.ex b/lib/pleroma/web/activity_pub/views/object_view.ex index ff664636c..efe16b2bf 100644 --- a/lib/pleroma/web/activity_pub/views/object_view.ex +++ b/lib/pleroma/web/activity_pub/views/object_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.ObjectView do use Pleroma.Web, :view alias Pleroma.{Object, Activity} diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index 869934172..f0c268755 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.UserView do use Pleroma.Web, :view alias Pleroma.Web.Salmon diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 683310168..49d237661 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.AdminAPI.AdminAPIController do use Pleroma.Web, :controller alias Pleroma.User diff --git a/lib/pleroma/web/channels/user_socket.ex b/lib/pleroma/web/channels/user_socket.ex index 9918d3b49..23ba5a381 100644 --- a/lib/pleroma/web/channels/user_socket.ex +++ b/lib/pleroma/web/channels/user_socket.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.UserSocket do use Phoenix.Socket alias Pleroma.User diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/chat_channel.ex index 37eba8c3f..ac28f300b 100644 --- a/lib/pleroma/web/chat_channel.ex +++ b/lib/pleroma/web/chat_channel.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ChatChannel do use Phoenix.Channel alias Pleroma.Web.ChatChannel.ChatChannelState diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index f01d36370..5e5821561 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.CommonAPI do alias Pleroma.{User, Repo, Activity, Object} alias Pleroma.Web.ActivityPub.ActivityPub diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 142283684..b91cfc4bb 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.CommonAPI.Utils do alias Calendar.Strftime alias Comeonin.Pbkdf2 diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex index ddf958811..cb0463eeb 100644 --- a/lib/pleroma/web/controller_helper.ex +++ b/lib/pleroma/web/controller_helper.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ControllerHelper do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 564fc2c1d..e994f8f37 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Endpoint do use Phoenix.Endpoint, otp_app: :pleroma diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index a9c7aecd5..3aec55274 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Federator do use GenServer alias Pleroma.User diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index 510b4315d..5f1d43008 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Federator.RetryQueue do use GenServer diff --git a/lib/pleroma/web/gettext.ex b/lib/pleroma/web/gettext.ex index 501545581..f40fd04c0 100644 --- a/lib/pleroma/web/gettext.ex +++ b/lib/pleroma/web/gettext.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. diff --git a/lib/pleroma/web/http_signatures/http_signatures.ex b/lib/pleroma/web/http_signatures/http_signatures.ex index 0e54debd5..0e4f8f14b 100644 --- a/lib/pleroma/web/http_signatures/http_signatures.ex +++ b/lib/pleroma/web/http_signatures/http_signatures.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + # https://tools.ietf.org/html/draft-cavage-http-signatures-08 defmodule Pleroma.Web.HTTPSignatures do alias Pleroma.User diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index c6db89442..22715bb76 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do use Pleroma.Web, :controller alias Pleroma.{Repo, Object, Activity, User, Notification, Stats} diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 50df88aca..aaaae2035 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.AccountView do use Pleroma.Web, :view alias Pleroma.User diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex index 6bd687d46..ffbd830e1 100644 --- a/lib/pleroma/web/mastodon_api/views/filter_view.ex +++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.FilterView do use Pleroma.Web, :view alias Pleroma.Web.MastodonAPI.FilterView diff --git a/lib/pleroma/web/mastodon_api/views/list_view.ex b/lib/pleroma/web/mastodon_api/views/list_view.ex index 1a1b7430b..dd0121f7a 100644 --- a/lib/pleroma/web/mastodon_api/views/list_view.ex +++ b/lib/pleroma/web/mastodon_api/views/list_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.ListView do use Pleroma.Web, :view alias Pleroma.Web.MastodonAPI.ListView diff --git a/lib/pleroma/web/mastodon_api/views/mastodon_view.ex b/lib/pleroma/web/mastodon_api/views/mastodon_view.ex index 1fd05d9f1..a3adabc50 100644 --- a/lib/pleroma/web/mastodon_api/views/mastodon_view.ex +++ b/lib/pleroma/web/mastodon_api/views/mastodon_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.MastodonView do use Pleroma.Web, :view import Phoenix.HTML diff --git a/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex b/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex index 67e86294e..7970bcd47 100644 --- a/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex +++ b/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.PushSubscriptionView do use Pleroma.Web, :view diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index d06da812c..4d4681da8 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.StatusView do use Pleroma.Web, :view diff --git a/lib/pleroma/web/mastodon_api/websocket_handler.ex b/lib/pleroma/web/mastodon_api/websocket_handler.ex index 11e0e1696..7b90649ad 100644 --- a/lib/pleroma/web/mastodon_api/websocket_handler.ex +++ b/lib/pleroma/web/mastodon_api/websocket_handler.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do require Logger diff --git a/lib/pleroma/web/media_proxy/controller.ex b/lib/pleroma/web/media_proxy/controller.ex index 63140feb9..8c82b4176 100644 --- a/lib/pleroma/web/media_proxy/controller.ex +++ b/lib/pleroma/web/media_proxy/controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MediaProxy.MediaProxyController do use Pleroma.Web, :controller alias Pleroma.{Web.MediaProxy, ReverseProxy} diff --git a/lib/pleroma/web/media_proxy/media_proxy.ex b/lib/pleroma/web/media_proxy/media_proxy.ex index 902ab1b77..a61726b3e 100644 --- a/lib/pleroma/web/media_proxy/media_proxy.ex +++ b/lib/pleroma/web/media_proxy/media_proxy.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.MediaProxy do @base64_opts [padding: false] diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 70921605d..1265d81c5 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Nodeinfo.NodeinfoController do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/oauth/app.ex b/lib/pleroma/web/oauth/app.ex index b3273bc6e..c18e9da8c 100644 --- a/lib/pleroma/web/oauth/app.ex +++ b/lib/pleroma/web/oauth/app.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.App do use Ecto.Schema import Ecto.{Changeset} diff --git a/lib/pleroma/web/oauth/authorization.ex b/lib/pleroma/web/oauth/authorization.ex index 2cad4550a..7e75d71b3 100644 --- a/lib/pleroma/web/oauth/authorization.ex +++ b/lib/pleroma/web/oauth/authorization.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.Authorization do use Ecto.Schema diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex index 3927cdb64..e1d91dc80 100644 --- a/lib/pleroma/web/oauth/fallback_controller.ex +++ b/lib/pleroma/web/oauth/fallback_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.FallbackController do use Pleroma.Web, :controller alias Pleroma.Web.OAuth.OAuthController diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 9a972ee47..41b0f253d 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.OAuthController do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/oauth/oauth_view.ex b/lib/pleroma/web/oauth/oauth_view.ex index b3923fcf5..da6f72433 100644 --- a/lib/pleroma/web/oauth/oauth_view.ex +++ b/lib/pleroma/web/oauth/oauth_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.OAuthView do use Pleroma.Web, :view import Phoenix.HTML.Form diff --git a/lib/pleroma/web/oauth/token.ex b/lib/pleroma/web/oauth/token.ex index a77d5af35..aa3610bb3 100644 --- a/lib/pleroma/web/oauth/token.ex +++ b/lib/pleroma/web/oauth/token.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OAuth.Token do use Ecto.Schema diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 537bd9f77..bd05c671b 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.ActivityRepresenter do alias Pleroma.{Activity, User, Object} alias Pleroma.Web.OStatus.UserRepresenter diff --git a/lib/pleroma/web/ostatus/feed_representer.ex b/lib/pleroma/web/ostatus/feed_representer.ex index 279672673..2c2157173 100644 --- a/lib/pleroma/web/ostatus/feed_representer.ex +++ b/lib/pleroma/web/ostatus/feed_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.FeedRepresenter do alias Pleroma.Web.OStatus alias Pleroma.Web.OStatus.{UserRepresenter, ActivityRepresenter} diff --git a/lib/pleroma/web/ostatus/handlers/delete_handler.ex b/lib/pleroma/web/ostatus/handlers/delete_handler.ex index 6330d7f64..e7cf4cb54 100644 --- a/lib/pleroma/web/ostatus/handlers/delete_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/delete_handler.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.DeleteHandler do require Logger alias Pleroma.Web.XML diff --git a/lib/pleroma/web/ostatus/handlers/follow_handler.ex b/lib/pleroma/web/ostatus/handlers/follow_handler.ex index 162407e04..aef450935 100644 --- a/lib/pleroma/web/ostatus/handlers/follow_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/follow_handler.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.FollowHandler do alias Pleroma.Web.{XML, OStatus} alias Pleroma.Web.ActivityPub.ActivityPub diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex index 0d4080291..7fd364b45 100644 --- a/lib/pleroma/web/ostatus/handlers/note_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.NoteHandler do require Logger alias Pleroma.Web.{XML, OStatus} diff --git a/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex b/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex index a115bf4c8..bd86a54c7 100644 --- a/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.UnfollowHandler do alias Pleroma.Web.{XML, OStatus} alias Pleroma.Web.ActivityPub.ActivityPub diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index c6440c20e..cd5493e16 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus do @httpoison Application.get_env(:pleroma, :httpoison) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 6005eadb2..9ad702dd4 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.OStatusController do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/ostatus/user_representer.ex b/lib/pleroma/web/ostatus/user_representer.ex index 2e696506e..ef8371a2c 100644 --- a/lib/pleroma/web/ostatus/user_representer.ex +++ b/lib/pleroma/web/ostatus/user_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.OStatus.UserRepresenter do alias Pleroma.User diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push/push.ex index 477943450..6459d4543 100644 --- a/lib/pleroma/web/push/push.ex +++ b/lib/pleroma/web/push/push.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Push do use GenServer diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex index 1ad405daf..65d28fee9 100644 --- a/lib/pleroma/web/push/subscription.ex +++ b/lib/pleroma/web/push/subscription.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Push.Subscription do use Ecto.Schema import Ecto.Changeset diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 2c62cdf2f..7ec0cabb3 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Router do use Pleroma.Web, :router diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index b67b1333f..1dc514976 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Salmon do @httpoison Application.get_env(:pleroma, :httpoison) diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index e1eecba4d..05f877438 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Streamer do use GenServer require Logger diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 3baeba619..c872aec2b 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.UtilController do use Pleroma.Web, :controller require Logger diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index d9dd352be..489a55b6c 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + # THIS MODULE IS DEPRECATED! DON'T USE IT! # USE THE Pleroma.Web.TwitterAPI.Views.ActivityView MODULE! defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do diff --git a/lib/pleroma/web/twitter_api/representers/base_representer.ex b/lib/pleroma/web/twitter_api/representers/base_representer.ex index f32a21d47..28a59205d 100644 --- a/lib/pleroma/web/twitter_api/representers/base_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/base_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.Representers.BaseRepresenter do defmacro __using__(_opts) do quote do diff --git a/lib/pleroma/web/twitter_api/representers/object_representer.ex b/lib/pleroma/web/twitter_api/representers/object_representer.ex index d5291a397..2f33e7af4 100644 --- a/lib/pleroma/web/twitter_api/representers/object_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/object_representer.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter do use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter alias Pleroma.Object diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index d816dc3bc..e2b1e0a8e 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.TwitterAPI do alias Pleroma.{UserInviteToken, User, Activity, Repo, Object} alias Pleroma.{UserEmail, Mailer} diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index c644681b0..c25cb0876 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.Controller do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index df93ceb6c..592cf622f 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.ActivityView do use Pleroma.Web, :view alias Pleroma.Web.CommonAPI.Utils diff --git a/lib/pleroma/web/twitter_api/views/notification_view.ex b/lib/pleroma/web/twitter_api/views/notification_view.ex index 9eeb3afdc..d889038a2 100644 --- a/lib/pleroma/web/twitter_api/views/notification_view.ex +++ b/lib/pleroma/web/twitter_api/views/notification_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.NotificationView do use Pleroma.Web, :view alias Pleroma.{Notification, User} diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 45b893eda..6e489624f 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.UserView do use Pleroma.Web, :view alias Pleroma.User diff --git a/lib/pleroma/web/twitter_api/views/util_view.ex b/lib/pleroma/web/twitter_api/views/util_view.ex index 71b04e6cc..aa5f842ac 100644 --- a/lib/pleroma/web/twitter_api/views/util_view.ex +++ b/lib/pleroma/web/twitter_api/views/util_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.UtilView do use Pleroma.Web, :view import Phoenix.HTML.Form diff --git a/lib/pleroma/web/views/error_helpers.ex b/lib/pleroma/web/views/error_helpers.ex index 3981b270d..df1e0d437 100644 --- a/lib/pleroma/web/views/error_helpers.ex +++ b/lib/pleroma/web/views/error_helpers.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. diff --git a/lib/pleroma/web/views/error_view.ex b/lib/pleroma/web/views/error_view.ex index 7106031ae..d8158edb4 100644 --- a/lib/pleroma/web/views/error_view.ex +++ b/lib/pleroma/web/views/error_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ErrorView do use Pleroma.Web, :view diff --git a/lib/pleroma/web/views/layout_view.ex b/lib/pleroma/web/views/layout_view.ex index d4d4c3bd3..ba94b9def 100644 --- a/lib/pleroma/web/views/layout_view.ex +++ b/lib/pleroma/web/views/layout_view.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.LayoutView do use Pleroma.Web, :view end diff --git a/lib/pleroma/web/web.ex b/lib/pleroma/web/web.ex index b82242a78..1aa86f645 100644 --- a/lib/pleroma/web/web.ex +++ b/lib/pleroma/web/web.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web do @moduledoc """ A module that keeps using definitions for controllers, diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 47c733da2..3cc90d5dd 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.WebFinger do @httpoison Application.get_env(:pleroma, :httpoison) diff --git a/lib/pleroma/web/web_finger/web_finger_controller.ex b/lib/pleroma/web/web_finger/web_finger_controller.ex index 8c60300a4..66d5a880d 100644 --- a/lib/pleroma/web/web_finger/web_finger_controller.ex +++ b/lib/pleroma/web/web_finger/web_finger_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.WebFinger.WebFingerController do use Pleroma.Web, :controller diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex index 8cb07006f..628ec38c5 100644 --- a/lib/pleroma/web/websub/websub.ex +++ b/lib/pleroma/web/websub/websub.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Websub do alias Ecto.Changeset alias Pleroma.Repo diff --git a/lib/pleroma/web/websub/websub_client_subscription.ex b/lib/pleroma/web/websub/websub_client_subscription.ex index 8cea02939..2f511cd5b 100644 --- a/lib/pleroma/web/websub/websub_client_subscription.ex +++ b/lib/pleroma/web/websub/websub_client_subscription.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Websub.WebsubClientSubscription do use Ecto.Schema alias Pleroma.User diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex index c1934ba92..c38a03808 100644 --- a/lib/pleroma/web/websub/websub_controller.ex +++ b/lib/pleroma/web/websub/websub_controller.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Websub.WebsubController do use Pleroma.Web, :controller alias Pleroma.{Repo, User} diff --git a/lib/pleroma/web/websub/websub_server_subscription.ex b/lib/pleroma/web/websub/websub_server_subscription.ex index 0e5248a73..81a2d7f07 100644 --- a/lib/pleroma/web/websub/websub_server_subscription.ex +++ b/lib/pleroma/web/websub/websub_server_subscription.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.Websub.WebsubServerSubscription do use Ecto.Schema diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex index b3ccf4a55..fa6dcd424 100644 --- a/lib/pleroma/web/xml/xml.ex +++ b/lib/pleroma/web/xml/xml.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.XML do require Logger -- cgit v1.2.3 From 69ad1039ba6cb94ea0f6c9d2c7171bdab789651f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 23 Dec 2018 20:05:55 +0000 Subject: mix tasks: add legal boilerplate --- lib/mix/tasks/pleroma/common.ex | 4 ++++ lib/mix/tasks/pleroma/instance.ex | 4 ++++ lib/mix/tasks/pleroma/relay.ex | 4 ++++ lib/mix/tasks/pleroma/uploads.ex | 4 ++++ lib/mix/tasks/pleroma/user.ex | 4 ++++ 5 files changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/common.ex b/lib/mix/tasks/pleroma/common.ex index 36432c291..48c0c1346 100644 --- a/lib/mix/tasks/pleroma/common.ex +++ b/lib/mix/tasks/pleroma/common.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Mix.Tasks.Pleroma.Common do @doc "Common functions to be reused in mix tasks" def start_pleroma do diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index 02e1ce27d..1ef40671c 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Mix.Tasks.Pleroma.Instance do use Mix.Task alias Mix.Tasks.Pleroma.Common diff --git a/lib/mix/tasks/pleroma/relay.ex b/lib/mix/tasks/pleroma/relay.ex index 03586d6c3..cbe23f82e 100644 --- a/lib/mix/tasks/pleroma/relay.ex +++ b/lib/mix/tasks/pleroma/relay.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Mix.Tasks.Pleroma.Relay do use Mix.Task alias Pleroma.Web.ActivityPub.Relay diff --git a/lib/mix/tasks/pleroma/uploads.ex b/lib/mix/tasks/pleroma/uploads.ex index 63299b2ae..f0eb13e1a 100644 --- a/lib/mix/tasks/pleroma/uploads.ex +++ b/lib/mix/tasks/pleroma/uploads.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Mix.Tasks.Pleroma.Uploads do use Mix.Task alias Pleroma.{Upload, Uploaders.Local} diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 51086a443..217a52fdd 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Mix.Tasks.Pleroma.User do use Mix.Task import Ecto.Changeset -- cgit v1.2.3 From 0f412cf6e68fcebda3e94b71b7f182af689748bf Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 24 Dec 2018 02:25:36 +0300 Subject: Create tombstone instead of object deletion --- lib/pleroma/activity.ex | 20 +++++++++++++++++++- lib/pleroma/object.ex | 22 ++++++++++++++++++++-- lib/pleroma/web/common_api/utils.ex | 7 ++++++- 3 files changed, 45 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 200addd6e..0845233ee 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -1,7 +1,7 @@ defmodule Pleroma.Activity do use Ecto.Schema alias Pleroma.{Repo, Activity, Notification} - import Ecto.Query + import Ecto.{Query, Changeset} # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 @mastodon_notification_types %{ @@ -103,4 +103,22 @@ defmodule Pleroma.Activity do end def mastodon_notification_type(%Activity{}), do: nil + + def get_tombstone(%Activity{data: data}, deleted \\ DateTime.utc_now()) do + %{ + id: data["id"], + context: data["context"], + type: "tombstone", + published: data["published"], + deleted: deleted + } + end + + def swap_data_with_tombstone(activity) do + tombstone = get_tombstone(activity) + + activity + |> change(%{data: tombstone}) + |> Repo.update() + end end diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 31c8dd5bd..436cf6d5d 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -62,9 +62,27 @@ defmodule Pleroma.Object do Object.change(%Object{}, %{data: %{"id" => context}}) end + def get_tombstone(%Object{data: data}, deleted \\ DateTime.utc_now()) do + %{ + id: data["id"], + type: "tombstone", + deleted: deleted + } + end + + def swap_data_with_tombstone(object) do + tombstone = get_tombstone(object) + + object + |> Object.change(%{data: tombstone}) + |> Repo.update() + end + def delete(%Object{data: %{"id" => id}} = object) do - with Repo.delete(object), - Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)), + with swap_data_with_tombstone(object), + Activity.all_non_create_by_object_ap_id_q(id) + |> Repo.all() + |> Enum.each(&Activity.swap_data_with_tombstone/1), {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do {:ok, object} end diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 142283684..d25fef6bc 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -69,7 +69,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end) if inReplyTo do - {Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []} + to = + [inReplyTo.data["actor"] | mentioned_users] + |> Enum.uniq() + |> Enum.reject(&is_nil/1) + + {to, []} else {mentioned_users, []} end -- cgit v1.2.3 From 18a4cbb244dbc188f5a391626fb98e3a53571318 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 24 Dec 2018 20:09:18 +0300 Subject: Capitalize "tombstone" --- lib/pleroma/object.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 436cf6d5d..31f206c39 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -65,7 +65,7 @@ defmodule Pleroma.Object do def get_tombstone(%Object{data: data}, deleted \\ DateTime.utc_now()) do %{ id: data["id"], - type: "tombstone", + type: "Tombstone", deleted: deleted } end -- cgit v1.2.3 From 2bbec33c7112ede3f93a7d35e9d5f3ac5a31ce05 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 00:29:13 +0300 Subject: Fix failing tests --- lib/pleroma/activity.ex | 15 +++++++++------ lib/pleroma/notification.ex | 10 +++++++--- lib/pleroma/web/activity_pub/transmogrifier.ex | 3 ++- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 0845233ee..be04363aa 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -108,17 +108,20 @@ defmodule Pleroma.Activity do %{ id: data["id"], context: data["context"], - type: "tombstone", + type: "Tombstone", published: data["published"], deleted: deleted } end def swap_data_with_tombstone(activity) do - tombstone = get_tombstone(activity) - - activity - |> change(%{data: tombstone}) - |> Repo.update() + with tombstone = get_tombstone(activity), + Notification.clear(activity), + {:ok, changed_activity} = + activity + |> change(%{data: tombstone}) + |> Repo.update() do + {:ok, changed_activity} + end end end diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 47f6b6ee7..457cba935 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -75,10 +75,14 @@ defmodule Pleroma.Notification do end end - def clear(user) do - query = from(n in Notification, where: n.user_id == ^user.id) + def clear(%User{} = user) do + from(n in Notification, where: n.user_id == ^user.id) + |> Repo.delete_all() + end - Repo.delete_all(query) + def clear(%Activity{} = activity) do + from(n in Notification, where: n.activity_id == ^activity.id) + |> Repo.delete_all() end def dismiss(%{id: user_id} = _user, id) do diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index e6af4b211..87514870d 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -586,7 +586,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do - with false <- String.starts_with?(inReplyTo, "http"), + with false <- is_nil(inReplyTo), + false <- String.starts_with?(inReplyTo, "http"), {:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo) else -- cgit v1.2.3 From f75f707f6cf07c66a23ddbbe80a9b782a1ecb6f8 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 03:00:06 +0300 Subject: Revert Activity tombstones, add ObjectTombstone struct --- lib/pleroma/activity.ex | 23 +---------------------- lib/pleroma/object.ex | 21 ++++++++++----------- lib/pleroma/object_tombstone.ex | 4 ++++ 3 files changed, 15 insertions(+), 33 deletions(-) create mode 100644 lib/pleroma/object_tombstone.ex (limited to 'lib') diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index be04363aa..200addd6e 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -1,7 +1,7 @@ defmodule Pleroma.Activity do use Ecto.Schema alias Pleroma.{Repo, Activity, Notification} - import Ecto.{Query, Changeset} + import Ecto.Query # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 @mastodon_notification_types %{ @@ -103,25 +103,4 @@ defmodule Pleroma.Activity do end def mastodon_notification_type(%Activity{}), do: nil - - def get_tombstone(%Activity{data: data}, deleted \\ DateTime.utc_now()) do - %{ - id: data["id"], - context: data["context"], - type: "Tombstone", - published: data["published"], - deleted: deleted - } - end - - def swap_data_with_tombstone(activity) do - with tombstone = get_tombstone(activity), - Notification.clear(activity), - {:ok, changed_activity} = - activity - |> change(%{data: tombstone}) - |> Repo.update() do - {:ok, changed_activity} - end - end end diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 31f206c39..5b1347b37 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -1,6 +1,6 @@ defmodule Pleroma.Object do use Ecto.Schema - alias Pleroma.{Repo, Object, User, Activity} + alias Pleroma.{Repo, Object, User, Activity, ObjectTombstone} import Ecto.{Query, Changeset} schema "objects" do @@ -62,16 +62,17 @@ defmodule Pleroma.Object do Object.change(%Object{}, %{data: %{"id" => context}}) end - def get_tombstone(%Object{data: data}, deleted \\ DateTime.utc_now()) do - %{ - id: data["id"], - type: "Tombstone", + def make_tombstone(%Object{data: %{"id" => id, "type" => type}}, deleted \\ DateTime.utc_now()) do + %ObjectTombstone{ + id: id, + formerType: type, deleted: deleted } + |> Map.from_struct() end - def swap_data_with_tombstone(object) do - tombstone = get_tombstone(object) + def swap_object_with_tombstone(object) do + tombstone = make_tombstone(object) object |> Object.change(%{data: tombstone}) @@ -79,10 +80,8 @@ defmodule Pleroma.Object do end def delete(%Object{data: %{"id" => id}} = object) do - with swap_data_with_tombstone(object), - Activity.all_non_create_by_object_ap_id_q(id) - |> Repo.all() - |> Enum.each(&Activity.swap_data_with_tombstone/1), + with {:ok, _obj} = swap_object_with_tombstone(object), + Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)), {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do {:ok, object} end diff --git a/lib/pleroma/object_tombstone.ex b/lib/pleroma/object_tombstone.ex new file mode 100644 index 000000000..64d836d3e --- /dev/null +++ b/lib/pleroma/object_tombstone.ex @@ -0,0 +1,4 @@ +defmodule Pleroma.ObjectTombstone do + @enforce_keys [:id, :formerType, :deleted] + defstruct [:id, :formerType, :deleted, type: "Tombstone"] +end -- cgit v1.2.3 From ca2e9ce9cc98f046ea2be0a9051cdf06d253d7f6 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 25 Dec 2018 03:44:48 +0300 Subject: Revert unneeded changes --- lib/pleroma/notification.ex | 7 +------ lib/pleroma/web/activity_pub/transmogrifier.ex | 3 +-- lib/pleroma/web/common_api/utils.ex | 7 +------ 3 files changed, 3 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 457cba935..47578d60e 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -75,16 +75,11 @@ defmodule Pleroma.Notification do end end - def clear(%User{} = user) do + def clear(user) do from(n in Notification, where: n.user_id == ^user.id) |> Repo.delete_all() end - def clear(%Activity{} = activity) do - from(n in Notification, where: n.activity_id == ^activity.id) - |> Repo.delete_all() - end - def dismiss(%{id: user_id} = _user, id) do notification = Repo.get(Notification, id) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 87514870d..e6af4b211 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -586,8 +586,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do - with false <- is_nil(inReplyTo), - false <- String.starts_with?(inReplyTo, "http"), + with false <- String.starts_with?(inReplyTo, "http"), {:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo) else diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d25fef6bc..142283684 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -69,12 +69,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end) if inReplyTo do - to = - [inReplyTo.data["actor"] | mentioned_users] - |> Enum.uniq() - |> Enum.reject(&is_nil/1) - - {to, []} + {Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []} else {mentioned_users, []} end -- cgit v1.2.3 From 91724d160acc39585c37742204c59b91e59df569 Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 25 Dec 2018 20:09:27 +0100 Subject: Reserve a few user names These are all names that are used for domain.com/:route routes or projected to be. --- lib/pleroma/user.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1f930479d..33f5e43fc 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -197,6 +197,7 @@ defmodule Pleroma.User do |> validate_confirmation(:password) |> unique_constraint(:email) |> unique_constraint(:nickname) + |> validate_exclusion(:nickname, Pleroma.Config.get([Pleroma.User, :restricted_nicknames])) |> validate_format(:nickname, local_nickname_regex()) |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) -- cgit v1.2.3 From 5811e65e67591b06238de66470c03744e0d83e2d Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 26 Dec 2018 12:39:35 +0100 Subject: Add some hard limits on inserted activities. --- lib/pleroma/web/activity_pub/activity_pub.ex | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 188060780..8b2f764e4 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -56,10 +56,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end + defp check_remote_limit(%{"object" => %{"content" => content}}) do + limit = Pleroma.Config.get([:instance, :remote_limit]) + String.length(content) <= limit + end + + defp check_remote_limit(_), do: true + def insert(map, local \\ true) when is_map(map) do with nil <- Activity.normalize(map), map <- lazy_put_activity_defaults(map), :ok <- check_actor_is_active(map["actor"]), + {_, true} <- {:remote_limit_error, check_remote_limit(map)}, {:ok, map} <- MRF.filter(map), :ok <- insert_full_object(map) do {recipients, _, _} = get_recipients(map) -- cgit v1.2.3 From 551d80cc0186424d2c1653f917749adea16d9963 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 26 Dec 2018 12:46:16 +0100 Subject: Expose restricted names in nodeinfo. --- lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 1265d81c5..a992f75f6 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -138,7 +138,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do }, accountActivationRequired: Keyword.get(instance, :account_activation_required, false), invitesEnabled: Keyword.get(instance, :invites_enabled, false), - features: features + features: features, + restrictedNicknames: Pleroma.Config.get([Pleroma.User, :restricted_nicknames]) } } -- cgit v1.2.3 From 448af3601a365e4f24a2db54af366d075af7e90f Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Thu, 27 Dec 2018 00:12:20 +0300 Subject: Up captcha timer to 60 secs again, save used captchas in cachex --- lib/pleroma/application.ex | 10 ++++++++++ lib/pleroma/captcha/captcha.ex | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index e15991957..bdd0ee26f 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -25,6 +25,16 @@ defmodule Pleroma.Application do supervisor(Pleroma.Repo, []), worker(Pleroma.Emoji, []), worker(Pleroma.Captcha, []), + worker( + Cachex, + [ + :used_captcha_cache, + [ + ttl_interval: :timer.seconds(60 * 2) + ] + ], + id: :cachex_used_captcha_cache + ), worker( Cachex, [ diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index 04769d4b2..c7abafeb1 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -80,9 +80,24 @@ defmodule Pleroma.Captcha do result = with {:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret), %{at: at, answer_data: answer_md5} <- :erlang.binary_to_term(data) do - if DateTime.after?(at, valid_if_after), - do: method().validate(token, captcha, answer_md5), - else: {:error, "CAPTCHA expired"} + try do + if DateTime.before?(at, valid_if_after), do: throw({:error, "CAPTCHA expired"}) + + if not is_nil(Cachex.get!(:used_captcha_cache, token)), + do: throw({:error, "CAPTCHA already used"}) + + res = method().validate(token, captcha, answer_md5) + # Throw if an error occurs + if res != :ok, do: throw(res) + + # Mark this captcha as used + {:ok, _} = + Cachex.put(:used_captcha_cache, token, true, ttl: :timer.seconds(seconds_valid)) + + :ok + catch + :throw, e -> e + end else _ -> {:error, "Invalid answer data"} end -- cgit v1.2.3 From 838c0242316545afa42384b8e50a401e54ad1405 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 27 Dec 2018 02:39:41 +0300 Subject: Treat any present value in "no_attachment_links" as true --- lib/pleroma/web/common_api/utils.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b91cfc4bb..d9cc52e26 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -89,7 +89,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do ) do status |> format_input(mentions, tags, content_type) - |> maybe_add_attachments(attachments, no_attachment_links) + |> maybe_add_attachments(attachments, !!no_attachment_links) end def make_context(%Activity{data: %{"context" => context}}), do: context -- cgit v1.2.3 From e4562105e77dd2d580921a07f05907a63da1d826 Mon Sep 17 00:00:00 2001 From: Vyr Cossont <600-VyrCossont@users.noreply.git.pleroma.social> Date: Wed, 26 Dec 2018 21:30:01 -0800 Subject: Implement exclude_reblogs and include_rts --- lib/pleroma/web/activity_pub/activity_pub.ex | 7 +++++++ lib/pleroma/web/twitter_api/twitter_api_controller.ex | 9 +++++++++ 2 files changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 188060780..2d4cc9f68 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -503,6 +503,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do defp restrict_replies(query, _), do: query + defp restrict_reblogs(query, %{"exclude_reblogs" => val}) when val == "true" or val == "1" do + from(activity in query, where: fragment("?->>'type' != 'Announce'", activity.data)) + end + + defp restrict_reblogs(query, _), do: query + # Only search through last 100_000 activities by default defp restrict_recent(query, %{"whole_db" => true}), do: query @@ -561,6 +567,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> restrict_media(opts) |> restrict_visibility(opts) |> restrict_replies(opts) + |> restrict_reblogs(opts) end def fetch_activities(recipients, opts \\ %{}) do diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index c25cb0876..7ae850d71 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -130,6 +130,15 @@ defmodule Pleroma.Web.TwitterAPI.Controller do def user_timeline(%{assigns: %{user: user}} = conn, params) do case TwitterAPI.get_user(user, params) do {:ok, target_user} -> + # Twitter and ActivityPub use a different name and sense for this parameter. + {include_rts, params} = Map.pop(params, "include_rts") + + params = + case include_rts do + x when x == "false" or x == "0" -> Map.put(params, "exclude_reblogs", "true") + _ -> params + end + activities = ActivityPub.fetch_user_activities(target_user, user, params) conn -- cgit v1.2.3 From 708a22891921d54c9c716ac250e75ae6a889eb7b Mon Sep 17 00:00:00 2001 From: vaartis Date: Thu, 27 Dec 2018 07:42:03 +0000 Subject: Set ttl_interval to the seconds_valid time --- lib/pleroma/application.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index bdd0ee26f..8dbacf258 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -30,7 +30,7 @@ defmodule Pleroma.Application do [ :used_captcha_cache, [ - ttl_interval: :timer.seconds(60 * 2) + ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid])) ] ], id: :cachex_used_captcha_cache -- cgit v1.2.3 From be70272ab08356353ff3c2685dbb639477c2cdf4 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 27 Dec 2018 13:21:04 +0300 Subject: Treat only true and "true" as true --- lib/pleroma/web/common_api/common_api.ex | 2 +- lib/pleroma/web/common_api/utils.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 5e5821561..085a95172 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -102,7 +102,7 @@ defmodule Pleroma.Web.CommonAPI do attachments, tags, get_content_type(data["content_type"]), - data["no_attachment_links"] + Enum.member?([true, "true"], data["no_attachment_links"]) ), context <- make_context(inReplyTo), cw <- data["spoiler_text"], diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d9cc52e26..b91cfc4bb 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -89,7 +89,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do ) do status |> format_input(mentions, tags, content_type) - |> maybe_add_attachments(attachments, !!no_attachment_links) + |> maybe_add_attachments(attachments, no_attachment_links) end def make_context(%Activity{data: %{"context" => context}}), do: context -- cgit v1.2.3 From e6aeb1d4a5c0e0e0e5e1e744b4062f7392ed0722 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 27 Dec 2018 15:46:18 +0300 Subject: [#471] Prevented rendering of inactive local accounts. --- lib/pleroma/user.ex | 2 ++ lib/pleroma/web/mastodon_api/views/account_view.ex | 22 ++++++++++++++- lib/pleroma/web/twitter_api/views/user_view.ex | 33 ++++++++++++++++++---- 3 files changed, 50 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1f930479d..b8a7a3fae 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -47,6 +47,8 @@ defmodule Pleroma.User do !Pleroma.Config.get([:instance, :account_activation_required]) end + def remote_or_auth_active?(%User{} = user), do: !user.local || auth_active?(user) + def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info) def avatar_url(user) do diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index aaaae2035..ba72e3a10 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -11,10 +11,30 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do alias Pleroma.HTML def render("accounts.json", %{users: users} = opts) do - render_many(users, AccountView, "account.json", opts) + users + |> render_many(AccountView, "account.json", opts) + |> Enum.filter(&Enum.any?/1) end def render("account.json", %{user: user} = opts) do + for_user = opts[:for] + + allow_render = + User.remote_or_auth_active?(user) || + (for_user && (for_user.id == user.id || User.superuser?(for_user))) + + if allow_render do + render("valid_account.json", opts) + else + render("invalid_account.json", opts) + end + end + + def render("invalid_account.json", _opts) do + %{} + end + + def render("valid_account.json", %{user: user} = opts) do image = User.avatar_url(user) |> MediaProxy.url() header = User.banner_url(user) |> MediaProxy.url() user_info = User.user_info(user) diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 6e489624f..41825f8f6 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -15,18 +15,39 @@ defmodule Pleroma.Web.TwitterAPI.UserView do end def render("index.json", %{users: users, for: user}) do - render_many(users, Pleroma.Web.TwitterAPI.UserView, "user.json", for: user) + users + |> render_many(Pleroma.Web.TwitterAPI.UserView, "user.json", for: user) + |> Enum.filter(&Enum.any?/1) end def render("user.json", %{user: user = %User{}} = assigns) do + for_user = assigns[:for] + + allow_render = + User.remote_or_auth_active?(user) || + (for_user && (for_user.id == user.id || User.superuser?(for_user))) + + if allow_render do + render("valid_user.json", assigns) + else + render("invalid_user.json", assigns) + end + end + + def render("invalid_user.json", _assigns) do + %{} + end + + def render("valid_user.json", %{user: user = %User{}} = assigns) do + for_user = assigns[:for] image = User.avatar_url(user) |> MediaProxy.url() {following, follows_you, statusnet_blocking} = - if assigns[:for] do + if for_user do { - User.following?(assigns[:for], user), - User.following?(user, assigns[:for]), - User.blocks?(assigns[:for], user) + User.following?(for_user, user), + User.following?(user, for_user), + User.blocks?(for_user, user) } else {false, false, false} @@ -51,7 +72,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do data = %{ "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "description" => HTML.strip_tags((user.bio || "") |> String.replace("
", "\n")), - "description_html" => HTML.filter_tags(user.bio, User.html_filter_policy(assigns[:for])), + "description_html" => HTML.filter_tags(user.bio, User.html_filter_policy(for_user)), "favourites_count" => 0, "followers_count" => user_info[:follower_count], "following" => following, -- cgit v1.2.3 From d8cc96cb1f9e2a4e736f6830529e8aa9a5d289d8 Mon Sep 17 00:00:00 2001 From: Vyr Cossont <600-VyrCossont@users.noreply.git.pleroma.social> Date: Thu, 27 Dec 2018 22:43:40 -0800 Subject: Fix Twitter timelines for private instances --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 7ae850d71..92b7386da 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -662,7 +662,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do json_reply(conn, 403, json) end - def only_if_public_instance(conn = %{conn: %{assigns: %{user: _user}}}, _), do: conn + def only_if_public_instance(%{assigns: %{user: %User{}}} = conn, _), do: conn def only_if_public_instance(conn, _) do if Keyword.get(Application.get_env(:pleroma, :instance), :public) do -- cgit v1.2.3 From 0d1788ce44cf7bf50aa40e56988be0d2e315d2e1 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Fri, 28 Dec 2018 14:35:25 +0300 Subject: [#471] Factored out User.visible_for?/2. --- lib/pleroma/user.ex | 6 ++++++ lib/pleroma/web/mastodon_api/views/account_view.ex | 14 +++----------- lib/pleroma/web/twitter_api/views/user_view.ex | 14 +++----------- 3 files changed, 12 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b8a7a3fae..7d97bf7e5 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -49,6 +49,12 @@ defmodule Pleroma.User do def remote_or_auth_active?(%User{} = user), do: !user.local || auth_active?(user) + def visible_for?(%User{} = user, for_user \\ nil) do + User.remote_or_auth_active?(user) || (for_user && for_user.id == user.id) || + User.superuser?(for_user) + end + + def superuser?(nil), do: false def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info) def avatar_url(user) do diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index ba72e3a10..32cb1ac60 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -17,17 +17,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do end def render("account.json", %{user: user} = opts) do - for_user = opts[:for] - - allow_render = - User.remote_or_auth_active?(user) || - (for_user && (for_user.id == user.id || User.superuser?(for_user))) - - if allow_render do - render("valid_account.json", opts) - else - render("invalid_account.json", opts) - end + if User.visible_for?(user, opts[:for]), + do: render("valid_account.json", opts), + else: render("invalid_account.json", opts) end def render("invalid_account.json", _opts) do diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 41825f8f6..890d4234e 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -21,17 +21,9 @@ defmodule Pleroma.Web.TwitterAPI.UserView do end def render("user.json", %{user: user = %User{}} = assigns) do - for_user = assigns[:for] - - allow_render = - User.remote_or_auth_active?(user) || - (for_user && (for_user.id == user.id || User.superuser?(for_user))) - - if allow_render do - render("valid_user.json", assigns) - else - render("invalid_user.json", assigns) - end + if User.visible_for?(user, assigns[:for]), + do: render("valid_user.json", assigns), + else: render("invalid_user.json", assigns) end def render("invalid_user.json", _assigns) do -- cgit v1.2.3 From b43d630f307110b5fa552c28c9fa0ebae09e85f2 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 23 Dec 2018 18:31:37 +0100 Subject: Web.TwitterAPI.UserView: Add rights.admin --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 3 ++- lib/pleroma/web/twitter_api/views/user_view.ex | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 22715bb76..a4b17e4f8 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -966,7 +966,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do max_toot_chars: limit }, rights: %{ - delete_others_notice: !!user.info.is_moderator + delete_others_notice: !!user.info.is_moderator, + admin: !!user.info.is_admin }, compose: %{ me: "#{user.id}", diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 6e489624f..c04d143c8 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -70,7 +70,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do "profile_image_url_profile_size" => image, "profile_image_url_original" => image, "rights" => %{ - "delete_others_notice" => !!user.info.is_moderator + "delete_others_notice" => !!user.info.is_moderator, + "admin" => !!user.info.is_admin }, "screen_name" => user.nickname, "statuses_count" => user_info[:note_count], -- cgit v1.2.3 From 6e9a15b181fcca9e7485a61b1cce2e4ec6d46b78 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Fri, 28 Dec 2018 21:08:07 +0300 Subject: [#483] Blocked users export for TwitterAPI. --- lib/pleroma/user.ex | 3 +++ lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 6 ++---- lib/pleroma/web/router.ex | 1 + lib/pleroma/web/twitter_api/twitter_api_controller.ex | 8 ++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 33f5e43fc..b64ed74c4 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -649,6 +649,9 @@ defmodule Pleroma.User do end) end + def blocked_users(user), + do: Repo.all(from(u in User, where: u.ap_id in ^user.info.blocks)) + def block_domain(user, domain) do info_cng = user.info diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 22715bb76..663a0fa08 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -704,11 +704,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end - # TODO: Use proper query def blocks(%{assigns: %{user: user}} = conn, _) do - with blocked_users <- user.info.blocks || [], - accounts <- Enum.map(blocked_users, fn ap_id -> User.get_cached_by_ap_id(ap_id) end) do - res = AccountView.render("accounts.json", users: accounts, for: user, as: :user) + with blocked_accounts <- User.blocked_users(user) do + res = AccountView.render("accounts.json", users: blocked_accounts, for: user, as: :user) json(conn, res) end end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 7ec0cabb3..a7f78ba81 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -281,6 +281,7 @@ defmodule Pleroma.Web.Router do get("/statuses/followers", TwitterAPI.Controller, :followers) get("/statuses/friends", TwitterAPI.Controller, :friends) + get("/statuses/blocks", TwitterAPI.Controller, :blocks) get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status) get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 7ae850d71..c11824afc 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -507,6 +507,14 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end end + def blocks(%{assigns: %{user: user}} = conn, _params) do + with blocked_users <- User.blocked_users(user) do + conn + |> put_view(UserView) + |> render("index.json", %{users: blocked_users, for: user}) + end + end + def friend_requests(conn, params) do with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), {:ok, friend_requests} <- User.get_follow_requests(user) do -- cgit v1.2.3 From 0a41786624454d26fd966748735a8f2333bf4012 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Fri, 28 Dec 2018 22:47:42 +0300 Subject: [#467] Refactored valid / invalid user rendering. --- lib/pleroma/web/mastodon_api/views/account_view.ex | 80 ++++++++++------------ lib/pleroma/web/twitter_api/views/user_view.ex | 40 +++++------ 2 files changed, 56 insertions(+), 64 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 32cb1ac60..555383503 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -18,15 +18,48 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do def render("account.json", %{user: user} = opts) do if User.visible_for?(user, opts[:for]), - do: render("valid_account.json", opts), - else: render("invalid_account.json", opts) + do: do_render("account.json", opts), + else: %{} end - def render("invalid_account.json", _opts) do - %{} + def render("mention.json", %{user: user}) do + %{ + id: to_string(user.id), + acct: user.nickname, + username: username_from_nickname(user.nickname), + url: user.ap_id + } + end + + def render("relationship.json", %{user: user, target: target}) do + follow_activity = Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(user, target) + + requested = + if follow_activity do + follow_activity.data["state"] == "pending" + else + false + end + + %{ + id: to_string(target.id), + following: User.following?(user, target), + followed_by: User.following?(target, user), + blocking: User.blocks?(user, target), + muting: false, + muting_notifications: false, + requested: requested, + domain_blocking: false, + showing_reblogs: false, + endorsed: false + } end - def render("valid_account.json", %{user: user} = opts) do + def render("relationships.json", %{user: user, targets: targets}) do + render_many(targets, AccountView, "relationship.json", user: user, as: :target) + end + + defp do_render("account.json", %{user: user} = opts) do image = User.avatar_url(user) |> MediaProxy.url() header = User.banner_url(user) |> MediaProxy.url() user_info = User.user_info(user) @@ -84,43 +117,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do } end - def render("mention.json", %{user: user}) do - %{ - id: to_string(user.id), - acct: user.nickname, - username: username_from_nickname(user.nickname), - url: user.ap_id - } - end - - def render("relationship.json", %{user: user, target: target}) do - follow_activity = Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(user, target) - - requested = - if follow_activity do - follow_activity.data["state"] == "pending" - else - false - end - - %{ - id: to_string(target.id), - following: User.following?(user, target), - followed_by: User.following?(target, user), - blocking: User.blocks?(user, target), - muting: false, - muting_notifications: false, - requested: requested, - domain_blocking: false, - showing_reblogs: false, - endorsed: false - } - end - - def render("relationships.json", %{user: user, targets: targets}) do - render_many(targets, AccountView, "relationship.json", user: user, as: :target) - end - defp username_from_nickname(string) when is_binary(string) do hd(String.split(string, "@")) end diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 890d4234e..ede3c0d25 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -22,15 +22,28 @@ defmodule Pleroma.Web.TwitterAPI.UserView do def render("user.json", %{user: user = %User{}} = assigns) do if User.visible_for?(user, assigns[:for]), - do: render("valid_user.json", assigns), - else: render("invalid_user.json", assigns) + do: do_render("user.json", assigns), + else: %{} end - def render("invalid_user.json", _assigns) do - %{} + def render("short.json", %{ + user: %User{ + nickname: nickname, + id: id, + ap_id: ap_id, + name: name + } + }) do + %{ + "fullname" => name, + "id" => id, + "ostatus_uri" => ap_id, + "profile_url" => ap_id, + "screen_name" => nickname + } end - def render("valid_user.json", %{user: user = %User{}} = assigns) do + defp do_render("user.json", %{user: user = %User{}} = assigns) do for_user = assigns[:for] image = User.avatar_url(user) |> MediaProxy.url() @@ -110,23 +123,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do end end - def render("short.json", %{ - user: %User{ - nickname: nickname, - id: id, - ap_id: ap_id, - name: name - } - }) do - %{ - "fullname" => name, - "id" => id, - "ostatus_uri" => ap_id, - "profile_url" => ap_id, - "screen_name" => nickname - } - end - defp image_url(%{"url" => [%{"href" => href} | _]}), do: href defp image_url(_), do: nil -- cgit v1.2.3 From 700661b761117e6673ad254877ebba902b9d751b Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Fri, 28 Dec 2018 23:01:03 +0300 Subject: [#483] Blocked users list import (TwitterAPI). --- lib/pleroma/web/router.ex | 1 + .../web/twitter_api/controllers/util_controller.ex | 31 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index a7f78ba81..43b04e508 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -137,6 +137,7 @@ defmodule Pleroma.Web.Router do scope "/api/pleroma", Pleroma.Web.TwitterAPI do pipe_through(:authenticated_api) + post("/blocks_import", UtilController, :blocks_import) post("/follow_import", UtilController, :follow_import) post("/change_password", UtilController, :change_password) post("/delete_account", UtilController, :delete_account) diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index c872aec2b..6a9325afe 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -242,9 +242,12 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do def follow_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do Task.start(fn -> - String.split(list) + follower = User.get_cached_by_ap_id(user.ap_id) + + list + |> String.split() |> Enum.map(fn account -> - with %User{} = follower <- User.get_cached_by_ap_id(user.ap_id), + with %User{} <- follower, %User{} = followed <- User.get_or_fetch(account), {:ok, follower} <- User.maybe_direct_follow(follower, followed) do ActivityPub.follow(follower, followed) @@ -257,6 +260,30 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do json(conn, "job started") end + def blocks_import(conn, %{"list" => %Plug.Upload{} = listfile}) do + blocks_import(conn, %{"list" => File.read!(listfile.path)}) + end + + def blocks_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do + Task.start(fn -> + blocker = User.get_cached_by_ap_id(user.ap_id) + + list + |> String.split() + |> Enum.map(fn account -> + with %User{} <- blocker, + %User{} = blocked <- User.get_or_fetch(account), + {:ok, blocker} <- User.block(blocker, blocked) do + ActivityPub.block(blocker, blocked) + else + err -> Logger.debug("blocks_import: blocking #{account} failed with #{inspect(err)}") + end + end) + end) + + json(conn, "job started") + end + def change_password(%{assigns: %{user: user}} = conn, params) do case CommonAPI.Utils.confirm_current_password(user, params["password"]) do {:ok, user} -> -- cgit v1.2.3 From 67b4297f4d4010ee1b66452af4cea094d2cab2c4 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Sat, 29 Dec 2018 12:02:37 +0300 Subject: [#483] Refactored blocks and follows import, added tests. --- lib/pleroma/user.ex | 37 +++++++++++++++++ .../web/twitter_api/controllers/util_controller.ex | 46 +++++----------------- 2 files changed, 47 insertions(+), 36 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b64ed74c4..558014760 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -13,6 +13,8 @@ defmodule Pleroma.User do alias Pleroma.Web.{OStatus, Websub, OAuth} alias Pleroma.Web.ActivityPub.{Utils, ActivityPub} + require Logger + @type t :: %__MODULE__{} @email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ @@ -331,6 +333,24 @@ defmodule Pleroma.User do Enum.member?(follower.following, followed.follower_address) end + def follow_import(%User{} = follower, followed_identifiers) + when is_list(followed_identifiers) do + Enum.map( + followed_identifiers, + fn followed_identifier -> + with %User{} = followed <- get_or_fetch(followed_identifier), + {:ok, follower} <- maybe_direct_follow(follower, followed), + {:ok, _} <- ActivityPub.follow(follower, followed) do + followed + else + err -> + Logger.debug("follow_import failed for #{followed_identifier} with: #{inspect(err)}") + err + end + end + ) + end + def locked?(%User{} = user) do user.info.locked || false end @@ -596,6 +616,23 @@ defmodule Pleroma.User do Repo.all(q) end + def blocks_import(%User{} = blocker, blocked_identifiers) when is_list(blocked_identifiers) do + Enum.map( + blocked_identifiers, + fn blocked_identifier -> + with %User{} = blocked <- get_or_fetch(blocked_identifier), + {:ok, blocker} <- block(blocker, blocked), + {:ok, _} <- ActivityPub.block(blocker, blocked) do + blocked + else + err -> + Logger.debug("blocks_import failed for #{blocked_identifier} with: #{inspect(err)}") + err + end + end + ) + end + def block(blocker, %User{ap_id: ap_id} = blocked) do # sever any follow relationships to prevent leaks per activitypub (Pleroma issue #213) blocker = diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 6a9325afe..87b8b71ba 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -240,48 +240,22 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do follow_import(conn, %{"list" => File.read!(listfile.path)}) end - def follow_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do - Task.start(fn -> - follower = User.get_cached_by_ap_id(user.ap_id) - - list - |> String.split() - |> Enum.map(fn account -> - with %User{} <- follower, - %User{} = followed <- User.get_or_fetch(account), - {:ok, follower} <- User.maybe_direct_follow(follower, followed) do - ActivityPub.follow(follower, followed) - else - err -> Logger.debug("follow_import: following #{account} failed with #{inspect(err)}") - end - end) - end) - - json(conn, "job started") + def follow_import(%{assigns: %{user: follower}} = conn, %{"list" => list}) do + with followed_identifiers <- String.split(list), + {:ok, _} = Task.start(fn -> User.follow_import(follower, followed_identifiers) end) do + json(conn, "job started") + end end def blocks_import(conn, %{"list" => %Plug.Upload{} = listfile}) do blocks_import(conn, %{"list" => File.read!(listfile.path)}) end - def blocks_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do - Task.start(fn -> - blocker = User.get_cached_by_ap_id(user.ap_id) - - list - |> String.split() - |> Enum.map(fn account -> - with %User{} <- blocker, - %User{} = blocked <- User.get_or_fetch(account), - {:ok, blocker} <- User.block(blocker, blocked) do - ActivityPub.block(blocker, blocked) - else - err -> Logger.debug("blocks_import: blocking #{account} failed with #{inspect(err)}") - end - end) - end) - - json(conn, "job started") + def blocks_import(%{assigns: %{user: blocker}} = conn, %{"list" => list}) do + with blocked_identifiers <- String.split(list), + {:ok, _} = Task.start(fn -> User.blocks_import(blocker, blocked_identifiers) end) do + json(conn, "job started") + end end def change_password(%{assigns: %{user: user}} = conn, params) do -- cgit v1.2.3 From b3574dccbbb9d24ed90f0a82627d18428aaa7a16 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Sat, 29 Dec 2018 12:15:46 +0300 Subject: [#483] User.get_by_nickname/1: allowed retrieving user by fully-qualified local nickname (@). --- lib/pleroma/user.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 558014760..d4a6b13fb 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -387,7 +387,11 @@ defmodule Pleroma.User do end def get_by_nickname(nickname) do - Repo.get_by(User, nickname: nickname) + Repo.get_by(User, nickname: nickname) || + if String.ends_with?(nickname, "@" <> Pleroma.Web.Endpoint.host()) do + [local_nickname, _] = String.split(nickname, "@") + Repo.get_by(User, nickname: local_nickname) + end end def get_by_nickname_or_email(nickname_or_email) do -- cgit v1.2.3 From 7bd49a32222045c34098f925fbd494461ab67ccd Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Sat, 29 Dec 2018 12:26:23 +0300 Subject: [#483] User.get_by_nickname/1: ensured case-insensitive matching for local FQN. Added tests. --- lib/pleroma/user.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index d4a6b13fb..1f6d4cc5e 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -388,7 +388,7 @@ defmodule Pleroma.User do def get_by_nickname(nickname) do Repo.get_by(User, nickname: nickname) || - if String.ends_with?(nickname, "@" <> Pleroma.Web.Endpoint.host()) do + if Regex.match?(~r(@#{Pleroma.Web.Endpoint.host()})i, nickname) do [local_nickname, _] = String.split(nickname, "@") Repo.get_by(User, nickname: local_nickname) end -- cgit v1.2.3 From 523848d1fd94cfefa0a81e585d5891135982f8c2 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sat, 29 Dec 2018 12:48:54 +0300 Subject: Salmon# fixed publish an activity to remote accounts --- lib/pleroma/activity.ex | 2 ++ lib/pleroma/http/http.ex | 2 ++ lib/pleroma/web/salmon/salmon.ex | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 34b665765..a14d1e8c6 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -7,6 +7,8 @@ defmodule Pleroma.Activity do alias Pleroma.{Repo, Activity, Notification} import Ecto.Query + @type t :: %__MODULE__{} + # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 @mastodon_notification_types %{ "Create" => "mention", diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index e572dfedf..32d9cf5aa 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -10,6 +10,8 @@ defmodule Pleroma.HTTP do alias Pleroma.HTTP.Connection alias Pleroma.HTTP.RequestBuilder, as: Builder + @type t :: __MODULE__ + @doc """ Builds and perform http request. diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index 1dc514976..f7d2257eb 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -161,16 +161,21 @@ defmodule Pleroma.Web.Salmon do |> Enum.filter(fn user -> user && !user.local end) end - defp send_to_user(%{info: %{salmon: salmon}}, feed, poster) do + # push an activity to remote accounts + # + defp send_to_user(%{info: %{salmon: salmon}}, feed, poster), + do: send_to_user(salmon, feed, poster) + + defp send_to_user(url, feed, poster) when is_binary(url) do with {:ok, %{status: code}} <- poster.( - salmon, + url, feed, [{"Content-Type", "application/magic-envelope+xml"}] ) do - Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end) + Logger.debug(fn -> "Pushed to #{url}, code #{code}" end) else - e -> Logger.debug(fn -> "Pushing Salmon to #{salmon} failed, #{inspect(e)}" end) + e -> Logger.debug(fn -> "Pushing Salmon to #{url} failed, #{inspect(e)}" end) end end @@ -184,6 +189,11 @@ defmodule Pleroma.Web.Salmon do "Undo", "Delete" ] + + @doc """ + Publishes an activity to remote accounts + """ + @spec publish(User.t(), Pleroma.Activity.t(), Pleroma.HTTP.t()) :: none def publish(user, activity, poster \\ &@httpoison.post/3) def publish(%{info: %{keys: keys}} = user, %{data: %{"type" => type}} = activity, poster) -- cgit v1.2.3 From ab9cda315f2ee7b0a2a6e505eface5d7c65d50b4 Mon Sep 17 00:00:00 2001 From: spctrl Date: Sat, 29 Dec 2018 12:43:54 +0100 Subject: Change 'name' to 'instance_name' so option is used when running non-interactive --- lib/mix/tasks/pleroma/instance.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index 1ef40671c..0a2c891c0 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -75,7 +75,7 @@ defmodule Mix.Tasks.Pleroma.Instance do name = Common.get_option( options, - :name, + :instance_name, "What is the name of your instance? (e.g. Pleroma/Soykaf)" ) -- cgit v1.2.3 From 19f9889fbe9d120acfaed2a5aedb4032d56eb217 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sat, 29 Dec 2018 17:45:50 +0100 Subject: I am not sure what's going on anymore so I'll just commit and reset all the other files to HEAD --- lib/pleroma/html.ex | 26 ++++----- lib/pleroma/user.ex | 4 +- lib/pleroma/web/common_api/common_api.ex | 3 +- lib/pleroma/web/common_api/utils.ex | 61 +++++++++++++++++++++- lib/pleroma/web/mastodon_api/views/status_view.ex | 2 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 2 +- 6 files changed, 81 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index a0473676b..169394af9 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -5,18 +5,8 @@ defmodule Pleroma.HTML do alias HtmlSanitizeEx.Scrubber - defp get_scrubbers(scrubber) when is_atom(scrubber), do: [scrubber] - defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers - defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default] - - def get_scrubbers() do - Pleroma.Config.get([:markup, :scrub_policy]) - |> get_scrubbers - end - - def filter_tags(html, nil) do - get_scrubbers() - |> Enum.reduce(html, fn scrubber, html -> + def filter_tags(html, scrubbers) when is_list(scrubbers) do + Enum.reduce(scrubbers, html, fn scrubber, html -> filter_tags(html, scrubber) end) end @@ -39,6 +29,10 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta + def version do + 0 + end + Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() @@ -77,6 +71,10 @@ defmodule Pleroma.HTML.Scrubber.Default do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta + def version do + 0 + end + @markup Application.get_env(:pleroma, :markup) @uri_schemes Application.get_env(:pleroma, :uri_schemes, []) @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, []) @@ -152,6 +150,10 @@ end defmodule Pleroma.HTML.Transform.MediaProxy do @moduledoc "Transforms inline image URIs to use MediaProxy." + def version do + 0 + end + alias Pleroma.Web.MediaProxy def before_scrub(html), do: html diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1f930479d..b0b65cbe2 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -733,7 +733,9 @@ defmodule Pleroma.User do Pleroma.HTML.Scrubber.TwitterText end - def html_filter_policy(_), do: nil + @default_scrubbers Pleroma.Config.get([:markup, :scrub_policy]) + + def html_filter_policy(_), do: @default_scrubbers def get_or_fetch_by_ap_id(ap_id) do user = get_by_ap_id(ap_id) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 5e5821561..06d44451e 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -128,7 +128,8 @@ defmodule Pleroma.Web.CommonAPI do |> Enum.reduce(%{}, fn {name, file}, acc -> Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}") end) - ) do + ), + object <- Map.put(object, "scrubber_cache", %{}) do res = ActivityPub.create(%{ to: to, diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b91cfc4bb..5c37fd671 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do alias Calendar.Strftime alias Comeonin.Pbkdf2 - alias Pleroma.{Activity, Formatter, Object, Repo} + alias Pleroma.{Activity, Formatter, Object, Repo, HTML} alias Pleroma.User alias Pleroma.Web alias Pleroma.Web.ActivityPub.Utils @@ -261,4 +261,63 @@ defmodule Pleroma.Web.CommonAPI.Utils do } end) end + + @doc """ + Get sanitized HTML from cache, or scrub it and save to cache. + """ + def get_scrubbed_html( + content, + scrubbers, + %{data: %{"object" => object}} = activity + ) do + scrubber_cache = + if object["scrubber_cache"] != nil and is_list(object["scrubber_cache"]) do + object["scrubber_cache"] + else + [] + end + + key = generate_scrubber_key(scrubbers) + + {new_scrubber_cache, scrubbed_html} = + Enum.map_reduce(scrubber_cache, nil, fn %{ + :scrubbers => current_key, + :content => current_content + }, + _ -> + if Map.keys(current_key) == Map.keys(key) do + if scrubbers == key do + {current_key, current_content} + else + # Remove the entry if scrubber version is outdated + {nil, nil} + end + end + end) + + new_scrubber_cache = Enum.reject(new_scrubber_cache, &is_nil/1) + + if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do + scrubbed_html = HTML.filter_tags(content, scrubbers) + new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] + + activity = + Map.merge(activity, %{ + data: %{"object" => %{"scrubber_cache" => new_scrubber_cache}} + }) + + cng = Ecto.Changeset.change(activity) + Repo.update(cng) + scrubbed_html + else + IO.puts("got the post from cache") + scrubbed_html + end + end + + defp generate_scrubber_key(scrubbers) do + Enum.reduce(scrubbers, %{}, fn scrubber, acc -> + Map.put(acc, to_string(scrubber), scrubber.version) + end) + end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 4d4681da8..8fa3798a6 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -120,7 +120,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do content = object |> render_content() - |> HTML.filter_tags(User.html_filter_policy(opts[:for])) + |> Utils.get_scrubbed_html(User.html_filter_policy(opts[:for]), activity) %{ id: to_string(activity.id), diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 592cf622f..adac1dfe9 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -245,7 +245,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do html = content - |> HTML.filter_tags(User.html_filter_policy(opts[:for])) + |> Utils.get_scrubbed_html(User.html_filter_policy(opts[:for]), activity) |> Formatter.emojify(object["emoji"]) text = -- cgit v1.2.3 From 816db3f494c6fcc60d0a700dfc473a9cc49c84a0 Mon Sep 17 00:00:00 2001 From: vaartis Date: Sat, 29 Dec 2018 17:44:26 +0000 Subject: Remove the debugging IO.inspect --- lib/pleroma/captcha/captcha.ex | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index c7abafeb1..424ad4add 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -54,8 +54,6 @@ defmodule Pleroma.Captcha do |> :erlang.term_to_binary() |> MessageEncryptor.encrypt(secret, sign_secret) - IO.inspect(%{new_captcha | answer_data: encrypted_captcha_answer}) - { :reply, # Repalce the answer with the encrypted answer -- cgit v1.2.3 From 9a0163db53580182599a9358bd0197ee0c61779d Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sat, 29 Dec 2018 21:50:34 +0100 Subject: use Kernel.put_in instead of Map.merge --- lib/pleroma/web/common_api/utils.ex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 5c37fd671..7b11bc3ed 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -300,17 +300,19 @@ defmodule Pleroma.Web.CommonAPI.Utils do if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do scrubbed_html = HTML.filter_tags(content, scrubbers) new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] + IO.puts(activity) activity = - Map.merge(activity, %{ - data: %{"object" => %{"scrubber_cache" => new_scrubber_cache}} - }) + Map.put( + activity, + :data, + Kernel.put_in(activity.data, ["object", "scrubber_cache"], new_scrubber_cache) + ) cng = Ecto.Changeset.change(activity) Repo.update(cng) scrubbed_html else - IO.puts("got the post from cache") scrubbed_html end end -- cgit v1.2.3 From aa082ca7b6a64f6cfd509118f76a5c18492e07b9 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sat, 29 Dec 2018 18:01:15 +0100 Subject: Wire up stub routes for client calls of activitypub inbox/outbox Code style: remove wrapping function of outbox --- .../web/activity_pub/activity_pub_controller.ex | 36 ++++++++++++++++++---- lib/pleroma/web/router.ex | 21 +++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 7fd6a45f5..dfa7eb94b 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -93,19 +93,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end end - def outbox(conn, %{"nickname" => nickname, "max_id" => max_id}) do + def outbox(conn, %{"nickname" => nickname} = params) do with %User{} = user <- User.get_cached_by_nickname(nickname), {:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do conn |> put_resp_header("content-type", "application/activity+json") - |> json(UserView.render("outbox.json", %{user: user, max_id: max_id})) + |> json(UserView.render("outbox.json", %{user: user, max_id: params["max_id"]})) end end - def outbox(conn, %{"nickname" => nickname}) do - outbox(conn, %{"nickname" => nickname, "max_id" => nil}) - end - def inbox(%{assigns: %{valid_signature: true}} = conn, %{"nickname" => nickname} = params) do with %User{} = user <- User.get_cached_by_nickname(nickname), true <- Utils.recipient_in_message(user.ap_id, params), @@ -156,6 +152,34 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end end + def read_inbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do + if nickname == user.nickname do + Logger.info("read inbox #{inspect(params)}") + + conn + |> put_resp_header("content-type", "application/activity+json") + |> json("ok!") + else + conn + |> put_status(:forbidden) + |> json("can't read inbox of #{nickname} as #{user.nickname}") + end + end + + def update_outbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do + if nickname == user.nickname do + Logger.info("update outbox #{inspect(params)}") + + conn + |> put_status(:created) + |> json("ok!") + else + conn + |> put_status(:forbidden) + |> json("can't update outbox of #{nickname} as #{user.nickname}") + end + end + def errors(conn, {:error, :not_found}) do conn |> put_status(404) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 43b04e508..33c573d46 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -412,6 +412,27 @@ defmodule Pleroma.Web.Router do get("/users/:nickname/outbox", ActivityPubController, :outbox) end + pipeline :activitypub_client do + plug(:accepts, ["activity+json"]) + plug(:fetch_session) + plug(Pleroma.Plugs.OAuthPlug) + plug(Pleroma.Plugs.BasicAuthDecoderPlug) + plug(Pleroma.Plugs.UserFetcherPlug) + plug(Pleroma.Plugs.SessionAuthenticationPlug) + plug(Pleroma.Plugs.LegacyAuthenticationPlug) + plug(Pleroma.Plugs.AuthenticationPlug) + plug(Pleroma.Plugs.UserEnabledPlug) + plug(Pleroma.Plugs.SetUserSessionIdPlug) + plug(Pleroma.Plugs.EnsureUserKeyPlug) + end + + scope "/", Pleroma.Web.ActivityPub do + pipe_through([:activitypub_client]) + + get("/users/:nickname/inbox", ActivityPubController, :read_inbox) + post("/users/:nickname/outbox", ActivityPubController, :update_outbox) + end + scope "/relay", Pleroma.Web.ActivityPub do pipe_through(:ap_relay) get("/", ActivityPubController, :relay) -- cgit v1.2.3 From a32e23905aa24335215f04fd56e33b663af54321 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 11:08:19 +0100 Subject: Use Object.change instead of Ecto.Changeset.change --- lib/pleroma/web/common_api/utils.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 7b11bc3ed..593404e4d 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -300,7 +300,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do scrubbed_html = HTML.filter_tags(content, scrubbers) new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] - IO.puts(activity) activity = Map.put( @@ -309,7 +308,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do Kernel.put_in(activity.data, ["object", "scrubber_cache"], new_scrubber_cache) ) - cng = Ecto.Changeset.change(activity) + cng = Object.change(activity) Repo.update(cng) scrubbed_html else -- cgit v1.2.3 From 26dc2dddab6103a3e6e44a3c7ba097283302fc2a Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sat, 29 Dec 2018 18:15:28 +0100 Subject: Implement ActivityPub inbox view More or less verbatim copied from the outbox template with only changes to the activities fetched and url reported --- .../web/activity_pub/activity_pub_controller.ex | 4 +- lib/pleroma/web/activity_pub/views/user_view.ex | 47 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index dfa7eb94b..9f083d0a5 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -154,11 +154,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do def read_inbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do if nickname == user.nickname do - Logger.info("read inbox #{inspect(params)}") - conn |> put_resp_header("content-type", "application/activity+json") - |> json("ok!") + |> json(UserView.render("inbox.json", %{user: user, max_id: params["max_id"]})) else conn |> put_status(:forbidden) diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index f0c268755..439d834e4 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -176,6 +176,53 @@ defmodule Pleroma.Web.ActivityPub.UserView do end end + def render("inbox.json", %{user: user, max_id: max_qid}) do + params = %{ + "limit" => "10" + } + + params = + if max_qid != nil do + Map.put(params, "max_id", max_qid) + else + params + end + + activities = ActivityPub.fetch_activities([user.ap_id | user.following], params) + + min_id = Enum.at(Enum.reverse(activities), 0).id + max_id = Enum.at(activities, 0).id + + collection = + Enum.map(activities, fn act -> + {:ok, data} = Transmogrifier.prepare_outgoing(act.data) + data + end) + + iri = "#{user.ap_id}/inbox" + + page = %{ + "id" => "#{iri}?max_id=#{max_id}", + "type" => "OrderedCollectionPage", + "partOf" => iri, + "totalItems" => -1, + "orderedItems" => collection, + "next" => "#{iri}?max_id=#{min_id - 1}" + } + + if max_qid == nil do + %{ + "id" => iri, + "type" => "OrderedCollection", + "totalItems" => -1, + "first" => page + } + |> Map.merge(Utils.make_json_ld_header()) + else + page |> Map.merge(Utils.make_json_ld_header()) + end + end + def collection(collection, iri, page, show_items \\ true, total \\ nil) do offset = (page - 1) * 10 items = Enum.slice(collection, offset, 10) -- cgit v1.2.3 From 569bad821006add1719123f6e2830f23542921d2 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sat, 29 Dec 2018 18:21:45 +0100 Subject: Create activity when client posts to outbox --- .../web/activity_pub/activity_pub_controller.ex | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 9f083d0a5..dca74db73 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -4,11 +4,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do use Pleroma.Web, :controller - alias Pleroma.{User, Object} + alias Pleroma.{Activity, User, Object} alias Pleroma.Web.ActivityPub.{ObjectView, UserView} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Relay alias Pleroma.Web.ActivityPub.Utils + alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.Federator require Logger @@ -166,11 +167,33 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do def update_outbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do if nickname == user.nickname do - Logger.info("update outbox #{inspect(params)}") - - conn - |> put_status(:created) - |> json("ok!") + actor = user.ap_id() + + params = + params + |> Map.drop(["id"]) + |> Map.put("actor", actor) + |> Transmogrifier.fix_addressing() + + object = + params["object"] + |> Map.merge(Map.take(params, ["to", "cc"])) + |> Map.put("attributedTo", actor) + |> Transmogrifier.fix_object() + + with {:ok, %Activity{} = activity} <- + ActivityPub.create(%{ + to: params["to"], + actor: user, + context: object["context"], + object: object, + additional: Map.take(params, ["cc"]) + }) do + conn + |> put_status(:created) + |> put_resp_header("location", activity.data["id"]) + |> json(%{"id" => activity.data["id"]}) + end else conn |> put_status(:forbidden) -- cgit v1.2.3 From 1e781715c8a9c7f6e24838a5522b960250cffc1b Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sat, 29 Dec 2018 18:22:40 +0100 Subject: Limit activity types accepted to outbox to only 'Create' --- lib/pleroma/web/activity_pub/activity_pub_controller.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index dca74db73..f90132b4d 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -165,7 +165,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end end - def update_outbox(%{assigns: %{user: user}} = conn, %{"nickname" => nickname} = params) do + def update_outbox( + %{assigns: %{user: user}} = conn, + %{"nickname" => nickname, "type" => "Create"} = params + ) do if nickname == user.nickname do actor = user.ap_id() -- cgit v1.2.3 From f40562b4e1ff213b88c8b6edf57431bfb1b804ac Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sun, 30 Dec 2018 11:19:53 +0100 Subject: Respond with full activity to outbox post --- lib/pleroma/web/activity_pub/activity_pub_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index f90132b4d..e41b14afc 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -195,7 +195,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do conn |> put_status(:created) |> put_resp_header("location", activity.data["id"]) - |> json(%{"id" => activity.data["id"]}) + |> json(activity.data) end else conn -- cgit v1.2.3 From 66d1c31461826b34d5c907dc3a91e86cce808c3e Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 13:51:01 +0100 Subject: Fix some stupid typos --- lib/pleroma/web/common_api/utils.ex | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 593404e4d..1aedbf962 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -281,35 +281,25 @@ defmodule Pleroma.Web.CommonAPI.Utils do {new_scrubber_cache, scrubbed_html} = Enum.map_reduce(scrubber_cache, nil, fn %{ - :scrubbers => current_key, - :content => current_content - }, - _ -> + "scrubbers" => current_key, + "content" => current_content + } = current_element, + _content -> if Map.keys(current_key) == Map.keys(key) do - if scrubbers == key do - {current_key, current_content} + if current_key == key do + {current_element, current_content} else # Remove the entry if scrubber version is outdated {nil, nil} end end end) - + new_scrubber_cache = Enum.reject(new_scrubber_cache, &is_nil/1) - - if !(new_scrubber_cache == scrubber_cache) or scrubbed_html == nil do + if scrubbed_html == nil or new_scrubber_cache != scrubber_cache do scrubbed_html = HTML.filter_tags(content, scrubbers) new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] - - activity = - Map.put( - activity, - :data, - Kernel.put_in(activity.data, ["object", "scrubber_cache"], new_scrubber_cache) - ) - - cng = Object.change(activity) - Repo.update(cng) + update_scrubber_cache(activity, new_scrubber_cache) scrubbed_html else scrubbed_html @@ -321,4 +311,9 @@ defmodule Pleroma.Web.CommonAPI.Utils do Map.put(acc, to_string(scrubber), scrubber.version) end) end + + defp update_scrubber_cache(activity, scrubber_cache) do + cng = Object.change(activity, %{data: Kernel.put_in(activity.data, ["object", "scrubber_cache"], scrubber_cache)}) + {:ok, _struct} = Repo.update(cng) + end end -- cgit v1.2.3 From bce152aba000e9b59562bf95f3a6df8540686317 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 15:58:19 +0100 Subject: Tidy up the code. Rename key to signature --- lib/pleroma/web/common_api/utils.ex | 53 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 1aedbf962..d4c169ad9 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -271,49 +271,50 @@ defmodule Pleroma.Web.CommonAPI.Utils do %{data: %{"object" => object}} = activity ) do scrubber_cache = - if object["scrubber_cache"] != nil and is_list(object["scrubber_cache"]) do + if is_list(object["scrubber_cache"]) do object["scrubber_cache"] else [] end - key = generate_scrubber_key(scrubbers) + signature = generate_scrubber_signature(scrubbers) {new_scrubber_cache, scrubbed_html} = - Enum.map_reduce(scrubber_cache, nil, fn %{ - "scrubbers" => current_key, - "content" => current_content - } = current_element, - _content -> - if Map.keys(current_key) == Map.keys(key) do - if current_key == key do - {current_element, current_content} - else - # Remove the entry if scrubber version is outdated - {nil, nil} + Enum.map_reduce(scrubber_cache, nil, fn + entry, _content -> + if Map.keys(entry["scrubbers"]) == Map.keys(signature) do + if entry["scrubbers"] == signature do + {entry, entry["content"]} + else + # Remove the entry if scrubber version is outdated + {nil, nil} + end end - end end) - + + # Remove nil objects new_scrubber_cache = Enum.reject(new_scrubber_cache, &is_nil/1) + if scrubbed_html == nil or new_scrubber_cache != scrubber_cache do scrubbed_html = HTML.filter_tags(content, scrubbers) - new_scrubber_cache = [%{:scrubbers => key, :content => scrubbed_html} | new_scrubber_cache] + new_scrubber_cache = [%{:scrubbers => signature, :content => scrubbed_html} | new_scrubber_cache] update_scrubber_cache(activity, new_scrubber_cache) - scrubbed_html - else - scrubbed_html end + scrubbed_html end - defp generate_scrubber_key(scrubbers) do - Enum.reduce(scrubbers, %{}, fn scrubber, acc -> - Map.put(acc, to_string(scrubber), scrubber.version) + defp generate_scrubber_signature(scrubbers) do + Enum.reduce(scrubbers, %{}, fn scrubber, signature -> + Map.put(signature, to_string(scrubber), scrubber.version) end) end - defp update_scrubber_cache(activity, scrubber_cache) do - cng = Object.change(activity, %{data: Kernel.put_in(activity.data, ["object", "scrubber_cache"], scrubber_cache)}) - {:ok, _struct} = Repo.update(cng) - end + defp update_scrubber_cache(activity, scrubber_cache) do + cng = + Object.change(activity, %{ + data: Kernel.put_in(activity.data, ["object", "scrubber_cache"], scrubber_cache) + }) + + {:ok, _struct} = Repo.update(cng) + end end -- cgit v1.2.3 From cb286fdeba1782b75d1d7bca484d80e3cd499a98 Mon Sep 17 00:00:00 2001 From: Michael Loftis Date: Sun, 30 Dec 2018 15:16:26 +0000 Subject: Improves RetryQueue behavior reduces to one single timer firing once a second switches to a parallel worker model --- lib/pleroma/web/federator/retry_queue.ex | 195 ++++++++++++++++++++++++++++--- 1 file changed, 180 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index 5f1d43008..e4340af7c 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -7,20 +7,34 @@ defmodule Pleroma.Web.Federator.RetryQueue do require Logger - # initial timeout, 5 min - @initial_timeout 30_000 + # seconds + @initial_timeout 30 @max_retries 5 + @max_jobs 20 + def init(args) do - {:ok, args} + queue_table = :ets.new(:pleroma_retry_queue, [:bag, :protected]) + + {:ok, %{args | queue_table: queue_table, running_jobs: :sets.new()}} end def start_link() do - enabled = Pleroma.Config.get([:retry_queue, :enabled], false) + enabled = + if Mix.env() == :test, do: true, else: Pleroma.Config.get([:retry_queue, :enabled], false) if enabled do Logger.info("Starting retry queue") - GenServer.start_link(__MODULE__, %{delivered: 0, dropped: 0}, name: __MODULE__) + + linkres = + GenServer.start_link( + __MODULE__, + %{delivered: 0, dropped: 0, queue_table: nil, running_jobs: nil}, + name: __MODULE__ + ) + + maybe_kickoff_timer() + linkres else Logger.info("Retry queue disabled") :ignore @@ -31,6 +45,14 @@ defmodule Pleroma.Web.Federator.RetryQueue do GenServer.cast(__MODULE__, {:maybe_enqueue, data, transport, retries + 1}) end + def get_stats() do + GenServer.call(__MODULE__, :get_stats) + end + + def reset_stats() do + GenServer.call(__MODULE__, :reset_stats) + end + def get_retry_params(retries) do if retries > @max_retries do {:drop, "Max retries reached"} @@ -39,16 +61,118 @@ defmodule Pleroma.Web.Federator.RetryQueue do end end - def handle_cast({:maybe_enqueue, data, transport, retries}, %{dropped: drop_count} = state) do + def get_retry_timer_interval() do + Pleroma.Config.get([:retry_queue, :interval], 1000) + end + + defp ets_count_expires(table, current_time) do + :ets.select_count( + table, + [ + { + {:"$1", :"$2"}, + [{:"=<", :"$1", {:const, current_time}}], + [true] + } + ] + ) + end + + defp ets_pop_n_expired(table, current_time, desired) do + {popped, _continuation} = + :ets.select( + table, + [ + { + {:"$1", :"$2"}, + [{:"=<", :"$1", {:const, current_time}}], + [:"$_"] + } + ], + desired + ) + + popped + |> List.foldl(true, fn e, acc -> + :ets.delete_object(table, e) + acc + end) + + popped + end + + def maybe_start_job(running_jobs, queue_table) do + # we don't want to hit the ets or the DateTime more times than we have to + # could optimize slightly further by not using the count, and instead grabbing + # up to N objects early... + current_time = DateTime.to_unix(DateTime.utc_now()) + n_running_jobs = :sets.size(running_jobs) + + if n_running_jobs < @max_jobs do + n_ready_jobs = ets_count_expires(queue_table, current_time) + + if n_ready_jobs > 0 do + # figure out how many we could start + available_job_slots = @max_jobs - n_running_jobs + start_n_jobs(running_jobs, queue_table, current_time, available_job_slots) + else + running_jobs + end + else + running_jobs + end + end + + defp start_n_jobs(running_jobs, _queue_table, _current_time, 0) do + running_jobs + end + + defp start_n_jobs(running_jobs, queue_table, current_time, available_job_slots) + when available_job_slots > 0 do + candidates = ets_pop_n_expired(queue_table, current_time, available_job_slots) + + candidates + |> List.foldl(running_jobs, fn {_, e}, rj -> + {:ok, pid} = Task.start(fn -> worker(e) end) + mref = Process.monitor(pid) + :sets.add_element(mref, rj) + end) + end + + def worker({:send, data, transport, retries}) do + case transport.publish_one(data) do + {:ok, _} -> + GenServer.cast(__MODULE__, :inc_delivered) + :delivered + + {:error, _reason} -> + enqueue(data, transport, retries) + :retry + end + end + + def handle_call(:get_stats, _from, %{delivered: delivery_count, dropped: drop_count} = state) do + {:reply, %{delivered: delivery_count, dropped: drop_count}, state} + end + + def handle_call(:reset_stats, _from, %{delivered: delivery_count, dropped: drop_count} = state) do + {:reply, %{delivered: delivery_count, dropped: drop_count}, + %{state | delivered: 0, dropped: 0}} + end + + def handle_cast(:reset_stats, state) do + {:noreply, %{state | delivered: 0, dropped: 0}} + end + + def handle_cast( + {:maybe_enqueue, data, transport, retries}, + %{dropped: drop_count, queue_table: queue_table, running_jobs: running_jobs} = state + ) do case get_retry_params(retries) do {:retry, timeout} -> - Process.send_after( - __MODULE__, - {:send, data, transport, retries}, - timeout - ) - - {:noreply, state} + :ets.insert(queue_table, {timeout, {:send, data, transport, retries}}) + running_jobs = maybe_start_job(running_jobs, queue_table) + {:noreply, %{state | running_jobs: running_jobs}} {:drop, message} -> Logger.debug(message) @@ -56,6 +180,20 @@ defmodule Pleroma.Web.Federator.RetryQueue do end end + def handle_cast(:kickoff_timer, state) do + retry_interval = get_retry_timer_interval() + Process.send_after(__MODULE__, :retry_timer_run, retry_interval) + {:noreply, state} + end + + def handle_cast(:inc_delivered, %{delivered: delivery_count} = state) do + {:noreply, %{state | delivered: delivery_count + 1}} + end + + def handle_cast(:inc_dropped, %{dropped: drop_count} = state) do + {:noreply, %{state | dropped: drop_count + 1}} + end + def handle_info({:send, data, transport, retries}, %{delivered: delivery_count} = state) do case transport.publish_one(data) do {:ok, _} -> @@ -67,12 +205,39 @@ defmodule Pleroma.Web.Federator.RetryQueue do end end + def handle_info( + :retry_timer_run, + %{queue_table: queue_table, running_jobs: running_jobs} = state + ) do + maybe_kickoff_timer() + running_jobs = maybe_start_job(running_jobs, queue_table) + {:noreply, %{state | running_jobs: running_jobs}} + end + + def handle_info({:DOWN, ref, :process, _pid, _reason}, state) do + %{running_jobs: running_jobs, queue_table: queue_table} = state + running_jobs = :sets.del_element(ref, running_jobs) + running_jobs = maybe_start_job(running_jobs, queue_table) + {:noreply, %{state | running_jobs: running_jobs}} + end + def handle_info(unknown, state) do Logger.debug("RetryQueue: don't know what to do with #{inspect(unknown)}, ignoring") {:noreply, state} end - defp growth_function(retries) do - round(@initial_timeout * :math.pow(retries, 3)) + if Mix.env() == :test do + defp growth_function(_retries) do + _shutit = @initial_timeout + DateTime.to_unix(DateTime.utc_now()) - 1 + end + else + defp growth_function(retries) do + round(@initial_timeout * :math.pow(retries, 3)) + DateTime.to_unix(DateTime.utc_now()) + end + end + + defp maybe_kickoff_timer() do + GenServer.cast(__MODULE__, :kickoff_timer) end end -- cgit v1.2.3 From d9f40b05b30dd735d0dc87f8268db842bf8ad1f0 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 16:51:16 +0100 Subject: Added get_stripped_html_for_object. Renamed a few things --- lib/pleroma/web/common_api/utils.ex | 34 ++++++++++++++++++---- lib/pleroma/web/mastodon_api/views/status_view.ex | 2 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 5 ++-- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d4c169ad9..759bd62af 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -262,10 +262,13 @@ defmodule Pleroma.Web.CommonAPI.Utils do end) end + def get_scrubbed_html_for_object(content, scrubber, activity) when is_atom(scrubber) do + get_scrubbed_html_for_object(content, [scrubber], activity) + end @doc """ Get sanitized HTML from cache, or scrub it and save to cache. """ - def get_scrubbed_html( + def get_scrubbed_html_for_object( content, scrubbers, %{data: %{"object" => object}} = activity @@ -281,7 +284,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do {new_scrubber_cache, scrubbed_html} = Enum.map_reduce(scrubber_cache, nil, fn - entry, _content -> + entry, content -> if Map.keys(entry["scrubbers"]) == Map.keys(signature) do if entry["scrubbers"] == signature do {entry, entry["content"]} @@ -289,6 +292,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do # Remove the entry if scrubber version is outdated {nil, nil} end + else + {entry, content} end end) @@ -297,15 +302,30 @@ defmodule Pleroma.Web.CommonAPI.Utils do if scrubbed_html == nil or new_scrubber_cache != scrubber_cache do scrubbed_html = HTML.filter_tags(content, scrubbers) - new_scrubber_cache = [%{:scrubbers => signature, :content => scrubbed_html} | new_scrubber_cache] + + new_scrubber_cache = [ + %{:scrubbers => signature, :content => scrubbed_html} | new_scrubber_cache + ] + update_scrubber_cache(activity, new_scrubber_cache) + scrubbed_html + else + scrubbed_html end - scrubbed_html end defp generate_scrubber_signature(scrubbers) do Enum.reduce(scrubbers, %{}, fn scrubber, signature -> - Map.put(signature, to_string(scrubber), scrubber.version) + Map.put( + signature, + to_string(scrubber), + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) + if Kernel.function_exported?(scrubber, :version, 0) do + scrubber.version + else + 0 + end + ) end) end @@ -317,4 +337,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do {:ok, _struct} = Repo.update(cng) end + + def get_stripped_html_for_object(content, activity) do + get_scrubbed_html_for_object(content, [HtmlSanitizeEx.Scrubber.StripTags], activity) + end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 8fa3798a6..05ed602d5 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -120,7 +120,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do content = object |> render_content() - |> Utils.get_scrubbed_html(User.html_filter_policy(opts[:for]), activity) + |> Utils.get_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) %{ id: to_string(activity.id), diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index adac1dfe9..7d0dea8c2 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -15,7 +15,6 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do alias Pleroma.User alias Pleroma.Repo alias Pleroma.Formatter - alias Pleroma.HTML import Ecto.Query require Logger @@ -245,14 +244,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do html = content - |> Utils.get_scrubbed_html(User.html_filter_policy(opts[:for]), activity) + |> Utils.get_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) |> Formatter.emojify(object["emoji"]) text = if content do content |> String.replace(~r//, "\n") - |> HTML.strip_tags() + |> Utils.get_stripped_html_for_object(activity) end reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From 535fddd2864f3ed8eebc24cbaf0e5b04ec6f4dbe Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 19:33:36 +0100 Subject: Friendship ended with Postgresql now Cachex is my best friend --- lib/pleroma/application.ex | 10 +++ lib/pleroma/object.ex | 34 ++++++++- lib/pleroma/web/common_api/common_api.ex | 3 +- lib/pleroma/web/common_api/utils.ex | 81 +--------------------- lib/pleroma/web/mastodon_api/views/status_view.ex | 3 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 4 +- 6 files changed, 49 insertions(+), 86 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 36a3694f2..4b997c048 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -53,6 +53,16 @@ defmodule Pleroma.Application do ], id: :cachex_object ), + worker( + Cachex, + [ + :scrubber_cache, + [ + limit: 2500 + ] + ], + id: :cachex_scrubber + ), worker( Cachex, [ diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index cc4a2181a..e148c1d75 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -4,7 +4,7 @@ defmodule Pleroma.Object do use Ecto.Schema - alias Pleroma.{Repo, Object, User, Activity} + alias Pleroma.{Repo, Object, User, Activity, HTML} import Ecto.{Query, Changeset} schema "objects" do @@ -73,4 +73,36 @@ defmodule Pleroma.Object do {:ok, object} end end + + def get_cached_scrubbed_html(content, scrubbers, object) do + key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" + Cachex.fetch!(:scrubber_cache, key, fn(_key) -> ensure_scrubbed_html(content, scrubbers) end ) + end + + def get_cached_stripped_html(content, object) do + get_cached_scrubbed_html(content, HtmlSanitizeEx.Scrubber.StripTags, object) + end + + def ensure_scrubbed_html( + content, + scrubbers + ) do + {:commit, HTML.filter_tags(content, scrubbers)} + end + + defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do + generate_scrubber_signature([scrubber]) + end + + defp generate_scrubber_signature(scrubbers) do + Enum.reduce(scrubbers, "", fn scrubber, signature -> + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) + version = if Kernel.function_exported?(scrubber, :version, 0) do + scrubber.version + else + 0 + end + "#{signature}#{to_string(scrubber)}#{version}" + end) + end end diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 06d44451e..5e5821561 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -128,8 +128,7 @@ defmodule Pleroma.Web.CommonAPI do |> Enum.reduce(%{}, fn {name, file}, acc -> Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}") end) - ), - object <- Map.put(object, "scrubber_cache", %{}) do + ) do res = ActivityPub.create(%{ to: to, diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 759bd62af..813eb4093 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do alias Calendar.Strftime alias Comeonin.Pbkdf2 - alias Pleroma.{Activity, Formatter, Object, Repo, HTML} + alias Pleroma.{Activity, Formatter, Object, Repo} alias Pleroma.User alias Pleroma.Web alias Pleroma.Web.ActivityPub.Utils @@ -262,83 +262,4 @@ defmodule Pleroma.Web.CommonAPI.Utils do end) end - def get_scrubbed_html_for_object(content, scrubber, activity) when is_atom(scrubber) do - get_scrubbed_html_for_object(content, [scrubber], activity) - end - @doc """ - Get sanitized HTML from cache, or scrub it and save to cache. - """ - def get_scrubbed_html_for_object( - content, - scrubbers, - %{data: %{"object" => object}} = activity - ) do - scrubber_cache = - if is_list(object["scrubber_cache"]) do - object["scrubber_cache"] - else - [] - end - - signature = generate_scrubber_signature(scrubbers) - - {new_scrubber_cache, scrubbed_html} = - Enum.map_reduce(scrubber_cache, nil, fn - entry, content -> - if Map.keys(entry["scrubbers"]) == Map.keys(signature) do - if entry["scrubbers"] == signature do - {entry, entry["content"]} - else - # Remove the entry if scrubber version is outdated - {nil, nil} - end - else - {entry, content} - end - end) - - # Remove nil objects - new_scrubber_cache = Enum.reject(new_scrubber_cache, &is_nil/1) - - if scrubbed_html == nil or new_scrubber_cache != scrubber_cache do - scrubbed_html = HTML.filter_tags(content, scrubbers) - - new_scrubber_cache = [ - %{:scrubbers => signature, :content => scrubbed_html} | new_scrubber_cache - ] - - update_scrubber_cache(activity, new_scrubber_cache) - scrubbed_html - else - scrubbed_html - end - end - - defp generate_scrubber_signature(scrubbers) do - Enum.reduce(scrubbers, %{}, fn scrubber, signature -> - Map.put( - signature, - to_string(scrubber), - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) - if Kernel.function_exported?(scrubber, :version, 0) do - scrubber.version - else - 0 - end - ) - end) - end - - defp update_scrubber_cache(activity, scrubber_cache) do - cng = - Object.change(activity, %{ - data: Kernel.put_in(activity.data, ["object", "scrubber_cache"], scrubber_cache) - }) - - {:ok, _struct} = Repo.update(cng) - end - - def get_stripped_html_for_object(content, activity) do - get_scrubbed_html_for_object(content, [HtmlSanitizeEx.Scrubber.StripTags], activity) - end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 05ed602d5..8a57a233a 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do alias Pleroma.HTML alias Pleroma.Repo alias Pleroma.User + alias Pleroma.Object alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.MediaProxy alias Pleroma.Web.MastodonAPI.AccountView @@ -120,7 +121,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do content = object |> render_content() - |> Utils.get_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) + |> Object.get_cached_scrubbed_html(User.html_filter_policy(opts[:for]), activity) %{ id: to_string(activity.id), diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 7d0dea8c2..4c29e03ce 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -244,14 +244,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do html = content - |> Utils.get_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) + |> Object.get_cached_scrubbed_html(User.html_filter_policy(opts[:for]), activity) |> Formatter.emojify(object["emoji"]) text = if content do content |> String.replace(~r//, "\n") - |> Utils.get_stripped_html_for_object(activity) + |> Object.get_cached_stripped_html(activity) end reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From c119ea3a5727d521c36d60eca22fa3f20d507b63 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:00:01 +0100 Subject: Friendship ended with Postgresql now Cachex is my best friend --- lib/pleroma/object.ex | 16 +++++++++------- lib/pleroma/web/common_api/utils.ex | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index e148c1d75..d9f0e91b0 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -73,10 +73,10 @@ defmodule Pleroma.Object do {:ok, object} end end - + def get_cached_scrubbed_html(content, scrubbers, object) do key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" - Cachex.fetch!(:scrubber_cache, key, fn(_key) -> ensure_scrubbed_html(content, scrubbers) end ) + Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end) end def get_cached_stripped_html(content, object) do @@ -87,22 +87,24 @@ defmodule Pleroma.Object do content, scrubbers ) do - {:commit, HTML.filter_tags(content, scrubbers)} + {:commit, HTML.filter_tags(content, scrubbers)} end - + defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do generate_scrubber_signature([scrubber]) end defp generate_scrubber_signature(scrubbers) do Enum.reduce(scrubbers, "", fn scrubber, signature -> - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) - version = if Kernel.function_exported?(scrubber, :version, 0) do + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) + version = + if Kernel.function_exported?(scrubber, :version, 0) do scrubber.version else 0 end - "#{signature}#{to_string(scrubber)}#{version}" + + "#{signature}#{to_string(scrubber)}#{version}" end) end end diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 813eb4093..b91cfc4bb 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -261,5 +261,4 @@ defmodule Pleroma.Web.CommonAPI.Utils do } end) end - end -- cgit v1.2.3 From 62af23bd26d370ecc38159a8a3803562514596f4 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:12:12 +0100 Subject: Revert some changes in html.ex --- lib/pleroma/html.ex | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 169394af9..f363ed85c 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -5,8 +5,18 @@ defmodule Pleroma.HTML do alias HtmlSanitizeEx.Scrubber - def filter_tags(html, scrubbers) when is_list(scrubbers) do - Enum.reduce(scrubbers, html, fn scrubber, html -> + defp get_scrubbers(scrubber) when is_atom(scrubber), do: [scrubber] + defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers + defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default] + + def get_scrubbers() do + Pleroma.Config.get([:markup, :scrub_policy]) + |> get_scrubbers + end + + def filter_tags(html, nil) do + get_scrubbers() + |> Enum.reduce(html, fn scrubber, html -> filter_tags(html, scrubber) end) end @@ -28,11 +38,8 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - - def version do - 0 - end - + + def version do 0 end Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() @@ -70,11 +77,7 @@ defmodule Pleroma.HTML.Scrubber.Default do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - - def version do - 0 - end - + def version do 0 end @markup Application.get_env(:pleroma, :markup) @uri_schemes Application.get_env(:pleroma, :uri_schemes, []) @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, []) @@ -150,12 +153,9 @@ end defmodule Pleroma.HTML.Transform.MediaProxy do @moduledoc "Transforms inline image URIs to use MediaProxy." - def version do - 0 - end - alias Pleroma.Web.MediaProxy - + + def version do 0 end def before_scrub(html), do: html def scrub_attribute("img", {"src", "http" <> target}) do -- cgit v1.2.3 From 3f9da55adc9798bd66749dcdbd02fded8494fda3 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:16:42 +0100 Subject: Fix formating. Aparently my pre-commit hook broke. --- lib/pleroma/html.ex | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index f363ed85c..44b6776f9 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -38,8 +38,11 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - - def version do 0 end + + def version do + 0 + end + Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() @@ -77,7 +80,11 @@ defmodule Pleroma.HTML.Scrubber.Default do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - def version do 0 end + + def version do + 0 + end + @markup Application.get_env(:pleroma, :markup) @uri_schemes Application.get_env(:pleroma, :uri_schemes, []) @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, []) @@ -154,8 +161,11 @@ defmodule Pleroma.HTML.Transform.MediaProxy do @moduledoc "Transforms inline image URIs to use MediaProxy." alias Pleroma.Web.MediaProxy - - def version do 0 end + + def version do + 0 + end + def before_scrub(html), do: html def scrub_attribute("img", {"src", "http" <> target}) do -- cgit v1.2.3 From c50353e6aef5ec482a427298fb20b1b75c208bca Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:44:17 +0100 Subject: shame on me for not testing after revert --- lib/pleroma/html.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 44b6776f9..5e1f5bf96 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -15,8 +15,11 @@ defmodule Pleroma.HTML do end def filter_tags(html, nil) do - get_scrubbers() - |> Enum.reduce(html, fn scrubber, html -> + filter_tags(html, get_scrubbers()) + end + + def filter_tags(html, scrubbers) when is_list(scrubbers) do + Enum.reduce(scrubbers, html, fn scrubber, html -> filter_tags(html, scrubber) end) end -- cgit v1.2.3 From ab3089d6a718d4a70b0d702307d41e64e17bc505 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 30 Dec 2018 20:51:31 +0100 Subject: Fix comment in object.ex --- lib/pleroma/object.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index d9f0e91b0..99c836309 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -96,7 +96,7 @@ defmodule Pleroma.Object do defp generate_scrubber_signature(scrubbers) do Enum.reduce(scrubbers, "", fn scrubber, signature -> - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber.StripTags) it is assumed it is always 0) version = if Kernel.function_exported?(scrubber, :version, 0) do scrubber.version -- cgit v1.2.3 From 7e09c2bd7d4e22eff75037d8ac1252347a404aea Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Mon, 31 Dec 2018 08:19:48 +0100 Subject: Move scrubber cache-related functions to Pleroma.HTML --- lib/pleroma/html.ex | 34 ++++++++++++++++++++++ lib/pleroma/object.ex | 34 ---------------------- lib/pleroma/web/mastodon_api/views/status_view.ex | 3 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 5 ++-- 4 files changed, 38 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 5e1f5bf96..eb31f131e 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -27,6 +27,40 @@ defmodule Pleroma.HTML do def filter_tags(html, scrubber), do: Scrubber.scrub(html, scrubber) def filter_tags(html), do: filter_tags(html, nil) def strip_tags(html), do: Scrubber.scrub(html, Scrubber.StripTags) + + def get_cached_scrubbed_html_for_object(content, scrubbers, object) do + key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" + Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end) + end + + def get_cached_stripped_html_for_object(content, object) do + get_cached_scrubbed_html_for_object(content, HtmlSanitizeEx.Scrubber.StripTags, object) + end + + def ensure_scrubbed_html( + content, + scrubbers + ) do + {:commit, filter_tags(content, scrubbers)} + end + + defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do + generate_scrubber_signature([scrubber]) + end + + defp generate_scrubber_signature(scrubbers) do + Enum.reduce(scrubbers, "", fn scrubber, signature -> + # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber.StripTags) it is assumed it is always 0) + version = + if Kernel.function_exported?(scrubber, :version, 0) do + scrubber.version + else + 0 + end + + "#{signature}#{to_string(scrubber)}#{version}" + end) + end end defmodule Pleroma.HTML.Scrubber.TwitterText do diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 9a6c256df..5241f00ae 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -4,7 +4,6 @@ defmodule Pleroma.Object do use Ecto.Schema - alias Pleroma.{Repo, Object, User, Activity, HTML, ObjectTombstone} alias Pleroma.{Repo, Object, User, Activity, ObjectTombstone} import Ecto.{Query, Changeset} @@ -92,37 +91,4 @@ defmodule Pleroma.Object do end end - def get_cached_scrubbed_html(content, scrubbers, object) do - key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" - Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end) - end - - def get_cached_stripped_html(content, object) do - get_cached_scrubbed_html(content, HtmlSanitizeEx.Scrubber.StripTags, object) - end - - def ensure_scrubbed_html( - content, - scrubbers - ) do - {:commit, HTML.filter_tags(content, scrubbers)} - end - - defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do - generate_scrubber_signature([scrubber]) - end - - defp generate_scrubber_signature(scrubbers) do - Enum.reduce(scrubbers, "", fn scrubber, signature -> - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber.StripTags) it is assumed it is always 0) - version = - if Kernel.function_exported?(scrubber, :version, 0) do - scrubber.version - else - 0 - end - - "#{signature}#{to_string(scrubber)}#{version}" - end) - end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 8a57a233a..da61bbd86 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -9,7 +9,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do alias Pleroma.HTML alias Pleroma.Repo alias Pleroma.User - alias Pleroma.Object alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.MediaProxy alias Pleroma.Web.MastodonAPI.AccountView @@ -121,7 +120,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do content = object |> render_content() - |> Object.get_cached_scrubbed_html(User.html_filter_policy(opts[:for]), activity) + |> HTML.get_cached_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) %{ id: to_string(activity.id), diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 4c29e03ce..469f780c7 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -11,6 +11,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do alias Pleroma.Web.TwitterAPI.TwitterAPI alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter alias Pleroma.Activity + alias Pleroma.HTML alias Pleroma.Object alias Pleroma.User alias Pleroma.Repo @@ -244,14 +245,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do html = content - |> Object.get_cached_scrubbed_html(User.html_filter_policy(opts[:for]), activity) + |> HTML.get_cached_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) |> Formatter.emojify(object["emoji"]) text = if content do content |> String.replace(~r//, "\n") - |> Object.get_cached_stripped_html(activity) + |> HTML.get_cached_stripped_html_for_object(activity) end reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From 6ed9b31a5fea055aad7d390d50ead4cdfd6b7378 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Mon, 31 Dec 2018 08:25:48 +0100 Subject: Eh? --- lib/pleroma/object.ex | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 5241f00ae..e2b648727 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -90,5 +90,4 @@ defmodule Pleroma.Object do {:ok, object} end end - end -- cgit v1.2.3 From 980b5288ed119a3579afe632dff3391528ff399c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 31 Dec 2018 15:41:47 +0000 Subject: update copyright years to 2019 --- lib/pleroma/PasswordResetToken.ex | 2 +- lib/pleroma/activity.ex | 2 +- lib/pleroma/application.ex | 2 +- lib/pleroma/captcha/captcha.ex | 2 +- lib/pleroma/captcha/captcha_service.ex | 2 +- lib/pleroma/captcha/kocaptcha.ex | 2 +- lib/pleroma/config.ex | 2 +- lib/pleroma/emails/mailer.ex | 2 +- lib/pleroma/emails/user_email.ex | 2 +- lib/pleroma/emoji.ex | 2 +- lib/pleroma/filter.ex | 2 +- lib/pleroma/formatter.ex | 2 +- lib/pleroma/gopher/server.ex | 2 +- lib/pleroma/html.ex | 2 +- lib/pleroma/http/connection.ex | 2 +- lib/pleroma/http/http.ex | 2 +- lib/pleroma/http/request_builder.ex | 2 +- lib/pleroma/list.ex | 2 +- lib/pleroma/mime.ex | 2 +- lib/pleroma/notification.ex | 2 +- lib/pleroma/object.ex | 2 +- lib/pleroma/plugs/admin_secret_authentication_plug.ex | 2 +- lib/pleroma/plugs/authentication_plug.ex | 2 +- lib/pleroma/plugs/basic_auth_decoder_plug.ex | 2 +- lib/pleroma/plugs/digest.ex | 2 +- lib/pleroma/plugs/ensure_authenticated_plug.ex | 2 +- lib/pleroma/plugs/ensure_user_key_plug.ex | 2 +- lib/pleroma/plugs/federating_plug.ex | 2 +- lib/pleroma/plugs/http_security_plug.ex | 2 +- lib/pleroma/plugs/http_signature.ex | 2 +- lib/pleroma/plugs/instance_static.ex | 2 +- lib/pleroma/plugs/legacy_authentication_plug.ex | 2 +- lib/pleroma/plugs/oauth_plug.ex | 2 +- lib/pleroma/plugs/session_authentication_plug.ex | 2 +- lib/pleroma/plugs/set_user_session_id_plug.ex | 2 +- lib/pleroma/plugs/uploaded_media.ex | 2 +- lib/pleroma/plugs/user_enabled_plug.ex | 2 +- lib/pleroma/plugs/user_fetcher_plug.ex | 2 +- lib/pleroma/plugs/user_is_admin_plug.ex | 2 +- lib/pleroma/repo.ex | 2 +- lib/pleroma/reverse_proxy.ex | 2 +- lib/pleroma/stats.ex | 2 +- lib/pleroma/upload.ex | 2 +- lib/pleroma/upload/filter.ex | 2 +- lib/pleroma/upload/filter/anonymize_filename.ex | 2 +- lib/pleroma/upload/filter/dedupe.ex | 2 +- lib/pleroma/upload/filter/mogrifun.ex | 2 +- lib/pleroma/upload/filter/mogrify.ex | 2 +- lib/pleroma/uploaders/local.ex | 2 +- lib/pleroma/uploaders/mdii.ex | 2 +- lib/pleroma/uploaders/s3.ex | 2 +- lib/pleroma/uploaders/swift/keystone.ex | 2 +- lib/pleroma/uploaders/swift/swift.ex | 2 +- lib/pleroma/uploaders/swift/uploader.ex | 2 +- lib/pleroma/uploaders/uploader.ex | 2 +- lib/pleroma/user.ex | 2 +- lib/pleroma/user/info.ex | 2 +- lib/pleroma/user_invite_token.ex | 2 +- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- lib/pleroma/web/activity_pub/activity_pub_controller.ex | 2 +- lib/pleroma/web/activity_pub/mrf.ex | 2 +- lib/pleroma/web/activity_pub/mrf/drop_policy.ex | 2 +- lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex | 2 +- lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex | 2 +- lib/pleroma/web/activity_pub/mrf/noop_policy.ex | 2 +- lib/pleroma/web/activity_pub/mrf/normalize_markup.ex | 2 +- lib/pleroma/web/activity_pub/mrf/reject_non_public.ex | 2 +- lib/pleroma/web/activity_pub/mrf/simple_policy.ex | 2 +- lib/pleroma/web/activity_pub/mrf/user_allowlist.ex | 2 +- lib/pleroma/web/activity_pub/relay.ex | 2 +- lib/pleroma/web/activity_pub/transmogrifier.ex | 2 +- lib/pleroma/web/activity_pub/utils.ex | 2 +- lib/pleroma/web/activity_pub/views/object_view.ex | 2 +- lib/pleroma/web/activity_pub/views/user_view.ex | 2 +- lib/pleroma/web/admin_api/admin_api_controller.ex | 2 +- lib/pleroma/web/channels/user_socket.ex | 2 +- lib/pleroma/web/chat_channel.ex | 2 +- lib/pleroma/web/common_api/common_api.ex | 2 +- lib/pleroma/web/common_api/utils.ex | 2 +- lib/pleroma/web/controller_helper.ex | 2 +- lib/pleroma/web/endpoint.ex | 2 +- lib/pleroma/web/federator/federator.ex | 2 +- lib/pleroma/web/federator/retry_queue.ex | 2 +- lib/pleroma/web/gettext.ex | 2 +- lib/pleroma/web/http_signatures/http_signatures.ex | 2 +- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 +- lib/pleroma/web/mastodon_api/views/account_view.ex | 2 +- lib/pleroma/web/mastodon_api/views/filter_view.ex | 2 +- lib/pleroma/web/mastodon_api/views/list_view.ex | 2 +- lib/pleroma/web/mastodon_api/views/mastodon_view.ex | 2 +- lib/pleroma/web/mastodon_api/views/push_subscription_view.ex | 2 +- lib/pleroma/web/mastodon_api/views/status_view.ex | 2 +- lib/pleroma/web/mastodon_api/websocket_handler.ex | 2 +- lib/pleroma/web/media_proxy/controller.ex | 2 +- lib/pleroma/web/media_proxy/media_proxy.ex | 2 +- lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 2 +- lib/pleroma/web/oauth/app.ex | 2 +- lib/pleroma/web/oauth/authorization.ex | 2 +- lib/pleroma/web/oauth/fallback_controller.ex | 2 +- lib/pleroma/web/oauth/oauth_controller.ex | 2 +- lib/pleroma/web/oauth/oauth_view.ex | 2 +- lib/pleroma/web/oauth/token.ex | 2 +- lib/pleroma/web/ostatus/activity_representer.ex | 2 +- lib/pleroma/web/ostatus/feed_representer.ex | 2 +- lib/pleroma/web/ostatus/handlers/delete_handler.ex | 2 +- lib/pleroma/web/ostatus/handlers/follow_handler.ex | 2 +- lib/pleroma/web/ostatus/handlers/note_handler.ex | 2 +- lib/pleroma/web/ostatus/handlers/unfollow_handler.ex | 2 +- lib/pleroma/web/ostatus/ostatus.ex | 2 +- lib/pleroma/web/ostatus/ostatus_controller.ex | 2 +- lib/pleroma/web/ostatus/user_representer.ex | 2 +- lib/pleroma/web/push/push.ex | 2 +- lib/pleroma/web/push/subscription.ex | 2 +- lib/pleroma/web/router.ex | 2 +- lib/pleroma/web/salmon/salmon.ex | 2 +- lib/pleroma/web/streamer.ex | 2 +- lib/pleroma/web/twitter_api/controllers/util_controller.ex | 2 +- lib/pleroma/web/twitter_api/representers/activity_representer.ex | 2 +- lib/pleroma/web/twitter_api/representers/base_representer.ex | 2 +- lib/pleroma/web/twitter_api/representers/object_representer.ex | 2 +- lib/pleroma/web/twitter_api/twitter_api.ex | 2 +- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 2 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 2 +- lib/pleroma/web/twitter_api/views/notification_view.ex | 2 +- lib/pleroma/web/twitter_api/views/user_view.ex | 2 +- lib/pleroma/web/twitter_api/views/util_view.ex | 2 +- lib/pleroma/web/views/error_helpers.ex | 2 +- lib/pleroma/web/views/error_view.ex | 2 +- lib/pleroma/web/views/layout_view.ex | 2 +- lib/pleroma/web/web.ex | 2 +- lib/pleroma/web/web_finger/web_finger.ex | 2 +- lib/pleroma/web/web_finger/web_finger_controller.ex | 2 +- lib/pleroma/web/websub/websub.ex | 2 +- lib/pleroma/web/websub/websub_client_subscription.ex | 2 +- lib/pleroma/web/websub/websub_controller.ex | 2 +- lib/pleroma/web/websub/websub_server_subscription.ex | 2 +- lib/pleroma/web/xml/xml.ex | 2 +- 137 files changed, 137 insertions(+), 137 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/PasswordResetToken.ex b/lib/pleroma/PasswordResetToken.ex index 57e3b7ef0..1dccdadae 100644 --- a/lib/pleroma/PasswordResetToken.ex +++ b/lib/pleroma/PasswordResetToken.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.PasswordResetToken do diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index a14d1e8c6..353f9f6cd 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Activity do diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 4b997c048..4542ed623 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Application do diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index f80946c8b..133a9fd68 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Captcha do diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex index 6037b7087..a820751a8 100644 --- a/lib/pleroma/captcha/captcha_service.ex +++ b/lib/pleroma/captcha/captcha_service.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Captcha.Service do diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index 54f4c8bcd..66f9ce754 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Captcha.Kocaptcha do diff --git a/lib/pleroma/config.ex b/lib/pleroma/config.ex index 6b1598d66..21507cd38 100644 --- a/lib/pleroma/config.ex +++ b/lib/pleroma/config.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Config do diff --git a/lib/pleroma/emails/mailer.ex b/lib/pleroma/emails/mailer.ex index a8bd70b6e..8d12641f2 100644 --- a/lib/pleroma/emails/mailer.ex +++ b/lib/pleroma/emails/mailer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Mailer do diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 688b0cd1c..c42c53c99 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.UserEmail do diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index b5e0a83d8..bb3190e08 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Emoji do diff --git a/lib/pleroma/filter.ex b/lib/pleroma/filter.ex index 9ddc5fd6c..df5374a5c 100644 --- a/lib/pleroma/filter.ex +++ b/lib/pleroma/filter.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Filter do diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 49a9913dc..d80ae6576 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Formatter do diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex index fee7156d3..336142e9b 100644 --- a/lib/pleroma/gopher/server.ex +++ b/lib/pleroma/gopher/server.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Gopher.Server do diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index eb31f131e..71db516e6 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTML do diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex index 35c1490da..1c3187768 100644 --- a/lib/pleroma/http/connection.ex +++ b/lib/pleroma/http/connection.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.Connection do diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 32d9cf5aa..f12f33566 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP do diff --git a/lib/pleroma/http/request_builder.ex b/lib/pleroma/http/request_builder.ex index 54569c6f7..bffc7c6fe 100644 --- a/lib/pleroma/http/request_builder.ex +++ b/lib/pleroma/http/request_builder.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.RequestBuilder do diff --git a/lib/pleroma/list.ex b/lib/pleroma/list.ex index 2c799bc33..a75dc006e 100644 --- a/lib/pleroma/list.ex +++ b/lib/pleroma/list.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.List do diff --git a/lib/pleroma/mime.ex b/lib/pleroma/mime.ex index e3a389749..84fb536e0 100644 --- a/lib/pleroma/mime.ex +++ b/lib/pleroma/mime.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.MIME do diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index b5aadfd17..51d59870c 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Notification do diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index e2b648727..ff5eb9b27 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Object do diff --git a/lib/pleroma/plugs/admin_secret_authentication_plug.ex b/lib/pleroma/plugs/admin_secret_authentication_plug.ex index 2c9348715..5baf8a691 100644 --- a/lib/pleroma/plugs/admin_secret_authentication_plug.ex +++ b/lib/pleroma/plugs/admin_secret_authentication_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.AdminSecretAuthenticationPlug do diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex index 6b8d51300..da4ed4226 100644 --- a/lib/pleroma/plugs/authentication_plug.ex +++ b/lib/pleroma/plugs/authentication_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.AuthenticationPlug do diff --git a/lib/pleroma/plugs/basic_auth_decoder_plug.ex b/lib/pleroma/plugs/basic_auth_decoder_plug.ex index 0690f4bea..7eeeb1e5d 100644 --- a/lib/pleroma/plugs/basic_auth_decoder_plug.ex +++ b/lib/pleroma/plugs/basic_auth_decoder_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.BasicAuthDecoderPlug do diff --git a/lib/pleroma/plugs/digest.ex b/lib/pleroma/plugs/digest.ex index 27b206965..0ba00845a 100644 --- a/lib/pleroma/plugs/digest.ex +++ b/lib/pleroma/plugs/digest.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Plugs.DigestPlug do diff --git a/lib/pleroma/plugs/ensure_authenticated_plug.ex b/lib/pleroma/plugs/ensure_authenticated_plug.ex index f18653f41..11c4342c4 100644 --- a/lib/pleroma/plugs/ensure_authenticated_plug.ex +++ b/lib/pleroma/plugs/ensure_authenticated_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.EnsureAuthenticatedPlug do diff --git a/lib/pleroma/plugs/ensure_user_key_plug.ex b/lib/pleroma/plugs/ensure_user_key_plug.ex index db3da228d..c88ebfb3f 100644 --- a/lib/pleroma/plugs/ensure_user_key_plug.ex +++ b/lib/pleroma/plugs/ensure_user_key_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.EnsureUserKeyPlug do diff --git a/lib/pleroma/plugs/federating_plug.ex b/lib/pleroma/plugs/federating_plug.ex index e7dfda295..effc154bf 100644 --- a/lib/pleroma/plugs/federating_plug.ex +++ b/lib/pleroma/plugs/federating_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.FederatingPlug do diff --git a/lib/pleroma/plugs/http_security_plug.ex b/lib/pleroma/plugs/http_security_plug.ex index 11bceafd4..2a266c407 100644 --- a/lib/pleroma/plugs/http_security_plug.ex +++ b/lib/pleroma/plugs/http_security_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.HTTPSecurityPlug do diff --git a/lib/pleroma/plugs/http_signature.ex b/lib/pleroma/plugs/http_signature.ex index 33fbba840..51bec910e 100644 --- a/lib/pleroma/plugs/http_signature.ex +++ b/lib/pleroma/plugs/http_signature.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do diff --git a/lib/pleroma/plugs/instance_static.ex b/lib/pleroma/plugs/instance_static.ex index 02ee99e0f..af2f6f331 100644 --- a/lib/pleroma/plugs/instance_static.ex +++ b/lib/pleroma/plugs/instance_static.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.InstanceStatic do diff --git a/lib/pleroma/plugs/legacy_authentication_plug.ex b/lib/pleroma/plugs/legacy_authentication_plug.ex index 3cb3fdf4b..78b7e388f 100644 --- a/lib/pleroma/plugs/legacy_authentication_plug.ex +++ b/lib/pleroma/plugs/legacy_authentication_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.LegacyAuthenticationPlug do diff --git a/lib/pleroma/plugs/oauth_plug.ex b/lib/pleroma/plugs/oauth_plug.ex index 7c3541197..437aa95b3 100644 --- a/lib/pleroma/plugs/oauth_plug.ex +++ b/lib/pleroma/plugs/oauth_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.OAuthPlug do diff --git a/lib/pleroma/plugs/session_authentication_plug.ex b/lib/pleroma/plugs/session_authentication_plug.ex index 413bdcf2c..a08484b65 100644 --- a/lib/pleroma/plugs/session_authentication_plug.ex +++ b/lib/pleroma/plugs/session_authentication_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.SessionAuthenticationPlug do diff --git a/lib/pleroma/plugs/set_user_session_id_plug.ex b/lib/pleroma/plugs/set_user_session_id_plug.ex index 9fad6dfee..9265cc116 100644 --- a/lib/pleroma/plugs/set_user_session_id_plug.ex +++ b/lib/pleroma/plugs/set_user_session_id_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.SetUserSessionIdPlug do diff --git a/lib/pleroma/plugs/uploaded_media.ex b/lib/pleroma/plugs/uploaded_media.ex index f998293e8..be53ac00c 100644 --- a/lib/pleroma/plugs/uploaded_media.ex +++ b/lib/pleroma/plugs/uploaded_media.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.UploadedMedia do diff --git a/lib/pleroma/plugs/user_enabled_plug.ex b/lib/pleroma/plugs/user_enabled_plug.ex index 79d6a9b99..da892c28b 100644 --- a/lib/pleroma/plugs/user_enabled_plug.ex +++ b/lib/pleroma/plugs/user_enabled_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.UserEnabledPlug do diff --git a/lib/pleroma/plugs/user_fetcher_plug.ex b/lib/pleroma/plugs/user_fetcher_plug.ex index 04957148b..f874e2f95 100644 --- a/lib/pleroma/plugs/user_fetcher_plug.ex +++ b/lib/pleroma/plugs/user_fetcher_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.UserFetcherPlug do diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex index a98c2c853..04329e919 100644 --- a/lib/pleroma/plugs/user_is_admin_plug.ex +++ b/lib/pleroma/plugs/user_is_admin_plug.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.UserIsAdminPlug do diff --git a/lib/pleroma/repo.ex b/lib/pleroma/repo.ex index 0b49f7712..e6a51b19e 100644 --- a/lib/pleroma/repo.ex +++ b/lib/pleroma/repo.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Repo do diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex index c9d6f0d2c..a3846c3bb 100644 --- a/lib/pleroma/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.ReverseProxy do diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index c48184ed3..8a030ecd0 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Stats do diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 744abec56..0b1bdeec4 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload do diff --git a/lib/pleroma/upload/filter.ex b/lib/pleroma/upload/filter.ex index f7257be65..fa02a55de 100644 --- a/lib/pleroma/upload/filter.ex +++ b/lib/pleroma/upload/filter.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter do diff --git a/lib/pleroma/upload/filter/anonymize_filename.ex b/lib/pleroma/upload/filter/anonymize_filename.ex index c26e4f32c..5ca53a79b 100644 --- a/lib/pleroma/upload/filter/anonymize_filename.ex +++ b/lib/pleroma/upload/filter/anonymize_filename.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter.AnonymizeFilename do diff --git a/lib/pleroma/upload/filter/dedupe.ex b/lib/pleroma/upload/filter/dedupe.ex index 2d1ddab7f..8fcce320f 100644 --- a/lib/pleroma/upload/filter/dedupe.ex +++ b/lib/pleroma/upload/filter/dedupe.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter.Dedupe do diff --git a/lib/pleroma/upload/filter/mogrifun.ex b/lib/pleroma/upload/filter/mogrifun.ex index f8920d31b..35a5a1381 100644 --- a/lib/pleroma/upload/filter/mogrifun.ex +++ b/lib/pleroma/upload/filter/mogrifun.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter.Mogrifun do diff --git a/lib/pleroma/upload/filter/mogrify.ex b/lib/pleroma/upload/filter/mogrify.ex index 7331c2bd9..f459eeecb 100644 --- a/lib/pleroma/upload/filter/mogrify.ex +++ b/lib/pleroma/upload/filter/mogrify.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter.Mogrify do diff --git a/lib/pleroma/uploaders/local.ex b/lib/pleroma/uploaders/local.ex index de50a13c1..fc533da23 100644 --- a/lib/pleroma/uploaders/local.ex +++ b/lib/pleroma/uploaders/local.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Local do diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex index b16782fbb..530b34362 100644 --- a/lib/pleroma/uploaders/mdii.ex +++ b/lib/pleroma/uploaders/mdii.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.MDII do diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index db5e8b75e..108cf06b5 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.S3 do diff --git a/lib/pleroma/uploaders/swift/keystone.ex b/lib/pleroma/uploaders/swift/keystone.ex index f10361b19..b4f250f9d 100644 --- a/lib/pleroma/uploaders/swift/keystone.ex +++ b/lib/pleroma/uploaders/swift/keystone.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Swift.Keystone do diff --git a/lib/pleroma/uploaders/swift/swift.ex b/lib/pleroma/uploaders/swift/swift.ex index fef426b42..2b0f2ad04 100644 --- a/lib/pleroma/uploaders/swift/swift.ex +++ b/lib/pleroma/uploaders/swift/swift.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Swift.Client do diff --git a/lib/pleroma/uploaders/swift/uploader.ex b/lib/pleroma/uploaders/swift/uploader.ex index d359ff8f8..d122b09e7 100644 --- a/lib/pleroma/uploaders/swift/uploader.ex +++ b/lib/pleroma/uploaders/swift/uploader.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Swift do diff --git a/lib/pleroma/uploaders/uploader.ex b/lib/pleroma/uploaders/uploader.ex index 49da6e9a9..0959d7a3e 100644 --- a/lib/pleroma/uploaders/uploader.ex +++ b/lib/pleroma/uploaders/uploader.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Uploaders.Uploader do diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b90a3efae..892f4e483 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.User do diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 71848d91e..2f419a5a2 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.User.Info do diff --git a/lib/pleroma/user_invite_token.ex b/lib/pleroma/user_invite_token.ex index 65ffe149c..5a448114c 100644 --- a/lib/pleroma/user_invite_token.ex +++ b/lib/pleroma/user_invite_token.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.UserInviteToken do diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 167471b7b..b9b95a0e9 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.ActivityPub do diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index e41b14afc..fc7972eaf 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.ActivityPubController do diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex index 00919a5f6..eebea207c 100644 --- a/lib/pleroma/web/activity_pub/mrf.ex +++ b/lib/pleroma/web/activity_pub/mrf.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF do diff --git a/lib/pleroma/web/activity_pub/mrf/drop_policy.ex b/lib/pleroma/web/activity_pub/mrf/drop_policy.ex index 6ac7b0ec1..a93ccf386 100644 --- a/lib/pleroma/web/activity_pub/mrf/drop_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/drop_policy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do diff --git a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex index ca3ee8a0d..895376c9d 100644 --- a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex +++ b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index e4fb0b5b0..a3f516ae7 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do diff --git a/lib/pleroma/web/activity_pub/mrf/noop_policy.ex b/lib/pleroma/web/activity_pub/mrf/noop_policy.ex index 8eacc62bc..40f37bdb1 100644 --- a/lib/pleroma/web/activity_pub/mrf/noop_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/noop_policy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do diff --git a/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex b/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex index 6cfd43974..3d13cdb32 100644 --- a/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex +++ b/lib/pleroma/web/activity_pub/mrf/normalize_markup.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do diff --git a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex index 07d739437..4197be847 100644 --- a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex +++ b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex index 9ced1e620..798ba9687 100644 --- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do diff --git a/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex b/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex index 7a78c50bf..a3b1f8aa0 100644 --- a/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex +++ b/lib/pleroma/web/activity_pub/mrf/user_allowlist.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index d0a866589..abddbc790 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.Relay do diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 315571e1a..87b7fc07f 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.Transmogrifier do diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 59cf6abfc..b313996db 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.Utils do diff --git a/lib/pleroma/web/activity_pub/views/object_view.ex b/lib/pleroma/web/activity_pub/views/object_view.ex index efe16b2bf..b5c9bf8d0 100644 --- a/lib/pleroma/web/activity_pub/views/object_view.ex +++ b/lib/pleroma/web/activity_pub/views/object_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.ObjectView do diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index 439d834e4..fe8248107 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.UserView do diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 49d237661..f6d90b552 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.AdminAPI.AdminAPIController do diff --git a/lib/pleroma/web/channels/user_socket.ex b/lib/pleroma/web/channels/user_socket.ex index 23ba5a381..aed8475fd 100644 --- a/lib/pleroma/web/channels/user_socket.ex +++ b/lib/pleroma/web/channels/user_socket.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.UserSocket do diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/chat_channel.ex index ac28f300b..fe63ede66 100644 --- a/lib/pleroma/web/chat_channel.ex +++ b/lib/pleroma/web/chat_channel.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ChatChannel do diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 085a95172..e474653ff 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI do diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b91cfc4bb..3ff9f9452 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI.Utils do diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex index cb0463eeb..14e3d19fd 100644 --- a/lib/pleroma/web/controller_helper.ex +++ b/lib/pleroma/web/controller_helper.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ControllerHelper do diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index e994f8f37..0b4ce9cc4 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Endpoint do diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index 3aec55274..d25bfc0c1 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Federator do diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index e4340af7c..c57bbb77c 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Federator.RetryQueue do diff --git a/lib/pleroma/web/gettext.ex b/lib/pleroma/web/gettext.ex index f40fd04c0..1328b46cc 100644 --- a/lib/pleroma/web/gettext.ex +++ b/lib/pleroma/web/gettext.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Gettext do diff --git a/lib/pleroma/web/http_signatures/http_signatures.ex b/lib/pleroma/web/http_signatures/http_signatures.ex index 0e4f8f14b..e81f9e27a 100644 --- a/lib/pleroma/web/http_signatures/http_signatures.ex +++ b/lib/pleroma/web/http_signatures/http_signatures.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only # https://tools.ietf.org/html/draft-cavage-http-signatures-08 diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 663a0fa08..11fcd1c11 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 555383503..bfd6b8b22 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.AccountView do diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex index ffbd830e1..1052a449d 100644 --- a/lib/pleroma/web/mastodon_api/views/filter_view.ex +++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.FilterView do diff --git a/lib/pleroma/web/mastodon_api/views/list_view.ex b/lib/pleroma/web/mastodon_api/views/list_view.ex index dd0121f7a..0f86e2512 100644 --- a/lib/pleroma/web/mastodon_api/views/list_view.ex +++ b/lib/pleroma/web/mastodon_api/views/list_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.ListView do diff --git a/lib/pleroma/web/mastodon_api/views/mastodon_view.ex b/lib/pleroma/web/mastodon_api/views/mastodon_view.ex index a3adabc50..33b9a74be 100644 --- a/lib/pleroma/web/mastodon_api/views/mastodon_view.ex +++ b/lib/pleroma/web/mastodon_api/views/mastodon_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.MastodonView do diff --git a/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex b/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex index 7970bcd47..e86b789c5 100644 --- a/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex +++ b/lib/pleroma/web/mastodon_api/views/push_subscription_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.PushSubscriptionView do diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index da61bbd86..477ab3b5f 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.StatusView do diff --git a/lib/pleroma/web/mastodon_api/websocket_handler.ex b/lib/pleroma/web/mastodon_api/websocket_handler.ex index 7b90649ad..c0254c8e6 100644 --- a/lib/pleroma/web/mastodon_api/websocket_handler.ex +++ b/lib/pleroma/web/mastodon_api/websocket_handler.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do diff --git a/lib/pleroma/web/media_proxy/controller.ex b/lib/pleroma/web/media_proxy/controller.ex index 8c82b4176..de79cad73 100644 --- a/lib/pleroma/web/media_proxy/controller.ex +++ b/lib/pleroma/web/media_proxy/controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MediaProxy.MediaProxyController do diff --git a/lib/pleroma/web/media_proxy/media_proxy.ex b/lib/pleroma/web/media_proxy/media_proxy.ex index a61726b3e..e1eb1472d 100644 --- a/lib/pleroma/web/media_proxy/media_proxy.ex +++ b/lib/pleroma/web/media_proxy/media_proxy.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MediaProxy do diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index a992f75f6..11b97164d 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Nodeinfo.NodeinfoController do diff --git a/lib/pleroma/web/oauth/app.ex b/lib/pleroma/web/oauth/app.ex index c18e9da8c..967ac04b5 100644 --- a/lib/pleroma/web/oauth/app.ex +++ b/lib/pleroma/web/oauth/app.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.App do diff --git a/lib/pleroma/web/oauth/authorization.ex b/lib/pleroma/web/oauth/authorization.ex index 7e75d71b3..cc4b74bc5 100644 --- a/lib/pleroma/web/oauth/authorization.ex +++ b/lib/pleroma/web/oauth/authorization.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.Authorization do diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex index e1d91dc80..1eeda3d24 100644 --- a/lib/pleroma/web/oauth/fallback_controller.ex +++ b/lib/pleroma/web/oauth/fallback_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.FallbackController do diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 41b0f253d..4d4e85836 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.OAuthController do diff --git a/lib/pleroma/web/oauth/oauth_view.ex b/lib/pleroma/web/oauth/oauth_view.ex index da6f72433..9b37a91c5 100644 --- a/lib/pleroma/web/oauth/oauth_view.ex +++ b/lib/pleroma/web/oauth/oauth_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.OAuthView do diff --git a/lib/pleroma/web/oauth/token.ex b/lib/pleroma/web/oauth/token.ex index aa3610bb3..f0ebc63f6 100644 --- a/lib/pleroma/web/oauth/token.ex +++ b/lib/pleroma/web/oauth/token.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OAuth.Token do diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index bd05c671b..94b1a7ad1 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.ActivityRepresenter do diff --git a/lib/pleroma/web/ostatus/feed_representer.ex b/lib/pleroma/web/ostatus/feed_representer.ex index 2c2157173..934d4042f 100644 --- a/lib/pleroma/web/ostatus/feed_representer.ex +++ b/lib/pleroma/web/ostatus/feed_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.FeedRepresenter do diff --git a/lib/pleroma/web/ostatus/handlers/delete_handler.ex b/lib/pleroma/web/ostatus/handlers/delete_handler.ex index e7cf4cb54..01b52f08f 100644 --- a/lib/pleroma/web/ostatus/handlers/delete_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/delete_handler.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.DeleteHandler do diff --git a/lib/pleroma/web/ostatus/handlers/follow_handler.ex b/lib/pleroma/web/ostatus/handlers/follow_handler.ex index aef450935..becdf2fbf 100644 --- a/lib/pleroma/web/ostatus/handlers/follow_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/follow_handler.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.FollowHandler do diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex index 7fd364b45..5aeed46f0 100644 --- a/lib/pleroma/web/ostatus/handlers/note_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.NoteHandler do diff --git a/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex b/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex index bd86a54c7..1c64f3c3d 100644 --- a/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/unfollow_handler.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.UnfollowHandler do diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index cd5493e16..bb28cd786 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus do diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 9ad702dd4..9b600737f 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.OStatusController do diff --git a/lib/pleroma/web/ostatus/user_representer.ex b/lib/pleroma/web/ostatus/user_representer.ex index ef8371a2c..852be6eb4 100644 --- a/lib/pleroma/web/ostatus/user_representer.ex +++ b/lib/pleroma/web/ostatus/user_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.UserRepresenter do diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push/push.ex index 6459d4543..ffd2aac91 100644 --- a/lib/pleroma/web/push/push.ex +++ b/lib/pleroma/web/push/push.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Push do diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex index 65d28fee9..82b30950c 100644 --- a/lib/pleroma/web/push/subscription.ex +++ b/lib/pleroma/web/push/subscription.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Push.Subscription do diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 33c573d46..1f929ee21 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Router do diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index f7d2257eb..e41657da1 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Salmon do diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 05f877438..3136b1b9d 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Streamer do diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 87b8b71ba..a79072f3d 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.UtilController do diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 489a55b6c..2a221cc66 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only # THIS MODULE IS DEPRECATED! DON'T USE IT! diff --git a/lib/pleroma/web/twitter_api/representers/base_representer.ex b/lib/pleroma/web/twitter_api/representers/base_representer.ex index 28a59205d..3d31e6079 100644 --- a/lib/pleroma/web/twitter_api/representers/base_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/base_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.Representers.BaseRepresenter do diff --git a/lib/pleroma/web/twitter_api/representers/object_representer.ex b/lib/pleroma/web/twitter_api/representers/object_representer.ex index 2f33e7af4..47130ba06 100644 --- a/lib/pleroma/web/twitter_api/representers/object_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/object_representer.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter do diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index e2b1e0a8e..0aa4a8d23 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.TwitterAPI do diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index aebc3bff4..1e04b8c4b 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.Controller do diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 469f780c7..84f35ebf9 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.ActivityView do diff --git a/lib/pleroma/web/twitter_api/views/notification_view.ex b/lib/pleroma/web/twitter_api/views/notification_view.ex index d889038a2..d6a1c0a4d 100644 --- a/lib/pleroma/web/twitter_api/views/notification_view.ex +++ b/lib/pleroma/web/twitter_api/views/notification_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.NotificationView do diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index ede3c0d25..40db0b117 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.UserView do diff --git a/lib/pleroma/web/twitter_api/views/util_view.ex b/lib/pleroma/web/twitter_api/views/util_view.ex index aa5f842ac..f4050650e 100644 --- a/lib/pleroma/web/twitter_api/views/util_view.ex +++ b/lib/pleroma/web/twitter_api/views/util_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.TwitterAPI.UtilView do diff --git a/lib/pleroma/web/views/error_helpers.ex b/lib/pleroma/web/views/error_helpers.ex index df1e0d437..bc08e60e4 100644 --- a/lib/pleroma/web/views/error_helpers.ex +++ b/lib/pleroma/web/views/error_helpers.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ErrorHelpers do diff --git a/lib/pleroma/web/views/error_view.ex b/lib/pleroma/web/views/error_view.ex index d8158edb4..86a1744b7 100644 --- a/lib/pleroma/web/views/error_view.ex +++ b/lib/pleroma/web/views/error_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ErrorView do diff --git a/lib/pleroma/web/views/layout_view.ex b/lib/pleroma/web/views/layout_view.ex index ba94b9def..e5183701d 100644 --- a/lib/pleroma/web/views/layout_view.ex +++ b/lib/pleroma/web/views/layout_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.LayoutView do diff --git a/lib/pleroma/web/web.ex b/lib/pleroma/web/web.ex index 1aa86f645..74b13f929 100644 --- a/lib/pleroma/web/web.ex +++ b/lib/pleroma/web/web.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web do diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 3cc90d5dd..0a6338312 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.WebFinger do diff --git a/lib/pleroma/web/web_finger/web_finger_controller.ex b/lib/pleroma/web/web_finger/web_finger_controller.ex index 66d5a880d..b77c75ec5 100644 --- a/lib/pleroma/web/web_finger/web_finger_controller.ex +++ b/lib/pleroma/web/web_finger/web_finger_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.WebFinger.WebFingerController do diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex index 628ec38c5..3a287edd9 100644 --- a/lib/pleroma/web/websub/websub.ex +++ b/lib/pleroma/web/websub/websub.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Websub do diff --git a/lib/pleroma/web/websub/websub_client_subscription.ex b/lib/pleroma/web/websub/websub_client_subscription.ex index 2f511cd5b..105b0069f 100644 --- a/lib/pleroma/web/websub/websub_client_subscription.ex +++ b/lib/pleroma/web/websub/websub_client_subscription.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Websub.WebsubClientSubscription do diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex index c38a03808..27304d988 100644 --- a/lib/pleroma/web/websub/websub_controller.ex +++ b/lib/pleroma/web/websub/websub_controller.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Websub.WebsubController do diff --git a/lib/pleroma/web/websub/websub_server_subscription.ex b/lib/pleroma/web/websub/websub_server_subscription.ex index 81a2d7f07..d0ef548da 100644 --- a/lib/pleroma/web/websub/websub_server_subscription.ex +++ b/lib/pleroma/web/websub/websub_server_subscription.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.Websub.WebsubServerSubscription do diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex index fa6dcd424..df50aac9c 100644 --- a/lib/pleroma/web/xml/xml.ex +++ b/lib/pleroma/web/xml/xml.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2019 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.XML do -- cgit v1.2.3 From 1e6c102bfcfe0e4835a48f2483f2376f9bf86a20 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 31 Dec 2018 12:18:59 +0100 Subject: Web.AdminAPI.AdminAPIController: Remove a useless if in user_delete --- lib/pleroma/web/admin_api/admin_api_controller.ex | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 49d237661..2b66a1848 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -14,13 +14,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do action_fallback(:errors) def user_delete(conn, %{"nickname" => nickname}) do - user = User.get_by_nickname(nickname) - - if user.local == true do - User.delete(user) - else - User.delete(user) - end + User.get_by_nickname(nickname) + |> User.delete() conn |> json(nickname) -- cgit v1.2.3 From d4799e0dc23605563a29d14ad4657183174b55f9 Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 1 Jan 2019 13:49:24 +0100 Subject: Remove default pool, it's used automatically anyway. --- lib/pleroma/http/connection.ex | 1 - lib/pleroma/http/http.ex | 1 - lib/pleroma/web/activity_pub/activity_pub.ex | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex index 35c1490da..e2e92857f 100644 --- a/lib/pleroma/http/connection.ex +++ b/lib/pleroma/http/connection.ex @@ -8,7 +8,6 @@ defmodule Pleroma.HTTP.Connection do """ @hackney_options [ - pool: :default, timeout: 10000, recv_timeout: 20000, follow_redirect: true diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 32d9cf5aa..0a46c11b5 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -56,7 +56,6 @@ defmodule Pleroma.HTTP do def process_request_options(options) do config = Application.get_env(:pleroma, :http, []) proxy = Keyword.get(config, :proxy_url, nil) - options = options ++ [adapter: [pool: :default]] case proxy do nil -> options diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 167471b7b..c8c2905a7 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -741,8 +741,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {"Content-Type", "application/activity+json"}, {"signature", signature}, {"digest", digest} - ], - hackney: [pool: :default] + ] ) end -- cgit v1.2.3 From 400337b0a78150704de650d62a499464e895816c Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 1 Jan 2019 14:46:55 +0100 Subject: Make Federator options configurable. --- lib/pleroma/web/federator/federator.ex | 3 +-- lib/pleroma/web/federator/retry_queue.ex | 19 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index d25bfc0c1..f3a0e18b8 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -17,7 +17,6 @@ defmodule Pleroma.Web.Federator do @websub Application.get_env(:pleroma, :websub) @ostatus Application.get_env(:pleroma, :ostatus) - @max_jobs 20 def init(args) do {:ok, args} @@ -168,7 +167,7 @@ defmodule Pleroma.Web.Federator do end def maybe_start_job(running_jobs, queue) do - if :sets.size(running_jobs) < @max_jobs && queue != [] do + if :sets.size(running_jobs) < Pleroma.Config.get([__MODULE__, :max_jobs]) && queue != [] do {{type, payload}, queue} = queue_pop(queue) {:ok, pid} = Task.start(fn -> handle(type, payload) end) mref = Process.monitor(pid) diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index c57bbb77c..230a2c939 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -7,12 +7,6 @@ defmodule Pleroma.Web.Federator.RetryQueue do require Logger - # seconds - @initial_timeout 30 - @max_retries 5 - - @max_jobs 20 - def init(args) do queue_table = :ets.new(:pleroma_retry_queue, [:bag, :protected]) @@ -21,7 +15,7 @@ defmodule Pleroma.Web.Federator.RetryQueue do def start_link() do enabled = - if Mix.env() == :test, do: true, else: Pleroma.Config.get([:retry_queue, :enabled], false) + if Mix.env() == :test, do: true, else: Pleroma.Config.get([__MODULE__, :enabled], false) if enabled do Logger.info("Starting retry queue") @@ -54,7 +48,7 @@ defmodule Pleroma.Web.Federator.RetryQueue do end def get_retry_params(retries) do - if retries > @max_retries do + if retries > Pleroma.Config.get([__MODULE__, :max_retries]) do {:drop, "Max retries reached"} else {:retry, growth_function(retries)} @@ -108,12 +102,12 @@ defmodule Pleroma.Web.Federator.RetryQueue do current_time = DateTime.to_unix(DateTime.utc_now()) n_running_jobs = :sets.size(running_jobs) - if n_running_jobs < @max_jobs do + if n_running_jobs < Pleroma.Config.get([__MODULE__, :max_jobs]) do n_ready_jobs = ets_count_expires(queue_table, current_time) if n_ready_jobs > 0 do # figure out how many we could start - available_job_slots = @max_jobs - n_running_jobs + available_job_slots = Pleroma.Config.get([__MODULE__, :max_jobs]) - n_running_jobs start_n_jobs(running_jobs, queue_table, current_time, available_job_slots) else running_jobs @@ -228,12 +222,13 @@ defmodule Pleroma.Web.Federator.RetryQueue do if Mix.env() == :test do defp growth_function(_retries) do - _shutit = @initial_timeout + _shutit = Pleroma.Config.get([__MODULE__, :initial_timeout]) DateTime.to_unix(DateTime.utc_now()) - 1 end else defp growth_function(retries) do - round(@initial_timeout * :math.pow(retries, 3)) + DateTime.to_unix(DateTime.utc_now()) + round(Pleroma.Config.get([__MODULE__, :initial_timeout]) * :math.pow(retries, 3)) + + DateTime.to_unix(DateTime.utc_now()) end end -- cgit v1.2.3 From 2aab4e03c3a2867abd4555dc776eebc8b0dba176 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 1 Jan 2019 23:26:40 +0300 Subject: Add OGP parser --- lib/pleroma/web/rich_media/data.ex | 3 +++ lib/pleroma/web/rich_media/parser.ex | 14 ++++++++++++++ lib/pleroma/web/rich_media/parsers/ogp.ex | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 lib/pleroma/web/rich_media/data.ex create mode 100644 lib/pleroma/web/rich_media/parser.ex create mode 100644 lib/pleroma/web/rich_media/parsers/ogp.ex (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/data.ex b/lib/pleroma/web/rich_media/data.ex new file mode 100644 index 000000000..403d1d341 --- /dev/null +++ b/lib/pleroma/web/rich_media/data.ex @@ -0,0 +1,3 @@ +defmodule Pleroma.Web.RichMedia.Data do + defstruct [:title, :type, :image, :url, :description] +end diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex new file mode 100644 index 000000000..d9c1684d5 --- /dev/null +++ b/lib/pleroma/web/rich_media/parser.ex @@ -0,0 +1,14 @@ +defmodule Pleroma.Web.RichMedia.Parser do + @parsers [Pleroma.Web.RichMedia.Parsers.OGP] + + def parse(url) do + {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) + + Enum.reduce_while(@parsers, %Pleroma.Web.RichMedia.Data{}, fn parser, acc -> + case parser.parse(html, acc) do + {:ok, data} -> {:halt, data} + {:error, _msg} -> {:cont, acc} + end + end) + end +end diff --git a/lib/pleroma/web/rich_media/parsers/ogp.ex b/lib/pleroma/web/rich_media/parsers/ogp.ex new file mode 100644 index 000000000..75084c7ee --- /dev/null +++ b/lib/pleroma/web/rich_media/parsers/ogp.ex @@ -0,0 +1,30 @@ +defmodule Pleroma.Web.RichMedia.Parsers.OGP do + def parse(html, data) do + with elements = [_ | _] <- get_elements(html), + ogp_data = + Enum.reduce(elements, data, fn el, acc -> + attributes = normalize_attributes(el) + + Map.merge(acc, attributes) + end) do + {:ok, ogp_data} + else + _e -> {:error, "No OGP metadata found"} + end + end + + defp get_elements(html) do + html |> Floki.find("meta[property^='og:']") + end + + defp normalize_attributes(tuple) do + {_tag, attributes, _children} = tuple + + data = + Enum.into(attributes, %{}, fn {name, value} -> + {name, String.trim_leading(value, "og:")} + end) + + %{String.to_atom(data["property"]) => data["content"]} + end +end -- cgit v1.2.3 From 917d48d09bad573260bc816310ee2c75d4db84a8 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 1 Jan 2019 23:29:47 +0300 Subject: Better variable name --- lib/pleroma/web/rich_media/parsers/ogp.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/parsers/ogp.ex b/lib/pleroma/web/rich_media/parsers/ogp.ex index 75084c7ee..5773a5263 100644 --- a/lib/pleroma/web/rich_media/parsers/ogp.ex +++ b/lib/pleroma/web/rich_media/parsers/ogp.ex @@ -17,8 +17,8 @@ defmodule Pleroma.Web.RichMedia.Parsers.OGP do html |> Floki.find("meta[property^='og:']") end - defp normalize_attributes(tuple) do - {_tag, attributes, _children} = tuple + defp normalize_attributes(html_node) do + {_tag, attributes, _children} = html_node data = Enum.into(attributes, %{}, fn {name, value} -> -- cgit v1.2.3 From 551c3d9391c0eeb282d750979b8eef5025c41482 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Tue, 1 Jan 2019 22:16:46 +0100 Subject: Split create activity specifics from update_outbox --- .../web/activity_pub/activity_pub_controller.ex | 42 ++++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index fc7972eaf..d23c54933 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -165,9 +165,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end end + def handle_user_activity(user, %{"type" => "Create"} = params) do + object = + params["object"] + |> Map.merge(Map.take(params, ["to", "cc"])) + |> Map.put("attributedTo", user.ap_id()) + |> Transmogrifier.fix_object() + + ActivityPub.create(%{ + to: params["to"], + actor: user, + context: object["context"], + object: object, + additional: Map.take(params, ["cc"]) + }) + end + + def handle_user_activity(_, _) do + {:error, "Unhandled activity type"} + end + def update_outbox( %{assigns: %{user: user}} = conn, - %{"nickname" => nickname, "type" => "Create"} = params + %{"nickname" => nickname} = params ) do if nickname == user.nickname do actor = user.ap_id() @@ -178,24 +198,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do |> Map.put("actor", actor) |> Transmogrifier.fix_addressing() - object = - params["object"] - |> Map.merge(Map.take(params, ["to", "cc"])) - |> Map.put("attributedTo", actor) - |> Transmogrifier.fix_object() - - with {:ok, %Activity{} = activity} <- - ActivityPub.create(%{ - to: params["to"], - actor: user, - context: object["context"], - object: object, - additional: Map.take(params, ["cc"]) - }) do + with {:ok, %Activity{} = activity} <- handle_user_activity(user, params) do conn |> put_status(:created) |> put_resp_header("location", activity.data["id"]) |> json(activity.data) + else + {:error, message} -> + conn + |> put_status(:bad_request) + |> json(message) end else conn -- cgit v1.2.3 From 4e1cc2bab6ec76af1b6de986561a82887d18f366 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Tue, 1 Jan 2019 23:19:40 +0100 Subject: Implement delete activity --- lib/pleroma/web/activity_pub/activity_pub_controller.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index d23c54933..a3f736fee 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -181,6 +181,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do }) end + def handle_user_activity(user, %{"type" => "Delete"} = params) do + with %Object{} = object <- Object.normalize(params["object"]), + true <- user.info.is_moderator || user.ap_id == object.data["actor"], + {:ok, delete} <- ActivityPub.delete(object) do + {:ok, delete} + else + _ -> {:error, "Can't delete object"} + end + end + def handle_user_activity(_, _) do {:error, "Unhandled activity type"} end -- cgit v1.2.3 From 48e81d3d40d334bccb8438c61ab6b307ddb1392f Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Wed, 2 Jan 2019 17:02:50 +0300 Subject: Add RichMediaController and tests --- .../web/rich_media/controllers/rich_media_controller.ex | 17 +++++++++++++++++ lib/pleroma/web/rich_media/data.ex | 3 --- lib/pleroma/web/rich_media/parser.ex | 14 +++++++++++++- lib/pleroma/web/router.ex | 6 ++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 lib/pleroma/web/rich_media/controllers/rich_media_controller.ex delete mode 100644 lib/pleroma/web/rich_media/data.ex (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/controllers/rich_media_controller.ex b/lib/pleroma/web/rich_media/controllers/rich_media_controller.ex new file mode 100644 index 000000000..91019961d --- /dev/null +++ b/lib/pleroma/web/rich_media/controllers/rich_media_controller.ex @@ -0,0 +1,17 @@ +defmodule Pleroma.Web.RichMedia.RichMediaController do + use Pleroma.Web, :controller + + import Pleroma.Web.ControllerHelper, only: [json_response: 3] + + def parse(conn, %{"url" => url}) do + case Pleroma.Web.RichMedia.Parser.parse(url) do + {:ok, data} -> + conn + |> json_response(200, data) + + {:error, msg} -> + conn + |> json_response(404, msg) + end + end +end diff --git a/lib/pleroma/web/rich_media/data.ex b/lib/pleroma/web/rich_media/data.ex deleted file mode 100644 index 403d1d341..000000000 --- a/lib/pleroma/web/rich_media/data.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Pleroma.Web.RichMedia.Data do - defstruct [:title, :type, :image, :url, :description] -end diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index d9c1684d5..477a38196 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -4,11 +4,23 @@ defmodule Pleroma.Web.RichMedia.Parser do def parse(url) do {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) - Enum.reduce_while(@parsers, %Pleroma.Web.RichMedia.Data{}, fn parser, acc -> + html |> maybe_parse() |> get_parsed_data() + end + + defp maybe_parse(html) do + Enum.reduce_while(@parsers, %{}, fn parser, acc -> case parser.parse(html, acc) do {:ok, data} -> {:halt, data} {:error, _msg} -> {:cont, acc} end end) end + + defp get_parsed_data(data) when data == %{} do + {:error, "No metadata found"} + end + + defp get_parsed_data(data) do + {:ok, data} + end end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 1f929ee21..8df45bf4d 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -232,6 +232,12 @@ defmodule Pleroma.Web.Router do put("/settings", MastodonAPIController, :put_settings) end + scope "/api", Pleroma.Web.RichMedia do + pipe_through(:authenticated_api) + + get("/rich_media/parse", RichMediaController, :parse) + end + scope "/api/v1", Pleroma.Web.MastodonAPI do pipe_through(:api) get("/instance", MastodonAPIController, :masto_instance) -- cgit v1.2.3 From 943211b035ccedb4889c5d0a55f68acf8117c163 Mon Sep 17 00:00:00 2001 From: Michael Loftis Date: Tue, 1 Jan 2019 15:40:57 +0000 Subject: rewrites List.foldl to Enum.each --- lib/pleroma/web/federator/retry_queue.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index 230a2c939..e0ce251d2 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -87,9 +87,8 @@ defmodule Pleroma.Web.Federator.RetryQueue do ) popped - |> List.foldl(true, fn e, acc -> + |> Enum.each(fn e -> :ets.delete_object(table, e) - acc end) popped -- cgit v1.2.3 From eb1a18d22f0284cfee571e6a83d4ddf69042dba0 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 2 Jan 2019 22:47:12 +0000 Subject: user: check that the follow request actually has an active account associated with it because of user refetch, accounts can stop existing (get_from_ap_id() can fail), accordingly filter the follow requests for these failures. --- lib/pleroma/user.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 892f4e483..1edded415 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -495,6 +495,7 @@ defmodule Pleroma.User do Enum.map(reqs, fn req -> req.actor end) |> Enum.uniq() |> Enum.map(fn ap_id -> get_by_ap_id(ap_id) end) + |> Enum.filter(fn u -> !is_nil(u) end) |> Enum.filter(fn u -> !following?(u, user) end) {:ok, users} -- cgit v1.2.3 From 5b23dfa1c5e6a3ec30fc6dc32761f27968eabf2f Mon Sep 17 00:00:00 2001 From: cascode Date: Fri, 4 Jan 2019 01:35:26 -0800 Subject: handle null --- lib/pleroma/user.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 1edded415..0e5e2d943 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -610,7 +610,7 @@ defmodule Pleroma.User do select_merge: %{ search_distance: fragment( - "? <-> (? || ?)", + "? <-> (? || coalesce(?, ''))", ^query, u.nickname, u.name -- cgit v1.2.3 From 4aa977d3b3ad731465f83f2d382fe9d856995e90 Mon Sep 17 00:00:00 2001 From: spctrl Date: Fri, 4 Jan 2019 22:11:46 +0100 Subject: fix 486: Add option --assume-yes to allow it to work non-interactive --- lib/mix/tasks/pleroma/user.ex | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 217a52fdd..c311d48e0 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -22,6 +22,7 @@ defmodule Mix.Tasks.Pleroma.User do - `--password PASSWORD` - the user's password - `--moderator`/`--no-moderator` - whether the user is a moderator - `--admin`/`--no-admin` - whether the user is an admin + - `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions ## Generate an invite link. @@ -61,7 +62,11 @@ defmodule Mix.Tasks.Pleroma.User do bio: :string, password: :string, moderator: :boolean, - admin: :boolean + admin: :boolean, + assume_yes: :boolean + ], + aliases: [ + y: :assume_yes ] ) @@ -79,6 +84,7 @@ defmodule Mix.Tasks.Pleroma.User do moderator? = Keyword.get(options, :moderator, false) admin? = Keyword.get(options, :admin, false) + assume_yes? = Keyword.get(options, :assume_yes, false) Mix.shell().info(""" A user will be created with the following information: @@ -93,7 +99,7 @@ defmodule Mix.Tasks.Pleroma.User do - admin: #{if(admin?, do: "true", else: "false")} """) - proceed? = Mix.shell().yes?("Continue?") + proceed? = assume_yes? or Mix.shell().yes?("Continue?") unless not proceed? do Common.start_pleroma() -- cgit v1.2.3 From 846082e54fcb9dceda476282c54d8cd36986203c Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sat, 5 Jan 2019 00:19:46 +0100 Subject: Different caches based on the module. Remove scrubber version since it is not relevant anymore --- lib/pleroma/html.ex | 30 ++++------------------ lib/pleroma/web/mastodon_api/views/status_view.ex | 6 ++++- lib/pleroma/web/twitter_api/views/activity_view.ex | 8 ++++-- 3 files changed, 16 insertions(+), 28 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 71db516e6..41d41e535 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -28,13 +28,13 @@ defmodule Pleroma.HTML do def filter_tags(html), do: filter_tags(html, nil) def strip_tags(html), do: Scrubber.scrub(html, Scrubber.StripTags) - def get_cached_scrubbed_html_for_object(content, scrubbers, object) do - key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" + def get_cached_scrubbed_html_for_object(content, scrubbers, object, module) do + key = "#{module}#{generate_scrubber_signature(scrubbers)}|#{object.id}" Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end) end - def get_cached_stripped_html_for_object(content, object) do - get_cached_scrubbed_html_for_object(content, HtmlSanitizeEx.Scrubber.StripTags, object) + def get_cached_stripped_html_for_object(content, object, module) do + get_cached_scrubbed_html_for_object(content, HtmlSanitizeEx.Scrubber.StripTags, object, module) end def ensure_scrubbed_html( @@ -50,15 +50,7 @@ defmodule Pleroma.HTML do defp generate_scrubber_signature(scrubbers) do Enum.reduce(scrubbers, "", fn scrubber, signature -> - # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber.StripTags) it is assumed it is always 0) - version = - if Kernel.function_exported?(scrubber, :version, 0) do - scrubber.version - else - 0 - end - - "#{signature}#{to_string(scrubber)}#{version}" + "#{signature}#{to_string(scrubber)}" end) end end @@ -76,10 +68,6 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - def version do - 0 - end - Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() @@ -118,10 +106,6 @@ defmodule Pleroma.HTML.Scrubber.Default do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - def version do - 0 - end - @markup Application.get_env(:pleroma, :markup) @uri_schemes Application.get_env(:pleroma, :uri_schemes, []) @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, []) @@ -199,10 +183,6 @@ defmodule Pleroma.HTML.Transform.MediaProxy do alias Pleroma.Web.MediaProxy - def version do - 0 - end - def before_scrub(html), do: html def scrub_attribute("img", {"src", "http" <> target}) do diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 477ab3b5f..8e8fa8121 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -120,7 +120,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do content = object |> render_content() - |> HTML.get_cached_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) + |> HTML.get_cached_scrubbed_html_for_object( + User.html_filter_policy(opts[:for]), + activity, + __MODULE__ + ) %{ id: to_string(activity.id), diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 84f35ebf9..a0be5cfc5 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -245,14 +245,18 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do html = content - |> HTML.get_cached_scrubbed_html_for_object(User.html_filter_policy(opts[:for]), activity) + |> HTML.get_cached_scrubbed_html_for_object( + User.html_filter_policy(opts[:for]), + activity, + __MODULE__ + ) |> Formatter.emojify(object["emoji"]) text = if content do content |> String.replace(~r//, "\n") - |> HTML.get_cached_stripped_html_for_object(activity) + |> HTML.get_cached_stripped_html_for_object(activity, __MODULE__) end reply_parent = Activity.get_in_reply_to_activity(activity) -- cgit v1.2.3 From 1e2d58982ee6a74a249fc92fa2711f678a9f7464 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sat, 5 Jan 2019 00:25:31 +0100 Subject: oopsies --- lib/pleroma/html.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 41d41e535..0c5b0f03f 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -34,7 +34,12 @@ defmodule Pleroma.HTML do end def get_cached_stripped_html_for_object(content, object, module) do - get_cached_scrubbed_html_for_object(content, HtmlSanitizeEx.Scrubber.StripTags, object, module) + get_cached_scrubbed_html_for_object( + content, + HtmlSanitizeEx.Scrubber.StripTags, + object, + module + ) end def ensure_scrubbed_html( -- cgit v1.2.3 From 0964c207eb184696355a2d8efd9d671dcc23ce66 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 4 Jan 2019 23:23:47 +0000 Subject: rich media: use cachex to avoid flooding remote servers --- lib/pleroma/application.ex | 11 +++++++++++ lib/pleroma/web/rich_media/parser.ex | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index cb3e6b69b..ad2797209 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -63,6 +63,17 @@ defmodule Pleroma.Application do ], id: :cachex_object ), + worker( + Cachex, + [ + :rich_media_cache, + [ + default_ttl: :timer.minutes(120), + limit: 5000 + ] + ], + id: :cachex_rich_media + ), worker( Cachex, [ diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index 477a38196..b88ed5371 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -2,9 +2,13 @@ defmodule Pleroma.Web.RichMedia.Parser do @parsers [Pleroma.Web.RichMedia.Parsers.OGP] def parse(url) do - {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) + Cachex.fetch!(:rich_media_cache, url, fn _ -> + {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) - html |> maybe_parse() |> get_parsed_data() + result = html |> maybe_parse() |> get_parsed_data() + + {:commit, result} + end) end defp maybe_parse(html) do -- cgit v1.2.3 From 487c00d36dee1b975ffc8fca8f0a5bb5510f71a3 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 4 Jan 2019 23:50:54 +0000 Subject: rich media: disable cachex in test mode --- lib/pleroma/web/rich_media/parser.ex | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index b88ed5371..3746feaf6 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -1,14 +1,17 @@ defmodule Pleroma.Web.RichMedia.Parser do @parsers [Pleroma.Web.RichMedia.Parsers.OGP] - def parse(url) do - Cachex.fetch!(:rich_media_cache, url, fn _ -> - {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) + if Mix.env() == :test do + def parse(url), do: parse_url(url) + else + def parse(url), + do: {:commit, Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end)} + end - result = html |> maybe_parse() |> get_parsed_data() + defp parse_url(url) do + {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) - {:commit, result} - end) + html |> maybe_parse() |> get_parsed_data() end defp maybe_parse(html) do -- cgit v1.2.3 From 2d7da5f4375164aa78e221ab054529a04d09e819 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Sat, 5 Jan 2019 10:38:38 +0100 Subject: Don't crash on AP request for tombstone Because tombstone objects has no addressing the is_public?-predicate would cause an error that propagated as a 500 error in the api --- lib/pleroma/web/activity_pub/activity_pub.ex | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 4d754de13..4685f6d95 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -801,6 +801,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end + def is_public?(%Object{data: %{"type" => "Tombstone"}}) do + false + end + def is_public?(activity) do "https://www.w3.org/ns/activitystreams#Public" in (activity.data["to"] ++ (activity.data["cc"] || [])) -- cgit v1.2.3 From 0787f0dfbe8daad53617217617fbc8784e45898f Mon Sep 17 00:00:00 2001 From: scarlett Date: Sat, 5 Jan 2019 17:28:47 +0000 Subject: Strip HTML in and allow emoji in summaries. --- lib/pleroma/web/common_api/common_api.ex | 2 +- lib/pleroma/web/twitter_api/views/activity_view.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index e474653ff..a20b854df 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Web.CommonAPI do Map.put( object, "emoji", - Formatter.get_emoji(status) + Formatter.get_emoji(status) ++ Formatter.get_emoji(data["spoiler_text"]) |> Enum.reduce(%{}, fn {name, file}, acc -> Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}") end) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 84f35ebf9..9ba347d12 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -285,7 +285,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), - "summary" => summary + "summary" => HTML.strip_tags(summary) |> Formatter.emojify(object["emoji"]) } end -- cgit v1.2.3 From 3c86d907d4d298b8a54d5292ff85107a1ada3bd5 Mon Sep 17 00:00:00 2001 From: scarlett Date: Sat, 5 Jan 2019 17:35:39 +0000 Subject: add some brakets to the emoji list. --- lib/pleroma/web/common_api/common_api.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index a20b854df..bb3c38f00 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Web.CommonAPI do Map.put( object, "emoji", - Formatter.get_emoji(status) ++ Formatter.get_emoji(data["spoiler_text"]) + (Formatter.get_emoji(status) ++ Formatter.get_emoji(data["spoiler_text"])) |> Enum.reduce(%{}, fn {name, file}, acc -> Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}") end) -- cgit v1.2.3 From 6556be344de981272b9c14faf5fb9837c1ea0da6 Mon Sep 17 00:00:00 2001 From: scarlett Date: Sat, 5 Jan 2019 18:20:42 +0000 Subject: Resolve some test failures. --- lib/pleroma/web/twitter_api/representers/activity_representer.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 2a221cc66..245cd52fd 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -207,7 +207,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), - "summary" => object["summary"] + "summary" => HTML.strip_tags(object["summary"]) |> Formatter.emojify(object["emoji"]) } end -- cgit v1.2.3 From 042852ecf344b4ede15a22ea0279fff8a67b75f0 Mon Sep 17 00:00:00 2001 From: Sadposter Date: Sat, 5 Jan 2019 22:54:25 +0000 Subject: Add check to prevent multiple follow notifications from the same user --- lib/pleroma/notification.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 51d59870c..c7d01f63b 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -109,7 +109,12 @@ defmodule Pleroma.Notification do # TODO move to sql, too. def create_notification(%Activity{} = activity, %User{} = user) do unless User.blocks?(user, %{ap_id: activity.data["actor"]}) or - user.ap_id == activity.data["actor"] do + user.ap_id == activity.data["actor"] or + (activity.data["type"] == "Follow" and + Enum.any?(Notification.for_user(user), fn notif -> + notif.activity.data["type"] == "Follow" and + notif.activity.data["actor"] == activity.data["actor"] + end)) do notification = %Notification{user_id: user.id, activity: activity} {:ok, notification} = Repo.insert(notification) Pleroma.Web.Streamer.stream("user", notification) -- cgit v1.2.3 From 52493467ac314ec58ed6123d3581428a82ec170c Mon Sep 17 00:00:00 2001 From: scarlett Date: Sun, 6 Jan 2019 10:16:40 +0000 Subject: Twitter API: Add a summary_html field. The intention here is to allow proper subject copying when it contains emoji, obviously this will require minor frontend changes, though. --- lib/pleroma/web/twitter_api/representers/activity_representer.ex | 5 ++++- lib/pleroma/web/twitter_api/views/activity_view.ex | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 245cd52fd..47154829d 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -181,6 +181,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor) + summary = HTML.strip_tags(object["summary"]) + %{ "id" => activity.id, "uri" => activity.data["object"]["id"], @@ -207,7 +209,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), - "summary" => HTML.strip_tags(object["summary"]) |> Formatter.emojify(object["emoji"]) + "summary" => summary, + "summary_html" => summary |> Formatter.emojify(object["emoji"]) } end diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index ad0cc76ed..61c617e87 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -263,6 +263,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor) + summary = HTML.strip_tags(summary) + %{ "id" => activity.id, "uri" => activity.data["object"]["id"], @@ -289,7 +291,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), - "summary" => HTML.strip_tags(summary) |> Formatter.emojify(object["emoji"]) + "summary" => summary, + "summary_html" => summary |> Formatter.emojify(object["emoji"]) } end -- cgit v1.2.3 From 36fa5e8802b45bdaee048dd63065d8e73142e52b Mon Sep 17 00:00:00 2001 From: scarlett Date: Mon, 7 Jan 2019 10:30:30 +0000 Subject: Check visible_for_user when performing a search using a direct link. --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 95d0f849c..f739e8f7d 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -725,11 +725,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do json(conn, %{}) end - def status_search(query) do + def status_search(user, query) do fetched = if Regex.match?(~r/https?:/, query) do - with {:ok, object} <- ActivityPub.fetch_object_from_id(query) do - [Activity.get_create_activity_by_object_ap_id(object.data["id"])] + with {:ok, object} <- ActivityPub.fetch_object_from_id(query), + %Activity{} = activity <- + Activity.get_create_activity_by_object_ap_id(object.data["id"]), + true <- ActivityPub.visible_for_user?(activity, user) do + [activity] else _e -> [] end @@ -756,7 +759,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def search2(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do accounts = User.search(query, params["resolve"] == "true") - statuses = status_search(query) + statuses = status_search(user, query) tags_path = Web.base_url() <> "/tag/" @@ -780,7 +783,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do accounts = User.search(query, params["resolve"] == "true") - statuses = status_search(query) + statuses = status_search(user, query) tags = String.split(query) -- cgit v1.2.3 From 7382adf407301945e30ee38aa4efe28a819fcf44 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 7 Jan 2019 12:41:31 +0100 Subject: Make TwAPI UserView more resilient to issues. Will work for missing users and badly migrated users. --- lib/pleroma/user.ex | 9 +++++++++ lib/pleroma/web/twitter_api/views/activity_view.ex | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 0e5e2d943..85d0f9fce 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -367,6 +367,15 @@ defmodule Pleroma.User do Repo.get_by(User, ap_id: ap_id) end + # This is mostly an SPC migration fix. This guesses the user nickname (by taking the last part of the ap_id and the domain) and tries to get that user + def get_by_guessed_nickname(ap_id) do + domain = URI.parse(ap_id).host + name = List.last(String.split(ap_id, "/")) + nickname = "#{name}@#{domain}" + + get_by_nickname(nickname) + end + def update_and_set_cache(changeset) do with {:ok, user} <- Repo.update(changeset) do Cachex.put(:user_cache, "ap_id:#{user.ap_id}", user) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index ad0cc76ed..0bae3d06f 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -94,11 +94,25 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do ap_id == "https://www.w3.org/ns/activitystreams#Public" -> nil + user = User.get_cached_by_ap_id(ap_id) -> + user + + user = User.get_by_guessed_nickname(ap_id) -> + user + true -> - User.get_cached_by_ap_id(ap_id) + error_user() end end + defp error_user do + %User{ + info: %User.Info{}, + nickname: "erroruser@example.com", + inserted_at: NaiveDateTime.utc_now() + } + end + def render("index.json", opts) do context_ids = collect_context_ids(opts.activities) users = collect_users(opts.activities) -- cgit v1.2.3 From 380e9fba21123467b41629828f97d5f2c257a128 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Mon, 7 Jan 2019 20:45:33 +0700 Subject: add pinned posts --- lib/pleroma/user/info.ex | 23 +++++++++++++++ lib/pleroma/web/activity_pub/activity_pub.ex | 8 +++++ lib/pleroma/web/common_api/common_api.ex | 34 ++++++++++++++++++++++ .../web/mastodon_api/mastodon_api_controller.ex | 29 +++++++++++++----- lib/pleroma/web/router.ex | 2 ++ 5 files changed, 89 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 2f419a5a2..ffb800177 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -31,6 +31,7 @@ defmodule Pleroma.User.Info do field(:hub, :string, default: nil) field(:salmon, :string, default: nil) field(:hide_network, :boolean, default: false) + field(:pinned_activities, {:array, :integer}, default: []) # Found in the wild # ap_id -> Where is this used? @@ -198,4 +199,26 @@ defmodule Pleroma.User.Info do :is_admin ]) end + + def add_pinnned_activity(info, %Pleroma.Activity{id: id}) do + if id not in info.pinned_activities do + max_pinned_posts = Pleroma.Config.get([:instance, :max_pinned_posts], 0) + params = %{pinned_activities: info.pinned_activities ++ [id]} + + info + |> cast(params, [:pinned_activities]) + |> validate_length(:pinned_activities, + max: max_pinned_posts, + message: "You have already pinned the maximum number of toots" + ) + else + change(info) + end + end + + def remove_pinnned_activity(info, %Pleroma.Activity{id: id}) do + params = %{pinned_activities: List.delete(info.pinned_activities, id)} + + cast(info, params, [:pinned_activities]) + end end diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 4685f6d95..c5f62c4f8 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -394,6 +394,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> Map.put("type", ["Create", "Announce"]) |> Map.put("actor_id", user.ap_id) |> Map.put("whole_db", true) + |> Map.put("pinned_activity_ids", user.info.pinned_activities) recipients = if reading_user do @@ -552,6 +553,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do ) end + defp restrict_pinned(query, %{"pinned" => "true", "pinned_activity_ids" => ids}) do + from(activity in query, where: activity.id in ^ids) + end + + defp restrict_pinned(query, _), do: query + def fetch_activities_query(recipients, opts \\ %{}) do base_query = from( @@ -576,6 +583,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do |> restrict_visibility(opts) |> restrict_replies(opts) |> restrict_reblogs(opts) + |> restrict_pinned(opts) end def fetch_activities(recipients, opts \\ %{}) do diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index bb3c38f00..6d22813b2 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -164,4 +164,38 @@ defmodule Pleroma.Web.CommonAPI do object: Pleroma.Web.ActivityPub.UserView.render("user.json", %{user: user}) }) end + + def pin(id_or_ap_id, user) do + with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id), + %{valid?: true} = info_changeset <- + Pleroma.User.Info.add_pinnned_activity(user.info, activity), + changeset <- + Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset), + {:ok, _user} <- User.update_and_set_cache(changeset) do + {:ok, activity} + else + %{errors: [pinned_activities: {err, _}]} -> + {:error, err} + + _ -> + {:error, "Could not pin"} + end + end + + def unpin(id_or_ap_id, user) do + with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id), + %{valid?: true} = info_changeset <- + Pleroma.User.Info.remove_pinnned_activity(user.info, activity), + changeset <- + Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_changeset), + {:ok, _user} <- User.update_and_set_cache(changeset) do + {:ok, activity} + else + %{errors: [pinned_activities: {err, _}]} -> + {:error, err} + + _ -> + {:error, "Could not unpin"} + end + end end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 95d0f849c..2fb2943f1 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -256,13 +256,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def user_statuses(%{assigns: %{user: reading_user}} = conn, params) do with %User{} = user <- Repo.get(User, params["id"]) do - # Since Pleroma has no "pinned" posts feature, we'll just set an empty list here - activities = - if params["pinned"] == "true" do - [] - else - ActivityPub.fetch_user_activities(user, reading_user, params) - end + activities = ActivityPub.fetch_user_activities(user, reading_user, params) conn |> add_link_headers(:user_statuses, activities, params["id"]) @@ -409,6 +403,27 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def pin_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do + with {:ok, activity} <- CommonAPI.pin(ap_id_or_id, user) do + conn + |> put_view(StatusView) + |> try_render("status.json", %{activity: activity, for: user, as: :activity}) + else + {:error, reason} -> + conn + |> put_resp_content_type("application/json") + |> send_resp(:bad_request, Jason.encode!(%{"error" => reason})) + end + end + + def unpin_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do + with {:ok, activity} <- CommonAPI.unpin(ap_id_or_id, user) do + conn + |> put_view(StatusView) + |> try_render("status.json", %{activity: activity, for: user, as: :activity}) + end + end + def notifications(%{assigns: %{user: user}} = conn, params) do notifications = Notification.for_user(user, params) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 8df45bf4d..ad73d8867 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -188,6 +188,8 @@ defmodule Pleroma.Web.Router do post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status) post("/statuses/:id/favourite", MastodonAPIController, :fav_status) post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status) + post("/statuses/:id/pin", MastodonAPIController, :pin_status) + post("/statuses/:id/unpin", MastodonAPIController, :unpin_status) post("/notifications/clear", MastodonAPIController, :clear_notifications) post("/notifications/dismiss", MastodonAPIController, :dismiss_notification) -- cgit v1.2.3 From a16b17cc61a57d1adbc6f10f16fc36e8238c6c2a Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 7 Jan 2019 20:59:30 +0100 Subject: Actually put some onformation in the error user, make it actually properly parse in conversations. --- lib/pleroma/web/twitter_api/views/activity_view.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 0bae3d06f..25e1486c1 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -101,12 +101,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do user true -> - error_user() + error_user(ap_id) end end - defp error_user do + defp error_user(ap_id) do %User{ + name: ap_id, + ap_id: ap_id, info: %User.Info{}, nickname: "erroruser@example.com", inserted_at: NaiveDateTime.utc_now() -- cgit v1.2.3 From 63dbd875684b192e57d356a194c5d07ad98bd810 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 15:25:50 +0700 Subject: rename `post` to `status` --- lib/pleroma/user/info.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index ffb800177..8ac50540d 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -202,14 +202,14 @@ defmodule Pleroma.User.Info do def add_pinnned_activity(info, %Pleroma.Activity{id: id}) do if id not in info.pinned_activities do - max_pinned_posts = Pleroma.Config.get([:instance, :max_pinned_posts], 0) + max_pinned_statuses = Pleroma.Config.get([:instance, :max_pinned_statuses], 0) params = %{pinned_activities: info.pinned_activities ++ [id]} info |> cast(params, [:pinned_activities]) |> validate_length(:pinned_activities, - max: max_pinned_posts, - message: "You have already pinned the maximum number of toots" + max: max_pinned_statuses, + message: "You have already pinned the maximum number of statuses" ) else change(info) -- cgit v1.2.3 From e679da4c34194b366624e31356d534ab73b11d2d Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 15:27:02 +0700 Subject: add `pinned` property to `StatusView` --- lib/pleroma/web/mastodon_api/views/status_view.ex | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 8e8fa8121..db543ffe5 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -76,6 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do reblogged: false, favourited: false, muted: false, + pinned: pinned?(activity, user), sensitive: false, spoiler_text: "", visibility: "public", @@ -142,6 +143,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do reblogged: present?(repeated), favourited: present?(favorited), muted: false, + pinned: pinned?(activity, user), sensitive: sensitive, spoiler_text: object["summary"] || "", visibility: get_visibility(object), @@ -295,4 +297,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do defp present?(nil), do: false defp present?(false), do: false defp present?(_), do: true + + defp pinned?(%Activity{id: id}, %User{info: %{pinned_activities: pinned_activities}}), + do: id in pinned_activities end -- cgit v1.2.3 From 0fae04c4e3961baf1f31ae664e5a7fa5de19158e Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 8 Jan 2019 09:55:33 +0100 Subject: Add a setting for users to autofollow on sign up. --- lib/pleroma/user.ex | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 85d0f9fce..8edf1c730 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -229,10 +229,27 @@ defmodule Pleroma.User do end end + defp autofollow_users(user) do + candidates = Pleroma.Config.get([:instance, :autofollowed_nicknames]) + + autofollowed_users = + from(u in User, + where: u.local == true, + where: u.nickname in ^candidates + ) + |> Repo.all() + + autofollowed_users + |> Enum.reduce({:ok, user}, fn other_user, {:ok, user} -> + follow(user, other_user) + end) + end + @doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)" def register(%Ecto.Changeset{} = changeset) do with {:ok, user} <- Repo.insert(changeset), - {:ok, _} = try_send_confirmation_email(user) do + {:ok, _} <- try_send_confirmation_email(user), + {:ok, user} <- autofollow_users(user) do {:ok, user} end end -- cgit v1.2.3 From 6428ef77adef6aa3fca1fbcdcfffc5db5fc953d5 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 8 Jan 2019 16:11:03 +0700 Subject: add default configuration for the pinned statuses and some doc --- lib/mix/tasks/pleroma/sample_config.eex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/sample_config.eex b/lib/mix/tasks/pleroma/sample_config.eex index 740b9f8d1..59c2c4fba 100644 --- a/lib/mix/tasks/pleroma/sample_config.eex +++ b/lib/mix/tasks/pleroma/sample_config.eex @@ -14,7 +14,8 @@ config :pleroma, :instance, email: "<%= email %>", limit: 5000, registrations_open: true, - dedupe_media: false + dedupe_media: false, + max_pinned_statuses: 1 config :pleroma, :media_proxy, enabled: false, -- cgit v1.2.3 From 595a970493a9bae0dcc4b84de338766c2cc61a75 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 04:46:03 +0000 Subject: user: use pattern matching to determine if user is local or remote instead of the previous hairy logic --- lib/pleroma/user.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 85d0f9fce..ce909601d 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -49,7 +49,8 @@ defmodule Pleroma.User do !Pleroma.Config.get([:instance, :account_activation_required]) end - def remote_or_auth_active?(%User{} = user), do: !user.local || auth_active?(user) + def remote_or_auth_active?(%User{local: false}), do: true + def remote_or_auth_active?(%User{local: true} = user), do: auth_active?(user) def visible_for?(%User{} = user, for_user \\ nil) do User.remote_or_auth_active?(user) || (for_user && for_user.id == user.id) || -- cgit v1.2.3 From 2af67353c5014edcc24bf2ec27b2bc871bd80eb7 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 06:21:21 +0000 Subject: user: harden auth_active?/1, superuser?/1, visible_for?/1 --- lib/pleroma/user.ex | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index ce909601d..5491e8b9a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -44,21 +44,28 @@ defmodule Pleroma.User do timestamps() end - def auth_active?(%User{} = user) do - (user.info && !user.info.confirmation_pending) || - !Pleroma.Config.get([:instance, :account_activation_required]) - end + def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true + + def auth_active?(%User{info: %User.Info{confirmation_pending: true}}), + do: !Pleroma.Config.get([:instance, :account_activation_required]) + + def auth_active?(_), do: false def remote_or_auth_active?(%User{local: false}), do: true def remote_or_auth_active?(%User{local: true} = user), do: auth_active?(user) - def visible_for?(%User{} = user, for_user \\ nil) do - User.remote_or_auth_active?(user) || (for_user && for_user.id == user.id) || - User.superuser?(for_user) + def visible_for?(user, for_user \\ nil) + + def visible_for?(%User{id: user_id}, %User{id: for_id}) when user_id == for_id, do: true + + def visible_for?(%User{} = user, for_user) do + remote_or_auth_active?(user) || superuser?(for_user) end - def superuser?(nil), do: false - def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info) + def visible_for?(_, _), do: false + + def superuser?(%User{info: %User.Info{} = info}), do: User.Info.superuser?(info) + def superuser?(_), do: false def avatar_url(user) do case user.avatar do -- cgit v1.2.3 From 74f48beec3bf78cd94cb6db5cbdb937505891eab Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 06:36:50 +0000 Subject: user: remove entirely redundant remote_or_auth_active?/1. auth_active?/1 can check remote users and return true directly. --- lib/pleroma/user.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 5491e8b9a..636c56312 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -44,6 +44,8 @@ defmodule Pleroma.User do timestamps() end + def auth_active?(%User{local: false}), do: false + def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true def auth_active?(%User{info: %User.Info{confirmation_pending: true}}), @@ -51,15 +53,12 @@ defmodule Pleroma.User do def auth_active?(_), do: false - def remote_or_auth_active?(%User{local: false}), do: true - def remote_or_auth_active?(%User{local: true} = user), do: auth_active?(user) - def visible_for?(user, for_user \\ nil) def visible_for?(%User{id: user_id}, %User{id: for_id}) when user_id == for_id, do: true def visible_for?(%User{} = user, for_user) do - remote_or_auth_active?(user) || superuser?(for_user) + auth_active?(user) || superuser?(for_user) end def visible_for?(_, _), do: false -- cgit v1.2.3 From 0015d43e13508155462a9e5d18f19725fadd8931 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 06:41:25 +0000 Subject: user: factor out illogical User.Info.superuser?/1. any actual callee will be dealing with a User struct to begin with, so just check the child struct inside User.superuser?/1 with pattern matching. --- lib/pleroma/user.ex | 3 ++- lib/pleroma/user/info.ex | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 636c56312..4d0f68cd6 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -63,7 +63,8 @@ defmodule Pleroma.User do def visible_for?(_, _), do: false - def superuser?(%User{info: %User.Info{} = info}), do: User.Info.superuser?(info) + def superuser?(%User{local: true, info: %User.Info{is_admin: true}}), do: true + def superuser?(%User{local: true, info: %User.Info{is_moderator: true}}), do: true def superuser?(_), do: false def avatar_url(user) do diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 2f419a5a2..7c79dfcff 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -41,8 +41,6 @@ defmodule Pleroma.User.Info do # subject _> Where is this used? end - def superuser?(info), do: info.is_admin || info.is_moderator - def set_activation_status(info, deactivated) do params = %{deactivated: deactivated} -- cgit v1.2.3 From f15183178c15bb01f6cd49f28f2177bfd26bdac8 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 06:45:17 +0000 Subject: user: fix auth_active?/1 for remote users --- lib/pleroma/user.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 4d0f68cd6..06049dc62 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -44,7 +44,7 @@ defmodule Pleroma.User do timestamps() end - def auth_active?(%User{local: false}), do: false + def auth_active?(%User{local: false}), do: true def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true -- cgit v1.2.3 From 20c0dd1e24b128e0be51197ac2d150052817c219 Mon Sep 17 00:00:00 2001 From: sxsdv1 Date: Tue, 8 Jan 2019 23:22:15 +0100 Subject: Support activity+json request for activity --- .../web/activity_pub/activity_pub_controller.ex | 13 +++++++++ lib/pleroma/web/ostatus/ostatus_controller.ex | 32 ++++++++++++---------- 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index a3f736fee..73ca07e84 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -54,6 +54,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end end + def activity(conn, %{"uuid" => uuid}) do + with ap_id <- o_status_url(conn, :activity, uuid), + %Activity{} = activity <- Activity.normalize(ap_id), + {_, true} <- {:public?, ActivityPub.is_public?(activity)} do + conn + |> put_resp_header("content-type", "application/activity+json") + |> json(ObjectView.render("object.json", %{object: activity})) + else + {:public?, false} -> + {:error, :not_found} + end + end + def following(conn, %{"nickname" => nickname, "page" => page}) do with %User{} = user <- User.get_cached_by_nickname(nickname), {:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 9b600737f..332cbef0e 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -112,23 +112,27 @@ defmodule Pleroma.Web.OStatus.OStatusController do end def activity(conn, %{"uuid" => uuid}) do - with id <- o_status_url(conn, :activity, uuid), - {_, %Activity{} = activity} <- {:activity, Activity.normalize(id)}, - {_, true} <- {:public?, ActivityPub.is_public?(activity)}, - %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do - case format = get_format(conn) do - "html" -> redirect(conn, to: "/notice/#{activity.id}") - _ -> represent_activity(conn, format, activity, user) - end + if get_format(conn) == "activity+json" do + ActivityPubController.call(conn, :activity) else - {:public?, false} -> - {:error, :not_found} + with id <- o_status_url(conn, :activity, uuid), + {_, %Activity{} = activity} <- {:activity, Activity.normalize(id)}, + {_, true} <- {:public?, ActivityPub.is_public?(activity)}, + %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do + case format = get_format(conn) do + "html" -> redirect(conn, to: "/notice/#{activity.id}") + _ -> represent_activity(conn, format, activity, user) + end + else + {:public?, false} -> + {:error, :not_found} - {:activity, nil} -> - {:error, :not_found} + {:activity, nil} -> + {:error, :not_found} - e -> - e + e -> + e + end end end -- cgit v1.2.3 From 28afcb7c31a357e05c6cb23645539389f37a15f4 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Jan 2019 17:02:30 +0700 Subject: move defaults from sample_config.exs to config.exs --- lib/mix/tasks/pleroma/sample_config.eex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mix/tasks/pleroma/sample_config.eex b/lib/mix/tasks/pleroma/sample_config.eex index 59c2c4fba..740b9f8d1 100644 --- a/lib/mix/tasks/pleroma/sample_config.eex +++ b/lib/mix/tasks/pleroma/sample_config.eex @@ -14,8 +14,7 @@ config :pleroma, :instance, email: "<%= email %>", limit: 5000, registrations_open: true, - dedupe_media: false, - max_pinned_statuses: 1 + dedupe_media: false config :pleroma, :media_proxy, enabled: false, -- cgit v1.2.3 From 26938d65fd5d59e6f50150f4e2bc924429d7733e Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 11:35:23 +0100 Subject: Add User mass following function. --- lib/pleroma/user.ex | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 7c2849ce2..916b14350 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -307,6 +307,25 @@ defmodule Pleroma.User do end end + @doc "A mass follow for local users. Ignores blocks and has no side effects" + @spec follow_all(User.t(), list(User.t())) :: {atom(), User.t()} + def follow_all(follower, followeds) do + following = + (follower.following ++ Enum.map(followeds, fn %{follower_address: fa} -> fa end)) + |> Enum.uniq() + + {:ok, follower} = + follower + |> follow_changeset(%{following: following}) + |> update_and_set_cache + + Enum.each(followeds, fn followed -> + update_follower_count(followed) + end) + + {:ok, follower} + end + def follow(%User{} = follower, %User{info: info} = followed) do user_config = Application.get_env(:pleroma, :user) deny_follow_blocked = Keyword.get(user_config, :deny_follow_blocked) -- cgit v1.2.3 From 65fc2df7ccc85f07ea64b0f7340b98d5615bb1a3 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 11:38:45 +0100 Subject: Use follow_all in autofollow. --- lib/pleroma/user.ex | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 916b14350..a49fa3fcd 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -247,10 +247,7 @@ defmodule Pleroma.User do ) |> Repo.all() - autofollowed_users - |> Enum.reduce({:ok, user}, fn other_user, {:ok, user} -> - follow(user, other_user) - end) + follow_all(user, autofollowed_users) end @doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)" -- cgit v1.2.3 From 1b06e6fdf3d879422d6cb0fe57cfcef223b54196 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Jan 2019 17:40:15 +0700 Subject: only non-reblogs, self-authored, public statuses can be pinned --- lib/pleroma/web/common_api/common_api.ex | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 6d22813b2..7ec6aa0ea 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -165,8 +165,18 @@ defmodule Pleroma.Web.CommonAPI do }) end - def pin(id_or_ap_id, user) do - with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id), + def pin(id_or_ap_id, %{ap_id: user_ap_id} = user) do + with %Activity{ + actor: ^user_ap_id, + data: %{ + "type" => "Create", + "object" => %{ + "to" => object_to, + "type" => "Note" + } + } + } = activity <- get_by_id_or_ap_id(id_or_ap_id), + true <- Enum.member?(object_to, "https://www.w3.org/ns/activitystreams#Public"), %{valid?: true} = info_changeset <- Pleroma.User.Info.add_pinnned_activity(user.info, activity), changeset <- -- cgit v1.2.3 From 44a1e6948488d9a96ed684f0a7855fe2fce02ed4 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Jan 2019 19:54:19 +0700 Subject: Add Twitter API for the pinned statuses ``` # Only return statuses that have been pinned GET /api/statuses/user_timeline.json?pinned=true # Pin POST /api/statuses/pin/:id # Unpin POST /api/statuses/unpin/:id ``` --- lib/pleroma/web/router.ex | 3 +++ .../representers/activity_representer.ex | 2 ++ lib/pleroma/web/twitter_api/twitter_api.ex | 8 ++++++++ .../web/twitter_api/twitter_api_controller.ex | 24 ++++++++++++++++++++++ lib/pleroma/web/twitter_api/views/activity_view.ex | 2 ++ 5 files changed, 39 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index ad73d8867..a5f4d8126 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -355,6 +355,9 @@ defmodule Pleroma.Web.Router do post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet) post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post) + post("/statuses/pin/:id", TwitterAPI.Controller, :pin) + post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin) + get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests) post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request) post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request) diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 245cd52fd..64f7c00c7 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -153,6 +153,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do announcement_count = object["announcement_count"] || 0 favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || []) repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || []) + pinned = activity.id in user.info.pinned_activities mentions = opts[:mentioned] || [] @@ -202,6 +203,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "repeat_num" => announcement_count, "favorited" => to_boolean(favorited), "repeated" => to_boolean(repeated), + "pinned" => pinned, "external_url" => object["external_url"] || object["id"], "tags" => tags, "activity_type" => "post", diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index ecf81d492..7a63724f1 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -82,6 +82,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end end + def pin(%User{} = user, ap_id_or_id) do + CommonAPI.pin(ap_id_or_id, user) + end + + def unpin(%User{} = user, ap_id_or_id) do + CommonAPI.unpin(ap_id_or_id, user) + end + def fav(%User{} = user, ap_id_or_id) do with {:ok, _fav, %{data: %{"id" => id}}} <- CommonAPI.favorite(ap_id_or_id, user), %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 1e04b8c4b..d5b9d2fb8 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -375,6 +375,30 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end end + def pin(%{assigns: %{user: user}} = conn, %{"id" => id}) do + with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)}, + {:ok, activity} <- TwitterAPI.pin(user, id) do + conn + |> put_view(ActivityView) + |> render("activity.json", %{activity: activity, for: user}) + else + {:error, message} -> bad_request_reply(conn, message) + err -> err + end + end + + def unpin(%{assigns: %{user: user}} = conn, %{"id" => id}) do + with {_, {:ok, id}} <- {:param_cast, Ecto.Type.cast(:integer, id)}, + {:ok, activity} <- TwitterAPI.unpin(user, id) do + conn + |> put_view(ActivityView) + |> render("activity.json", %{activity: activity, for: user}) + else + {:error, message} -> bad_request_reply(conn, message) + err -> err + end + end + def register(conn, params) do with {:ok, user} <- TwitterAPI.register_user(params) do conn diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 25e1486c1..425df8672 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -243,6 +243,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do announcement_count = object["announcement_count"] || 0 favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || []) repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || []) + pinned = activity.id in user.info.pinned_activities attentions = activity.recipients @@ -300,6 +301,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "repeat_num" => announcement_count, "favorited" => !!favorited, "repeated" => !!repeated, + "pinned" => pinned, "external_url" => object["external_url"] || object["id"], "tags" => tags, "activity_type" => "post", -- cgit v1.2.3 From 5027f82cdef52391e408428ecc8013b1c4847b6b Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 16:45:09 +0100 Subject: Add activity visibility index. --- lib/pleroma/web/activity_pub/activity_pub.ex | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 4685f6d95..b8141146f 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -364,21 +364,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do @valid_visibilities ~w[direct unlisted public private] - defp restrict_visibility(query, %{visibility: "direct"}) do - public = "https://www.w3.org/ns/activitystreams#Public" + defp restrict_visibility(query, %{visibility: visibility}) + when visibility in @valid_visibilities do + query = + from( + a in query, + where: + fragment("activity_visibility(?, ?, ?) = ?", a.actor, a.recipients, a.data, ^visibility) + ) - from( - activity in query, - join: sender in User, - on: sender.ap_id == activity.actor, - # Are non-direct statuses with no to/cc possible? - where: - fragment( - "not (? && ?)", - [^public, sender.follower_address], - activity.recipients - ) - ) + Ecto.Adapters.SQL.to_sql(:all, Repo, query) + + query end defp restrict_visibility(_query, %{visibility: visibility}) -- cgit v1.2.3 From 7ac152ed38267bde3e318fab82db7d7d610cdbbb Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 18:14:32 +0100 Subject: TwitterAPI: Add follower/following pagination. --- lib/pleroma/user.ex | 32 ++++++++++++++++++---- .../web/twitter_api/twitter_api_controller.ex | 8 ++++-- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 7c2849ce2..f5f5dea1c 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -471,7 +471,7 @@ defmodule Pleroma.User do end end - def get_followers_query(%User{id: id, follower_address: follower_address}) do + def get_followers_query(%User{id: id, follower_address: follower_address}, nil) do from( u in User, where: fragment("? <@ ?", ^[follower_address], u.following), @@ -479,13 +479,23 @@ defmodule Pleroma.User do ) end - def get_followers(user) do - q = get_followers_query(user) + def get_followers_query(user, page) do + from( + u in get_followers_query(user, nil), + limit: 20, + offset: ^((page - 1) * 20) + ) + end + + def get_followers_query(user), do: get_followers_query(user, nil) + + def get_followers(user, page \\ nil) do + q = get_followers_query(user, page) {:ok, Repo.all(q)} end - def get_friends_query(%User{id: id, following: following}) do + def get_friends_query(%User{id: id, following: following}, nil) do from( u in User, where: u.follower_address in ^following, @@ -493,8 +503,18 @@ defmodule Pleroma.User do ) end - def get_friends(user) do - q = get_friends_query(user) + def get_friends_query(user, page) do + from( + u in get_friends_query(user, nil), + limit: 20, + offset: ^((page - 1) * 20) + ) + end + + def get_friends_query(user), do: get_friends_query(user, nil) + + def get_friends(user, page \\ nil) do + q = get_friends_query(user, page) {:ok, Repo.all(q)} end diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 1e04b8c4b..0653acebe 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -472,8 +472,10 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def followers(%{assigns: %{user: for_user}} = conn, params) do + page = params["page"] || 1 + with {:ok, user} <- TwitterAPI.get_user(for_user, params), - {:ok, followers} <- User.get_followers(user) do + {:ok, followers} <- User.get_followers(user, page) do followers = cond do for_user && user.id == for_user.id -> followers @@ -490,8 +492,10 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def friends(%{assigns: %{user: for_user}} = conn, params) do + page = params["page"] || 1 + with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), - {:ok, friends} <- User.get_friends(user) do + {:ok, friends} <- User.get_friends(user, page) do friends = cond do for_user && user.id == for_user.id -> friends -- cgit v1.2.3 From a99e156f2c0e3d2e5b5dec167efb29be1e429542 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 18:17:23 +0100 Subject: Add integer casts. --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 0653acebe..a44c8c50a 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -472,7 +472,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def followers(%{assigns: %{user: for_user}} = conn, params) do - page = params["page"] || 1 + {:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1) with {:ok, user} <- TwitterAPI.get_user(for_user, params), {:ok, followers} <- User.get_followers(user, page) do @@ -492,7 +492,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def friends(%{assigns: %{user: for_user}} = conn, params) do - page = params["page"] || 1 + {:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1) with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), {:ok, friends} <- User.get_friends(user, page) do -- cgit v1.2.3 From a2d7f0e0e9aaf03798b11d5c158c9382eaf698a1 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 9 Jan 2019 21:35:01 +0300 Subject: Remove :commit since a tuple is already returned --- lib/pleroma/web/rich_media/parser.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index 3746feaf6..18d9e2df5 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Web.RichMedia.Parser do def parse(url), do: parse_url(url) else def parse(url), - do: {:commit, Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end)} + do: Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end) end defp parse_url(url) do -- cgit v1.2.3 From 2ecf81f10c1ebc01d21b4183f6cd248ce5cfbd6a Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 10 Jan 2019 02:22:11 +0000 Subject: common api: fix newlines in markdown code blocks --- lib/pleroma/web/common_api/utils.ex | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 3ff9f9452..187e908ce 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -150,7 +150,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do |> Formatter.mentions_escape(mentions) |> Earmark.as_html!() |> Formatter.html_escape("text/html") - |> String.replace(~r/\r?\n/, "") |> (&{[], &1}).() |> Formatter.add_user_links(mentions) |> Formatter.add_hashtag_links(tags) -- cgit v1.2.3 From 0bdbd4f968b20a508f9433480c7e358428dc55d7 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 10 Jan 2019 03:45:58 +0000 Subject: common api: utils: remove newline to
conversion from bare HTML to be consistent with markdown ok @lanodan --- lib/pleroma/web/common_api/utils.ex | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 187e908ce..7e30d224c 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -136,7 +136,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do def format_input(text, mentions, _tags, "text/html") do text |> Formatter.html_escape("text/html") - |> String.replace(~r/\r?\n/, "
") |> (&{[], &1}).() |> Formatter.add_user_links(mentions) |> Formatter.finalize() -- cgit v1.2.3 From 1f851a07232e510e82e7b13400dfcb31cca555bb Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 10 Jan 2019 18:09:56 +0000 Subject: Add Twitter Card parser --- lib/pleroma/web/rich_media/parser.ex | 2 +- .../web/rich_media/parsers/meta_tags_parser.ex | 30 ++++++++++++++++++++ lib/pleroma/web/rich_media/parsers/ogp.ex | 33 +++++----------------- lib/pleroma/web/rich_media/parsers/twitter_card.ex | 11 ++++++++ 4 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex create mode 100644 lib/pleroma/web/rich_media/parsers/twitter_card.ex (limited to 'lib') diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index 18d9e2df5..fe092bf19 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -1,5 +1,5 @@ defmodule Pleroma.Web.RichMedia.Parser do - @parsers [Pleroma.Web.RichMedia.Parsers.OGP] + @parsers [Pleroma.Web.RichMedia.Parsers.OGP, Pleroma.Web.RichMedia.Parsers.TwitterCard] if Mix.env() == :test do def parse(url), do: parse_url(url) diff --git a/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex b/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex new file mode 100644 index 000000000..4a7c5eae0 --- /dev/null +++ b/lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex @@ -0,0 +1,30 @@ +defmodule Pleroma.Web.RichMedia.Parsers.MetaTagsParser do + def parse(html, data, prefix, error_message, key_name, value_name \\ "content") do + with elements = [_ | _] <- get_elements(html, key_name, prefix), + meta_data = + Enum.reduce(elements, data, fn el, acc -> + attributes = normalize_attributes(el, prefix, key_name, value_name) + + Map.merge(acc, attributes) + end) do + {:ok, meta_data} + else + _e -> {:error, error_message} + end + end + + defp get_elements(html, key_name, prefix) do + html |> Floki.find("meta[#{key_name}^='#{prefix}:']") + end + + defp normalize_attributes(html_node, prefix, key_name, value_name) do + {_tag, attributes, _children} = html_node + + data = + Enum.into(attributes, %{}, fn {name, value} -> + {name, String.trim_leading(value, "#{prefix}:")} + end) + + %{String.to_atom(data[key_name]) => data[value_name]} + end +end diff --git a/lib/pleroma/web/rich_media/parsers/ogp.ex b/lib/pleroma/web/rich_media/parsers/ogp.ex index 5773a5263..0e1a0e719 100644 --- a/lib/pleroma/web/rich_media/parsers/ogp.ex +++ b/lib/pleroma/web/rich_media/parsers/ogp.ex @@ -1,30 +1,11 @@ defmodule Pleroma.Web.RichMedia.Parsers.OGP do def parse(html, data) do - with elements = [_ | _] <- get_elements(html), - ogp_data = - Enum.reduce(elements, data, fn el, acc -> - attributes = normalize_attributes(el) - - Map.merge(acc, attributes) - end) do - {:ok, ogp_data} - else - _e -> {:error, "No OGP metadata found"} - end - end - - defp get_elements(html) do - html |> Floki.find("meta[property^='og:']") - end - - defp normalize_attributes(html_node) do - {_tag, attributes, _children} = html_node - - data = - Enum.into(attributes, %{}, fn {name, value} -> - {name, String.trim_leading(value, "og:")} - end) - - %{String.to_atom(data["property"]) => data["content"]} + Pleroma.Web.RichMedia.Parsers.MetaTagsParser.parse( + html, + data, + "og", + "No OGP metadata found", + "property" + ) end end diff --git a/lib/pleroma/web/rich_media/parsers/twitter_card.ex b/lib/pleroma/web/rich_media/parsers/twitter_card.ex new file mode 100644 index 000000000..a317c3e78 --- /dev/null +++ b/lib/pleroma/web/rich_media/parsers/twitter_card.ex @@ -0,0 +1,11 @@ +defmodule Pleroma.Web.RichMedia.Parsers.TwitterCard do + def parse(html, data) do + Pleroma.Web.RichMedia.Parsers.MetaTagsParser.parse( + html, + data, + "twitter", + "No twitter card metadata found", + "name" + ) + end +end -- cgit v1.2.3 From b594a54d0caf0f91dd9188157cb34e01ee9ea794 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Fri, 11 Jan 2019 12:31:31 +0700 Subject: unpin when deleting a status --- lib/pleroma/web/common_api/common_api.ex | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 7ec6aa0ea..2902905fd 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -14,6 +14,7 @@ defmodule Pleroma.Web.CommonAPI do with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id), %Object{} = object <- Object.normalize(object_id), true <- user.info.is_moderator || user.ap_id == object.data["actor"], + {:ok, _} <- unpin(activity_id, user), {:ok, delete} <- ActivityPub.delete(object) do {:ok, delete} end -- cgit v1.2.3